Remove IBody, IBodyPart, IMechanism and IMechanismBehavior (#4187)
* Remove IBody, IBodyPart, IMechanism and IMechanismBehavior interfaces * Summary cleanup
This commit is contained in:
@@ -11,42 +11,42 @@ namespace Content.Server.Body.Behavior
|
||||
{
|
||||
public class BrainBehavior : MechanismBehavior
|
||||
{
|
||||
protected override void OnAddedToBody(IBody body)
|
||||
protected override void OnAddedToBody(SharedBodyComponent body)
|
||||
{
|
||||
base.OnAddedToBody(body);
|
||||
|
||||
HandleMind(body.Owner, Owner);
|
||||
}
|
||||
|
||||
protected override void OnAddedToPart(IBodyPart part)
|
||||
protected override void OnAddedToPart(SharedBodyPartComponent part)
|
||||
{
|
||||
base.OnAddedToPart(part);
|
||||
|
||||
HandleMind(part.Owner, Owner);
|
||||
}
|
||||
|
||||
protected override void OnAddedToPartInBody(IBody body, IBodyPart part)
|
||||
protected override void OnAddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part)
|
||||
{
|
||||
base.OnAddedToPartInBody(body, part);
|
||||
|
||||
HandleMind(body.Owner, Owner);
|
||||
}
|
||||
|
||||
protected override void OnRemovedFromBody(IBody old)
|
||||
protected override void OnRemovedFromBody(SharedBodyComponent old)
|
||||
{
|
||||
base.OnRemovedFromBody(old);
|
||||
|
||||
HandleMind(Part!.Owner, old.Owner);
|
||||
}
|
||||
|
||||
protected override void OnRemovedFromPart(IBodyPart old)
|
||||
protected override void OnRemovedFromPart(SharedBodyPartComponent old)
|
||||
{
|
||||
base.OnRemovedFromPart(old);
|
||||
|
||||
HandleMind(Owner, old.Owner);
|
||||
}
|
||||
|
||||
protected override void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart)
|
||||
protected override void OnRemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart)
|
||||
{
|
||||
base.OnRemovedFromPartInBody(oldBody, oldPart);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Content.Server.Body.Behavior
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
protected override void OnAddedToBody(IBody body)
|
||||
protected override void OnAddedToBody(SharedBodyComponent body)
|
||||
{
|
||||
base.OnAddedToBody(body);
|
||||
Inhale(CycleDelay);
|
||||
|
||||
@@ -8,22 +8,24 @@ using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Body.Behavior
|
||||
{
|
||||
public abstract class MechanismBehavior : IMechanismBehavior
|
||||
public abstract class MechanismBehavior : SharedMechanismBehavior
|
||||
{
|
||||
public IBody? Body => Part?.Body;
|
||||
private SharedMechanismComponent _parent = default!;
|
||||
|
||||
public IBodyPart? Part => Parent.Part;
|
||||
public override SharedBodyComponent? Body => Part?.Body;
|
||||
|
||||
public IMechanism Parent { get; private set; } = default!;
|
||||
public override SharedBodyPartComponent? Part => Parent.Part;
|
||||
|
||||
public IEntity Owner => Parent.Owner;
|
||||
public override SharedMechanismComponent Parent => _parent;
|
||||
|
||||
public virtual void Initialize(IMechanism parent)
|
||||
public override IEntity Owner => Parent.Owner;
|
||||
|
||||
public override void Initialize(SharedMechanismComponent parent)
|
||||
{
|
||||
Parent = parent;
|
||||
_parent = parent;
|
||||
}
|
||||
|
||||
public virtual void Startup()
|
||||
public override void Startup()
|
||||
{
|
||||
if (Part == null)
|
||||
{
|
||||
@@ -40,7 +42,9 @@ namespace Content.Server.Body.Behavior
|
||||
}
|
||||
}
|
||||
|
||||
public void AddedToBody(IBody body)
|
||||
public override void Update(float frameTime) { }
|
||||
|
||||
public override void AddedToBody(SharedBodyComponent body)
|
||||
{
|
||||
DebugTools.AssertNotNull(Body);
|
||||
DebugTools.AssertNotNull(body);
|
||||
@@ -48,7 +52,7 @@ namespace Content.Server.Body.Behavior
|
||||
OnAddedToBody(body);
|
||||
}
|
||||
|
||||
public void AddedToPart(IBodyPart part)
|
||||
public override void AddedToPart(SharedBodyPartComponent part)
|
||||
{
|
||||
DebugTools.AssertNotNull(Part);
|
||||
DebugTools.AssertNotNull(part);
|
||||
@@ -56,7 +60,7 @@ namespace Content.Server.Body.Behavior
|
||||
OnAddedToPart(part);
|
||||
}
|
||||
|
||||
public void AddedToPartInBody(IBody body, IBodyPart part)
|
||||
public override void AddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part)
|
||||
{
|
||||
DebugTools.AssertNotNull(Body);
|
||||
DebugTools.AssertNotNull(body);
|
||||
@@ -66,7 +70,7 @@ namespace Content.Server.Body.Behavior
|
||||
OnAddedToPartInBody(body, part);
|
||||
}
|
||||
|
||||
public void RemovedFromBody(IBody old)
|
||||
public override void RemovedFromBody(SharedBodyComponent old)
|
||||
{
|
||||
DebugTools.AssertNull(Body);
|
||||
DebugTools.AssertNotNull(old);
|
||||
@@ -74,7 +78,7 @@ namespace Content.Server.Body.Behavior
|
||||
OnRemovedFromBody(old);
|
||||
}
|
||||
|
||||
public void RemovedFromPart(IBodyPart old)
|
||||
public override void RemovedFromPart(SharedBodyPartComponent old)
|
||||
{
|
||||
DebugTools.AssertNull(Part);
|
||||
DebugTools.AssertNotNull(old);
|
||||
@@ -82,7 +86,7 @@ namespace Content.Server.Body.Behavior
|
||||
OnRemovedFromPart(old);
|
||||
}
|
||||
|
||||
public void RemovedFromPartInBody(IBody oldBody, IBodyPart oldPart)
|
||||
public override void RemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart)
|
||||
{
|
||||
DebugTools.AssertNull(Body);
|
||||
DebugTools.AssertNull(Part);
|
||||
@@ -92,18 +96,16 @@ namespace Content.Server.Body.Behavior
|
||||
OnRemovedFromPartInBody(oldBody, oldPart);
|
||||
}
|
||||
|
||||
protected virtual void OnAddedToBody(IBody body) { }
|
||||
protected virtual void OnAddedToBody(SharedBodyComponent body) { }
|
||||
|
||||
protected virtual void OnAddedToPart(IBodyPart part) { }
|
||||
protected virtual void OnAddedToPart(SharedBodyPartComponent part) { }
|
||||
|
||||
protected virtual void OnAddedToPartInBody(IBody body, IBodyPart part) { }
|
||||
protected virtual void OnAddedToPartInBody(SharedBodyComponent body, SharedBodyPartComponent part) { }
|
||||
|
||||
protected virtual void OnRemovedFromBody(IBody old) { }
|
||||
protected virtual void OnRemovedFromBody(SharedBodyComponent old) { }
|
||||
|
||||
protected virtual void OnRemovedFromPart(IBodyPart old) { }
|
||||
protected virtual void OnRemovedFromPart(SharedBodyPartComponent old) { }
|
||||
|
||||
protected virtual void OnRemovedFromPartInBody(IBody oldBody, IBodyPart oldPart) { }
|
||||
|
||||
public virtual void Update(float frameTime) { }
|
||||
protected virtual void OnRemovedFromPartInBody(SharedBodyComponent oldBody, SharedBodyPartComponent oldPart) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Shared.Body.Behavior;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
|
||||
namespace Content.Server.Body.Behavior
|
||||
{
|
||||
public static class MechanismExtensions
|
||||
{
|
||||
public static bool HasMechanismBehavior<T>(this IBody body) where T : IMechanismBehavior
|
||||
{
|
||||
return body.Parts.Any(p => p.Key.HasMechanismBehavior<T>());
|
||||
}
|
||||
|
||||
public static bool HasMechanismBehavior<T>(this IBodyPart part) where T : IMechanismBehavior
|
||||
{
|
||||
return part.Mechanisms.Any(m => m.HasBehavior<T>());
|
||||
}
|
||||
|
||||
public static IEnumerable<IMechanismBehavior> GetMechanismBehaviors(this IBody body)
|
||||
{
|
||||
foreach (var (part, _) in body.Parts)
|
||||
foreach (var mechanism in part.Mechanisms)
|
||||
foreach (var behavior in mechanism.Behaviors.Values)
|
||||
{
|
||||
yield return behavior;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetMechanismBehaviors(this IBody body,
|
||||
[NotNullWhen(true)] out List<IMechanismBehavior>? behaviors)
|
||||
{
|
||||
behaviors = body.GetMechanismBehaviors().ToList();
|
||||
|
||||
if (behaviors.Count == 0)
|
||||
{
|
||||
behaviors = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IEnumerable<T> GetMechanismBehaviors<T>(this IBody body) where T : class, IMechanismBehavior
|
||||
{
|
||||
foreach (var (part, _) in body.Parts)
|
||||
foreach (var mechanism in part.Mechanisms)
|
||||
foreach (var behavior in mechanism.Behaviors.Values)
|
||||
{
|
||||
if (behavior is T tBehavior)
|
||||
{
|
||||
yield return tBehavior;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TryGetMechanismBehaviors<T>(this IBody entity, [NotNullWhen(true)] out List<T>? behaviors)
|
||||
where T : class, IMechanismBehavior
|
||||
{
|
||||
behaviors = entity.GetMechanismBehaviors<T>().ToList();
|
||||
|
||||
if (behaviors.Count == 0)
|
||||
{
|
||||
behaviors = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,27 +21,26 @@ namespace Content.Server.Body
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedBodyComponent))]
|
||||
[ComponentReference(typeof(IBody))]
|
||||
[ComponentReference(typeof(IGhostOnMove))]
|
||||
public class BodyComponent : SharedBodyComponent, IRelayMoveInput, IGhostOnMove
|
||||
{
|
||||
private Container _partContainer = default!;
|
||||
[Dependency] private readonly IGameTicker _gameTicker = default!;
|
||||
|
||||
protected override bool CanAddPart(string slotId, IBodyPart part)
|
||||
protected override bool CanAddPart(string slotId, SharedBodyPartComponent part)
|
||||
{
|
||||
return base.CanAddPart(slotId, part) &&
|
||||
_partContainer.CanInsert(part.Owner);
|
||||
}
|
||||
|
||||
protected override void OnAddPart(BodyPartSlot slot, IBodyPart part)
|
||||
protected override void OnAddPart(BodyPartSlot slot, SharedBodyPartComponent part)
|
||||
{
|
||||
base.OnAddPart(slot, part);
|
||||
|
||||
_partContainer.Insert(part.Owner);
|
||||
}
|
||||
|
||||
protected override void OnRemovePart(BodyPartSlot slot, IBodyPart part)
|
||||
protected override void OnRemovePart(BodyPartSlot slot, SharedBodyPartComponent part)
|
||||
{
|
||||
base.OnRemovePart(slot, part);
|
||||
|
||||
@@ -64,9 +63,9 @@ namespace Content.Server.Body
|
||||
// a crash within the character preview menu in the lobby
|
||||
var entity = Owner.EntityManager.SpawnEntity(preset.PartIDs[slot.Id], Owner.Transform.MapPosition);
|
||||
|
||||
if (!entity.TryGetComponent(out IBodyPart? part))
|
||||
if (!entity.TryGetComponent(out SharedBodyPartComponent? part))
|
||||
{
|
||||
Logger.Error($"Entity {slot.Id} does not have a {nameof(IBodyPart)} component.");
|
||||
Logger.Error($"Entity {slot.Id} does not have a {nameof(SharedBodyPartComponent)} component.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@ using Content.Shared.Damage;
|
||||
|
||||
namespace Content.Server.Body
|
||||
{
|
||||
// TODO BODY: Remove and pretend it never existed
|
||||
public interface IBodyHealthChangeParams
|
||||
{
|
||||
BodyPartType Part { get; }
|
||||
}
|
||||
|
||||
// TODO BODY: Remove and pretend it never existed
|
||||
public class BodyDamageChangeParams : DamageChangeParams, IBodyHealthChangeParams
|
||||
{
|
||||
public BodyDamageChangeParams(BodyPartType part)
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Content.Server.Body.Commands
|
||||
}
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent(out IBody? body))
|
||||
if (!entity.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
@@ -131,9 +131,9 @@ namespace Content.Server.Body.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hand.TryGetComponent(out IBodyPart? part))
|
||||
if (!hand.TryGetComponent(out SharedBodyPartComponent? part))
|
||||
{
|
||||
shell.WriteLine($"Hand entity {hand} does not have a {nameof(IBodyPart)} component.");
|
||||
shell.WriteLine($"Hand entity {hand} does not have a {nameof(SharedBodyPartComponent)} component.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,9 +76,9 @@ namespace Content.Server.Body.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity.TryGetComponent(out IBody? body))
|
||||
if (!entity.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
shell.WriteLine($"Entity {entity.Name} with uid {entity.Uid} does not have a {nameof(IBody)} component.");
|
||||
shell.WriteLine($"Entity {entity.Name} with uid {entity.Uid} does not have a {nameof(SharedBodyComponent)} component.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,9 +88,9 @@ namespace Content.Server.Body.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!partEntity.TryGetComponent(out IBodyPart? part))
|
||||
if (!partEntity.TryGetComponent(out SharedBodyPartComponent? part))
|
||||
{
|
||||
shell.WriteLine($"Entity {partEntity.Name} with uid {args[0]} does not have a {nameof(IBodyPart)} component.");
|
||||
shell.WriteLine($"Entity {partEntity.Name} with uid {args[0]} does not have a {nameof(SharedBodyPartComponent)} component.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Content.Server.Body.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.AttachedEntity.TryGetComponent(out IBody? body))
|
||||
if (!player.AttachedEntity.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Content.Server.Body.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.AttachedEntity.TryGetComponent(out IBody? body))
|
||||
if (!player.AttachedEntity.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace Content.Server.Body.Mechanism
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedMechanismComponent))]
|
||||
[ComponentReference(typeof(IMechanism))]
|
||||
public class MechanismComponent : SharedMechanismComponent, IAfterInteract
|
||||
{
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key);
|
||||
@@ -47,11 +46,11 @@ namespace Content.Server.Body.Mechanism
|
||||
PerformerCache = null;
|
||||
BodyCache = null;
|
||||
|
||||
if (eventArgs.Target.TryGetComponent(out IBody? body))
|
||||
if (eventArgs.Target.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
SendBodyPartListToUser(eventArgs, body);
|
||||
}
|
||||
else if (eventArgs.Target.TryGetComponent<IBodyPart>(out var part))
|
||||
else if (eventArgs.Target.TryGetComponent<SharedBodyPartComponent>(out var part))
|
||||
{
|
||||
DebugTools.AssertNotNull(part);
|
||||
|
||||
@@ -64,7 +63,7 @@ namespace Content.Server.Body.Mechanism
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SendBodyPartListToUser(AfterInteractEventArgs eventArgs, IBody body)
|
||||
private void SendBodyPartListToUser(AfterInteractEventArgs eventArgs, SharedBodyComponent body)
|
||||
{
|
||||
// Create dictionary to send to client (text to be shown : data sent back if selected)
|
||||
var toSend = new Dictionary<string, int>();
|
||||
@@ -120,7 +119,7 @@ namespace Content.Server.Body.Mechanism
|
||||
return;
|
||||
}
|
||||
|
||||
var target = (IBodyPart) targetObject;
|
||||
var target = (SharedBodyPartComponent) targetObject;
|
||||
var message = target.TryAddMechanism(this)
|
||||
? Loc.GetString("You jam {0:theName} inside {1:them}.", Owner, PerformerCache)
|
||||
: Loc.GetString("You can't fit it in!");
|
||||
|
||||
@@ -25,31 +25,30 @@ namespace Content.Server.Body.Part
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedBodyPartComponent))]
|
||||
[ComponentReference(typeof(IBodyPart))]
|
||||
public class BodyPartComponent : SharedBodyPartComponent, IAfterInteract
|
||||
{
|
||||
private readonly Dictionary<int, object> _optionsCache = new();
|
||||
private IBody? _owningBodyCache;
|
||||
private SharedBodyComponent? _owningBodyCache;
|
||||
private int _idHash;
|
||||
private IEntity? _surgeonCache;
|
||||
private Container _mechanismContainer = default!;
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key);
|
||||
|
||||
public override bool CanAddMechanism(IMechanism mechanism)
|
||||
public override bool CanAddMechanism(SharedMechanismComponent mechanism)
|
||||
{
|
||||
return base.CanAddMechanism(mechanism) &&
|
||||
_mechanismContainer.CanInsert(mechanism.Owner);
|
||||
}
|
||||
|
||||
protected override void OnAddMechanism(IMechanism mechanism)
|
||||
protected override void OnAddMechanism(SharedMechanismComponent mechanism)
|
||||
{
|
||||
base.OnAddMechanism(mechanism);
|
||||
|
||||
_mechanismContainer.Insert(mechanism.Owner);
|
||||
}
|
||||
|
||||
protected override void OnRemoveMechanism(IMechanism mechanism)
|
||||
protected override void OnRemoveMechanism(SharedMechanismComponent mechanism)
|
||||
{
|
||||
base.OnRemoveMechanism(mechanism);
|
||||
|
||||
@@ -70,9 +69,9 @@ namespace Content.Server.Body.Part
|
||||
{
|
||||
var entity = Owner.EntityManager.SpawnEntity(mechanismId, Owner.Transform.MapPosition);
|
||||
|
||||
if (!entity.TryGetComponent(out IMechanism? mechanism))
|
||||
if (!entity.TryGetComponent(out SharedMechanismComponent? mechanism))
|
||||
{
|
||||
Logger.Error($"Entity {mechanismId} does not have a {nameof(IMechanism)} component.");
|
||||
Logger.Error($"Entity {mechanismId} does not have a {nameof(SharedMechanismComponent)} component.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -108,7 +107,7 @@ namespace Content.Server.Body.Part
|
||||
_surgeonCache = null;
|
||||
_owningBodyCache = null;
|
||||
|
||||
if (eventArgs.Target.TryGetComponent(out IBody? body))
|
||||
if (eventArgs.Target.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
SendSlots(eventArgs, body);
|
||||
}
|
||||
@@ -116,7 +115,7 @@ namespace Content.Server.Body.Part
|
||||
return true;
|
||||
}
|
||||
|
||||
private void SendSlots(AfterInteractEventArgs eventArgs, IBody body)
|
||||
private void SendSlots(AfterInteractEventArgs eventArgs, SharedBodyComponent body)
|
||||
{
|
||||
// Create dictionary to send to client (text to be shown : data sent back if selected)
|
||||
var toSend = new Dictionary<string, int>();
|
||||
@@ -246,7 +245,7 @@ namespace Content.Server.Body.Part
|
||||
return;
|
||||
}
|
||||
|
||||
if (!user.TryGetComponent(out IBody? body))
|
||||
if (!user.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -262,7 +261,7 @@ namespace Content.Server.Body.Part
|
||||
|
||||
protected override void Activate(IEntity user, BodyPartComponent component)
|
||||
{
|
||||
if (!user.TryGetComponent(out IBody? body))
|
||||
if (!user.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Content.Server.Body.Scanner
|
||||
return;
|
||||
}
|
||||
|
||||
if (session.AttachedEntity.TryGetComponent(out IBody? body))
|
||||
if (session.AttachedEntity.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
var state = InterfaceState(body);
|
||||
UserInterface?.SetState(state);
|
||||
@@ -56,7 +56,7 @@ namespace Content.Server.Body.Scanner
|
||||
/// <summary>
|
||||
/// Copy BodyTemplate and BodyPart data into a common data class that the client can read.
|
||||
/// </summary>
|
||||
private BodyScannerUIState InterfaceState(IBody body)
|
||||
private BodyScannerUIState InterfaceState(SharedBodyComponent body)
|
||||
{
|
||||
return new(body.Owner.Uid);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Content.Server.Body.Surgery
|
||||
{
|
||||
public override string Name => "BiologicalSurgeryData";
|
||||
|
||||
private readonly HashSet<IMechanism> _disconnectedOrgans = new();
|
||||
private readonly HashSet<SharedMechanismComponent> _disconnectedOrgans = new();
|
||||
|
||||
private bool SkinOpened { get; set; }
|
||||
|
||||
@@ -33,11 +33,11 @@ namespace Content.Server.Body.Surgery
|
||||
|
||||
private bool VesselsClamped { get; set; }
|
||||
|
||||
public IBodyPart? Parent => Owner.GetComponentOrNull<IBodyPart>();
|
||||
public SharedBodyPartComponent? Parent => Owner.GetComponentOrNull<SharedBodyPartComponent>();
|
||||
|
||||
public BodyPartType? ParentType => Parent?.PartType;
|
||||
|
||||
private void AddDisconnectedOrgan(IMechanism mechanism)
|
||||
private void AddDisconnectedOrgan(SharedMechanismComponent mechanism)
|
||||
{
|
||||
if (_disconnectedOrgans.Add(mechanism))
|
||||
{
|
||||
@@ -45,7 +45,7 @@ namespace Content.Server.Body.Surgery
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveDisconnectedOrgan(IMechanism mechanism)
|
||||
private void RemoveDisconnectedOrgan(SharedMechanismComponent mechanism)
|
||||
{
|
||||
if (_disconnectedOrgans.Remove(mechanism))
|
||||
{
|
||||
@@ -117,7 +117,7 @@ namespace Content.Server.Body.Surgery
|
||||
return toReturn.ToString();
|
||||
}
|
||||
|
||||
public bool CanAddMechanism(IMechanism mechanism)
|
||||
public bool CanAddMechanism(SharedMechanismComponent mechanism)
|
||||
{
|
||||
return Parent != null &&
|
||||
SkinOpened &&
|
||||
@@ -125,7 +125,7 @@ namespace Content.Server.Body.Surgery
|
||||
SkinRetracted;
|
||||
}
|
||||
|
||||
public bool CanAttachBodyPart(IBodyPart part)
|
||||
public bool CanAttachBodyPart(SharedBodyPartComponent part)
|
||||
{
|
||||
return Parent != null;
|
||||
// TODO BODY if a part is disconnected, you should have to do some surgery to allow another body part to be attached.
|
||||
@@ -276,7 +276,7 @@ namespace Content.Server.Body.Surgery
|
||||
if (Parent == null) return;
|
||||
if (Parent.Mechanisms.Count <= 0) return;
|
||||
|
||||
var toSend = new List<IMechanism>();
|
||||
var toSend = new List<SharedMechanismComponent>();
|
||||
foreach (var mechanism in Parent.Mechanisms)
|
||||
{
|
||||
if (!_disconnectedOrgans.Contains(mechanism))
|
||||
@@ -291,7 +291,7 @@ namespace Content.Server.Body.Surgery
|
||||
}
|
||||
}
|
||||
|
||||
private async void LoosenOrganSurgeryCallback(IMechanism? target, IBodyPartContainer container, ISurgeon surgeon,
|
||||
private async void LoosenOrganSurgeryCallback(SharedMechanismComponent? target, IBodyPartContainer container, ISurgeon surgeon,
|
||||
IEntity performer)
|
||||
{
|
||||
if (Parent == null || target == null || !Parent.Mechanisms.Contains(target))
|
||||
@@ -332,7 +332,7 @@ namespace Content.Server.Body.Surgery
|
||||
}
|
||||
}
|
||||
|
||||
private async void RemoveOrganSurgeryCallback(IMechanism? target, IBodyPartContainer container, ISurgeon surgeon,
|
||||
private async void RemoveOrganSurgeryCallback(SharedMechanismComponent? target, IBodyPartContainer container, ISurgeon surgeon,
|
||||
IEntity performer)
|
||||
{
|
||||
if (Parent == null || target == null || !Parent.Mechanisms.Contains(target))
|
||||
@@ -359,7 +359,7 @@ namespace Content.Server.Body.Surgery
|
||||
private async void RemoveBodyPartSurgery(IBodyPartContainer container, ISurgeon surgeon, IEntity performer)
|
||||
{
|
||||
if (Parent == null) return;
|
||||
if (container is not IBody body) return;
|
||||
if (container is not SharedBodyComponent body) return;
|
||||
|
||||
performer.PopupMessage(Loc.GetString("Sawing off the limb!"));
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Content.Server.Body.Surgery.Components
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key);
|
||||
|
||||
public IBody? BodyCache { get; private set; }
|
||||
public SharedBodyComponent? BodyCache { get; private set; }
|
||||
|
||||
public IEntity? PerformerCache { get; private set; }
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace Content.Server.Body.Surgery.Components
|
||||
CloseAllSurgeryUIs();
|
||||
|
||||
// Attempt surgery on a body by sending a list of operable parts for the client to choose from
|
||||
if (eventArgs.Target.TryGetComponent(out IBody? body))
|
||||
if (eventArgs.Target.TryGetComponent(out SharedBodyComponent? body))
|
||||
{
|
||||
// Create dictionary to send to client (text to be shown : data sent back if selected)
|
||||
var toSend = new Dictionary<string, int>();
|
||||
@@ -93,7 +93,7 @@ namespace Content.Server.Body.Surgery.Components
|
||||
NotUsefulPopup();
|
||||
}
|
||||
}
|
||||
else if (eventArgs.Target.TryGetComponent<IBodyPart>(out var part))
|
||||
else if (eventArgs.Target.TryGetComponent<SharedBodyPartComponent>(out var part))
|
||||
{
|
||||
// Attempt surgery on a DroppedBodyPart - there's only one possible target so no need for selection UI
|
||||
PerformerCache = eventArgs.User;
|
||||
@@ -113,7 +113,7 @@ namespace Content.Server.Body.Surgery.Components
|
||||
}
|
||||
|
||||
// Log error if the surgery fails somehow.
|
||||
Logger.Debug($"Error when trying to perform surgery on ${nameof(IBodyPart)} {eventArgs.User.Name}");
|
||||
Logger.Debug($"Error when trying to perform surgery on ${nameof(SharedBodyPartComponent)} {eventArgs.User.Name}");
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Content.Server.Body.Surgery.Components
|
||||
|
||||
public float BaseOperationTime { get => _baseOperateTime; set => _baseOperateTime = value; }
|
||||
|
||||
public void RequestMechanism(IEnumerable<IMechanism> options, ISurgeon.MechanismRequestCallback callback)
|
||||
public void RequestMechanism(IEnumerable<SharedMechanismComponent> options, ISurgeon.MechanismRequestCallback callback)
|
||||
{
|
||||
var toSend = new Dictionary<string, int>();
|
||||
foreach (var mechanism in options)
|
||||
@@ -211,7 +211,7 @@ namespace Content.Server.Body.Surgery.Components
|
||||
|
||||
/// <summary>
|
||||
/// Called after the client chooses from a list of possible
|
||||
/// <see cref="IBodyPart"/> that can be operated on.
|
||||
/// <see cref="SharedBodyPartComponent"/> that can be operated on.
|
||||
/// </summary>
|
||||
private void HandleReceiveBodyPart(int key)
|
||||
{
|
||||
@@ -230,7 +230,7 @@ namespace Content.Server.Body.Surgery.Components
|
||||
return;
|
||||
}
|
||||
|
||||
var target = (IBodyPart) targetObject!;
|
||||
var target = (SharedBodyPartComponent) targetObject!;
|
||||
|
||||
// TODO BODY Reconsider
|
||||
if (!target.AttemptSurgery(_surgeryType, BodyCache, this, PerformerCache))
|
||||
@@ -241,7 +241,7 @@ namespace Content.Server.Body.Surgery.Components
|
||||
|
||||
/// <summary>
|
||||
/// Called after the client chooses from a list of possible
|
||||
/// <see cref="IMechanism"/> to choose from.
|
||||
/// <see cref="SharedMechanismComponent"/> to choose from.
|
||||
/// </summary>
|
||||
private void HandleReceiveMechanism(int key)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user