Felinids fit in duffelbags. (#515)
* - add: Felinids fit in duffelbags. * - add: This is better. * - add: Move to shared.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Shared._White.Item.PseudoItem;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -67,7 +68,8 @@ public abstract class SharedVirtualItemSystem : EntitySystem
|
||||
private void OnBeforeRangedInteract(Entity<VirtualItemComponent> ent, ref BeforeRangedInteractEvent args)
|
||||
{
|
||||
// No interactions with a virtual item, please.
|
||||
args.Handled = true;
|
||||
if (!HasComp<PseudoItemComponent>(ent.Comp.BlockingEntity))
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
#region Hands
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Frozen;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared._White.Item.PseudoItem;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Coordinates;
|
||||
@@ -10,6 +11,7 @@ using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Implants.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Inventory.VirtualItem;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Lock;
|
||||
using Content.Shared.Materials;
|
||||
@@ -223,6 +225,12 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
if (HasComp<PlaceableSurfaceComponent>(uid))
|
||||
return;
|
||||
|
||||
if (TryComp<VirtualItemComponent>(args.Used, out var virtualItem)) // WD
|
||||
{
|
||||
RaiseLocalEvent(uid, new PseudoItemInteractEvent(virtualItem.BlockingEntity, args.User));
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerInsertHeldEntity(uid, args.User, storageComp);
|
||||
// Always handle it, even if insertion fails.
|
||||
// We don't want to trigger any AfterInteract logic here.
|
||||
@@ -1072,7 +1080,7 @@ public abstract class SharedStorageSystem : EntitySystem
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
var saved = list[i];
|
||||
|
||||
|
||||
if (saved == location)
|
||||
{
|
||||
list.Remove(location);
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared._White.Containers;
|
||||
using Content.Shared._White.Events;
|
||||
using Content.Shared._White.Item.PseudoItem;
|
||||
using Content.Shared._White.WeaponModules;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Actions;
|
||||
|
||||
22
Content.Shared/_White/Item/PseudoItem/PseudoItemComponent.cs
Normal file
22
Content.Shared/_White/Item/PseudoItem/PseudoItemComponent.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Content.Shared.Item;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared._White.Item.PseudoItem;
|
||||
|
||||
/// <summary>
|
||||
/// For entities that behave like an item under certain conditions,
|
||||
/// but not under most conditions.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class PseudoItemComponent : Component
|
||||
{
|
||||
[DataField]
|
||||
public ProtoId<ItemSizePrototype> Size = "Huge";
|
||||
|
||||
[DataField]
|
||||
public List<Box2i>? Shape = new() {new Box2i(0, 0, 4, 4)};
|
||||
|
||||
[AutoNetworkedField]
|
||||
public bool Active;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Item;
|
||||
|
||||
namespace Content.Shared._White.Item.PseudoItem;
|
||||
|
||||
public abstract class SharedPseudoItemSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<PseudoItemComponent, GettingPickedUpAttemptEvent>(OnGettingPickedUpAttempt);
|
||||
SubscribeLocalEvent<PseudoItemComponent, AttackAttemptEvent>(OnAttackAttempt);
|
||||
}
|
||||
|
||||
private void OnAttackAttempt(Entity<PseudoItemComponent> ent, ref AttackAttemptEvent args)
|
||||
{
|
||||
if (ent.Comp.Active)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnGettingPickedUpAttempt(Entity<PseudoItemComponent> ent, ref GettingPickedUpAttemptEvent args)
|
||||
{
|
||||
args.Cancel();
|
||||
OnGettingPickedUp(ent, args);
|
||||
}
|
||||
|
||||
protected virtual void OnGettingPickedUp(Entity<PseudoItemComponent> ent, GettingPickedUpAttemptEvent args) {}
|
||||
}
|
||||
|
||||
public sealed class PseudoItemInteractEvent(EntityUid used, EntityUid user)
|
||||
: EntityEventArgs
|
||||
{
|
||||
public EntityUid Used { get; } = used;
|
||||
public EntityUid User { get; } = user;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using Content.Shared.DoAfter;
|
||||
|
||||
namespace Content.Shared.Item.PseudoItem
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed partial class PseudoItemInsertDoAfterEvent : SimpleDoAfterEvent
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user