Fix namespaces and optimize imports (#1651)

* Fix namespaces and optimize imports

* Cleanup fixes

* Merge conflict fixes

* Merge conflict fixes

* Merge conflict fixes
This commit is contained in:
DrSmugleaf
2020-08-13 14:40:27 +02:00
committed by GitHub
parent 05a76d55f7
commit 4a8ed41e3a
500 changed files with 1044 additions and 1557 deletions

View File

@@ -1,16 +1,22 @@
using Robust.Shared.GameObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.Health.BodySystem.BodyPart;
using Content.Server.Health.BodySystem.BodyPreset;
using Content.Server.Health.BodySystem.BodyTemplate;
using Content.Server.Interfaces.GameObjects.Components.Interaction;
using Content.Shared.Health.BodySystem;
using Content.Shared.Health.BodySystem.BodyPart;
using Content.Shared.Health.BodySystem.BodyPreset;
using Content.Shared.Health.BodySystem.BodyTemplate;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using System;
using System.Collections.Generic;
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 {
namespace Content.Server.Health.BodySystem {
/// <summary>
/// Component representing a collection of <see cref="BodyPart">BodyParts</see> attached to each other.
@@ -24,23 +30,23 @@ namespace Content.Server.BodySystem {
#pragma warning restore
[ViewVariables]
private BodyTemplate _template;
private BodyTemplate.BodyTemplate _template;
[ViewVariables]
private string _presetName;
[ViewVariables]
private Dictionary<string, BodyPart> _partDictionary = new Dictionary<string, BodyPart>();
private Dictionary<string, BodyPart.BodyPart> _partDictionary = new Dictionary<string, BodyPart.BodyPart>();
/// <summary>
/// The <see cref="BodyTemplate"/> that this BodyManagerComponent is adhering to.
/// </summary>
public BodyTemplate Template => _template;
public BodyTemplate.BodyTemplate Template => _template;
/// <summary>
/// Maps <see cref="BodyTemplate"/> slot name to the <see cref="BodyPart"/> object filling it (if there is one).
/// </summary>
public Dictionary<string, BodyPart> PartDictionary => _partDictionary;
public Dictionary<string, BodyPart.BodyPart> PartDictionary => _partDictionary;
/// <summary>
/// List of all occupied slots in this body, taken from the values of _parts.
@@ -67,7 +73,7 @@ namespace Content.Server.BodySystem {
/// <summary>
/// List of all <see cref="BodyPart">BodyParts</see> in this body, taken from the keys of _parts.
/// </summary>
public IEnumerable<BodyPart> Parts {
public IEnumerable<BodyPart.BodyPart> Parts {
get {
return _partDictionary.Values;
}
@@ -77,14 +83,14 @@ namespace Content.Server.BodySystem {
/// Recursive search that returns whether a given <see cref="BodyPart"/> is connected to the center <see cref="BodyPart"/>.
/// Not efficient (O(n^2)), but most bodies don't have a ton of <see cref="BodyPart">BodyParts</see>.
/// </summary>
public bool ConnectedToCenterPart(BodyPart target) {
public bool ConnectedToCenterPart(BodyPart.BodyPart target) {
List<string> searchedSlots = new List<string> { };
if (TryGetSlotName(target, out string result))
return false;
return ConnectedToCenterPartRecursion(searchedSlots, result);
}
private bool ConnectedToCenterPartRecursion(List<string> searchedSlots, string slotName) {
TryGetBodyPart(slotName, out BodyPart part);
TryGetBodyPart(slotName, out BodyPart.BodyPart part);
if (part != null && part == GetCenterBodyPart())
return true;
searchedSlots.Add(slotName);
@@ -101,8 +107,8 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Returns the central <see cref="BodyPart"/> of this body based on the <see cref="BodyTemplate"/>. For humans, this is the torso. Returns null if not found.
/// </summary>
public BodyPart GetCenterBodyPart() {
_partDictionary.TryGetValue(_template.CenterSlot, out BodyPart center);
public BodyPart.BodyPart GetCenterBodyPart() {
_partDictionary.TryGetValue(_template.CenterSlot, out BodyPart.BodyPart center);
return center;
}
@@ -119,7 +125,7 @@ namespace Content.Server.BodySystem {
/// Grabs the <see cref="BodyPart"/> in the given slotName if there is one. Returns true if a <see cref="BodyPart"/> is found,
/// false otherwise. If false, result will be null.
/// </summary>
public bool TryGetBodyPart(string slotName, out BodyPart result) {
public bool TryGetBodyPart(string slotName, out BodyPart.BodyPart result) {
return _partDictionary.TryGetValue(slotName, out result);
}
@@ -127,7 +133,7 @@ namespace Content.Server.BodySystem {
/// Grabs the slotName that the given <see cref="BodyPart"/> resides in. Returns true if the <see cref="BodyPart"/> is
/// part of this body and a slot is found, false otherwise. If false, result will be null.
/// </summary>
public bool TryGetSlotName(BodyPart part, out string result) {
public bool TryGetSlotName(BodyPart.BodyPart part, out string result) {
result = _partDictionary.FirstOrDefault(x => x.Value == part).Key; //We enforce that there is only one of each value in the dictionary, so we can iterate through the dictionary values to get the key from there.
return result == null;
}
@@ -150,15 +156,15 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Grabs all occupied slots connected to the given slot, regardless of whether the target slot is occupied. Returns true if successful, false if there was an error or no connected BodyParts were found.
/// </summary>
public bool TryGetBodyPartConnections(string slotName, out List<BodyPart> result)
public bool TryGetBodyPartConnections(string slotName, out List<BodyPart.BodyPart> result)
{
result = null;
if (!_template.Connections.TryGetValue(slotName, out List<string> connections))
return false;
List<BodyPart> toReturn = new List<BodyPart>();
List<BodyPart.BodyPart> toReturn = new List<BodyPart.BodyPart>();
foreach (string connection in connections)
{
if (TryGetBodyPart(connection, out BodyPart bodyPartResult))
if (TryGetBodyPart(connection, out BodyPart.BodyPart bodyPartResult))
{
toReturn.Add(bodyPartResult);
}
@@ -192,7 +198,7 @@ namespace Content.Server.BodySystem {
throw new InvalidOperationException("No BodyTemplatePrototype was found with the name " + template + " while loading a BodyTemplate!"); //Should never happen unless you fuck up the prototype.
}
_template = new BodyTemplate(templateData);
_template = new BodyTemplate.BodyTemplate(templateData);
},
() => _template.Name);
@@ -206,7 +212,7 @@ namespace Content.Server.BodySystem {
throw new InvalidOperationException("No BodyPresetPrototype was found with the name " + preset + " while loading a BodyPreset!"); //Should never happen unless you fuck up the prototype.
}
LoadBodyPreset(new BodyPreset(presetData));
LoadBodyPreset(new BodyPreset.BodyPreset(presetData));
},
() => _presetName);
}
@@ -214,7 +220,7 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Loads the given <see cref="BodyPreset"/> - forcefully changes all limbs found in both the preset and this template!
/// </summary>
public void LoadBodyPreset(BodyPreset preset)
public void LoadBodyPreset(BodyPreset.BodyPreset preset)
{
_presetName = preset.Name;
@@ -232,7 +238,7 @@ namespace Content.Server.BodySystem {
BodyPartRemoved(removedPart, slotName);
}
var addedPart = new BodyPart(newPartData);
var addedPart = new BodyPart.BodyPart(newPartData);
_partDictionary.Add(slotName, addedPart); //Add a new BodyPart with the BodyPartPrototype as a baseline to our BodyComponent.
BodyPartAdded(addedPart, slotName);
}
@@ -243,7 +249,7 @@ namespace Content.Server.BodySystem {
/// if there is a slot for them in both <see cref="BodyTemplate"/>.
/// </summary>
public void ChangeBodyTemplate(BodyTemplatePrototype newTemplate) {
foreach (KeyValuePair<string, BodyPart> part in _partDictionary) {
foreach (KeyValuePair<string, BodyPart.BodyPart> part in _partDictionary) {
//TODO: Make this work.
}
}
@@ -251,8 +257,8 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Grabs all <see cref="BodyPart">BodyParts</see> of the given type in this body.
/// </summary>
public List<BodyPart> GetBodyPartsOfType(BodyPartType type) {
List<BodyPart> toReturn = new List<BodyPart>();
public List<BodyPart.BodyPart> GetBodyPartsOfType(BodyPartType type) {
List<BodyPart.BodyPart> toReturn = new List<BodyPart.BodyPart>();
foreach (var (slotName, bodyPart) in _partDictionary) {
if (bodyPart.PartType == type)
toReturn.Add(bodyPart);
@@ -265,11 +271,11 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Installs the given <see cref="BodyPart"/> into the given slot. Returns true if successful, false otherwise.
/// </summary>
public bool InstallBodyPart(BodyPart part, string slotName)
public bool InstallBodyPart(BodyPart.BodyPart part, string slotName)
{
if (!SlotExists(slotName)) //Make sure the given slot exists
return false;
if (TryGetBodyPart(slotName, out BodyPart result)) //And that nothing is in it
if (TryGetBodyPart(slotName, out BodyPart.BodyPart result)) //And that nothing is in it
return false;
_partDictionary.Add(slotName, part);
BodyPartAdded(part, slotName);
@@ -293,7 +299,7 @@ namespace Content.Server.BodySystem {
/// Disconnects the given <see cref="BodyPart"/> reference, potentially dropping other <see cref="BodyPart">BodyParts</see>
/// if they were hanging off it. Returns the IEntity representing the dropped BodyPart.
/// </summary>
public IEntity DropBodyPart(BodyPart part)
public IEntity DropBodyPart(BodyPart.BodyPart part)
{
if (!_partDictionary.ContainsValue(part))
return null;
@@ -305,7 +311,7 @@ namespace Content.Server.BodySystem {
{
foreach (string connectionName in connections) //This loop is an unoptimized travesty. TODO: optimize to be less shit
{
if (TryGetBodyPart(connectionName, out BodyPart result) && !ConnectedToCenterPart(result))
if (TryGetBodyPart(connectionName, out BodyPart.BodyPart result) && !ConnectedToCenterPart(result))
{
DisconnectBodyPartByName(connectionName, true);
}
@@ -321,7 +327,7 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Disconnects the given <see cref="BodyPart"/> reference, potentially dropping other <see cref="BodyPart">BodyParts</see> if they were hanging off it.
/// </summary>
public void DisconnectBodyPart(BodyPart part, bool dropEntity) {
public void DisconnectBodyPart(BodyPart.BodyPart part, bool dropEntity) {
if (!_partDictionary.ContainsValue(part))
return;
if (part != null) {
@@ -335,7 +341,7 @@ namespace Content.Server.BodySystem {
{
foreach (string connectionName in connections) //This loop is an unoptimized travesty. TODO: optimize to be less shit
{
if (TryGetBodyPart(connectionName, out BodyPart result) && !ConnectedToCenterPart(result)) {
if (TryGetBodyPart(connectionName, out BodyPart.BodyPart result) && !ConnectedToCenterPart(result)) {
DisconnectBodyPartByName(connectionName, dropEntity);
}
}
@@ -351,7 +357,7 @@ namespace Content.Server.BodySystem {
/// Internal string version of DisconnectBodyPart for performance purposes. Yes, it is actually more performant.
/// </summary>
private void DisconnectBodyPartByName(string name, bool dropEntity) {
if (!TryGetBodyPart(name, out BodyPart part))
if (!TryGetBodyPart(name, out BodyPart.BodyPart part))
return;
if (part != null) {
if (_partDictionary.Remove(name, out var partRemoved))
@@ -361,7 +367,7 @@ namespace Content.Server.BodySystem {
if (TryGetBodyPartConnections(name, out List<string> connections)) {
foreach (string connectionName in connections) {
if (TryGetBodyPart(connectionName, out BodyPart result) && !ConnectedToCenterPart(result)) {
if (TryGetBodyPart(connectionName, out BodyPart.BodyPart result) && !ConnectedToCenterPart(result)) {
DisconnectBodyPartByName(connectionName, dropEntity);
}
}
@@ -373,7 +379,7 @@ namespace Content.Server.BodySystem {
}
}
private void BodyPartAdded(BodyPart part, string slotName)
private void BodyPartAdded(BodyPart.BodyPart part, string slotName)
{
var argsAdded = new BodyPartAddedEventArgs(part, slotName);
@@ -383,7 +389,7 @@ namespace Content.Server.BodySystem {
}
}
private void BodyPartRemoved(BodyPart part, string slotName)
private void BodyPartRemoved(BodyPart.BodyPart part, string slotName)
{
var args = new BodyPartRemovedEventArgs(part, slotName);

View File

@@ -1,16 +1,19 @@
using Content.Shared.BodySystem;
using System;
using System.Collections.Generic;
using Content.Server.Health.BodySystem.Mechanism;
using Content.Server.Health.BodySystem.Surgery.Surgeon;
using Content.Server.Health.BodySystem.Surgery.SurgeryData;
using Content.Shared.Health.BodySystem;
using Content.Shared.Health.BodySystem.BodyPart;
using Content.Shared.Health.BodySystem.Mechanism;
using Content.Shared.Health.DamageContainer;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Serialization;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using System;
using System.Collections.Generic;
namespace Content.Server.BodySystem
namespace Content.Server.Health.BodySystem.BodyPart
{
@@ -25,7 +28,7 @@ namespace Content.Server.BodySystem
private ISurgeryData _surgeryData;
[ViewVariables]
private List<Mechanism> _mechanisms = new List<Mechanism>();
private List<Mechanism.Mechanism> _mechanisms = new List<Mechanism.Mechanism>();
[ViewVariables]
private int _sizeUsed = 0;
@@ -44,55 +47,55 @@ namespace Content.Server.BodySystem
/// <summary>
/// Path to the RSI that represents this BodyPart.
/// </summary>
/// </summary>
[ViewVariables]
public string RSIPath { get; set; }
/// <summary>
/// RSI state that represents this BodyPart.
/// </summary>
/// </summary>
[ViewVariables]
public string RSIState { get; set; }
/// <summary>
/// <see cref="BodyPartType"/> that this BodyPart is considered to be. For example, BodyPartType.Arm.
/// <see cref="BodyPartType"/> that this BodyPart is considered to be. For example, BodyPartType.Arm.
/// </summary>
[ViewVariables]
public BodyPartType PartType { get; set; }
/// <summary>
/// Max HP of this BodyPart.
/// </summary>
/// </summary>
[ViewVariables]
public int MaxDurability { get; set; }
/// <summary>
/// Current HP of this BodyPart based on sum of all damage types.
/// </summary>
/// </summary>
[ViewVariables]
public int CurrentDurability => MaxDurability - CurrentDamages.Damage;
/// <summary>
/// Current damage dealt to this BodyPart.
/// </summary>
/// </summary>
[ViewVariables]
public AbstractDamageContainer CurrentDamages { get; set; }
/// <summary>
/// At what HP this BodyPartis completely destroyed.
/// </summary>
/// </summary>
[ViewVariables]
public int DestroyThreshold { get; set; }
/// <summary>
/// Armor of this BodyPart against attacks.
/// </summary>
/// </summary>
[ViewVariables]
public float Resistance { get; set; }
/// <summary>
/// Determines many things: how many mechanisms can be fit inside this BodyPart, whether a body can fit through tiny crevices, etc.
/// </summary>
/// </summary>
[ViewVariables]
public int Size { get; set; }
@@ -112,7 +115,7 @@ namespace Content.Server.BodySystem
/// List of all <see cref="Mechanism">Mechanisms</see> currently inside this BodyPart.
/// </summary>
[ViewVariables]
public List<Mechanism> Mechanisms => _mechanisms;
public List<Mechanism.Mechanism> Mechanisms => _mechanisms;
public BodyPart() { }
@@ -139,7 +142,7 @@ namespace Content.Server.BodySystem
/// <summary>
/// Returns whether the given <see cref="Mechanism"/> can be installed on this BodyPart.
/// </summary>
public bool CanInstallMechanism(Mechanism mechanism)
public bool CanInstallMechanism(Mechanism.Mechanism mechanism)
{
if (_sizeUsed + mechanism.Size > Size)
return false; //No space
@@ -149,7 +152,7 @@ namespace Content.Server.BodySystem
/// <summary>
/// Attempts to add a <see cref="Mechanism"/>. Returns true if successful, false if there was an error (e.g. not enough room in BodyPart). Call InstallDroppedMechanism instead if you want to easily install an IEntity with a DroppedMechanismComponent.
/// </summary>
public bool TryInstallMechanism(Mechanism mechanism)
public bool TryInstallMechanism(Mechanism.Mechanism mechanism)
{
if (CanInstallMechanism(mechanism))
{
@@ -173,8 +176,8 @@ namespace Content.Server.BodySystem
/// <summary>
/// Tries to remove the given <see cref="Mechanism"/> reference from this BodyPart. Returns null if there was an error in spawning the entity or removing the mechanism, otherwise returns a reference to the <see cref="DroppedMechanismComponent"/> on the newly spawned entity.
/// </summary>
public DroppedMechanismComponent DropMechanism(IEntity dropLocation, Mechanism mechanismTarget)
/// </summary>
public DroppedMechanismComponent DropMechanism(IEntity dropLocation, Mechanism.Mechanism mechanismTarget)
{
if (!_mechanisms.Contains(mechanismTarget))
return null;
@@ -189,8 +192,8 @@ namespace Content.Server.BodySystem
/// <summary>
/// Tries to destroy the given <see cref="Mechanism"/> in the given BodyPart. Returns false if there was an error, true otherwise. Does NOT spawn a dropped entity.
/// </summary>
public bool DestroyMechanism(BodyPart bodyPartTarget, Mechanism mechanismTarget)
/// </summary>
public bool DestroyMechanism(BodyPart bodyPartTarget, Mechanism.Mechanism mechanismTarget)
{
if (!_mechanisms.Contains(mechanismTarget))
return false;
@@ -225,7 +228,7 @@ namespace Content.Server.BodySystem
/// <summary>
/// Loads the given <see cref="BodyPartPrototype"/> - current data on this <see cref="BodyPart"/> will be overwritten!
/// </summary>
/// </summary>
public virtual void LoadFromPrototype(BodyPartPrototype data)
{
Name = data.Name;
@@ -249,7 +252,7 @@ namespace Content.Server.BodySystem
{
throw new InvalidOperationException("No MechanismPrototype was found with the name " + mechanismPrototypeID + " while loading a BodyPartPrototype!");
}
_mechanisms.Add(new Mechanism(mechanismData));
_mechanisms.Add(new Mechanism.Mechanism(mechanismData));
}
}

View File

@@ -1,19 +1,20 @@
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using System.Collections.Generic;
using Content.Shared.BodySystem;
using Robust.Shared.ViewVariables;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Content.Shared.Health.BodySystem;
using Content.Shared.Health.BodySystem.Surgery;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.Player;
using Content.Shared.Interfaces;
using System.Linq;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.ViewVariables;
namespace Content.Server.BodySystem
namespace Content.Server.Health.BodySystem.BodyPart
{
/// <summary>

View File

@@ -1,8 +1,10 @@
using System.Collections.Generic;
using Content.Shared.BodySystem;
using Content.Server.Health.BodySystem.BodyPart;
using Content.Shared.Health.BodySystem.BodyPart;
using Content.Shared.Health.BodySystem.BodyPreset;
using Robust.Shared.ViewVariables;
namespace Content.Server.BodySystem {
namespace Content.Server.Health.BodySystem.BodyPreset {
/// <summary>
/// Stores data on what <see cref="BodyPartPrototype">BodyPartPrototypes</see> should fill a BodyTemplate. Used for loading complete body presets, like a "basic human" with all human limbs.
@@ -16,7 +18,7 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Maps a template slot to the ID of the <see cref="BodyPart"> that should fill it. E.g. "right arm" : "BodyPart.arm.basic_human".
/// </summary>
/// </summary>
[ViewVariables]
public Dictionary<string, string> PartIDs => _partIDs;

View File

@@ -1,11 +1,11 @@
using Robust.Server.GameObjects.Components.UserInterface;
using System.Collections.Generic;
using Content.Shared.Health.BodySystem.BodyScanner;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using System.Collections.Generic;
using Content.Shared.BodySystem;
using Content.Shared.Interfaces.GameObjects.Components;
namespace Content.Server.BodySystem
namespace Content.Server.Health.BodySystem.BodyScanner
{
[RegisterComponent]
[ComponentReference(typeof(IActivate))]
@@ -45,7 +45,7 @@ namespace Content.Server.BodySystem
/// <summary>
/// Copy BodyTemplate and BodyPart data into a common data class that the client can read.
/// </summary>
private BodyScannerInterfaceState PrepareBodyScannerInterfaceState(BodyTemplate template, Dictionary<string, BodyPart> bodyParts)
private BodyScannerInterfaceState PrepareBodyScannerInterfaceState(BodyTemplate.BodyTemplate template, Dictionary<string, BodyPart.BodyPart> bodyParts)
{
Dictionary<string, BodyScannerBodyPartData> partsData = new Dictionary<string, BodyScannerBodyPartData>();
foreach (var(slotname, bpart) in bodyParts) {

View File

@@ -1,14 +1,15 @@
using System;
using System.Collections.Generic;
using Content.Shared.BodySystem;
using Content.Shared.Health.BodySystem;
using Content.Shared.Health.BodySystem.BodyTemplate;
using Robust.Shared.ViewVariables;
namespace Content.Server.BodySystem {
namespace Content.Server.Health.BodySystem.BodyTemplate {
/// <summary>
/// This class is a data capsule representing the standard format of a <see cref="BodyManagerComponent"/>. For instance, the "humanoid" BodyTemplate
/// defines two arms, each connected to a torso and so on. Capable of loading data from a <see cref="BodyTemplatePrototype"/>.
/// </summary>
/// </summary>
public class BodyTemplate {
[ViewVariables]
@@ -16,13 +17,13 @@ namespace Content.Server.BodySystem {
/// <summary>
/// The name of the center BodyPart. For humans, this is set to "torso". Used in many calculations.
/// </summary>
/// </summary>
[ViewVariables]
public string CenterSlot { get; set; }
/// <summary>
/// Maps all parts on this template to its BodyPartType. For instance, "right arm" is mapped to "BodyPartType.arm" on the humanoid template.
/// </summary>
/// </summary>
[ViewVariables]
public Dictionary<string, BodyPartType> Slots { get; set; }
@@ -30,7 +31,7 @@ namespace Content.Server.BodySystem {
/// Maps limb name to the list of their connections to other limbs. For instance, on the humanoid template "torso" is mapped to a list containing "right arm", "left arm",
/// "left leg", and "right leg". This is mapped both ways during runtime, but in the prototype only one way has to be defined, i.e., "torso" to "left arm" will automatically
/// map "left arm" to "torso".
/// </summary>
/// </summary>
[ViewVariables]
public Dictionary<string, List<string>> Connections { get; set; }
@@ -54,7 +55,7 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Returns whether the given slot exists in this BodyTemplate.
/// </summary>
/// </summary>
public bool SlotExists(string slotName)
{
foreach (string slot in Slots.Keys)
@@ -67,7 +68,7 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Returns an integer unique to this BodyTemplate's layout. It does not matter in which order the Connections or Slots are defined.
/// </summary>
/// </summary>
public override int GetHashCode()
{
int slotsHash = 0;

View File

@@ -1,9 +1,6 @@
using Robust.Shared.Interfaces.GameObjects;
using System;
using System.Collections.Generic;
using System.Text;
using Content.Server.Health.BodySystem.Surgery.SurgeryData;
namespace Content.Server.BodySystem
namespace Content.Server.Health.BodySystem
{
/// <summary>

View File

@@ -1,22 +1,24 @@
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using System;
using System;
using System.Collections.Generic;
using Content.Shared.BodySystem;
using Robust.Shared.ViewVariables;
using System.Globalization;
using Robust.Server.GameObjects;
using Robust.Shared.Log;
using Content.Server.Health.BodySystem.BodyPart;
using Content.Shared.Health.BodySystem.Mechanism;
using Content.Shared.Health.BodySystem.Surgery;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Server.BodySystem {
namespace Content.Server.Health.BodySystem.Mechanism {
/// <summary>
/// Component representing a dropped, tangible <see cref="Mechanism"/> entity.
@@ -138,7 +140,7 @@ namespace Content.Server.BodySystem {
{
_sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, Loc.GetString("You see no useful way to use the {0} anymore.", Owner.Name));
}
BodyPart target = targetObject as BodyPart;
BodyPart.BodyPart target = targetObject as BodyPart.BodyPart;
if (!target.TryInstallDroppedMechanism(this))
{
_sharedNotifyManager.PopupMessage(_bodyManagerComponentCache.Owner, _performerCache, Loc.GetString("You can't fit it in!"));

View File

@@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using Content.Shared.BodySystem;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Content.Server.Health.BodySystem.BodyPart;
using Content.Shared.Health.BodySystem;
using Content.Shared.Health.BodySystem.Mechanism;
using Robust.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
namespace Content.Server.BodySystem {
namespace Content.Server.Health.BodySystem.Mechanism {
/// <summary>
/// Data class representing a persistent item inside a <see cref="BodyPart"/>. This includes livers, eyes, cameras, brains, explosive implants, binary communicators, and other things.
@@ -21,55 +15,55 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Professional description of the Mechanism.
/// </summary>
/// </summary>
[ViewVariables]
public string Description { get; set; }
/// <summary>
/// The message to display upon examining a mob with this Mechanism installed. If the string is empty (""), no message will be displayed.
/// </summary>
/// The message to display upon examining a mob with this Mechanism installed. If the string is empty (""), no message will be displayed.
/// </summary>
[ViewVariables]
public string ExamineMessage { get; set; }
/// <summary>
/// Path to the RSI that represents this Mechanism.
/// </summary>
/// </summary>
[ViewVariables]
public string RSIPath { get; set; }
/// <summary>
/// RSI state that represents this Mechanism.
/// </summary>
/// </summary>
[ViewVariables]
public string RSIState { get; set; }
/// <summary>
/// Max HP of this Mechanism.
/// </summary>
/// </summary>
[ViewVariables]
public int MaxDurability { get; set; }
/// <summary>
/// Current HP of this Mechanism.
/// </summary>
/// </summary>
[ViewVariables]
public int CurrentDurability { get; set; }
/// <summary>
/// At what HP this Mechanism is completely destroyed.
/// </summary>
/// </summary>
[ViewVariables]
public int DestroyThreshold { get; set; }
/// <summary>
/// Armor of this Mechanism against attacks.
/// </summary>
/// </summary>
[ViewVariables]
public int Resistance { get; set; }
/// <summary>
/// Determines a handful of things - mostly whether this Mechanism can fit into a BodyPart.
/// </summary>
/// </summary>
[ViewVariables]
public int Size { get; set; }
@@ -91,7 +85,7 @@ namespace Content.Server.BodySystem {
/// <summary>
/// Loads the given <see cref="MechanismPrototype"/> - current data on this Mechanism will be overwritten!
/// </summary>
/// </summary>
public void LoadFromPrototype(MechanismPrototype data)
{
Name = data.Name;

View File

@@ -1,30 +1,29 @@
using Content.Shared.BodySystem;
using System.Collections.Generic;
using Content.Server.Health.BodySystem.Surgery.SurgeryData;
using Robust.Shared.Interfaces.GameObjects;
using System;
using System.Collections.Generic;
namespace Content.Server.BodySystem
namespace Content.Server.Health.BodySystem.Surgery.Surgeon
{
/// <summary>
/// Interface representing an entity capable of performing surgery (performing operations on an <see cref="ISurgeryData"/> class).
/// For an example see <see cref="SurgeryToolComponent"/>, which inherits from this class.
/// </summary>
/// </summary>
public interface ISurgeon
{
/// <summary>
/// How long it takes to perform a single surgery step (in seconds).
/// </summary>
/// </summary>
public float BaseOperationTime { get; set; }
public delegate void MechanismRequestCallback(Mechanism target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer);
public delegate void MechanismRequestCallback(Mechanism.Mechanism target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer);
/// <summary>
/// When performing a surgery, the <see cref="ISurgeryData"/> may sometimes require selecting from a set of Mechanisms to operate on.
/// This function is called in that scenario, and it is expected that you call the callback with one mechanism from the provided list.
/// </summary>
public void RequestMechanism(List<Mechanism> options, MechanismRequestCallback callback);
/// </summary>
public void RequestMechanism(List<Mechanism.Mechanism> options, MechanismRequestCallback callback);
}
}

View File

@@ -1,7 +1,10 @@
using System;
using System.Collections.Generic;
using Content.Shared.BodySystem;
using Content.Server.Health.BodySystem.BodyPart;
using Content.Server.Health.BodySystem.Mechanism;
using Content.Shared.GameObjects;
using Content.Shared.Health.BodySystem;
using Content.Shared.Health.BodySystem.Surgery;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
@@ -14,7 +17,7 @@ using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Serialization;
namespace Content.Server.BodySystem
namespace Content.Server.Health.BodySystem.Surgery.Surgeon
{
//TODO: add checks to close UI if user walks too far away from tool or target.
@@ -106,10 +109,10 @@ namespace Content.Server.BodySystem
}
}
public void RequestMechanism(List<Mechanism> options, ISurgeon.MechanismRequestCallback callback)
public void RequestMechanism(List<Mechanism.Mechanism> options, ISurgeon.MechanismRequestCallback callback)
{
var toSend = new Dictionary<string, int> ();
foreach (Mechanism mechanism in options)
foreach (Mechanism.Mechanism mechanism in options)
{
_optionsCache.Add(_idHash, mechanism);
toSend.Add(mechanism.Name, _idHash++);
@@ -181,7 +184,7 @@ namespace Content.Server.BodySystem
{
SendNoUsefulWayToUseAnymorePopup();
}
BodyPart target = targetObject as BodyPart;
BodyPart.BodyPart target = targetObject as BodyPart.BodyPart;
if (!target.AttemptSurgery(_surgeryType, _bodyManagerComponentCache, this, _performerCache))
{
SendNoUsefulWayToUseAnymorePopup();
@@ -198,7 +201,7 @@ namespace Content.Server.BodySystem
{
SendNoUsefulWayToUseAnymorePopup();
}
Mechanism target = targetObject as Mechanism;
Mechanism.Mechanism target = targetObject as Mechanism.Mechanism;
CloseSurgeryUI(_performerCache.GetComponent<BasicActorComponent>().playerSession);
_callbackCache(target, _bodyManagerComponentCache, this, _performerCache);
}

View File

@@ -1,32 +1,26 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.BodySystem;
using Content.Server.Health.BodySystem.Surgery.Surgeon;
using Content.Shared.Health.BodySystem;
using Content.Shared.Interfaces;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Serialization;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
namespace Content.Server.BodySystem
namespace Content.Server.Health.BodySystem.Surgery.SurgeryData
{
/// <summary>
/// Data class representing the surgery state of a biological entity.
/// </summary>
/// </summary>
public class BiologicalSurgeryData : ISurgeryData
{
protected bool _skinOpened = false;
protected bool _vesselsClamped = false;
protected bool _skinRetracted = false;
protected List<Mechanism> _disconnectedOrgans = new List<Mechanism>();
protected List<Mechanism.Mechanism> _disconnectedOrgans = new List<Mechanism.Mechanism>();
public BiologicalSurgeryData(BodyPart parent) : base(parent) { }
public BiologicalSurgeryData(BodyPart.BodyPart parent) : base(parent) { }
public override SurgeryAction GetSurgeryStep(SurgeryType toolType)
{
@@ -79,7 +73,7 @@ namespace Content.Server.BodySystem
else if (_skinOpened && _vesselsClamped && _skinRetracted) //Case: skin is fully open.
{
toReturn += Loc.GetString("There is an incision on {0:their} {1}.\n", target, _parent.Name);
foreach (Mechanism mechanism in _disconnectedOrgans)
foreach (Mechanism.Mechanism mechanism in _disconnectedOrgans)
{
toReturn += Loc.GetString("{0:their} {1} is loose.\n", target, mechanism.Name);
}
@@ -87,12 +81,12 @@ namespace Content.Server.BodySystem
return toReturn;
}
public override bool CanInstallMechanism(Mechanism toBeInstalled)
public override bool CanInstallMechanism(Mechanism.Mechanism toBeInstalled)
{
return _skinOpened && _vesselsClamped && _skinRetracted;
}
public override bool CanAttachBodyPart(BodyPart toBeConnected)
public override bool CanAttachBodyPart(BodyPart.BodyPart toBeConnected)
{
return true;
//TODO: if a bodypart is disconnected, you should have to do some surgery to allow another bodypart to be attached.
@@ -141,8 +135,8 @@ namespace Content.Server.BodySystem
{
if (_parent.Mechanisms.Count <= 0)
return;
List<Mechanism> toSend = new List<Mechanism>();
foreach (Mechanism mechanism in _parent.Mechanisms)
List<Mechanism.Mechanism> toSend = new List<Mechanism.Mechanism>();
foreach (Mechanism.Mechanism mechanism in _parent.Mechanisms)
{
if (!_disconnectedOrgans.Contains(mechanism))
toSend.Add(mechanism);
@@ -150,7 +144,7 @@ namespace Content.Server.BodySystem
if (toSend.Count > 0)
surgeon.RequestMechanism(toSend, LoosenOrganSurgeryCallback);
}
public void LoosenOrganSurgeryCallback(Mechanism target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer)
public void LoosenOrganSurgeryCallback(Mechanism.Mechanism target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer)
{
if (target != null && _parent.Mechanisms.Contains(target))
{
@@ -172,7 +166,7 @@ namespace Content.Server.BodySystem
}
public void RemoveOrganSurgeryCallback(Mechanism target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer)
public void RemoveOrganSurgeryCallback(Mechanism.Mechanism target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer)
{
if (target != null && _parent.Mechanisms.Contains(target))
{

View File

@@ -1,58 +1,54 @@
using System;
using System.Collections.Generic;
using Content.Shared.BodySystem;
using Content.Server.Health.BodySystem.BodyPart;
using Content.Server.Health.BodySystem.Mechanism;
using Content.Server.Health.BodySystem.Surgery.Surgeon;
using Content.Shared.Health.BodySystem;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Serialization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using YamlDotNet.RepresentationModel;
namespace Content.Server.BodySystem
namespace Content.Server.Health.BodySystem.Surgery.SurgeryData
{
/// <summary>
/// This data class represents the state of a <see cref="BodyPart"/> in regards to everything surgery related - whether there's an incision on it, whether the bone is broken, etc.
/// </summary>
/// </summary>
public abstract class ISurgeryData
{
/// <summary>
/// The <see cref="BodyPart"/> this surgeryData is attached to. The ISurgeryData class should not exist without a <see cref="BodyPart"/> that it
/// represents, and will throw errors if it is null.
/// </summary>
protected BodyPart _parent;
/// </summary>
protected BodyPart.BodyPart _parent;
/// <summary>
/// The <see cref="BodyPartType"/> of the parent <see cref="BodyPart"/>.
/// </summary>
/// </summary>
protected BodyPartType _parentType => _parent.PartType;
public delegate void SurgeryAction(IBodyPartContainer container, ISurgeon surgeon, IEntity performer);
public ISurgeryData(BodyPart parent)
public ISurgeryData(BodyPart.BodyPart parent)
{
_parent = parent;
}
/// <summary>
/// Returns the description of this current <see cref="BodyPart"/> to be shown upon observing the given entity.
/// Returns the description of this current <see cref="BodyPart"/> to be shown upon observing the given entity.
/// </summary>
public abstract string GetDescription(IEntity target);
/// <summary>
/// Returns whether a <see cref="Mechanism"/> can be installed into the <see cref="BodyPart"/> this ISurgeryData represents.
/// Returns whether a <see cref="Mechanism"/> can be installed into the <see cref="BodyPart"/> this ISurgeryData represents.
/// </summary>
public abstract bool CanInstallMechanism(Mechanism toBeInstalled);
public abstract bool CanInstallMechanism(Mechanism.Mechanism toBeInstalled);
/// <summary>
/// Returns whether the given <see cref="BodyPart"/> can be connected to the <see cref="BodyPart"/> this ISurgeryData represents.
/// </summary>
public abstract bool CanAttachBodyPart(BodyPart toBeConnected);
public abstract bool CanAttachBodyPart(BodyPart.BodyPart toBeConnected);
/// <summary>
/// Gets the delegate corresponding to the surgery step using the given <see cref="SurgeryType"/>. Returns null if no surgery step can be performed.