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.GUI;
|
||||||
using Content.Server.GameObjects.Components.Items.Storage;
|
using Content.Server.GameObjects.Components.Items.Storage;
|
||||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||||
|
using Content.Server.GameObjects.Components.Projectiles;
|
||||||
using Content.Server.GameObjects.EntitySystems.DoAfter;
|
using Content.Server.GameObjects.EntitySystems.DoAfter;
|
||||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||||
using Content.Server.Utility;
|
using Content.Server.Utility;
|
||||||
using Content.Shared.GameObjects.Components.Body;
|
using Content.Shared.GameObjects.Components.Body;
|
||||||
using Content.Shared.GameObjects.Components.Disposal;
|
using Content.Shared.GameObjects.Components.Disposal;
|
||||||
|
using Content.Shared.GameObjects.Components.Items;
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.GameObjects.Verbs;
|
using Content.Shared.GameObjects.Verbs;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
@@ -28,6 +30,7 @@ using Robust.Shared.GameObjects.Components;
|
|||||||
using Robust.Shared.GameObjects.Components.Transform;
|
using Robust.Shared.GameObjects.Components.Transform;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.Random;
|
||||||
using Robust.Shared.Interfaces.Timing;
|
using Robust.Shared.Interfaces.Timing;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
@@ -42,7 +45,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
[ComponentReference(typeof(SharedDisposalUnitComponent))]
|
[ComponentReference(typeof(SharedDisposalUnitComponent))]
|
||||||
[ComponentReference(typeof(IActivate))]
|
[ComponentReference(typeof(IActivate))]
|
||||||
[ComponentReference(typeof(IInteractUsing))]
|
[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!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
|
||||||
@@ -96,11 +99,6 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
!Owner.TryGetComponent(out PowerReceiverComponent? receiver) ||
|
!Owner.TryGetComponent(out PowerReceiverComponent? receiver) ||
|
||||||
receiver.Powered;
|
receiver.Powered;
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
public bool Anchored =>
|
|
||||||
!Owner.TryGetComponent(out CollidableComponent? collidable) ||
|
|
||||||
collidable.Anchored;
|
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private PressureState State => _pressure >= 1 ? PressureState.Ready : PressureState.Pressurizing;
|
private PressureState State => _pressure >= 1 ? PressureState.Ready : PressureState.Pressurizing;
|
||||||
|
|
||||||
@@ -411,8 +409,7 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!Anchored)
|
if (!Anchored)
|
||||||
{
|
{
|
||||||
appearance.SetData(Visuals.VisualState, VisualState.UnAnchored);
|
appearance.SetData(Visuals.VisualState, VisualState.UnAnchored);
|
||||||
@@ -685,6 +682,18 @@ namespace Content.Server.GameObjects.Components.Disposal
|
|||||||
_ = TryInsert(eventArgs.Dropped, eventArgs.User);
|
_ = TryInsert(eventArgs.Dropped, eventArgs.User);
|
||||||
return true;
|
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]
|
[Verb]
|
||||||
private sealed class SelfInsertVerb : Verb<DisposalUnitComponent>
|
private sealed class SelfInsertVerb : Verb<DisposalUnitComponent>
|
||||||
|
|||||||
@@ -1,25 +1,28 @@
|
|||||||
using System;
|
#nullable enable
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Components;
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.GameObjects.Components;
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Physics;
|
using Robust.Shared.Physics;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components.Disposal
|
namespace Content.Shared.GameObjects.Components.Disposal
|
||||||
{
|
{
|
||||||
public abstract class SharedDisposalUnitComponent : Component, ICollideSpecial
|
public abstract class SharedDisposalUnitComponent : Component, ICollideSpecial
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
||||||
|
|
||||||
public override string Name => "DisposalUnit";
|
public override string Name => "DisposalUnit";
|
||||||
|
|
||||||
private readonly List<IEntity> _intersecting = new List<IEntity>();
|
private readonly List<IEntity> _intersecting = new List<IEntity>();
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
|
public bool Anchored =>
|
||||||
|
!Owner.TryGetComponent(out CollidableComponent? collidable) ||
|
||||||
|
collidable.Anchored;
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
[Serializable, NetSerializable]
|
||||||
public enum Visuals
|
public enum Visuals
|
||||||
{
|
{
|
||||||
@@ -71,7 +74,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
|
|||||||
bool ICollideSpecial.PreventCollide(IPhysBody collided)
|
bool ICollideSpecial.PreventCollide(IPhysBody collided)
|
||||||
{
|
{
|
||||||
if (IsExiting(collided.Entity)) return true;
|
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))
|
if (manager.ContainsEntity(collided.Entity))
|
||||||
{
|
{
|
||||||
@@ -98,13 +101,12 @@ namespace Content.Shared.GameObjects.Components.Disposal
|
|||||||
{
|
{
|
||||||
if(_intersecting.Count == 0) return;
|
if(_intersecting.Count == 0) return;
|
||||||
|
|
||||||
var intersectingEntities = _entityManager.GetEntitiesIntersecting(Owner);
|
|
||||||
for (var i = _intersecting.Count - 1; i >= 0; i--)
|
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);
|
_intersecting.RemoveAt(i);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +129,7 @@ namespace Content.Shared.GameObjects.Components.Disposal
|
|||||||
Engaged = engaged;
|
Engaged = engaged;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(DisposalUnitBoundUserInterfaceState other)
|
public bool Equals(DisposalUnitBoundUserInterfaceState? other)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, other)) return false;
|
if (ReferenceEquals(null, other)) return false;
|
||||||
if (ReferenceEquals(this, other)) return true;
|
if (ReferenceEquals(this, other)) return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user