diff --git a/Content.Server/Singularity/Components/ServerSingularityComponent.cs b/Content.Server/Singularity/Components/ServerSingularityComponent.cs index 768299350a..4440da7ff7 100644 --- a/Content.Server/Singularity/Components/ServerSingularityComponent.cs +++ b/Content.Server/Singularity/Components/ServerSingularityComponent.cs @@ -14,7 +14,7 @@ namespace Content.Server.Singularity.Components { [RegisterComponent] [ComponentReference(typeof(SharedSingularityComponent))] - public class ServerSingularityComponent : SharedSingularityComponent, IStartCollide + public class ServerSingularityComponent : SharedSingularityComponent { private SharedSingularitySystem _singularitySystem = default!; @@ -94,46 +94,6 @@ namespace Content.Server.Singularity.Components Energy -= EnergyDrain * seconds; } - void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold) - { - // If we're being deleted by another singularity, this call is probably for that singularity. - // Even if not, just don't bother. - if (BeingDeletedByAnotherSingularity) - return; - - var otherEntity = otherFixture.Body.Owner; - - if (otherEntity.TryGetComponent(out var mapGridComponent)) - { - foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(ourFixture.Body.GetWorldAABB())) - { - mapGridComponent.Grid.SetTile(tile.GridIndices, Robust.Shared.Map.Tile.Empty); - Energy++; - } - return; - } - - if (otherEntity.HasComponent() || - (otherEntity.TryGetComponent(out var component) && component.CanRepell(Owner))) - { - return; - } - - if (otherEntity.IsInContainer()) - return; - - // Singularity priority management / etc. - if (otherEntity.TryGetComponent(out var otherSingulo)) - otherSingulo.BeingDeletedByAnotherSingularity = true; - - otherEntity.QueueDelete(); - - if (otherEntity.TryGetComponent(out var singuloFood)) - Energy += singuloFood.Energy; - else - Energy++; - } - protected override void OnRemove() { _playingSound?.Stop(); diff --git a/Content.Server/Singularity/EntitySystems/SingularitySystem.cs b/Content.Server/Singularity/EntitySystems/SingularitySystem.cs index cc457295d3..eafc982c37 100644 --- a/Content.Server/Singularity/EntitySystems/SingularitySystem.cs +++ b/Content.Server/Singularity/EntitySystems/SingularitySystem.cs @@ -1,6 +1,9 @@ using Content.Server.Singularity.Components; using Content.Shared.Singularity; using JetBrains.Annotations; +using Robust.Shared.Containers; +using Robust.Shared.GameObjects; +using Robust.Shared.Physics.Dynamics; namespace Content.Server.Singularity.EntitySystems { @@ -10,6 +13,52 @@ namespace Content.Server.Singularity.EntitySystems private float _updateInterval = 1.0f; private float _accumulator; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(HandleCollide); + } + + private void HandleCollide(EntityUid uid, ServerSingularityComponent component, StartCollideEvent args) + { + // If we're being deleted by another singularity, this call is probably for that singularity. + // Even if not, just don't bother. + if (component.BeingDeletedByAnotherSingularity) + return; + + var otherEntity = args.OtherFixture.Body.Owner; + + if (otherEntity.TryGetComponent(out var mapGridComponent)) + { + foreach (var tile in mapGridComponent.Grid.GetTilesIntersecting(args.OurFixture.Body.GetWorldAABB())) + { + mapGridComponent.Grid.SetTile(tile.GridIndices, Robust.Shared.Map.Tile.Empty); + component.Energy++; + } + return; + } + + if (otherEntity.HasComponent() || + (otherEntity.TryGetComponent(out var containmentField) && containmentField.CanRepell(component.Owner))) + { + return; + } + + if (otherEntity.IsInContainer()) + return; + + // Singularity priority management / etc. + if (otherEntity.TryGetComponent(out var otherSingulo)) + otherSingulo.BeingDeletedByAnotherSingularity = true; + + otherEntity.QueueDelete(); + + if (otherEntity.TryGetComponent(out var singuloFood)) + component.Energy += singuloFood.Energy; + else + component.Energy++; + } + public override void Update(float frameTime) { base.Update(frameTime);