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