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:
@@ -8,6 +8,7 @@ using Content.Shared.BodySystem;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using System.Linq;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
||||
|
||||
namespace Content.Server.BodySystem {
|
||||
|
||||
@@ -178,8 +179,7 @@ namespace Content.Server.BodySystem {
|
||||
///////// Server-specific stuff
|
||||
/////////
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
public override void ExposeData(ObjectSerializer serializer) {
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataReadWriteFunction(
|
||||
@@ -225,8 +225,16 @@ namespace Content.Server.BodySystem {
|
||||
if (!_prototypeManager.TryIndex(partID, out BodyPartPrototype newPartData)) { //Get the BodyPartPrototype corresponding to the BodyPart ID we grabbed.
|
||||
throw new InvalidOperationException("BodyPart prototype with ID " + partID + " could not be found!");
|
||||
}
|
||||
_partDictionary.Remove(slotName); //Try and remove an existing limb if that exists.
|
||||
_partDictionary.Add(slotName, new BodyPart(newPartData)); //Add a new BodyPart with the BodyPartPrototype as a baseline to our BodyComponent.
|
||||
|
||||
//Try and remove an existing limb if that exists.
|
||||
if (_partDictionary.Remove(slotName, out var removedPart))
|
||||
{
|
||||
BodyPartRemoved(removedPart, slotName);
|
||||
}
|
||||
|
||||
var addedPart = new BodyPart(newPartData);
|
||||
_partDictionary.Add(slotName, addedPart); //Add a new BodyPart with the BodyPartPrototype as a baseline to our BodyComponent.
|
||||
BodyPartAdded(addedPart, slotName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,6 +272,8 @@ namespace Content.Server.BodySystem {
|
||||
if (TryGetBodyPart(slotName, out BodyPart result)) //And that nothing is in it
|
||||
return false;
|
||||
_partDictionary.Add(slotName, part);
|
||||
BodyPartAdded(part, slotName);
|
||||
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -316,7 +326,11 @@ namespace Content.Server.BodySystem {
|
||||
return;
|
||||
if (part != null) {
|
||||
string slotName = _partDictionary.FirstOrDefault(x => x.Value == part).Key;
|
||||
_partDictionary.Remove(slotName);
|
||||
if (_partDictionary.Remove(slotName, out var partRemoved))
|
||||
{
|
||||
BodyPartRemoved(partRemoved, slotName);
|
||||
}
|
||||
|
||||
if (TryGetBodyPartConnections(slotName, out List<string> connections)) //Call disconnect on all limbs that were hanging off this limb.
|
||||
{
|
||||
foreach (string connectionName in connections) //This loop is an unoptimized travesty. TODO: optimize to be less shit
|
||||
@@ -340,7 +354,11 @@ namespace Content.Server.BodySystem {
|
||||
if (!TryGetBodyPart(name, out BodyPart part))
|
||||
return;
|
||||
if (part != null) {
|
||||
_partDictionary.Remove(name);
|
||||
if (_partDictionary.Remove(name, out var partRemoved))
|
||||
{
|
||||
BodyPartRemoved(partRemoved, name);
|
||||
}
|
||||
|
||||
if (TryGetBodyPartConnections(name, out List<string> connections)) {
|
||||
foreach (string connectionName in connections) {
|
||||
if (TryGetBodyPart(connectionName, out BodyPart result) && !ConnectedToCenterPart(result)) {
|
||||
@@ -355,5 +373,24 @@ namespace Content.Server.BodySystem {
|
||||
}
|
||||
}
|
||||
|
||||
private void BodyPartAdded(BodyPart part, string slotName)
|
||||
{
|
||||
var argsAdded = new BodyPartAddedEventArgs(part, slotName);
|
||||
|
||||
foreach (var component in Owner.GetAllComponents<IBodyPartAdded>().ToArray())
|
||||
{
|
||||
component.BodyPartAdded(argsAdded);
|
||||
}
|
||||
}
|
||||
|
||||
private void BodyPartRemoved(BodyPart part, string slotName)
|
||||
{
|
||||
var args = new BodyPartRemovedEventArgs(part, slotName);
|
||||
|
||||
foreach (var component in Owner.GetAllComponents<IBodyPartRemoved>())
|
||||
{
|
||||
component.BodyPartRemoved(args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user