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:
@@ -7,11 +7,13 @@ using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||
using Content.Server.GameObjects.Components.Projectiles;
|
||||
using Content.Server.GameObjects.EntitySystems.DoAfter;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||
using Content.Server.Utility;
|
||||
using Content.Shared.GameObjects.Components.Body;
|
||||
using Content.Shared.GameObjects.Components.Disposal;
|
||||
using Content.Shared.GameObjects.Components.Items;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.Verbs;
|
||||
using Content.Shared.Interfaces;
|
||||
@@ -28,6 +30,7 @@ using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
@@ -42,7 +45,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
[ComponentReference(typeof(SharedDisposalUnitComponent))]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
[ComponentReference(typeof(IInteractUsing))]
|
||||
public class DisposalUnitComponent : SharedDisposalUnitComponent, IInteractHand, IActivate, IInteractUsing, IDragDropOn
|
||||
public class DisposalUnitComponent : SharedDisposalUnitComponent, IInteractHand, IActivate, IInteractUsing, IDragDropOn, IThrowCollide
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
@@ -96,11 +99,6 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
!Owner.TryGetComponent(out PowerReceiverComponent? receiver) ||
|
||||
receiver.Powered;
|
||||
|
||||
[ViewVariables]
|
||||
public bool Anchored =>
|
||||
!Owner.TryGetComponent(out CollidableComponent? collidable) ||
|
||||
collidable.Anchored;
|
||||
|
||||
[ViewVariables]
|
||||
private PressureState State => _pressure >= 1 ? PressureState.Ready : PressureState.Pressurizing;
|
||||
|
||||
@@ -412,7 +410,6 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!Anchored)
|
||||
{
|
||||
appearance.SetData(Visuals.VisualState, VisualState.UnAnchored);
|
||||
@@ -686,6 +683,18 @@ namespace Content.Server.GameObjects.Components.Disposal
|
||||
return true;
|
||||
}
|
||||
|
||||
void IThrowCollide.HitBy(ThrowCollideEventArgs eventArgs)
|
||||
{
|
||||
if (!CanInsert(eventArgs.Thrown) ||
|
||||
IoCManager.Resolve<IRobustRandom>().NextDouble() > 0.75 ||
|
||||
!_container.Insert(eventArgs.Thrown))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AfterInsert(eventArgs.Thrown);
|
||||
}
|
||||
|
||||
[Verb]
|
||||
private sealed class SelfInsertVerb : Verb<DisposalUnitComponent>
|
||||
{
|
||||
|
||||
@@ -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,15 +101,14 @@ 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class DisposalUnitBoundUserInterfaceState : BoundUserInterfaceState, IEquatable<DisposalUnitBoundUserInterfaceState>
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user