Moves Hands to shared, some prediction (#3829)
* HandsGuiState * Gui state setting methods * code cleanup * Removes TryGetHands * ClientHand * Gui Hands * Refactor WIP 1 * Hand index * refactors 2 * wip 3 * wip 4 * wiip 4 * wip 5 * wip 6 * wip 7 * wip 8 * wip 9 * wip 11 * Hand ui mostly looks fine * hands gui cleanup 1 * cleanup 2 * wip 13 * hand enabled * stuff * Hands gui gap fix * onpressed test * hand gui buttons events work * bag activation works * fix item use * todo comment * hands activate fix * Moves Client Hands back to using strings to identify active hand * fixes action hand highlighting * diff fix * serverhand * SharedHand * SharedHand, IReadOnlyHand * Client Hands only stores SharedHand * cleanup server hands * server hand container shutdown * misc renames, refactors of serverhand * stuff 1 * stuff 3 * server hand refactor 1 * Undo API changes to remove massive diff * More API name fixes * server hands cleanup 2 * cleanup 3 * dropping cleanup * Cleanup 4 * MoveItemFromHand * Stuff * region sorting * Hand Putter methods cleanup * stuff 2 * Merges all of serverhand and clienthand into sharedhand * Other hands systems, hack to make inhands update (gui state set every frame, visualzier updated every frame) * GetFinalDropCoordinates cleanup * SwapHands cleanup * Moves server hands code to shared hands * Fixed hand selected and deselected * Naming fixes * Server hands system cleanup * Hands privacy fixes * Client hand updates when containers are modified * HeldItemVisualizer * Fixes hand gui item status panel * method name fix * Swap hands prediction * Dropping prediction * Fixes pickup entity animation * Fixes HeldItemsVisualizer * moves item pickup to shared * PR cleanup * fixes hand enabling/disabling * build fix * Conflict fixes * Fixes pickup animation * Uses component directed message subscriptions * event unsubscriptions in hand system * unsubscribe fix * CanInsertEntityIntoHand checks if hand is enabled * Moving items from one hand to another checks if the hands can pick up and drop * Fixes stop pulling not re-enabling hand * Fixes pickup animation for entities containers on the floor * Fixes using held items * Fixes multiple hands guis appearing * test fix * removes obsolete system sunsubscribes * Checks IsFirstTimePredicted before playing drop animation * fixes hand item deleted crash * Uses Get to get other system * Replaces AppearanceComponent with SharedAppearanceComponent * Replaces EnsureComponent with TryGetComponent * Improves event class names * Moves property up to top of class * Moves code for determining the hand visualizer rsi state into the visualizer instead of being determined on hand component * Eventbus todo comment * Yaml fix for changed visualizer name * Makes HandsVisuals a byte * Removes state from HandsVisualizer * Fixes hand using interaction method name * Namespace changes fixes * Fix for changed hand interaction method * missing } * conflict build fix * Moves cleint HandsSystem to correct folder * Moved namespace fix for interaction test * Moves Handsvisualizer ot correct folder * Moves SharedHandsSystem to correct folder * Fixes errors from moving namespace of hand systems * Fixes PDA component changes * Fixes ActionsComponent diff * Fixes inventory component diff * fixes null ref * Replaces obsolete Loc.GetString usage with fluent translations * Fluent for hands disarming * SwapHands and Drop user input specify to the server which hand * Pickup animation WorldPosiiton todo * Cleans up hands gui subscription handling * Fixes change in ActionBlockerSystem access * Namespace references fixes * HandsComponent PlayerAttached/Detached messages are handled through eventbus * Fixes GasCanisterSystem drop method usage * Fix gameticker equipping method at new location Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -42,7 +42,7 @@ namespace Content.Shared.Actions.Components
|
||||
/// <summary>
|
||||
/// hand it's currently in, null if not in a hand.
|
||||
/// </summary>
|
||||
public SharedHand? InHand { get; private set; }
|
||||
public HandState? InHand { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Entity currently holding this in hand or equip slot. Null if not held.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,12 +23,12 @@ namespace Content.Shared.Hands
|
||||
|
||||
public class EquippedHandEventArgs : UserEventArgs
|
||||
{
|
||||
public EquippedHandEventArgs(IEntity user, SharedHand hand) : base(user)
|
||||
public EquippedHandEventArgs(IEntity user, HandState hand) : base(user)
|
||||
{
|
||||
Hand = hand;
|
||||
}
|
||||
|
||||
public SharedHand Hand { get; }
|
||||
public HandState Hand { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -50,9 +50,9 @@ namespace Content.Shared.Hands
|
||||
/// <summary>
|
||||
/// Hand that the item was placed into.
|
||||
/// </summary>
|
||||
public SharedHand Hand { get; }
|
||||
public HandState Hand { get; }
|
||||
|
||||
public EquippedHandEvent(IEntity user, IEntity equipped, SharedHand hand)
|
||||
public EquippedHandEvent(IEntity user, IEntity equipped, HandState hand)
|
||||
{
|
||||
User = user;
|
||||
Equipped = equipped;
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace Content.Shared.Hands
|
||||
|
||||
public class UnequippedHandEventArgs : UserEventArgs
|
||||
{
|
||||
public UnequippedHandEventArgs(IEntity user, SharedHand hand) : base(user)
|
||||
public UnequippedHandEventArgs(IEntity user, HandState hand) : base(user)
|
||||
{
|
||||
Hand = hand;
|
||||
}
|
||||
|
||||
public SharedHand Hand { get; }
|
||||
public HandState Hand { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -49,9 +49,9 @@ namespace Content.Shared.Hands
|
||||
/// <summary>
|
||||
/// Hand that the item is removed from.
|
||||
/// </summary>
|
||||
public SharedHand Hand { get; }
|
||||
public HandState Hand { get; }
|
||||
|
||||
public UnequippedHandEvent(IEntity user, IEntity unequipped, SharedHand hand)
|
||||
public UnequippedHandEvent(IEntity user, IEntity unequipped, HandState hand)
|
||||
{
|
||||
User = user;
|
||||
Unequipped = unequipped;
|
||||
|
||||
79
Content.Shared/Hands/SharedHandsSystem.cs
Normal file
79
Content.Shared/Hands/SharedHandsSystem.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using Content.Shared.Hands.Components;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
|
||||
namespace Content.Shared.Hands
|
||||
{
|
||||
public abstract class SharedHandsSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SharedHandsComponent, EntRemovedFromContainerMessage>(HandleContainerModified);
|
||||
SubscribeLocalEvent<SharedHandsComponent, EntInsertedIntoContainerMessage>(HandleContainerModified);
|
||||
|
||||
SubscribeLocalEvent<RequestSetHandEvent>(HandleSetHand);
|
||||
SubscribeNetworkEvent<RequestSetHandEvent>(HandleSetHand);
|
||||
|
||||
SubscribeLocalEvent<RequestDropHeldEntityEvent>(HandleDrop);
|
||||
SubscribeNetworkEvent<RequestDropHeldEntityEvent>(HandleDrop);
|
||||
}
|
||||
|
||||
private void HandleSetHand(RequestSetHandEvent msg, EntitySessionEventArgs eventArgs)
|
||||
{
|
||||
var entity = eventArgs.SenderSession?.AttachedEntity;
|
||||
|
||||
if (entity == null || !entity.TryGetComponent(out SharedHandsComponent? hands))
|
||||
return;
|
||||
|
||||
hands.ActiveHand = msg.HandName;
|
||||
}
|
||||
|
||||
private void HandleDrop(RequestDropHeldEntityEvent msg, EntitySessionEventArgs eventArgs)
|
||||
{
|
||||
var entity = eventArgs.SenderSession?.AttachedEntity;
|
||||
|
||||
if (entity == null || !entity.TryGetComponent(out SharedHandsComponent? hands))
|
||||
return;
|
||||
|
||||
hands.TryDropHand(msg.HandName, msg.DropTarget);
|
||||
}
|
||||
|
||||
protected abstract void HandleContainerModified(EntityUid uid, SharedHandsComponent component, ContainerModifiedMessage args);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class RequestSetHandEvent : EntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The hand to be swapped to.
|
||||
/// </summary>
|
||||
public string HandName { get; }
|
||||
|
||||
public RequestSetHandEvent(string handName)
|
||||
{
|
||||
HandName = handName;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class RequestDropHeldEntityEvent : EntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The hand to drop from.
|
||||
/// </summary>
|
||||
public string HandName { get; }
|
||||
|
||||
public EntityCoordinates DropTarget { get; }
|
||||
|
||||
public RequestDropHeldEntityEvent(string handName, EntityCoordinates dropTarget)
|
||||
{
|
||||
HandName = handName;
|
||||
DropTarget = dropTarget;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using Content.Shared.Inventory;
|
||||
@@ -136,14 +137,22 @@ namespace Content.Shared.Item
|
||||
|
||||
bool IInteractHand.InteractHand(InteractHandEventArgs eventArgs)
|
||||
{
|
||||
return TryPutInHand(eventArgs.User);
|
||||
}
|
||||
var user = eventArgs.User;
|
||||
|
||||
/// <summary>
|
||||
/// Tries to put this item in a player's hands.
|
||||
/// TODO: Move server implementation here once hands are in shared.
|
||||
/// </summary>
|
||||
public abstract bool TryPutInHand(IEntity user);
|
||||
if (!CanPickup(user))
|
||||
return false;
|
||||
|
||||
if (!user.TryGetComponent(out SharedHandsComponent? hands))
|
||||
return false;
|
||||
|
||||
var activeHand = hands.ActiveHand;
|
||||
|
||||
if (activeHand == null)
|
||||
return false;
|
||||
|
||||
hands.TryPickupEntityToActiveHand(Owner);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual void OnEquippedPrefixChange() { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user