Stop singularity from pulling ghosts, stop singularity from leaving the pull controller attached (#3021)

This commit is contained in:
20kdc
2021-01-19 06:35:44 +00:00
committed by GitHub
parent a7354f8e0d
commit 6f360b48bf

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Server.GameObjects.Components.StationEvents; using Content.Server.GameObjects.Components.StationEvents;
using Content.Server.GameObjects.Components.Observer;
using Content.Shared.GameObjects; using Content.Shared.GameObjects;
using Content.Shared.Physics; using Content.Shared.Physics;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -159,7 +160,7 @@ namespace Content.Server.GameObjects.Components.Singularity
} }
private readonly List<IEntity> _previousPulledEntities = new(); private readonly List<IEntity> _previousPulledEntities = new();
public void PullUpdate() public void CleanupPulledEntities()
{ {
foreach (var previousPulledEntity in _previousPulledEntities) foreach (var previousPulledEntity in _previousPulledEntities)
{ {
@@ -169,11 +170,16 @@ namespace Content.Server.GameObjects.Components.Singularity
controller.StopPull(); controller.StopPull();
} }
_previousPulledEntities.Clear(); _previousPulledEntities.Clear();
}
public void PullUpdate()
{
CleanupPulledEntities();
var entitiesToPull = Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10); var entitiesToPull = Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10);
foreach (var entity in entitiesToPull) foreach (var entity in entitiesToPull)
{ {
if (!entity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue; if (!entity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue;
if (entity.HasComponent<GhostComponent>()) continue;
var controller = collidableComponent.EnsureController<SingularityPullController>(); var controller = collidableComponent.EnsureController<SingularityPullController>();
if(Owner.Transform.Coordinates.EntityId != entity.Transform.Coordinates.EntityId) continue; if(Owner.Transform.Coordinates.EntityId != entity.Transform.Coordinates.EntityId) continue;
var vec = (Owner.Transform.Coordinates - entity.Transform.Coordinates).Position; var vec = (Owner.Transform.Coordinates - entity.Transform.Coordinates).Position;
@@ -215,6 +221,7 @@ namespace Content.Server.GameObjects.Components.Singularity
{ {
_playingSound?.Stop(); _playingSound?.Stop();
_audioSystem.PlayAtCoords("/Audio/Effects/singularity_collapse.ogg", Owner.Transform.Coordinates); _audioSystem.PlayAtCoords("/Audio/Effects/singularity_collapse.ogg", Owner.Transform.Coordinates);
CleanupPulledEntities();
base.OnRemove(); base.OnRemove();
} }
} }