Refactor body component to use slots instead of an army of dictionaries (#3749)
* Refactor body component to use slots instead of an army of dictionaries * Update vox * Replace static method call with extension * Add setpart method, replace dispose with shutdown * Fix tests, fix not listening to slot events when setting a part
This commit is contained in:
@@ -8,7 +8,6 @@ using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using static Robust.Client.UserInterface.Controls.ItemList;
|
||||
|
||||
namespace Content.Client.GameObjects.Components.Body.Scanner
|
||||
@@ -114,9 +113,9 @@ namespace Content.Client.GameObjects.Components.Body.Scanner
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var slotName in body.Parts.Keys)
|
||||
foreach (var (part, _) in body.Parts)
|
||||
{
|
||||
BodyPartList.AddItem(Loc.GetString(slotName));
|
||||
BodyPartList.AddItem(Loc.GetString(part.Name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,12 +128,12 @@ namespace Content.Client.GameObjects.Components.Body.Scanner
|
||||
return;
|
||||
}
|
||||
|
||||
var slot = body.SlotAt(args.ItemIndex).Key;
|
||||
_currentBodyPart = body.PartAt(args.ItemIndex).Value;
|
||||
var slot = body.SlotAt(args.ItemIndex);
|
||||
_currentBodyPart = body.PartAt(args.ItemIndex).Key;
|
||||
|
||||
if (body.Parts.TryGetValue(slot, out var part))
|
||||
if (slot.Part != null)
|
||||
{
|
||||
UpdateBodyPartBox(part, slot);
|
||||
UpdateBodyPartBox(slot.Part, slot.Id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user