Body System Part 1 POGGERS!!! (#855)
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
|
||||
namespace Content.Shared.BodySystem {
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
class ArmLength : IExposeData {
|
||||
private float _length;
|
||||
|
||||
public void ExposeData(ObjectSerializer serializer){
|
||||
serializer.DataField(ref _length, "length", 2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
|
||||
namespace Content.Shared.BodySystem {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Prototype for the BodyPart class.
|
||||
/// </summary>
|
||||
[Prototype("bodyPart")]
|
||||
[NetSerializable, Serializable]
|
||||
public class BodyPartPrototype : IPrototype, IIndexedPrototype {
|
||||
private string _id;
|
||||
private string _name;
|
||||
private string _plural;
|
||||
private string _rsiPath;
|
||||
private string _rsiState;
|
||||
private BodyPartType _partType;
|
||||
private int _durability;
|
||||
private int _destroyThreshold;
|
||||
private float _resistance;
|
||||
private int _size;
|
||||
private BodyPartCompatibility _compatibility;
|
||||
private string _surgeryDataName;
|
||||
private List<IExposeData> _properties;
|
||||
private List<string> _mechanisms;
|
||||
|
||||
[ViewVariables]
|
||||
public string ID => _id;
|
||||
|
||||
[ViewVariables]
|
||||
public string Name => _name;
|
||||
|
||||
[ViewVariables]
|
||||
public string Plural => _plural;
|
||||
|
||||
[ViewVariables]
|
||||
public string RSIPath => _rsiPath;
|
||||
|
||||
[ViewVariables]
|
||||
public string RSIState => _rsiState;
|
||||
|
||||
[ViewVariables]
|
||||
public BodyPartType PartType => _partType;
|
||||
|
||||
[ViewVariables]
|
||||
public int Durability => _durability;
|
||||
|
||||
[ViewVariables]
|
||||
public int DestroyThreshold => _destroyThreshold;
|
||||
|
||||
[ViewVariables]
|
||||
public float Resistance => _resistance;
|
||||
|
||||
[ViewVariables]
|
||||
public int Size => _size;
|
||||
|
||||
[ViewVariables]
|
||||
public BodyPartCompatibility Compatibility => _compatibility;
|
||||
|
||||
[ViewVariables]
|
||||
public string SurgeryDataName => _surgeryDataName;
|
||||
|
||||
[ViewVariables]
|
||||
public List<IExposeData> Properties => _properties;
|
||||
|
||||
[ViewVariables]
|
||||
public List<string> Mechanisms => _mechanisms;
|
||||
|
||||
public virtual void LoadFrom(YamlMappingNode mapping){
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
serializer.DataField(ref _name, "name", string.Empty);
|
||||
serializer.DataField(ref _id, "id", string.Empty);
|
||||
serializer.DataField(ref _plural, "plural", string.Empty);
|
||||
serializer.DataField(ref _rsiPath, "rsiPath", string.Empty);
|
||||
serializer.DataField(ref _rsiState, "rsiState", string.Empty);
|
||||
serializer.DataField(ref _partType, "partType", BodyPartType.Other);
|
||||
serializer.DataField(ref _surgeryDataName, "surgeryDataType", "BiologicalSurgeryData");
|
||||
serializer.DataField(ref _durability, "durability", 50);
|
||||
serializer.DataField(ref _destroyThreshold, "destroyThreshold", -50);
|
||||
serializer.DataField(ref _resistance, "resistance", 0f);
|
||||
serializer.DataField(ref _size, "size", 0);
|
||||
serializer.DataField(ref _compatibility, "compatibility", BodyPartCompatibility.Universal);
|
||||
serializer.DataField(ref _properties, "properties", new List<IExposeData>());
|
||||
serializer.DataField(ref _mechanisms, "mechanisms", new List<string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Shared.BodySystem {
|
||||
|
||||
/// <summary>
|
||||
/// Prototype for the BodyPreset class.
|
||||
/// </summary>
|
||||
[Prototype("bodyPreset")]
|
||||
[NetSerializable, Serializable]
|
||||
public class BodyPresetPrototype : IPrototype, IIndexedPrototype {
|
||||
private string _id;
|
||||
private string _name;
|
||||
private Dictionary<string,string> _partIDs;
|
||||
|
||||
[ViewVariables]
|
||||
public string ID => _id;
|
||||
|
||||
[ViewVariables]
|
||||
public string Name => _name;
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, string> PartIDs => _partIDs;
|
||||
|
||||
public virtual void LoadFrom(YamlMappingNode mapping){
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
serializer.DataField(ref _id, "id", string.Empty);
|
||||
serializer.DataField(ref _name, "name", string.Empty);
|
||||
serializer.DataField(ref _partIDs, "partIDs", new Dictionary<string, string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
namespace Content.Shared.BodySystem
|
||||
{
|
||||
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public enum BodyScannerUiKey
|
||||
{
|
||||
Key
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public class BodyScannerInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public readonly Dictionary<string, BodyScannerBodyPartData> Parts;
|
||||
public readonly BodyScannerTemplateData Template;
|
||||
public BodyScannerInterfaceState(Dictionary<string, BodyScannerBodyPartData> parts, BodyScannerTemplateData template)
|
||||
{
|
||||
Template = template;
|
||||
Parts = parts;
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public class BodyScannerBodyPartData
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly string RSIPath;
|
||||
public readonly string RSIState;
|
||||
public readonly int MaxDurability;
|
||||
public readonly int CurrentDurability;
|
||||
public readonly List<BodyScannerMechanismData> Mechanisms;
|
||||
public BodyScannerBodyPartData(string name, string rsiPath, string rsiState, int maxDurability, int currentDurability, List<BodyScannerMechanismData> mechanisms)
|
||||
{
|
||||
Name = name;
|
||||
RSIPath = rsiPath;
|
||||
RSIState = rsiState;
|
||||
MaxDurability = maxDurability;
|
||||
CurrentDurability = currentDurability;
|
||||
Mechanisms = mechanisms;
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public class BodyScannerMechanismData
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly string Description;
|
||||
public readonly string RSIPath;
|
||||
public readonly string RSIState;
|
||||
public readonly int MaxDurability;
|
||||
public readonly int CurrentDurability;
|
||||
public BodyScannerMechanismData(string name, string description, string rsiPath, string rsiState, int maxDurability, int currentDurability)
|
||||
{
|
||||
Name = name;
|
||||
Description = description;
|
||||
RSIPath = rsiPath;
|
||||
RSIState = rsiState;
|
||||
MaxDurability = maxDurability;
|
||||
CurrentDurability = currentDurability;
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public class BodyScannerTemplateData
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly Dictionary<string, BodyPartType> Slots;
|
||||
public BodyScannerTemplateData(string name, Dictionary<string, BodyPartType> slots)
|
||||
{
|
||||
Name = name;
|
||||
Slots = slots;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Shared.BodySystem {
|
||||
|
||||
/// <summary>
|
||||
/// Prototype for the BodyTemplate class.
|
||||
/// </summary>
|
||||
[Prototype("bodyTemplate")]
|
||||
[NetSerializable, Serializable]
|
||||
public class BodyTemplatePrototype : IPrototype, IIndexedPrototype {
|
||||
private string _id;
|
||||
private string _name;
|
||||
private string _centerSlot;
|
||||
private Dictionary<string, BodyPartType> _slots;
|
||||
private Dictionary<string, List<string>> _connections;
|
||||
|
||||
[ViewVariables]
|
||||
public string ID => _id;
|
||||
|
||||
[ViewVariables]
|
||||
public string Name => _name;
|
||||
|
||||
[ViewVariables]
|
||||
public string CenterSlot => _centerSlot;
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, BodyPartType> Slots => _slots;
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, List<string>> Connections => _connections;
|
||||
|
||||
public virtual void LoadFrom(YamlMappingNode mapping){
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
serializer.DataField(ref _name, "name", string.Empty);
|
||||
serializer.DataField(ref _id, "id", string.Empty);
|
||||
serializer.DataField(ref _centerSlot, "centerSlot", string.Empty);
|
||||
serializer.DataField(ref _slots, "slots", new Dictionary<string, BodyPartType>());
|
||||
serializer.DataField(ref _connections, "connections", new Dictionary<string, List<string>>());
|
||||
|
||||
|
||||
//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.
|
||||
Dictionary<string, List<string>> cleanedConnections = new Dictionary<string, List<string>>();
|
||||
foreach (var (targetSlotName, slotType) in _slots)
|
||||
{
|
||||
List<string> tempConnections = new List<string>();
|
||||
foreach (var (slotName, slotConnections) in _connections)
|
||||
{
|
||||
if (slotName == targetSlotName){
|
||||
foreach (string connection in slotConnections) {
|
||||
if (!tempConnections.Contains(connection))
|
||||
tempConnections.Add(connection);
|
||||
}
|
||||
}
|
||||
else if (slotConnections.Contains(slotName))
|
||||
{
|
||||
tempConnections.Add(slotName);
|
||||
}
|
||||
}
|
||||
if(tempConnections.Count > 0)
|
||||
cleanedConnections.Add(targetSlotName, tempConnections);
|
||||
}
|
||||
_connections = cleanedConnections;
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Content.Shared/Health/BodySystem/BodysystemValues.cs
Normal file
9
Content.Shared/Health/BodySystem/BodysystemValues.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
namespace Content.Shared.BodySystem
|
||||
{
|
||||
public enum BodyPartCompatibility { Mechanical, Biological, Universal };
|
||||
public enum BodyPartType { Other, Torso, Head, Arm, Hand, Leg, Foot };
|
||||
public enum SurgeryToolType { Incision, Retraction, Cauterization, VesselCompression, Drilling, BoneSawing, Amputation }
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Content.Shared.BodySystem {
|
||||
|
||||
/// <summary>
|
||||
/// Prototype for the Mechanism class.
|
||||
/// </summary>
|
||||
[Prototype("mechanism")]
|
||||
[NetSerializable, Serializable]
|
||||
public class MechanismPrototype : IPrototype, IIndexedPrototype {
|
||||
private string _id;
|
||||
private string _name;
|
||||
private string _description;
|
||||
private string _examineMessage;
|
||||
private string _spritePath;
|
||||
private string _rsiPath;
|
||||
private string _rsiState;
|
||||
private int _durability;
|
||||
private int _destroyThreshold;
|
||||
private int _resistance;
|
||||
private int _size;
|
||||
private BodyPartCompatibility _compatibility;
|
||||
|
||||
[ViewVariables]
|
||||
public string ID => _id;
|
||||
|
||||
[ViewVariables]
|
||||
public string Name => _name;
|
||||
|
||||
[ViewVariables]
|
||||
public string Description => _description;
|
||||
|
||||
[ViewVariables]
|
||||
public string ExamineMessage => _examineMessage;
|
||||
|
||||
[ViewVariables]
|
||||
public string RSIPath => _rsiPath;
|
||||
|
||||
[ViewVariables]
|
||||
public string RSIState => _rsiState;
|
||||
|
||||
[ViewVariables]
|
||||
public int Durability => _durability;
|
||||
|
||||
[ViewVariables]
|
||||
public int DestroyThreshold => _destroyThreshold;
|
||||
|
||||
[ViewVariables]
|
||||
public int Resistance => _resistance;
|
||||
|
||||
[ViewVariables]
|
||||
public int Size => _size;
|
||||
|
||||
[ViewVariables]
|
||||
public BodyPartCompatibility Compatibility => _compatibility;
|
||||
|
||||
public virtual void LoadFrom(YamlMappingNode mapping){
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
serializer.DataField(ref _id, "id", string.Empty);
|
||||
serializer.DataField(ref _name, "name", string.Empty);
|
||||
serializer.DataField(ref _description, "description", string.Empty);
|
||||
serializer.DataField(ref _examineMessage, "examineMessage", string.Empty);
|
||||
serializer.DataField(ref _rsiPath, "rsiPath", string.Empty);
|
||||
serializer.DataField(ref _rsiState, "rsiState", string.Empty);
|
||||
serializer.DataField(ref _durability, "durability", 0);
|
||||
serializer.DataField(ref _destroyThreshold, "destroyThreshold", 0);
|
||||
serializer.DataField(ref _resistance, "resistance", 0);
|
||||
serializer.DataField(ref _size, "size", 2);
|
||||
serializer.DataField(ref _compatibility, "compatibility", BodyPartCompatibility.Universal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Serialization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Shared.BodySystem {
|
||||
|
||||
|
||||
public class SharedSurgeryToolComponent : Component {
|
||||
|
||||
protected SurgeryToolType _surgeryToolClass;
|
||||
protected float _baseOperateTime;
|
||||
public override string Name => "SurgeryTool";
|
||||
public override uint? NetID => ContentNetIDs.SURGERY;
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
serializer.DataField(ref _surgeryToolClass, "surgeryToolClass", SurgeryToolType.Incision);
|
||||
serializer.DataField(ref _baseOperateTime, "baseOperateTime", 5);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class OpenSurgeryUIMessage : ComponentMessage
|
||||
{
|
||||
public OpenSurgeryUIMessage()
|
||||
{
|
||||
Directed = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class CloseSurgeryUIMessage : ComponentMessage
|
||||
{
|
||||
public CloseSurgeryUIMessage()
|
||||
{
|
||||
Directed = true;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class UpdateSurgeryUIMessage : ComponentMessage
|
||||
{
|
||||
public Dictionary<string, string> Targets;
|
||||
public UpdateSurgeryUIMessage(Dictionary<string, string> targets)
|
||||
{
|
||||
Targets = targets;
|
||||
Directed = true;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class SelectSurgeryUIMessage : ComponentMessage
|
||||
{
|
||||
public string TargetSlot;
|
||||
public SelectSurgeryUIMessage(string target)
|
||||
{
|
||||
TargetSlot = target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user