diff --git a/Content.Server/ParticleAccelerator/Components/ParticleProjectileComponent.cs b/Content.Server/ParticleAccelerator/Components/ParticleProjectileComponent.cs index baf2ee7c02..b49a0f2b2a 100644 --- a/Content.Server/ParticleAccelerator/Components/ParticleProjectileComponent.cs +++ b/Content.Server/ParticleAccelerator/Components/ParticleProjectileComponent.cs @@ -12,30 +12,14 @@ using Robust.Shared.Timing; namespace Content.Server.ParticleAccelerator.Components { [RegisterComponent] - public class ParticleProjectileComponent : Component, IStartCollide + public class ParticleProjectileComponent : Component { public override string Name => "ParticleProjectile"; - private ParticleAcceleratorPowerState _state; - void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold) - { - if (otherFixture.Body.Owner.TryGetComponent(out var singularityGeneratorComponent)) - { - singularityGeneratorComponent.Power += _state switch - { - ParticleAcceleratorPowerState.Standby => 0, - ParticleAcceleratorPowerState.Level0 => 1, - ParticleAcceleratorPowerState.Level1 => 2, - ParticleAcceleratorPowerState.Level2 => 4, - ParticleAcceleratorPowerState.Level3 => 8, - _ => 0 - }; - Owner.Delete(); - } - } + public ParticleAcceleratorPowerState State; public void Fire(ParticleAcceleratorPowerState state, Angle angle, IEntity firer) { - _state = state; + State = state; if (!Owner.TryGetComponent(out var physicsComponent)) { @@ -56,7 +40,7 @@ namespace Content.Server.ParticleAccelerator.Components Logger.Error("ParticleProjectile tried firing, but it was spawned without a SinguloFoodComponent"); return; } - var multiplier = _state switch + var multiplier = State switch { ParticleAcceleratorPowerState.Standby => 0, ParticleAcceleratorPowerState.Level0 => 1, diff --git a/Content.Server/Singularity/Components/ContainmentFieldComponent.cs b/Content.Server/Singularity/Components/ContainmentFieldComponent.cs index 072bddfd6b..f40cce21c0 100644 --- a/Content.Server/Singularity/Components/ContainmentFieldComponent.cs +++ b/Content.Server/Singularity/Components/ContainmentFieldComponent.cs @@ -1,24 +1,11 @@ using Robust.Shared.GameObjects; -using Robust.Shared.Physics.Collision; -using Robust.Shared.Physics.Dynamics; namespace Content.Server.Singularity.Components { [RegisterComponent] - public class ContainmentFieldComponent : Component, IStartCollide + public class ContainmentFieldComponent : Component { public override string Name => "ContainmentField"; public ContainmentFieldConnection? Parent; - - void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold) - { - if (Parent == null) - { - Owner.QueueDelete(); - return; - } - - Parent.TryRepell(Owner, otherFixture.Body.Owner); - } } } diff --git a/Content.Server/Singularity/Components/ContainmentFieldGeneratorComponent.cs b/Content.Server/Singularity/Components/ContainmentFieldGeneratorComponent.cs index c0e21f9b5b..eb5f57d0ee 100644 --- a/Content.Server/Singularity/Components/ContainmentFieldGeneratorComponent.cs +++ b/Content.Server/Singularity/Components/ContainmentFieldGeneratorComponent.cs @@ -2,21 +2,18 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Linq; using Content.Shared.Physics; -using Content.Shared.Tag; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.Log; using Robust.Shared.Maths; using Robust.Shared.Physics; using Robust.Shared.Physics.Broadphase; -using Robust.Shared.Physics.Collision; -using Robust.Shared.Physics.Dynamics; using Robust.Shared.ViewVariables; namespace Content.Server.Singularity.Components { [RegisterComponent] - public class ContainmentFieldGeneratorComponent : Component, IStartCollide + public class ContainmentFieldGeneratorComponent : Component { public override string Name => "ContainmentFieldGenerator"; @@ -165,13 +162,6 @@ namespace Content.Server.Singularity.Components } } - void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold) - { - if (otherFixture.Body.Owner.HasTag("EmitterBolt")) { - ReceivePower(6); - } - } - public void UpdateConnectionLights() { if (_pointLightComponent != null) diff --git a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs index 89660d7548..d553d2e927 100644 --- a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs +++ b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs @@ -1,5 +1,9 @@ -using Content.Server.Singularity.Components; +using Content.Server.ParticleAccelerator.Components; +using Content.Server.Singularity.Components; +using Content.Shared.Singularity.Components; +using Content.Shared.Tag; using Robust.Shared.GameObjects; +using Robust.Shared.Physics.Dynamics; namespace Content.Server.Singularity.EntitySystems { @@ -10,6 +14,45 @@ namespace Content.Server.Singularity.EntitySystems base.Initialize(); SubscribeLocalEvent(BodyTypeChanged); + SubscribeLocalEvent(HandleFieldCollide); + SubscribeLocalEvent(HandleGeneratorCollide); + SubscribeLocalEvent(HandleParticleCollide); + } + + private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent component, StartCollideEvent args) + { + if (args.OtherFixture.Body.Owner.TryGetComponent(out var singularityGeneratorComponent)) + { + singularityGeneratorComponent.Power += component.State switch + { + ParticleAcceleratorPowerState.Standby => 0, + ParticleAcceleratorPowerState.Level0 => 1, + ParticleAcceleratorPowerState.Level1 => 2, + ParticleAcceleratorPowerState.Level2 => 4, + ParticleAcceleratorPowerState.Level3 => 8, + _ => 0 + }; + + EntityManager.QueueDeleteEntity(uid); + } + } + + private void HandleGeneratorCollide(EntityUid uid, ContainmentFieldGeneratorComponent component, StartCollideEvent args) + { + if (args.OtherFixture.Body.Owner.HasTag("EmitterBolt")) { + component.ReceivePower(6); + } + } + + private void HandleFieldCollide(EntityUid uid, ContainmentFieldComponent component, StartCollideEvent args) + { + if (component.Parent == null) + { + EntityManager.QueueDeleteEntity(uid); + return; + } + + component.Parent.TryRepell(component.Owner, args.OtherFixture.Body.Owner); } private static void BodyTypeChanged(