diff --git a/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs b/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs index ba5e54100a..d06732e2ee 100644 --- a/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs +++ b/Content.Server/GameObjects/Components/Singularity/ContainmentFieldGeneratorComponent.cs @@ -7,6 +7,7 @@ using Content.Server.Utility; using Content.Shared.Physics; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; +using Robust.Shared.GameObjects.ComponentDependencies; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Interfaces.Physics; using Robust.Shared.IoC; @@ -14,6 +15,7 @@ using Robust.Shared.Log; using Robust.Shared.Maths; using Robust.Shared.Physics; using Robust.Shared.ViewVariables; +using Robust.Server.GameObjects; namespace Content.Server.GameObjects.Components.Singularity { @@ -63,7 +65,8 @@ namespace Content.Server.GameObjects.Components.Singularity } } - private PhysicsComponent? _collidableComponent; + [ComponentDependency] private readonly PhysicsComponent? _collidableComponent = default; + [ComponentDependency] private readonly PointLightComponent? _pointLightComponent = default; private Tuple? _connection1; private Tuple? _connection2; @@ -71,16 +74,6 @@ namespace Content.Server.GameObjects.Components.Singularity public bool CanRepell(IEntity toRepell) => _connection1?.Item2?.CanRepell(toRepell) == true || _connection2?.Item2?.CanRepell(toRepell) == true; - public override void Initialize() - { - base.Initialize(); - if (!Owner.TryGetComponent(out _collidableComponent)) - { - Logger.Error("ContainmentFieldGeneratorComponent created with no CollidableComponent"); - return; - } - } - public override void HandleMessage(ComponentMessage message, IComponent? component) { base.HandleMessage(message, component); @@ -168,7 +161,7 @@ namespace Content.Server.GameObjects.Components.Singularity { Logger.Error("When trying to connect two Containmentfieldgenerators, the second one already had two connection but the check didn't catch it"); } - + UpdateConnectionLights(); return true; } @@ -180,9 +173,12 @@ namespace Content.Server.GameObjects.Components.Singularity if (_connection1?.Item2 == connection) { _connection1 = null; - }else if (_connection2?.Item2 == connection) + UpdateConnectionLights(); + } + else if (_connection2?.Item2 == connection) { _connection2 = null; + UpdateConnectionLights(); } else if(connection != null) { @@ -198,6 +194,15 @@ namespace Content.Server.GameObjects.Components.Singularity } } + public void UpdateConnectionLights() + { + if (_pointLightComponent != null) + { + bool hasAnyConnection = (_connection1 != null) || (_connection2 != null); + _pointLightComponent.Enabled = hasAnyConnection; + } + } + public override void OnRemove() { _connection1?.Item2.Dispose(); diff --git a/Resources/Prototypes/Entities/singularity.yml b/Resources/Prototypes/Entities/singularity.yml index 97cc72271b..e1576249ed 100644 --- a/Resources/Prototypes/Entities/singularity.yml +++ b/Resources/Prototypes/Entities/singularity.yml @@ -85,6 +85,12 @@ - type: ContainmentFieldGenerator - type: Anchorable - type: Pullable + - type: PointLight + enabled: false + color: "#4080FF" + radius: 32 + energy: 2.0 + softness: 32.0 - type: entity name: Containment Field