Add changing the amount of hands on the GUI depending on your body parts (#1406)
* Multiple hands in gui first pass * Remove IHandsComponent interface * Create hand class and more hand textures * Refactor ServerHandsComponent to use a single list of hands * Seal SharedHand * Fix picked up items not showing on top of the hand buttons * Remove HandsGui buttons and panels dictionaries * Fix items in hands rendering * Fix wrong hand container comparison * Fix not updating the location of duplicate hands * Change ClientHandsComponent to use a SortedList instead of a dictionary * More merge conflict fixes * Change SortedList to List * Fix hand button order * Add item tooltip for more than 2 hands and updating when removing hands * Add add hand and remove hand command * Merge conflict fixes * Remove nullable reference type from ContainerSlot * Fix texture errors * Fix error when reaching 0 hands * Fix error when swapping hands with no hands * Merged remove hand methods * Fix item panel texture errors * Merge conflict fixes * Fix addhand and removehand command descriptions * Add properly displaying tooltips for 2 hands * Make hand indexes and locations consistent across the client and server * Add dropping held entity if a hand is removed * Change hand location to be calculated by index * Made different hand gui updates more consistent * Remove human body yml testing changes * Sanitize addhand and removehand commands * Merge conflict fixes * Remove testing changes * Revert body system changes * Add missing imports * Remove obsolete hands parameter in yml files * Fix broken import * Fix startup error and adding and removing hands on the same tick * Make hand container id use an uint In case someone gets more than 2 billion hands * Rename hand component files * Make hands state use an array
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Stack;
|
||||
using Content.Server.Interfaces;
|
||||
using Content.Server.Throw;
|
||||
using Content.Shared.GameObjects.Components.Inventory;
|
||||
using Content.Shared.Input;
|
||||
@@ -15,6 +16,8 @@ using Robust.Shared.Localization;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
using System;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Items;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Server.GameObjects.Components;
|
||||
@@ -74,11 +77,10 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
|
||||
|
||||
var ent = session.AttachedEntity;
|
||||
|
||||
if (ent == null || !ent.IsValid())
|
||||
return false;
|
||||
|
||||
if (!ent.TryGetComponent(out T comp))
|
||||
if (ent == null || !ent.IsValid() || !ent.TryGetComponent(out T comp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
component = comp;
|
||||
return true;
|
||||
@@ -87,9 +89,11 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
|
||||
private static void HandleSwapHands(ICommonSession session)
|
||||
{
|
||||
if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent handsComp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var interactionSystem = EntitySystem.Get<InteractionSystem>();
|
||||
var interactionSystem = Get<InteractionSystem>();
|
||||
|
||||
var oldItem = handsComp.GetActiveHand;
|
||||
|
||||
@@ -97,11 +101,15 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
|
||||
|
||||
var newItem = handsComp.GetActiveHand;
|
||||
|
||||
if(oldItem != null)
|
||||
if (oldItem != null)
|
||||
{
|
||||
interactionSystem.HandDeselectedInteraction(handsComp.Owner, oldItem.Owner);
|
||||
}
|
||||
|
||||
if(newItem != null)
|
||||
if (newItem != null)
|
||||
{
|
||||
interactionSystem.HandSelectedInteraction(handsComp.Owner, newItem.Owner);
|
||||
}
|
||||
}
|
||||
|
||||
private bool HandleDrop(ICommonSession session, GridCoordinates coords, EntityUid uid)
|
||||
@@ -119,11 +127,11 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
|
||||
|
||||
var entCoords = ent.Transform.GridPosition.Position;
|
||||
var entToDesiredDropCoords = coords.Position - entCoords;
|
||||
var targetLength = Math.Min(entToDesiredDropCoords.Length, InteractionSystem.InteractionRange - 0.001f); // InteractionRange is reduced due to InRange not dealing with floating point error
|
||||
var targetLength = Math.Min(entToDesiredDropCoords.Length, SharedInteractionSystem.InteractionRange - 0.001f); // InteractionRange is reduced due to InRange not dealing with floating point error
|
||||
var newCoords = new GridCoordinates((entToDesiredDropCoords.Normalized * targetLength) + entCoords, coords.GridID);
|
||||
var rayLength = EntitySystem.Get<SharedInteractionSystem>().UnobstructedRayLength(ent.Transform.MapPosition, newCoords.ToMap(_mapManager), ignoredEnt: ent);
|
||||
var rayLength = Get<SharedInteractionSystem>().UnobstructedRayLength(ent.Transform.MapPosition, newCoords.ToMap(_mapManager), ignoredEnt: ent);
|
||||
|
||||
handsComp.Drop(handsComp.ActiveIndex, new GridCoordinates(entCoords + (entToDesiredDropCoords.Normalized * rayLength), coords.GridID));
|
||||
handsComp.Drop(handsComp.ActiveHand, new GridCoordinates(entCoords + (entToDesiredDropCoords.Normalized * rayLength), coords.GridID));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -146,10 +154,10 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
|
||||
if (!plyEnt.TryGetComponent(out HandsComponent handsComp))
|
||||
return false;
|
||||
|
||||
if (!handsComp.CanDrop(handsComp.ActiveIndex))
|
||||
if (!handsComp.CanDrop(handsComp.ActiveHand))
|
||||
return false;
|
||||
|
||||
var throwEnt = handsComp.GetHand(handsComp.ActiveIndex).Owner;
|
||||
var throwEnt = handsComp.GetItem(handsComp.ActiveHand).Owner;
|
||||
|
||||
if (!handsComp.ThrowItem())
|
||||
return false;
|
||||
@@ -157,7 +165,7 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
|
||||
// throw the item, split off from a stack if it's meant to be thrown individually
|
||||
if (!throwEnt.TryGetComponent(out StackComponent stackComp) || stackComp.Count < 2 || !stackComp.ThrowIndividually)
|
||||
{
|
||||
handsComp.Drop(handsComp.ActiveIndex);
|
||||
handsComp.Drop(handsComp.ActiveHand);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -201,7 +209,7 @@ namespace Content.Server.Interfaces.GameObjects.Components.Interaction
|
||||
return;
|
||||
}
|
||||
|
||||
var heldItem = handsComp.GetHand(handsComp.ActiveIndex)?.Owner;
|
||||
var heldItem = handsComp.GetItem(handsComp.ActiveHand)?.Owner;
|
||||
|
||||
if (heldItem != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user