Partial hand ECS (#5634)
Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com> Co-authored-by: Paul <ritter.paul1@googlemail.com>
This commit is contained in:
@@ -24,7 +24,7 @@ namespace Content.Shared.Actions.Components
|
||||
/// Currently only maintained server side and not synced to client, as are all the equip/unequip events.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class ItemActionsComponent : Component, IEquippedHand, IUnequippedHand
|
||||
public class ItemActionsComponent : Component
|
||||
{
|
||||
public override string Name => "ItemActions";
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Content.Shared.Actions.Components
|
||||
/// <summary>
|
||||
/// hand it's currently in, null if not in a hand.
|
||||
/// </summary>
|
||||
public HandState? InHand;
|
||||
public Hand? InHand;
|
||||
|
||||
/// <summary>
|
||||
/// Entity currently holding this in hand or equip slot. Null if not held.
|
||||
@@ -179,19 +179,19 @@ namespace Content.Shared.Actions.Components
|
||||
GrantOrUpdate(actionType, toggleOn: toggleOn);
|
||||
}
|
||||
|
||||
void IEquippedHand.EquippedHand(EquippedHandEventArgs eventArgs)
|
||||
public void EquippedHand(EntityUid user, Hand hand)
|
||||
{
|
||||
// this entity cannot be granted actions if no actions component
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedActionsComponent?>(eventArgs.User, out var actionsComponent))
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedActionsComponent?>(user, out var actionsComponent))
|
||||
return;
|
||||
Holder = eventArgs.User;
|
||||
Holder = user;
|
||||
HolderActionsComponent = actionsComponent;
|
||||
IsEquipped = true;
|
||||
InHand = eventArgs.Hand;
|
||||
InHand = hand;
|
||||
GrantOrUpdateAllToHolder();
|
||||
}
|
||||
|
||||
void IUnequippedHand.UnequippedHand(UnequippedHandEventArgs eventArgs)
|
||||
public void UnequippedHand()
|
||||
{
|
||||
RevokeAllFromHolder();
|
||||
Holder = null;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Content.Shared.Actions.Components;
|
||||
using Content.Shared.Actions.Components;
|
||||
using Content.Shared.Hands;
|
||||
using Robust.Shared.GameObjects;
|
||||
using System;
|
||||
|
||||
namespace Content.Shared.Actions
|
||||
{
|
||||
@@ -16,6 +18,18 @@ namespace Content.Shared.Actions
|
||||
base.Initialize();
|
||||
|
||||
UpdatesOutsidePrediction = true;
|
||||
SubscribeLocalEvent<ItemActionsComponent, UnequippedHandEvent>(OnHandUnequipped);
|
||||
SubscribeLocalEvent<ItemActionsComponent, EquippedHandEvent>(OnHandEquipped);
|
||||
}
|
||||
|
||||
private void OnHandEquipped(EntityUid uid, ItemActionsComponent component, EquippedHandEvent args)
|
||||
{
|
||||
component.EquippedHand(args.User, args.Hand);
|
||||
}
|
||||
|
||||
private void OnHandUnequipped(EntityUid uid, ItemActionsComponent component, UnequippedHandEvent args)
|
||||
{
|
||||
component.UnequippedHand();
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
|
||||
Reference in New Issue
Block a user