Adds yeeting to disposal bins (#2218)

* Adds yeeting to disposal bins

Kobe

* Thanks zum

* ?

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2020-10-11 22:13:34 +11:00
committed by GitHub
parent 40504c2555
commit ab2149abf0
2 changed files with 30 additions and 19 deletions

View File

@@ -1,25 +1,28 @@
using System;
#nullable enable
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;
using Robust.Shared.ViewVariables;
namespace Content.Shared.GameObjects.Components.Disposal
{
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>();
[ViewVariables]
public bool Anchored =>
!Owner.TryGetComponent(out CollidableComponent? collidable) ||
collidable.Anchored;
[Serializable, NetSerializable]
public enum Visuals
{
@@ -71,7 +74,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
bool ICollideSpecial.PreventCollide(IPhysBody collided)
{
if (IsExiting(collided.Entity)) return true;
if (!Owner.TryGetComponent(out IContainerManager manager)) return false;
if (!Owner.TryGetComponent(out IContainerManager? manager)) return false;
if (manager.ContainsEntity(collided.Entity))
{
@@ -98,13 +101,12 @@ namespace Content.Shared.GameObjects.Components.Disposal
{
if(_intersecting.Count == 0) return;
var intersectingEntities = _entityManager.GetEntitiesIntersecting(Owner);
for (var i = _intersecting.Count - 1; i >= 0; i--)
{
if (!intersectingEntities.Contains(_intersecting[i]))
{
var entity = _intersecting[i];
if (!Owner.EntityManager.IsIntersecting(entity, Owner))
_intersecting.RemoveAt(i);
}
}
}
@@ -127,7 +129,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
Engaged = engaged;
}
public bool Equals(DisposalUnitBoundUserInterfaceState other)
public bool Equals(DisposalUnitBoundUserInterfaceState? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;