Convert StomachBehavior to a component/system + rejig body namespaces (#5249)
* Convert StomachBehavior to a component/system + rejig body namespaces * test * slightly more namespace changes * remove * Hello????? * fuck you github test runner * reviews * oobsy!
This commit is contained in:
31
Content.Shared/Body/Prototypes/BodyPresetPrototype.cs
Normal file
31
Content.Shared/Body/Prototypes/BodyPresetPrototype.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Body.Prototypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the parts used in a body.
|
||||
/// </summary>
|
||||
[Prototype("bodyPreset")]
|
||||
[Serializable, NetSerializable]
|
||||
public class BodyPresetPrototype : IPrototype
|
||||
{
|
||||
[ViewVariables]
|
||||
[DataField("id", required: true)]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[DataField("partIDs")]
|
||||
private Dictionary<string, string> _partIDs = new();
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("name")]
|
||||
public string Name { get; } = string.Empty;
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, string> PartIDs => new(_partIDs);
|
||||
}
|
||||
}
|
||||
90
Content.Shared/Body/Prototypes/BodyTemplatePrototype.cs
Normal file
90
Content.Shared/Body/Prototypes/BodyTemplatePrototype.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Body.Part;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Body.Prototypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the layout of a body.
|
||||
/// </summary>
|
||||
[Prototype("bodyTemplate")]
|
||||
[Serializable, NetSerializable]
|
||||
public class BodyTemplatePrototype : IPrototype, ISerializationHooks
|
||||
{
|
||||
[DataField("slots")]
|
||||
private Dictionary<string, BodyPartType> _slots = new();
|
||||
|
||||
[DataField("connections")]
|
||||
private Dictionary<string, List<string>> _rawConnections = new();
|
||||
|
||||
[DataField("layers")]
|
||||
private Dictionary<string, string> _layers = new();
|
||||
|
||||
[DataField("mechanismLayers")]
|
||||
private Dictionary<string, string> _mechanismLayers = new();
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("id", required: true)]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("name")]
|
||||
public string Name { get; } = string.Empty;
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("centerSlot")]
|
||||
public string CenterSlot { get; } = string.Empty;
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, BodyPartType> Slots => new(_slots);
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, HashSet<string>> Connections { get; set; } = new();
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, string> Layers => new(_layers);
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, string> MechanismLayers => new(_mechanismLayers);
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
//Our prototypes don't force the user to define a BodyPart connection twice. E.g. Head: Torso v.s. Torso: Head.
|
||||
//The user only has to do one. We want it to be that way in the code, though, so this cleans that up.
|
||||
var cleanedConnections = new Dictionary<string, HashSet<string>>();
|
||||
|
||||
foreach (var targetSlotName in _slots.Keys)
|
||||
{
|
||||
var tempConnections = new HashSet<string>();
|
||||
foreach (var (slotName, slotConnections) in _rawConnections)
|
||||
{
|
||||
if (slotName == targetSlotName)
|
||||
{
|
||||
foreach (var connection in slotConnections)
|
||||
{
|
||||
if (!tempConnections.Contains(connection))
|
||||
{
|
||||
tempConnections.Add(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (slotConnections.Contains(targetSlotName))
|
||||
{
|
||||
tempConnections.Add(slotName);
|
||||
}
|
||||
}
|
||||
|
||||
if (tempConnections.Count > 0)
|
||||
{
|
||||
cleanedConnections.Add(targetSlotName, tempConnections);
|
||||
}
|
||||
}
|
||||
|
||||
Connections = cleanedConnections;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Content.Shared/Body/Prototypes/MetabolismGroupPrototype.cs
Normal file
12
Content.Shared/Body/Prototypes/MetabolismGroupPrototype.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.Body.Prototypes
|
||||
{
|
||||
[Prototype("metabolismGroup")]
|
||||
public class MetabolismGroupPrototype : IPrototype
|
||||
{
|
||||
[DataField("id", required: true)]
|
||||
public string ID { get; } = default!;
|
||||
}
|
||||
}
|
||||
12
Content.Shared/Body/Prototypes/MetabolizerTypePrototype.cs
Normal file
12
Content.Shared/Body/Prototypes/MetabolizerTypePrototype.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.Body.Prototypes
|
||||
{
|
||||
[Prototype("metabolizerType")]
|
||||
public class MetabolizerTypePrototype : IPrototype
|
||||
{
|
||||
[DataField("id", required: true)]
|
||||
public string ID { get; } = default!;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user