Fix foldables (#19717)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Content.Client.Storage.Components;
|
using Content.Client.Storage.Components;
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
|
using Content.Shared.Foldable;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Lock;
|
using Content.Shared.Lock;
|
||||||
using Content.Shared.Movement.Events;
|
using Content.Shared.Movement.Events;
|
||||||
@@ -23,6 +24,7 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
|
|||||||
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestruction);
|
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestruction);
|
||||||
SubscribeLocalEvent<EntityStorageComponent, GetVerbsEvent<InteractionVerb>>(AddToggleOpenVerb);
|
SubscribeLocalEvent<EntityStorageComponent, GetVerbsEvent<InteractionVerb>>(AddToggleOpenVerb);
|
||||||
SubscribeLocalEvent<EntityStorageComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
SubscribeLocalEvent<EntityStorageComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
||||||
|
SubscribeLocalEvent<EntityStorageComponent, FoldAttemptEvent>(OnFoldAttempt);
|
||||||
|
|
||||||
SubscribeLocalEvent<EntityStorageComponent, ComponentGetState>(OnGetState);
|
SubscribeLocalEvent<EntityStorageComponent, ComponentGetState>(OnGetState);
|
||||||
SubscribeLocalEvent<EntityStorageComponent, ComponentHandleState>(OnHandleState);
|
SubscribeLocalEvent<EntityStorageComponent, ComponentHandleState>(OnHandleState);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Server.Construction.Components;
|
|||||||
using Content.Server.Storage.Components;
|
using Content.Server.Storage.Components;
|
||||||
using Content.Server.Tools.Systems;
|
using Content.Server.Tools.Systems;
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
|
using Content.Shared.Foldable;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Lock;
|
using Content.Shared.Lock;
|
||||||
using Content.Shared.Movement.Events;
|
using Content.Shared.Movement.Events;
|
||||||
@@ -35,6 +36,7 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
|
|||||||
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestruction);
|
SubscribeLocalEvent<EntityStorageComponent, DestructionEventArgs>(OnDestruction);
|
||||||
SubscribeLocalEvent<EntityStorageComponent, GetVerbsEvent<InteractionVerb>>(AddToggleOpenVerb);
|
SubscribeLocalEvent<EntityStorageComponent, GetVerbsEvent<InteractionVerb>>(AddToggleOpenVerb);
|
||||||
SubscribeLocalEvent<EntityStorageComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
SubscribeLocalEvent<EntityStorageComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
|
||||||
|
SubscribeLocalEvent<EntityStorageComponent, FoldAttemptEvent>(OnFoldAttempt);
|
||||||
|
|
||||||
SubscribeLocalEvent<EntityStorageComponent, ComponentGetState>(OnGetState);
|
SubscribeLocalEvent<EntityStorageComponent, ComponentGetState>(OnGetState);
|
||||||
SubscribeLocalEvent<EntityStorageComponent, ComponentHandleState>(OnHandleState);
|
SubscribeLocalEvent<EntityStorageComponent, ComponentHandleState>(OnHandleState);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Content.Shared.Buckle.Components;
|
using Content.Shared.Buckle.Components;
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
using Content.Shared.DragDrop;
|
using Content.Shared.DragDrop;
|
||||||
|
using Content.Shared.Foldable;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Storage;
|
using Content.Shared.Storage;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
@@ -31,6 +32,7 @@ public abstract partial class SharedBuckleSystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<StrapComponent, DragDropTargetEvent>(OnStrapDragDropTarget);
|
SubscribeLocalEvent<StrapComponent, DragDropTargetEvent>(OnStrapDragDropTarget);
|
||||||
SubscribeLocalEvent<StrapComponent, CanDropTargetEvent>(OnCanDropTarget);
|
SubscribeLocalEvent<StrapComponent, CanDropTargetEvent>(OnCanDropTarget);
|
||||||
|
SubscribeLocalEvent<StrapComponent, FoldAttemptEvent>(OnAttemptFold);
|
||||||
|
|
||||||
SubscribeLocalEvent<StrapComponent, MoveEvent>(OnStrapMoveEvent);
|
SubscribeLocalEvent<StrapComponent, MoveEvent>(OnStrapMoveEvent);
|
||||||
}
|
}
|
||||||
@@ -115,7 +117,7 @@ public abstract partial class SharedBuckleSystem
|
|||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ToggleBuckle(args.User, args.User, uid);
|
args.Handled = ToggleBuckle(args.User, args.User, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddStrapVerbs(EntityUid uid, StrapComponent component, GetVerbsEvent<InteractionVerb> args)
|
private void AddStrapVerbs(EntityUid uid, StrapComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||||
@@ -199,6 +201,14 @@ public abstract partial class SharedBuckleSystem
|
|||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnAttemptFold(EntityUid uid, StrapComponent component, ref FoldAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (args.Cancelled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
args.Cancelled = component.BuckledEntities.Count != 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void OnStrapDragDropTarget(EntityUid uid, StrapComponent component, ref DragDropTargetEvent args)
|
private void OnStrapDragDropTarget(EntityUid uid, StrapComponent component, ref DragDropTargetEvent args)
|
||||||
{
|
{
|
||||||
if (!StrapCanDragDropOn(uid, args.User, uid, args.Dragged, component))
|
if (!StrapCanDragDropOn(uid, args.User, uid, args.Dragged, component))
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Shared.Buckle;
|
using Content.Shared.Buckle;
|
||||||
using Content.Shared.Buckle.Components;
|
|
||||||
using Content.Shared.Storage.Components;
|
using Content.Shared.Storage.Components;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
@@ -105,17 +103,9 @@ public sealed class FoldableSystem : EntitySystem
|
|||||||
if (_container.IsEntityInContainer(uid))
|
if (_container.IsEntityInContainer(uid))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If an entity is buckled to the object we can't pick it up or fold it
|
var ev = new FoldAttemptEvent();
|
||||||
if (TryComp(uid, out StrapComponent? strap) && strap.BuckledEntities.Any())
|
RaiseLocalEvent(uid, ref ev);
|
||||||
return false;
|
return !ev.Cancelled;
|
||||||
|
|
||||||
if (TryComp(uid, out SharedEntityStorageComponent? storage))
|
|
||||||
{
|
|
||||||
if (storage.Open || storage.Contents.ContainedEntities.Any())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -161,3 +151,10 @@ public sealed class FoldableSystem : EntitySystem
|
|||||||
State
|
State
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event raised on an entity to determine if it can be folded.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Cancelled"></param>
|
||||||
|
[ByRefEvent]
|
||||||
|
public record struct FoldAttemptEvent(bool Cancelled = false);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ public abstract class SharedItemSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<ItemComponent, GetVerbsEvent<InteractionVerb>>(AddPickupVerb);
|
SubscribeLocalEvent<ItemComponent, GetVerbsEvent<InteractionVerb>>(AddPickupVerb);
|
||||||
SubscribeLocalEvent<ItemComponent, InteractHandEvent>(OnHandInteract);
|
SubscribeLocalEvent<ItemComponent, InteractHandEvent>(OnHandInteract, before: new []{typeof(SharedItemSystem)});
|
||||||
SubscribeLocalEvent<ItemComponent, StackCountChangedEvent>(OnStackCountChanged);
|
SubscribeLocalEvent<ItemComponent, StackCountChangedEvent>(OnStackCountChanged);
|
||||||
|
|
||||||
SubscribeLocalEvent<ItemComponent, ComponentGetState>(OnGetState);
|
SubscribeLocalEvent<ItemComponent, ComponentGetState>(OnGetState);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Linq;
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Content.Shared.Body.Components;
|
using Content.Shared.Body.Components;
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
|
using Content.Shared.Foldable;
|
||||||
using Content.Shared.Hands.Components;
|
using Content.Shared.Hands.Components;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
@@ -130,6 +131,13 @@ public abstract class SharedEntityStorageSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void OnFoldAttempt(EntityUid uid, SharedEntityStorageComponent component, ref FoldAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (args.Cancelled)
|
||||||
|
return;
|
||||||
|
args.Cancelled = component.Open || component.Contents.ContainedEntities.Count != 0;
|
||||||
|
}
|
||||||
|
|
||||||
protected void AddToggleOpenVerb(EntityUid uid, SharedEntityStorageComponent component, GetVerbsEvent<InteractionVerb> args)
|
protected void AddToggleOpenVerb(EntityUid uid, SharedEntityStorageComponent component, GetVerbsEvent<InteractionVerb> args)
|
||||||
{
|
{
|
||||||
if (!args.CanAccess || !args.CanInteract)
|
if (!args.CanAccess || !args.CanInteract)
|
||||||
|
|||||||
Reference in New Issue
Block a user