The disposals pushing and pulling update (#1875)

* Add collision to disposal unit and pipes
Make disposal unit and pipes pullable
Implement proper handling of collisions in disposals

* Implement IsExiting
Move DisposalSystem to shared

* Change SharedDisosalUnitComponent to call manager.ContainsEntity directly

* Update saltern.yml

Co-authored-by: Julian Giebel <j.giebel@netrocks.info>
This commit is contained in:
Julian Giebel
2020-08-24 20:41:15 +02:00
committed by GitHub
parent 9019079d79
commit d9f02a6a0a
8 changed files with 374 additions and 554 deletions

View File

@@ -1,14 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Components.UserInterface;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.IoC;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Disposal
{
public abstract class SharedDisposalUnitComponent : Component
public abstract class SharedDisposalUnitComponent : Component, ICollideSpecial
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "DisposalUnit";
private readonly List<IEntity> _intersecting = new List<IEntity>();
[Serializable, NetSerializable]
public enum Visuals
{
@@ -57,6 +68,46 @@ namespace Content.Shared.GameObjects.Components.Disposal
Pressurizing
}
bool ICollideSpecial.PreventCollide(IPhysBody collided)
{
if (IsExiting(collided.Entity)) return true;
if (!Owner.TryGetComponent(out IContainerManager manager)) return false;
if (manager.ContainsEntity(collided.Entity))
{
if (!_intersecting.Contains(collided.Entity))
{
_intersecting.Add(collided.Entity);
}
return true;
}
return false;
}
public virtual void Update(float frameTime)
{
UpdateIntersecting();
}
private bool IsExiting(IEntity entity)
{
return _intersecting.Contains(entity);
}
private void UpdateIntersecting()
{
if(_intersecting.Count == 0) return;
var intersectingEntities = _entityManager.GetEntitiesIntersecting(Owner);
for (var i = _intersecting.Count - 1; i >= 0; i--)
{
if (!intersectingEntities.Contains(_intersecting[i]))
{
_intersecting.RemoveAt(i);
}
}
}
[Serializable, NetSerializable]
public class DisposalUnitBoundUserInterfaceState : BoundUserInterfaceState, IEquatable<DisposalUnitBoundUserInterfaceState>
{