-
Notifications
You must be signed in to change notification settings - Fork 15
Brain Blip's back #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,12 +1,15 @@ | ||||||
| using Content.Shared.Item.ItemToggle.Components; | ||||||
| using Robust.Shared.Timing; | ||||||
|
|
||||||
| namespace Content.Shared.Item.ItemToggle; | ||||||
|
|
||||||
| /// <summary> | ||||||
| /// Handles <see cref="ComponentTogglerComponent"/> component manipulation. | ||||||
| /// </summary> | ||||||
| public sealed class ComponentTogglerSystem : EntitySystem | ||||||
| public sealed partial class ComponentTogglerSystem : EntitySystem | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| { | ||||||
| [Dependency] private IGameTiming _timing = default!; // LuaM: predict err fix | ||||||
|
|
||||||
| public override void Initialize() | ||||||
| { | ||||||
| base.Initialize(); | ||||||
|
|
@@ -22,14 +25,32 @@ private void OnToggled(Entity<ComponentTogglerComponent> ent, ref ItemToggledEve | |||||
| // Goobstation - Make this system more flexible | ||||||
| public void ToggleComponent(EntityUid uid, bool activate) | ||||||
| { | ||||||
| if (!TryComp<ComponentTogglerComponent>(uid, out var component)) | ||||||
| if (!_timing.IsFirstTimePredicted) // LuaM: predict err fix | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| return; | ||||||
|
|
||||||
| var target = component.Parent ? Transform(uid).ParentUid : uid; | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Закомментить, а не удалить. |
||||||
| if (!TryComp<ComponentTogglerComponent>(uid, out var component)) | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| return; | ||||||
|
|
||||||
| // LuaM-start: add target for the correct remove component, in o.w. - wizden logic | ||||||
| if (activate) | ||||||
| { | ||||||
| var target = component.Parent ? Transform(uid).ParentUid : uid; | ||||||
| if (TerminatingOrDeleted(target)) | ||||||
| return; | ||||||
|
|
||||||
| component.Target = target; | ||||||
| EntityManager.AddComponents(target, component.Components); | ||||||
| } | ||||||
| else | ||||||
| EntityManager.RemoveComponents(target, component.RemoveComponents ?? component.Components); | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Закомментить, а не удалить. |
||||||
| { | ||||||
| if (component.Target == null) | ||||||
| return; | ||||||
|
|
||||||
| if (TerminatingOrDeleted(component.Target.Value)) | ||||||
| return; | ||||||
|
|
||||||
| EntityManager.RemoveComponents(component.Target.Value, component.RemoveComponents ?? component.Components); | ||||||
| } | ||||||
| // LuaM-end | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,4 +29,10 @@ public sealed partial class ComponentTogglerComponent : Component | |||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||
| [DataField] | ||||||||||||||||||||||||||||
| public bool Parent; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // <summary> | ||||||||||||||||||||||||||||
| // It holds the entity that the component gave the component to, so it can remove from it even if it changes parent. | ||||||||||||||||||||||||||||
| // </summary> | ||||||||||||||||||||||||||||
| [DataField] | ||||||||||||||||||||||||||||
| public EntityUid? Target; | ||||||||||||||||||||||||||||
|
Comment on lines
+32
to
+37
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| using Robust.Shared.Prototypes; | ||
|
|
||
| namespace Content.Shared._LuaM.Container.Components | ||
| { | ||
| /// <summary> | ||
| /// Grants the listed components to entity if it NOT inside any container | ||
| /// for example: brain has Blip if he not in the containers (other words, brain in space) | ||
| /// <summary> | ||
| [RegisterComponent] | ||
| public sealed partial class OutOfContainerGrantComponent : Component | ||
| { | ||
| [DataField(required: true)] | ||
| [AlwaysPushInheritance] | ||
| public ComponentRegistry Components { get; private set; } = new(); | ||
|
|
||
| [ViewVariables(VVAccess.ReadWrite)] | ||
| public Dictionary<string, bool> Active = new(); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| using Content.Shared._LuaM.Container.Components; | ||
| using Robust.Shared.Containers; | ||
| using Robust.Shared.Serialization.Manager; | ||
|
|
||
| namespace Content.Shared._LuaM.Container.Systems; // idk how name that. | ||
|
|
||
| // A simple system that add components to entity if he not inside a container | ||
| // Following the example of goob <see cref="Content.Shared._Goobstation.Clothing.Systems.ClothingGrantingSystem"/> | ||
| public sealed partial class OutOfContainerGrantSystem : EntitySystem // this name is suck, i know | ||
| { | ||
| [Dependency] private readonly ISerializationManager _serializationManager = default!; | ||
| [Dependency] private readonly SharedContainerSystem _container = default!; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| SubscribeLocalEvent<OutOfContainerGrantComponent, ComponentStartup>(OnStartup); | ||
|
|
||
| SubscribeLocalEvent<OutOfContainerGrantComponent, EntGotInsertedIntoContainerMessage>(OnContainerChanged); | ||
| SubscribeLocalEvent<OutOfContainerGrantComponent, EntGotRemovedFromContainerMessage>(OnContainerChanged); | ||
| } | ||
|
|
||
| private void OnStartup(EntityUid uid, OutOfContainerGrantComponent component, ComponentStartup args) | ||
| { | ||
| UpdateComp(uid, component); | ||
| } | ||
|
|
||
| private void OnContainerChanged(EntityUid uid, OutOfContainerGrantComponent component, EntityEventArgs args) | ||
| { | ||
| UpdateComp(uid, component); | ||
| } | ||
|
|
||
| private void UpdateComp(EntityUid uid, OutOfContainerGrantComponent component) | ||
| { | ||
| if (_container.IsEntityInContainer(uid)) | ||
| RemoveComp(uid, component); | ||
| else | ||
| AddComp(uid, component); | ||
| } | ||
|
|
||
| private void AddComp(EntityUid uid, OutOfContainerGrantComponent component) | ||
| { | ||
| foreach (var (name, data) in component.Components) | ||
| { | ||
| if (component.Active.TryGetValue(name, out var active) && active) | ||
| continue; | ||
|
|
||
| var newComp = (Component)Factory.GetComponent(name); | ||
|
|
||
| if (HasComp(uid, newComp.GetType())) | ||
| { | ||
| component.Active[name] = true; | ||
| continue; | ||
| } | ||
|
|
||
| object? temp = newComp; | ||
| _serializationManager.CopyTo(data.Component, ref temp); | ||
| EntityManager.AddComponent(uid, (Component)temp!); | ||
|
|
||
| component.Active[name] = true; | ||
| } | ||
| } | ||
|
|
||
| private void RemoveComp(EntityUid uid, OutOfContainerGrantComponent component) | ||
| { | ||
| foreach (var (name, _) in component.Components) | ||
| { | ||
| if (!component.Active.TryGetValue(name, out var active) || !active) | ||
| continue; | ||
|
|
||
| var newComp = (Component)Factory.GetComponent(name); | ||
| RemComp(uid, newComp.GetType()); | ||
|
|
||
| component.Active[name] = false; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -97,17 +97,21 @@ | |||||||||||||
| - type: Item | ||||||||||||||
| size: Small | ||||||||||||||
| heldPrefix: brain | ||||||||||||||
| # - type: RadarBlip # LuaM | ||||||||||||||
| # radarColor: "#E0FFFF" | ||||||||||||||
| # scale: 6 | ||||||||||||||
| # shape: Star | ||||||||||||||
| # visibleFromOtherGrids: true | ||||||||||||||
| # gridConfig: | ||||||||||||||
| # color: "#E0FFFF" | ||||||||||||||
| # shape: Star | ||||||||||||||
| # respectZoom: true | ||||||||||||||
| # rotate: true | ||||||||||||||
| # bounds: "-0.5,-0.5,0.5,0.5" | ||||||||||||||
| - type: OutOfContainerGrant # LuaM | ||||||||||||||
| components: | ||||||||||||||
| - type: RadarBlip | ||||||||||||||
| radarColor: "#E0FFFF" | ||||||||||||||
| scale: 3 | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| shape: Star | ||||||||||||||
| maxDistance: 512 | ||||||||||||||
| requireNoGrid: true | ||||||||||||||
|
Comment on lines
+106
to
+107
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
| visibleFromOtherGrids: true | ||||||||||||||
| gridConfig: | ||||||||||||||
| color: "#E0FFFF" | ||||||||||||||
| shape: Star | ||||||||||||||
| respectZoom: true | ||||||||||||||
| rotate: true | ||||||||||||||
| bounds: "-0.5,-0.5,0.5,0.5" | ||||||||||||||
|
|
||||||||||||||
| - type: entity | ||||||||||||||
| id: OrganHumanEyes | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.