get that crap outta here (completely rewrites inventorysystem) (#5807)
* some work * equip: done unequip: todo * unequipping done & refactored events * workin * movin * reee namespaces * stun * mobstate * fixes * some work on events * removes serverside itemcomp & misc fixes * work * smol merge fix * ports template to prototype & finishes ui * moves relay & adds containerenumerator * actions & cuffs * my god what is actioncode * more fixes * im loosing my grasp on reality * more fixes * more work * explosions * yes * more work * more fixes * merge master & misc fixed because i forgot to commit before merging master * more fixes * fixes * moar * more work * moar fixes * suffixmap * more work on client * motivation low * no. no containers * mirroring client to server * fixes * move serverinvcomp * serverinventorycomponent is dead * gaming * only strippable & ai left... * only ai and richtext left * fixes ai * fixes * fixes sprite layers * more fixes * resolves optional * yes * stable™️ * fixes * moar fixes * moar * fix some tests * lmao * no comment * good to merge™️ * fixes build but for real * adresses some reviews * adresses some more reviews * nullables, yo * fixes lobbyscreen * timid refactor to differentiate actor & target * adresses more reviews * more * my god what a mess * removed the rest of duplicates * removed duplicate slotflags and renamed shoes to feet * removes another unused one * yes * fixes lobby & makes tryunequip return unequipped item * fixes * some funny renames * fixes * misc improvements to attemptevents * fixes * merge fixes Co-authored-by: Paul Ritter <ritter.paul1@gmail.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Shared.Item
|
||||
@@ -11,6 +13,38 @@ namespace Content.Shared.Item
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SharedItemComponent, GetInteractionVerbsEvent>(AddPickupVerb);
|
||||
|
||||
SubscribeLocalEvent<SharedSpriteComponent, GotEquippedEvent>(OnEquipped);
|
||||
SubscribeLocalEvent<SharedSpriteComponent, GotUnequippedEvent>(OnUnequipped);
|
||||
|
||||
SubscribeLocalEvent<SharedItemComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<SharedItemComponent, ComponentHandleState>(OnHandleState);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, SharedItemComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not ItemComponentState state)
|
||||
return;
|
||||
|
||||
component.Size = state.Size;
|
||||
component.EquippedPrefix = state.EquippedPrefix;
|
||||
component.Color = state.Color;
|
||||
component.RsiPath = state.RsiPath;
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, SharedItemComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new ItemComponentState(component.Size, component.EquippedPrefix, component.Color, component.RsiPath);
|
||||
}
|
||||
|
||||
private void OnUnequipped(EntityUid uid, SharedSpriteComponent component, GotUnequippedEvent args)
|
||||
{
|
||||
component.Visible = true;
|
||||
}
|
||||
|
||||
private void OnEquipped(EntityUid uid, SharedSpriteComponent component, GotEquippedEvent args)
|
||||
{
|
||||
component.Visible = false;
|
||||
}
|
||||
|
||||
private void AddPickupVerb(EntityUid uid, SharedItemComponent component, GetInteractionVerbsEvent args)
|
||||
|
||||
@@ -4,6 +4,7 @@ using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Sound;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -19,7 +20,7 @@ namespace Content.Shared.Item
|
||||
/// Players can pick up, drop, and put items in bags, and they can be seen in player's hands.
|
||||
/// </summary>
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedItemComponent : Component, IEquipped, IUnequipped, IInteractHand
|
||||
public class SharedItemComponent : Component, IInteractHand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
@@ -44,6 +45,7 @@ namespace Content.Shared.Item
|
||||
/// <summary>
|
||||
/// Part of the state of the sprite shown on the player when this item is in their hands.
|
||||
/// </summary>
|
||||
// todo paul make this update slotvisuals on client on change
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public string? EquippedPrefix
|
||||
{
|
||||
@@ -58,6 +60,13 @@ namespace Content.Shared.Item
|
||||
[DataField("HeldPrefix")]
|
||||
private string? _equippedPrefix;
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("Slots")]
|
||||
public SlotFlags SlotFlags = SlotFlags.PREVENTEQUIP; //Different from None, NONE allows equips if no slot flags are required
|
||||
|
||||
[DataField("EquipSound")]
|
||||
public SoundSpecifier? EquipSound { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Color of the sprite shown on the player when this item is in their hands.
|
||||
/// </summary>
|
||||
@@ -65,7 +74,7 @@ namespace Content.Shared.Item
|
||||
public Color Color
|
||||
{
|
||||
get => _color;
|
||||
protected set
|
||||
set
|
||||
{
|
||||
_color = value;
|
||||
Dirty();
|
||||
@@ -90,24 +99,6 @@ namespace Content.Shared.Item
|
||||
[DataField("sprite")]
|
||||
private string? _rsiPath;
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
{
|
||||
return new ItemComponentState(Size, EquippedPrefix, Color, RsiPath);
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
|
||||
if (curState is not ItemComponentState state)
|
||||
return;
|
||||
|
||||
Size = state.Size;
|
||||
EquippedPrefix = state.EquippedPrefix;
|
||||
Color = state.Color;
|
||||
RsiPath = state.RsiPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If a player can pick up this item.
|
||||
/// </summary>
|
||||
@@ -125,16 +116,6 @@ namespace Content.Shared.Item
|
||||
return user.InRangeUnobstructed(Owner, ignoreInsideBlocker: true, popup: popup);
|
||||
}
|
||||
|
||||
void IEquipped.Equipped(EquippedEventArgs eventArgs)
|
||||
{
|
||||
EquippedToSlot();
|
||||
}
|
||||
|
||||
void IUnequipped.Unequipped(UnequippedEventArgs eventArgs)
|
||||
{
|
||||
RemovedFromSlot();
|
||||
}
|
||||
|
||||
bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs)
|
||||
{
|
||||
var user = eventArgs.User;
|
||||
|
||||
Reference in New Issue
Block a user