Kill bobby 2.0 (#6023)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Body.Components
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Content.Shared.Body.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Body.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedMechanismComponent))]
|
||||
public class MechanismComponent : SharedMechanismComponent
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ namespace Content.Client.Body.UI
|
||||
UpdateMechanismBox(_currentBodyPart?.Mechanisms.ElementAt(args.ItemIndex));
|
||||
}
|
||||
|
||||
private void UpdateMechanismBox(SharedMechanismComponent? mechanism)
|
||||
private void UpdateMechanismBox(MechanismComponent? mechanism)
|
||||
{
|
||||
// TODO BODY Improve UI
|
||||
if (mechanism == null)
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
using Content.Shared.Body.Surgery;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Body.UI
|
||||
{
|
||||
// TODO BODY Make window close if target or surgery tool gets too far away from user.
|
||||
|
||||
/// <summary>
|
||||
/// Generic client-side UI list popup that allows users to choose from an option
|
||||
/// of limbs or organs to operate on.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class SurgeryBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private SurgeryWindow? _window;
|
||||
|
||||
public SurgeryBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey) { }
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
_window = new SurgeryWindow();
|
||||
|
||||
_window.OpenCentered();
|
||||
_window.OnClose += Close;
|
||||
}
|
||||
|
||||
protected override void ReceiveMessage(BoundUserInterfaceMessage message)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case RequestBodyPartSurgeryUIMessage msg:
|
||||
HandleBodyPartRequest(msg);
|
||||
break;
|
||||
case RequestMechanismSurgeryUIMessage msg:
|
||||
HandleMechanismRequest(msg);
|
||||
break;
|
||||
case RequestBodyPartSlotSurgeryUIMessage msg:
|
||||
HandleBodyPartSlotRequest(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleBodyPartRequest(RequestBodyPartSurgeryUIMessage msg)
|
||||
{
|
||||
_window?.BuildDisplay(msg.Targets, BodyPartSelectedCallback);
|
||||
}
|
||||
|
||||
private void HandleMechanismRequest(RequestMechanismSurgeryUIMessage msg)
|
||||
{
|
||||
_window?.BuildDisplay(msg.Targets, MechanismSelectedCallback);
|
||||
}
|
||||
|
||||
private void HandleBodyPartSlotRequest(RequestBodyPartSlotSurgeryUIMessage msg)
|
||||
{
|
||||
_window?.BuildDisplay(msg.Targets, BodyPartSlotSelectedCallback);
|
||||
}
|
||||
|
||||
private void BodyPartSelectedCallback(int selectedOptionData)
|
||||
{
|
||||
SendMessage(new ReceiveBodyPartSurgeryUIMessage(selectedOptionData));
|
||||
}
|
||||
|
||||
private void MechanismSelectedCallback(int selectedOptionData)
|
||||
{
|
||||
SendMessage(new ReceiveMechanismSurgeryUIMessage(selectedOptionData));
|
||||
}
|
||||
|
||||
private void BodyPartSlotSelectedCallback(int selectedOptionData)
|
||||
{
|
||||
SendMessage(new ReceiveBodyPartSlotSurgeryUIMessage(selectedOptionData));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
|
||||
if (disposing)
|
||||
{
|
||||
_window?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
||||
|
||||
namespace Content.Client.Body.UI
|
||||
{
|
||||
public class SurgeryWindow : SS14Window
|
||||
{
|
||||
public delegate void OptionSelectedCallback(int selectedOptionData);
|
||||
|
||||
private readonly BoxContainer _optionsBox;
|
||||
private OptionSelectedCallback? _optionSelectedCallback;
|
||||
|
||||
public SurgeryWindow()
|
||||
{
|
||||
MinSize = SetSize = (300, 400);
|
||||
Title = Loc.GetString("surgery-window-title");
|
||||
RectClipContent = true;
|
||||
|
||||
var vSplitContainer = new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Vertical,
|
||||
Children =
|
||||
{
|
||||
new ScrollContainer
|
||||
{
|
||||
VerticalExpand = true,
|
||||
HorizontalExpand = true,
|
||||
HScrollEnabled = true,
|
||||
VScrollEnabled = true,
|
||||
Children =
|
||||
{
|
||||
(_optionsBox = new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Vertical,
|
||||
HorizontalExpand = true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Contents.AddChild(vSplitContainer);
|
||||
}
|
||||
|
||||
public void BuildDisplay(Dictionary<string, int> data, OptionSelectedCallback callback)
|
||||
{
|
||||
_optionsBox.DisposeAllChildren();
|
||||
_optionSelectedCallback = callback;
|
||||
|
||||
foreach (var (displayText, callbackData) in data)
|
||||
{
|
||||
var button = new SurgeryButton(callbackData);
|
||||
|
||||
button.SetOnToggleBehavior(OnButtonPressed);
|
||||
button.SetDisplayText(Loc.GetString(displayText));
|
||||
|
||||
_optionsBox.AddChild(button);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnButtonPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
if (args.Button.Parent is SurgeryButton surgery)
|
||||
{
|
||||
_optionSelectedCallback?.Invoke(surgery.CallbackData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SurgeryButton : PanelContainer
|
||||
{
|
||||
public Button Button { get; }
|
||||
|
||||
private SpriteView SpriteView { get; }
|
||||
|
||||
private Label DisplayText { get; }
|
||||
|
||||
public int CallbackData { get; }
|
||||
|
||||
public SurgeryButton(int callbackData)
|
||||
{
|
||||
CallbackData = callbackData;
|
||||
|
||||
Button = new Button
|
||||
{
|
||||
HorizontalExpand = true,
|
||||
VerticalExpand = true,
|
||||
ToggleMode = true,
|
||||
MouseFilter = MouseFilterMode.Stop
|
||||
};
|
||||
|
||||
AddChild(Button);
|
||||
|
||||
AddChild(new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Horizontal,
|
||||
Children =
|
||||
{
|
||||
(SpriteView = new SpriteView
|
||||
{
|
||||
MinSize = new Vector2(32.0f, 32.0f)
|
||||
}),
|
||||
(DisplayText = new Label
|
||||
{
|
||||
VerticalAlignment = VAlignment.Center,
|
||||
Text = Loc.GetString("surgery-window-not-available-button-text"),
|
||||
}),
|
||||
(new Control
|
||||
{
|
||||
HorizontalExpand = true
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void SetDisplayText(string text)
|
||||
{
|
||||
DisplayText.Text = text;
|
||||
}
|
||||
|
||||
public void SetOnToggleBehavior(Action<BaseButton.ButtonToggledEventArgs> behavior)
|
||||
{
|
||||
Button.OnToggled += behavior;
|
||||
}
|
||||
|
||||
public void SetSprite()
|
||||
{
|
||||
//button.SpriteView.Sprite = sprite;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace Content.Client.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var mechanisms = entityManager.EntityQuery<SharedMechanismComponent>(true);
|
||||
var mechanisms = entityManager.EntityQuery<MechanismComponent>(true);
|
||||
|
||||
foreach (var mechanism in mechanisms)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Content.Client.Commands
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
var mechanisms = entityManager.EntityQuery<SharedMechanismComponent>(true);
|
||||
var mechanisms = entityManager.EntityQuery<MechanismComponent>(true);
|
||||
|
||||
foreach (var mechanism in mechanisms)
|
||||
{
|
||||
|
||||
@@ -121,7 +121,6 @@ namespace Content.Client.Entry
|
||||
"Cable",
|
||||
"StressTestMovement",
|
||||
"Toys",
|
||||
"SurgeryTool",
|
||||
"EmitSoundOnThrow",
|
||||
"Salvage",
|
||||
"SalvageMagnet",
|
||||
@@ -251,7 +250,6 @@ namespace Content.Client.Entry
|
||||
"MachineFrame",
|
||||
"MachineBoard",
|
||||
"ChemicalAmmo",
|
||||
"BiologicalSurgeryData",
|
||||
"CargoTelepad",
|
||||
"TraitorDeathMatchRedemption",
|
||||
"GlassBeaker",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Body.Components;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Body.Components;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Ghost;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
@@ -16,8 +15,7 @@ namespace Content.Server.Body.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedBodyComponent))]
|
||||
[ComponentReference(typeof(IGhostOnMove))]
|
||||
public class BodyComponent : SharedBodyComponent, IGhostOnMove
|
||||
public class BodyComponent : SharedBodyComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
|
||||
@@ -1,50 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Surgery;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Body.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedBodyPartComponent))]
|
||||
public class BodyPartComponent : SharedBodyPartComponent, IAfterInteract
|
||||
public class BodyPartComponent : SharedBodyPartComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
private readonly Dictionary<int, object> _optionsCache = new();
|
||||
private SharedBodyComponent? _owningBodyCache;
|
||||
private int _idHash;
|
||||
private EntityUid? _surgeonCache;
|
||||
private Container _mechanismContainer = default!;
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key);
|
||||
|
||||
public override bool CanAddMechanism(SharedMechanismComponent mechanism)
|
||||
public override bool CanAddMechanism(MechanismComponent mechanism)
|
||||
{
|
||||
return base.CanAddMechanism(mechanism) &&
|
||||
_mechanismContainer.CanInsert(mechanism.Owner);
|
||||
}
|
||||
|
||||
protected override void OnAddMechanism(SharedMechanismComponent mechanism)
|
||||
protected override void OnAddMechanism(MechanismComponent mechanism)
|
||||
{
|
||||
base.OnAddMechanism(mechanism);
|
||||
|
||||
_mechanismContainer.Insert(mechanism.Owner);
|
||||
}
|
||||
|
||||
protected override void OnRemoveMechanism(SharedMechanismComponent mechanism)
|
||||
protected override void OnRemoveMechanism(MechanismComponent mechanism)
|
||||
{
|
||||
base.OnRemoveMechanism(mechanism);
|
||||
|
||||
@@ -65,156 +49,14 @@ namespace Content.Server.Body.Components
|
||||
{
|
||||
var entity = _entMan.SpawnEntity(mechanismId, _entMan.GetComponent<TransformComponent>(Owner).MapPosition);
|
||||
|
||||
if (!_entMan.TryGetComponent(entity, out SharedMechanismComponent? mechanism))
|
||||
if (!_entMan.TryGetComponent(entity, out MechanismComponent? mechanism))
|
||||
{
|
||||
Logger.Error($"Entity {mechanismId} does not have a {nameof(SharedMechanismComponent)} component.");
|
||||
Logger.Error($"Entity {mechanismId} does not have a {nameof(MechanismComponent)} component.");
|
||||
continue;
|
||||
}
|
||||
|
||||
TryAddMechanism(mechanism, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
if (UserInterface != null)
|
||||
{
|
||||
UserInterface.OnReceiveMessage += OnUIMessage;
|
||||
}
|
||||
|
||||
foreach (var mechanism in Mechanisms)
|
||||
{
|
||||
mechanism.Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
// TODO BODY
|
||||
if (eventArgs.Target == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CloseAllSurgeryUIs();
|
||||
_optionsCache.Clear();
|
||||
_surgeonCache = null;
|
||||
_owningBodyCache = null;
|
||||
|
||||
if (_entMan.TryGetComponent(eventArgs.Target.Value, out SharedBodyComponent? body))
|
||||
{
|
||||
SendSlots(eventArgs, body);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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>();
|
||||
|
||||
// Here we are trying to grab a list of all empty BodySlots adjacent to an existing BodyPart that can be
|
||||
// attached to. i.e. an empty left hand slot, connected to an occupied left arm slot would be valid.
|
||||
foreach (var slot in body.EmptySlots)
|
||||
{
|
||||
if (slot.PartType != PartType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var connection in slot.Connections)
|
||||
{
|
||||
if (connection.Part == null ||
|
||||
!connection.Part.CanAttachPart(this))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_optionsCache.Add(_idHash, slot);
|
||||
toSend.Add(slot.Id, _idHash++);
|
||||
}
|
||||
}
|
||||
|
||||
if (_optionsCache.Count > 0)
|
||||
{
|
||||
OpenSurgeryUI(_entMan.GetComponent<ActorComponent>(eventArgs.User).PlayerSession);
|
||||
BodyPartSlotRequest(_entMan.GetComponent<ActorComponent>(eventArgs.User).PlayerSession,
|
||||
toSend);
|
||||
_surgeonCache = eventArgs.User;
|
||||
_owningBodyCache = body;
|
||||
}
|
||||
else // If surgery cannot be performed, show message saying so.
|
||||
{
|
||||
eventArgs.Target?.PopupMessage(eventArgs.User,
|
||||
Loc.GetString("bodypart-component-no-way-to-install-message", ("partName", Owner)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the client chooses from a list of possible
|
||||
/// BodyPartSlots to install the limb on.
|
||||
/// </summary>
|
||||
private void ReceiveBodyPartSlot(int key)
|
||||
{
|
||||
if (_surgeonCache == null ||
|
||||
!_entMan.TryGetComponent(_surgeonCache.Value, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CloseSurgeryUI(actor.PlayerSession);
|
||||
|
||||
if (_owningBodyCache == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: sanity checks to see whether user is in range, user is still able-bodied, target is still the same, etc etc
|
||||
if (!_optionsCache.TryGetValue(key, out var targetObject))
|
||||
{
|
||||
_owningBodyCache.Owner.PopupMessage(_surgeonCache.Value,
|
||||
Loc.GetString("bodypart-component-no-way-to-attach-message", ("partName", Owner)));
|
||||
}
|
||||
|
||||
var target = (string) targetObject!;
|
||||
var message = _owningBodyCache.TryAddPart(target, this)
|
||||
? Loc.GetString("bodypart-component-attach-success-message",("partName", Owner))
|
||||
: Loc.GetString("bodypart-component-attach-fail-message",("partName", Owner));
|
||||
|
||||
_owningBodyCache.Owner.PopupMessage(_surgeonCache.Value, message);
|
||||
}
|
||||
|
||||
private void OpenSurgeryUI(IPlayerSession session)
|
||||
{
|
||||
UserInterface?.Open(session);
|
||||
}
|
||||
|
||||
private void BodyPartSlotRequest(IPlayerSession session, Dictionary<string, int> options)
|
||||
{
|
||||
UserInterface?.SendMessage(new RequestBodyPartSlotSurgeryUIMessage(options), session);
|
||||
}
|
||||
|
||||
private void CloseSurgeryUI(IPlayerSession session)
|
||||
{
|
||||
UserInterface?.Close(session);
|
||||
}
|
||||
|
||||
private void CloseAllSurgeryUIs()
|
||||
{
|
||||
UserInterface?.CloseAll();
|
||||
}
|
||||
|
||||
private void OnUIMessage(ServerBoundUserInterfaceMessage message)
|
||||
{
|
||||
switch (message.Message)
|
||||
{
|
||||
case ReceiveBodyPartSlotSurgeryUIMessage msg:
|
||||
ReceiveBodyPartSlot(msg.SelectedOptionId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Surgery;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Body.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedMechanismComponent))]
|
||||
public class MechanismComponent : SharedMechanismComponent, IAfterInteract
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key);
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (UserInterface != null)
|
||||
{
|
||||
UserInterface.OnReceiveMessage += OnUIMessage;
|
||||
}
|
||||
}
|
||||
|
||||
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs.Target == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CloseAllSurgeryUIs();
|
||||
OptionsCache.Clear();
|
||||
PerformerCache = null;
|
||||
BodyCache = null;
|
||||
|
||||
if (_entities.TryGetComponent(eventArgs.Target.Value, out SharedBodyComponent? body))
|
||||
{
|
||||
SendBodyPartListToUser(eventArgs, body);
|
||||
}
|
||||
else if (_entities.TryGetComponent<SharedBodyPartComponent?>(eventArgs.Target.Value, out var part))
|
||||
{
|
||||
DebugTools.AssertNotNull(part);
|
||||
|
||||
if (!part.TryAddMechanism(this))
|
||||
{
|
||||
eventArgs.Target.Value.PopupMessage(eventArgs.User, Loc.GetString("mechanism-component-cannot-fit-message"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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>();
|
||||
|
||||
foreach (var (part, slot) in body.Parts)
|
||||
{
|
||||
// For each limb in the target, add it to our cache if it is a valid option.
|
||||
if (part.CanAddMechanism(this))
|
||||
{
|
||||
OptionsCache.Add(IdHash, slot);
|
||||
toSend.Add(part + ": " + part.Name, IdHash++);
|
||||
}
|
||||
}
|
||||
|
||||
if (OptionsCache.Count > 0 &&
|
||||
_entities.TryGetComponent(eventArgs.User, out ActorComponent? actor))
|
||||
{
|
||||
OpenSurgeryUI(actor.PlayerSession);
|
||||
UpdateSurgeryUIBodyPartRequest(actor.PlayerSession, toSend);
|
||||
PerformerCache = eventArgs.User;
|
||||
BodyCache = body;
|
||||
}
|
||||
else // If surgery cannot be performed, show message saying so.
|
||||
{
|
||||
eventArgs.Target?.PopupMessage(eventArgs.User,
|
||||
Loc.GetString("mechanism-component-no-way-to-install-message", ("partName", Name: _entities.GetComponent<MetaDataComponent>(Owner).EntityName)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the client chooses from a list of possible BodyParts that can be operated on.
|
||||
/// </summary>
|
||||
private void HandleReceiveBodyPart(int key)
|
||||
{
|
||||
if (PerformerCache == null ||
|
||||
!_entities.TryGetComponent(PerformerCache.Value, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CloseSurgeryUI(actor.PlayerSession);
|
||||
|
||||
if (BodyCache == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: sanity checks to see whether user is in range, user is still able-bodied, target is still the same, etc etc
|
||||
if (!OptionsCache.TryGetValue(key, out var targetObject))
|
||||
{
|
||||
BodyCache.Owner.PopupMessage(PerformerCache.Value,
|
||||
Loc.GetString("mechanism-component-no-useful-way-to-use-message",("partName", Name: _entities.GetComponent<MetaDataComponent>(Owner).EntityName)));
|
||||
return;
|
||||
}
|
||||
|
||||
var target = (SharedBodyPartComponent) targetObject;
|
||||
var message = target.TryAddMechanism(this)
|
||||
? Loc.GetString("mechanism-component-jam-inside-message",("ownerName", Owner),("them", PerformerCache))
|
||||
: Loc.GetString("mechanism-component-cannot-fit-message");
|
||||
|
||||
BodyCache.Owner.PopupMessage(PerformerCache.Value, message);
|
||||
|
||||
// TODO: {1:theName}
|
||||
}
|
||||
|
||||
private void OpenSurgeryUI(IPlayerSession session)
|
||||
{
|
||||
UserInterface?.Open(session);
|
||||
}
|
||||
|
||||
private void UpdateSurgeryUIBodyPartRequest(IPlayerSession session, Dictionary<string, int> options)
|
||||
{
|
||||
UserInterface?.SendMessage(new RequestBodyPartSurgeryUIMessage(options), session);
|
||||
}
|
||||
|
||||
private void CloseSurgeryUI(IPlayerSession session)
|
||||
{
|
||||
UserInterface?.Close(session);
|
||||
}
|
||||
|
||||
private void CloseAllSurgeryUIs()
|
||||
{
|
||||
UserInterface?.CloseAll();
|
||||
}
|
||||
|
||||
private void OnUIMessage(ServerBoundUserInterfaceMessage message)
|
||||
{
|
||||
switch (message.Message)
|
||||
{
|
||||
case ReceiveBodyPartSurgeryUIMessage msg:
|
||||
HandleReceiveBodyPart(msg.SelectedOptionId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,372 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Body.Surgery;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using static Content.Shared.Body.Surgery.ISurgeryData;
|
||||
|
||||
namespace Content.Server.Body.Surgery
|
||||
{
|
||||
/// <summary>
|
||||
/// Data class representing the surgery state of a biological entity.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(ISurgeryData))]
|
||||
public class BiologicalSurgeryDataComponent : Component, ISurgeryData
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "BiologicalSurgeryData";
|
||||
|
||||
private readonly HashSet<SharedMechanismComponent> _disconnectedOrgans = new();
|
||||
|
||||
private bool SkinOpened { get; set; }
|
||||
|
||||
private bool SkinRetracted { get; set; }
|
||||
|
||||
private bool VesselsClamped { get; set; }
|
||||
|
||||
public SharedBodyPartComponent? Parent => _entMan.GetComponentOrNull<SharedBodyPartComponent>(Owner);
|
||||
|
||||
public BodyPartType? ParentType => Parent?.PartType;
|
||||
|
||||
private void AddDisconnectedOrgan(SharedMechanismComponent mechanism)
|
||||
{
|
||||
if (_disconnectedOrgans.Add(mechanism))
|
||||
{
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveDisconnectedOrgan(SharedMechanismComponent mechanism)
|
||||
{
|
||||
if (_disconnectedOrgans.Remove(mechanism))
|
||||
{
|
||||
Dirty();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<bool> SurgeryDoAfter(EntityUid performer)
|
||||
{
|
||||
if (!_entMan.HasComponent<DoAfterComponent>(performer))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var doAfterSystem = EntitySystem.Get<DoAfterSystem>();
|
||||
var target = Parent?.Body?.Owner ?? Owner;
|
||||
var args = new DoAfterEventArgs(performer, 3, target: target)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnTargetMove = true
|
||||
};
|
||||
|
||||
return await doAfterSystem.WaitDoAfter(args) == DoAfterStatus.Finished;
|
||||
}
|
||||
|
||||
private bool HasIncisionNotClamped()
|
||||
{
|
||||
return SkinOpened && !VesselsClamped;
|
||||
}
|
||||
|
||||
private bool HasClampedIncisionNotRetracted()
|
||||
{
|
||||
return SkinOpened && VesselsClamped && !SkinRetracted;
|
||||
}
|
||||
|
||||
private bool HasFullyOpenIncision()
|
||||
{
|
||||
return SkinOpened && VesselsClamped && SkinRetracted;
|
||||
}
|
||||
|
||||
public string GetDescription()
|
||||
{
|
||||
if (Parent == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var toReturn = new StringBuilder();
|
||||
|
||||
if (HasIncisionNotClamped())
|
||||
{
|
||||
toReturn.Append(Loc.GetString("biological-surgery-data-component-has-incision-not-clamped-message",
|
||||
("owner", Owner),("bodyPart", Parent.Name)));
|
||||
}
|
||||
else if (HasClampedIncisionNotRetracted())
|
||||
{
|
||||
toReturn.AppendLine(Loc.GetString("biological-surgery-data-component-has-clamped-incision-not-retracted-message",
|
||||
("owner", Owner),("bodyPary", Parent.Name)));
|
||||
}
|
||||
else if (HasFullyOpenIncision())
|
||||
{
|
||||
toReturn.AppendLine(Loc.GetString("biological-surgery-data-component-has-fully-open-incision-message", ("owner", Owner), ("bodyPart", Parent.Name)) + "\n");
|
||||
foreach (var mechanism in _disconnectedOrgans)
|
||||
{
|
||||
toReturn.AppendLine(Loc.GetString("biological-surgery-data-component-part-is-loose-message",("owner", Owner), ("bodyPart", mechanism.Name)));
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn.ToString();
|
||||
}
|
||||
|
||||
public bool CanAddMechanism(SharedMechanismComponent mechanism)
|
||||
{
|
||||
return Parent != null &&
|
||||
SkinOpened &&
|
||||
VesselsClamped &&
|
||||
SkinRetracted;
|
||||
}
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
public SurgeryAction? GetSurgeryStep(SurgeryType toolType)
|
||||
{
|
||||
if (Parent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (toolType == SurgeryType.Amputation)
|
||||
{
|
||||
return RemoveBodyPartSurgery;
|
||||
}
|
||||
|
||||
if (!SkinOpened)
|
||||
{
|
||||
// Case: skin is normal.
|
||||
if (toolType == SurgeryType.Incision)
|
||||
{
|
||||
return OpenSkinSurgery;
|
||||
}
|
||||
}
|
||||
else if (!VesselsClamped)
|
||||
{
|
||||
// Case: skin is opened, but not clamped.
|
||||
switch (toolType)
|
||||
{
|
||||
case SurgeryType.VesselCompression:
|
||||
return ClampVesselsSurgery;
|
||||
case SurgeryType.Cauterization:
|
||||
return CauterizeIncisionSurgery;
|
||||
}
|
||||
}
|
||||
else if (!SkinRetracted)
|
||||
{
|
||||
// Case: skin is opened and clamped, but not retracted.
|
||||
switch (toolType)
|
||||
{
|
||||
case SurgeryType.Retraction:
|
||||
return RetractSkinSurgery;
|
||||
case SurgeryType.Cauterization:
|
||||
return CauterizeIncisionSurgery;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case: skin is fully open.
|
||||
if (Parent.Mechanisms.Count > 0 &&
|
||||
toolType == SurgeryType.VesselCompression)
|
||||
{
|
||||
if (_disconnectedOrgans.Except(Parent.Mechanisms).Count() != 0 ||
|
||||
Parent.Mechanisms.Except(_disconnectedOrgans).Count() != 0)
|
||||
{
|
||||
return LoosenOrganSurgery;
|
||||
}
|
||||
}
|
||||
|
||||
if (_disconnectedOrgans.Count > 0 && toolType == SurgeryType.Incision)
|
||||
{
|
||||
return RemoveOrganSurgery;
|
||||
}
|
||||
|
||||
if (toolType == SurgeryType.Cauterization)
|
||||
{
|
||||
return CauterizeIncisionSurgery;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool CheckSurgery(SurgeryType toolType)
|
||||
{
|
||||
return GetSurgeryStep(toolType) != null;
|
||||
}
|
||||
|
||||
public bool PerformSurgery(SurgeryType surgeryType, IBodyPartContainer container, ISurgeon surgeon, EntityUid performer)
|
||||
{
|
||||
var step = GetSurgeryStep(surgeryType);
|
||||
|
||||
if (step == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
step(container, surgeon, performer);
|
||||
return true;
|
||||
}
|
||||
|
||||
private async void OpenSkinSurgery(IBodyPartContainer container, ISurgeon surgeon, EntityUid performer)
|
||||
{
|
||||
if (Parent == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
performer.PopupMessage(Loc.GetString("biological-surgery-data-component-open-skin-message"));
|
||||
|
||||
if (await SurgeryDoAfter(performer))
|
||||
{
|
||||
SkinOpened = true;
|
||||
}
|
||||
}
|
||||
|
||||
private async void ClampVesselsSurgery(IBodyPartContainer container, ISurgeon surgeon, EntityUid performer)
|
||||
{
|
||||
if (Parent == null) return;
|
||||
|
||||
performer.PopupMessage(Loc.GetString("biological-surgery-data-component-clamp-vessels-message"));
|
||||
|
||||
if (await SurgeryDoAfter(performer))
|
||||
{
|
||||
VesselsClamped = true;
|
||||
}
|
||||
}
|
||||
|
||||
private async void RetractSkinSurgery(IBodyPartContainer container, ISurgeon surgeon, EntityUid performer)
|
||||
{
|
||||
if (Parent == null) return;
|
||||
|
||||
performer.PopupMessage(Loc.GetString("biological-surgery-data-component-retract-skin-message"));
|
||||
|
||||
if (await SurgeryDoAfter(performer))
|
||||
{
|
||||
SkinRetracted = true;
|
||||
}
|
||||
}
|
||||
|
||||
private async void CauterizeIncisionSurgery(IBodyPartContainer container, ISurgeon surgeon, EntityUid performer)
|
||||
{
|
||||
if (Parent == null) return;
|
||||
|
||||
performer.PopupMessage(Loc.GetString("biological-surgery-data-component-cauterize-incision-message"));
|
||||
|
||||
if (await SurgeryDoAfter(performer))
|
||||
{
|
||||
SkinOpened = false;
|
||||
VesselsClamped = false;
|
||||
SkinRetracted = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoosenOrganSurgery(IBodyPartContainer container, ISurgeon surgeon, EntityUid performer)
|
||||
{
|
||||
if (Parent == null) return;
|
||||
if (Parent.Mechanisms.Count <= 0) return;
|
||||
|
||||
var toSend = new List<SharedMechanismComponent>();
|
||||
foreach (var mechanism in Parent.Mechanisms)
|
||||
{
|
||||
if (!_disconnectedOrgans.Contains(mechanism))
|
||||
{
|
||||
toSend.Add(mechanism);
|
||||
}
|
||||
}
|
||||
|
||||
if (toSend.Count > 0)
|
||||
{
|
||||
surgeon.RequestMechanism(toSend, LoosenOrganSurgeryCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private async void LoosenOrganSurgeryCallback(SharedMechanismComponent? target, IBodyPartContainer container, ISurgeon surgeon,
|
||||
EntityUid performer)
|
||||
{
|
||||
if (Parent == null || target == null || !Parent.Mechanisms.Contains(target))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
performer.PopupMessage(Loc.GetString("biological-surgery-data-component-loosen-organ-message"));
|
||||
|
||||
if (!_entMan.HasComponent<DoAfterComponent>(performer))
|
||||
{
|
||||
AddDisconnectedOrgan(target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (await SurgeryDoAfter(performer))
|
||||
{
|
||||
AddDisconnectedOrgan(target);
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveOrganSurgery(IBodyPartContainer container, ISurgeon surgeon, EntityUid performer)
|
||||
{
|
||||
if (Parent == null) return;
|
||||
|
||||
if (_disconnectedOrgans.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_disconnectedOrgans.Count == 1)
|
||||
{
|
||||
RemoveOrganSurgeryCallback(_disconnectedOrgans.First(), container, surgeon, performer);
|
||||
}
|
||||
else
|
||||
{
|
||||
surgeon.RequestMechanism(_disconnectedOrgans, RemoveOrganSurgeryCallback);
|
||||
}
|
||||
}
|
||||
|
||||
private async void RemoveOrganSurgeryCallback(SharedMechanismComponent? target, IBodyPartContainer container, ISurgeon surgeon,
|
||||
EntityUid performer)
|
||||
{
|
||||
if (Parent == null || target == null || !Parent.Mechanisms.Contains(target))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
performer.PopupMessage(Loc.GetString("biological-surgery-data-component-remove-organ-message"));
|
||||
|
||||
if (!_entMan.HasComponent<DoAfterComponent>(performer))
|
||||
{
|
||||
Parent.RemoveMechanism(target, _entMan.GetComponent<TransformComponent>(performer).Coordinates);
|
||||
RemoveDisconnectedOrgan(target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (await SurgeryDoAfter(performer))
|
||||
{
|
||||
Parent.RemoveMechanism(target, _entMan.GetComponent<TransformComponent>(performer).Coordinates);
|
||||
RemoveDisconnectedOrgan(target);
|
||||
}
|
||||
}
|
||||
|
||||
private async void RemoveBodyPartSurgery(IBodyPartContainer container, ISurgeon surgeon, EntityUid performer)
|
||||
{
|
||||
if (Parent == null) return;
|
||||
if (container is not SharedBodyComponent body) return;
|
||||
|
||||
performer.PopupMessage(Loc.GetString("biological-surgery-data-component-remove-bodypart-message"));
|
||||
|
||||
if (await SurgeryDoAfter(performer))
|
||||
{
|
||||
body.RemovePart(Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Surgery.Messages;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Surgery;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Body.Surgery.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Server-side component representing a generic tool capable of performing surgery.
|
||||
/// For instance, the scalpel.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class SurgeryToolComponent : Component, ISurgeon, IAfterInteract
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entities = default!;
|
||||
|
||||
public override string Name => "SurgeryTool";
|
||||
|
||||
private readonly Dictionary<int, object> _optionsCache = new();
|
||||
|
||||
[DataField("baseOperateTime")]
|
||||
private float _baseOperateTime = 5;
|
||||
|
||||
private ISurgeon.MechanismRequestCallback? _callbackCache;
|
||||
|
||||
private int _idHash;
|
||||
|
||||
[DataField("surgeryType")]
|
||||
private SurgeryType _surgeryType = SurgeryType.Incision;
|
||||
|
||||
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(SurgeryUIKey.Key);
|
||||
|
||||
public SharedBodyComponent? BodyCache { get; private set; }
|
||||
|
||||
public EntityUid? PerformerCache { get; private set; }
|
||||
|
||||
async Task<bool> IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs.Target == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_entities.TryGetComponent(eventArgs.User, out ActorComponent? actor))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CloseAllSurgeryUIs();
|
||||
|
||||
// Attempt surgery on a body by sending a list of operable parts for the client to choose from
|
||||
if (_entities.TryGetComponent(eventArgs.Target.Value, out SharedBodyComponent? body))
|
||||
{
|
||||
// Create dictionary to send to client (text to be shown : data sent back if selected)
|
||||
var toSend = new Dictionary<string, int>();
|
||||
|
||||
foreach (var (part, slot) in body.Parts)
|
||||
{
|
||||
// For each limb in the target, add it to our cache if it is a valid option.
|
||||
if (part.SurgeryCheck(_surgeryType))
|
||||
{
|
||||
_optionsCache.Add(_idHash, part);
|
||||
toSend.Add(slot.Id + ": " + part.Name, _idHash++);
|
||||
}
|
||||
}
|
||||
|
||||
if (_optionsCache.Count > 0)
|
||||
{
|
||||
OpenSurgeryUI(actor.PlayerSession);
|
||||
UpdateSurgeryUIBodyPartRequest(actor.PlayerSession, toSend);
|
||||
PerformerCache = eventArgs.User; // Also, cache the data.
|
||||
BodyCache = body;
|
||||
}
|
||||
else // If surgery cannot be performed, show message saying so.
|
||||
{
|
||||
NotUsefulPopup();
|
||||
}
|
||||
}
|
||||
else if (_entities.TryGetComponent<SharedBodyPartComponent?>(eventArgs.Target.Value, out var part))
|
||||
{
|
||||
// Attempt surgery on a DroppedBodyPart - there's only one possible target so no need for selection UI
|
||||
PerformerCache = eventArgs.User;
|
||||
|
||||
// If surgery can be performed...
|
||||
if (!part.SurgeryCheck(_surgeryType))
|
||||
{
|
||||
NotUsefulPopup();
|
||||
return true;
|
||||
}
|
||||
|
||||
// ...do the surgery.
|
||||
if (part.AttemptSurgery(_surgeryType, part, this,
|
||||
eventArgs.User))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Log error if the surgery fails somehow.
|
||||
Logger.Debug($"Error when trying to perform surgery on ${nameof(SharedBodyPartComponent)} {_entities.GetComponent<MetaDataComponent>(eventArgs.User).EntityName}");
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public float BaseOperationTime { get => _baseOperateTime; set => _baseOperateTime = value; }
|
||||
|
||||
public void RequestMechanism(IEnumerable<SharedMechanismComponent> options, ISurgeon.MechanismRequestCallback callback)
|
||||
{
|
||||
var toSend = new Dictionary<string, int>();
|
||||
foreach (var mechanism in options)
|
||||
{
|
||||
_optionsCache.Add(_idHash, mechanism);
|
||||
toSend.Add(mechanism.Name, _idHash++);
|
||||
}
|
||||
|
||||
if (_optionsCache.Count > 0 && PerformerCache != null)
|
||||
{
|
||||
OpenSurgeryUI(_entities.GetComponent<ActorComponent>(PerformerCache.Value).PlayerSession);
|
||||
UpdateSurgeryUIMechanismRequest(_entities.GetComponent<ActorComponent>(PerformerCache.Value).PlayerSession,
|
||||
toSend);
|
||||
_callbackCache = callback;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Debug("Error on callback from mechanisms: there were no viable options to choose from!");
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
if (UserInterface != null)
|
||||
{
|
||||
UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenSurgeryUI(IPlayerSession session)
|
||||
{
|
||||
UserInterface?.Open(session);
|
||||
|
||||
var message = new SurgeryWindowOpenMessage(this);
|
||||
|
||||
#pragma warning disable 618
|
||||
SendMessage(message);
|
||||
#pragma warning restore 618
|
||||
_entities.EventBus.RaiseEvent(EventSource.Local, message);
|
||||
}
|
||||
|
||||
private void UpdateSurgeryUIBodyPartRequest(IPlayerSession session, Dictionary<string, int> options)
|
||||
{
|
||||
UserInterface?.SendMessage(new RequestBodyPartSurgeryUIMessage(options), session);
|
||||
}
|
||||
|
||||
private void UpdateSurgeryUIMechanismRequest(IPlayerSession session, Dictionary<string, int> options)
|
||||
{
|
||||
UserInterface?.SendMessage(new RequestMechanismSurgeryUIMessage(options), session);
|
||||
}
|
||||
|
||||
private void ClearUIData()
|
||||
{
|
||||
_optionsCache.Clear();
|
||||
|
||||
PerformerCache = null;
|
||||
BodyCache = null;
|
||||
_callbackCache = null;
|
||||
}
|
||||
|
||||
private void CloseSurgeryUI(IPlayerSession session)
|
||||
{
|
||||
UserInterface?.Close(session);
|
||||
ClearUIData();
|
||||
}
|
||||
|
||||
public void CloseAllSurgeryUIs()
|
||||
{
|
||||
UserInterface?.CloseAll();
|
||||
ClearUIData();
|
||||
}
|
||||
|
||||
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
|
||||
{
|
||||
switch (message.Message)
|
||||
{
|
||||
case ReceiveBodyPartSurgeryUIMessage msg:
|
||||
HandleReceiveBodyPart(msg.SelectedOptionId);
|
||||
break;
|
||||
case ReceiveMechanismSurgeryUIMessage msg:
|
||||
HandleReceiveMechanism(msg.SelectedOptionId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the client chooses from a list of possible
|
||||
/// <see cref="SharedBodyPartComponent"/> that can be operated on.
|
||||
/// </summary>
|
||||
private void HandleReceiveBodyPart(int key)
|
||||
{
|
||||
if (PerformerCache == null ||
|
||||
!_entities.TryGetComponent(PerformerCache.Value, out ActorComponent? actor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CloseSurgeryUI(actor.PlayerSession);
|
||||
// TODO: sanity checks to see whether user is in range, user is still able-bodied, target is still the same, etc etc
|
||||
if (!_optionsCache.TryGetValue(key, out var targetObject) ||
|
||||
BodyCache == null)
|
||||
{
|
||||
NotUsefulAnymorePopup();
|
||||
return;
|
||||
}
|
||||
|
||||
var target = (SharedBodyPartComponent) targetObject;
|
||||
|
||||
// TODO BODY Reconsider
|
||||
if (!target.AttemptSurgery(_surgeryType, BodyCache, this, PerformerCache.Value))
|
||||
{
|
||||
NotUsefulAnymorePopup();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called after the client chooses from a list of possible
|
||||
/// <see cref="SharedMechanismComponent"/> to choose from.
|
||||
/// </summary>
|
||||
private void HandleReceiveMechanism(int key)
|
||||
{
|
||||
// TODO: sanity checks to see whether user is in range, user is still able-bodied, target is still the same, etc etc
|
||||
if (BodyCache == null ||
|
||||
!_optionsCache.TryGetValue(key, out var targetObject) ||
|
||||
targetObject is not MechanismComponent target ||
|
||||
PerformerCache == null ||
|
||||
!_entities.TryGetComponent(PerformerCache.Value, out ActorComponent? actor))
|
||||
{
|
||||
NotUsefulAnymorePopup();
|
||||
return;
|
||||
}
|
||||
|
||||
CloseSurgeryUI(actor.PlayerSession);
|
||||
_callbackCache?.Invoke(target, BodyCache, this, PerformerCache.Value);
|
||||
}
|
||||
|
||||
private void NotUsefulPopup()
|
||||
{
|
||||
if (PerformerCache == null) return;
|
||||
|
||||
BodyCache?.Owner.PopupMessage(PerformerCache.Value,
|
||||
Loc.GetString("surgery-tool-component-not-useful-message", ("bodyPart", Owner)));
|
||||
}
|
||||
|
||||
private void NotUsefulAnymorePopup()
|
||||
{
|
||||
if (PerformerCache == null) return;
|
||||
|
||||
BodyCache?.Owner.PopupMessage(PerformerCache.Value,
|
||||
Loc.GetString("surgery-tool-component-not-useful-anymore-message", ("bodyPart", Owner)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Body.Surgery.Messages;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Interaction.Helpers;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Body.Surgery.Components
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class SurgeryToolSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||
|
||||
private readonly HashSet<SurgeryToolComponent> _openSurgeryUIs = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
||||
SubscribeLocalEvent<SurgeryWindowOpenMessage>(OnSurgeryWindowOpen);
|
||||
SubscribeLocalEvent<SurgeryWindowCloseMessage>(OnSurgeryWindowClose);
|
||||
}
|
||||
|
||||
public void Reset(RoundRestartCleanupEvent ev)
|
||||
{
|
||||
_openSurgeryUIs.Clear();
|
||||
}
|
||||
|
||||
private void OnSurgeryWindowOpen(SurgeryWindowOpenMessage ev)
|
||||
{
|
||||
_openSurgeryUIs.Add(ev.Tool);
|
||||
}
|
||||
|
||||
private void OnSurgeryWindowClose(SurgeryWindowCloseMessage ev)
|
||||
{
|
||||
_openSurgeryUIs.Remove(ev.Tool);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
foreach (var tool in _openSurgeryUIs)
|
||||
{
|
||||
if (tool.PerformerCache == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tool.BodyCache == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_actionBlockerSystem.CanInteract(tool.PerformerCache.Value) ||
|
||||
!tool.PerformerCache.Value.InRangeUnobstructed(tool.BodyCache))
|
||||
{
|
||||
tool.CloseAllSurgeryUIs();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Content.Server.Body.Surgery.Components;
|
||||
|
||||
namespace Content.Server.Body.Surgery.Messages
|
||||
{
|
||||
public class SurgeryWindowCloseMessage
|
||||
{
|
||||
public SurgeryWindowCloseMessage(SurgeryToolComponent tool)
|
||||
{
|
||||
Tool = tool;
|
||||
}
|
||||
|
||||
public SurgeryToolComponent Tool { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Content.Server.Body.Surgery.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Body.Surgery.Messages
|
||||
{
|
||||
#pragma warning disable 618
|
||||
public class SurgeryWindowOpenMessage : ComponentMessage
|
||||
#pragma warning restore 618
|
||||
{
|
||||
public SurgeryWindowOpenMessage(SurgeryToolComponent tool)
|
||||
{
|
||||
Tool = tool;
|
||||
}
|
||||
|
||||
public SurgeryToolComponent Tool { get; }
|
||||
}
|
||||
}
|
||||
@@ -41,13 +41,13 @@ namespace Content.Server.Body.Systems
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of ValueTuples of <see cref="T"/> and SharedMechanismComponent on each mechanism
|
||||
/// Returns a list of ValueTuples of <see cref="T"/> and MechanismComponent on each mechanism
|
||||
/// in the given body.
|
||||
/// </summary>
|
||||
/// <param name="uid">The entity to check for the component on.</param>
|
||||
/// <param name="body">The body to check for mechanisms on.</param>
|
||||
/// <typeparam name="T">The component to check for.</typeparam>
|
||||
public IEnumerable<(T Comp, SharedMechanismComponent Mech)> GetComponentsOnMechanisms<T>(EntityUid uid,
|
||||
public IEnumerable<(T Comp, MechanismComponent Mech)> GetComponentsOnMechanisms<T>(EntityUid uid,
|
||||
SharedBodyComponent? body=null) where T : Component
|
||||
{
|
||||
if (!Resolve(uid, ref body))
|
||||
@@ -62,7 +62,7 @@ namespace Content.Server.Body.Systems
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to get a list of ValueTuples of <see cref="T"/> and SharedMechanismComponent on each mechanism
|
||||
/// Tries to get a list of ValueTuples of <see cref="T"/> and MechanismComponent on each mechanism
|
||||
/// in the given body.
|
||||
/// </summary>
|
||||
/// <param name="uid">The entity to check for the component on.</param>
|
||||
@@ -71,7 +71,7 @@ namespace Content.Server.Body.Systems
|
||||
/// <typeparam name="T">The component to check for.</typeparam>
|
||||
/// <returns>Whether any were found.</returns>
|
||||
public bool TryGetComponentsOnMechanisms<T>(EntityUid uid,
|
||||
[NotNullWhen(true)] out IEnumerable<(T Comp, SharedMechanismComponent Mech)>? comps,
|
||||
[NotNullWhen(true)] out IEnumerable<(T Comp, MechanismComponent Mech)>? comps,
|
||||
SharedBodyComponent? body=null) where T: Component
|
||||
{
|
||||
if (!Resolve(uid, ref body))
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Ghost;
|
||||
using Content.Server.Ghost.Components;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Events;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -14,12 +15,12 @@ namespace Content.Server.Body.Systems
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<BrainComponent, AddedToBodyEvent>((uid, component, args) => HandleMind((args.Body).Owner, uid));
|
||||
SubscribeLocalEvent<BrainComponent, AddedToPartEvent>((uid, component, args) => HandleMind((args.Part).Owner, uid));
|
||||
SubscribeLocalEvent<BrainComponent, AddedToPartInBodyEvent>((uid, component, args) => HandleMind((args.Body).Owner, uid));
|
||||
SubscribeLocalEvent<BrainComponent, AddedToBodyEvent>((uid, _, args) => HandleMind((args.Body).Owner, uid));
|
||||
SubscribeLocalEvent<BrainComponent, AddedToPartEvent>((uid, _, args) => HandleMind((args.Part).Owner, uid));
|
||||
SubscribeLocalEvent<BrainComponent, AddedToPartInBodyEvent>((uid, _, args) => HandleMind((args.Body).Owner, uid));
|
||||
SubscribeLocalEvent<BrainComponent, RemovedFromBodyEvent>(OnRemovedFromBody);
|
||||
SubscribeLocalEvent<BrainComponent, RemovedFromPartEvent>((uid, component, args) => HandleMind(uid, (args.Old).Owner));
|
||||
SubscribeLocalEvent<BrainComponent, RemovedFromPartInBodyEvent>((uid, component, args) => HandleMind((args.OldBody).Owner, uid));
|
||||
SubscribeLocalEvent<BrainComponent, RemovedFromPartEvent>((uid, _, args) => HandleMind(uid, (args.Old).Owner));
|
||||
SubscribeLocalEvent<BrainComponent, RemovedFromPartInBodyEvent>((uid, _, args) => HandleMind((args.OldBody).Owner, uid));
|
||||
}
|
||||
|
||||
private void OnRemovedFromBody(EntityUid uid, BrainComponent component, RemovedFromBodyEvent args)
|
||||
@@ -36,8 +37,9 @@ namespace Content.Server.Body.Systems
|
||||
EntityManager.EnsureComponent<MindComponent>(newEntity);
|
||||
var oldMind = EntityManager.EnsureComponent<MindComponent>(oldEntity);
|
||||
|
||||
if (!EntityManager.HasComponent<IGhostOnMove>(newEntity))
|
||||
EntityManager.AddComponent<GhostOnMoveComponent>(newEntity);
|
||||
EnsureComp<GhostOnMoveComponent>(newEntity);
|
||||
if (HasComp<BodyComponent>(newEntity))
|
||||
Comp<GhostOnMoveComponent>(newEntity).MustBeDead = true;
|
||||
|
||||
// TODO: This is an awful solution.
|
||||
if (!EntityManager.HasComponent<IMoverComponent>(newEntity))
|
||||
|
||||
@@ -57,7 +57,7 @@ public class LungSystem : EntitySystem
|
||||
|
||||
public void Gasp(EntityUid uid,
|
||||
LungComponent? lung=null,
|
||||
SharedMechanismComponent? mech=null)
|
||||
MechanismComponent? mech=null)
|
||||
{
|
||||
if (!Resolve(uid, ref lung, ref mech))
|
||||
return;
|
||||
@@ -76,7 +76,7 @@ public class LungSystem : EntitySystem
|
||||
|
||||
public void UpdateLung(EntityUid uid,
|
||||
LungComponent? lung=null,
|
||||
SharedMechanismComponent? mech=null)
|
||||
MechanismComponent? mech=null)
|
||||
{
|
||||
if (!Resolve(uid, ref lung, ref mech))
|
||||
return;
|
||||
@@ -128,7 +128,7 @@ public class LungSystem : EntitySystem
|
||||
/// </summary>
|
||||
public void Inhale(EntityUid uid, float frameTime,
|
||||
LungComponent? lung=null,
|
||||
SharedMechanismComponent? mech=null)
|
||||
MechanismComponent? mech=null)
|
||||
{
|
||||
if (!Resolve(uid, ref lung, ref mech))
|
||||
return;
|
||||
@@ -159,7 +159,7 @@ public class LungSystem : EntitySystem
|
||||
/// </summary>
|
||||
public void TakeGasFrom(EntityUid uid, float frameTime, GasMixture from,
|
||||
LungComponent? lung=null,
|
||||
SharedMechanismComponent? mech=null)
|
||||
MechanismComponent? mech=null)
|
||||
{
|
||||
if (!Resolve(uid, ref lung, ref mech))
|
||||
return;
|
||||
@@ -186,7 +186,7 @@ public class LungSystem : EntitySystem
|
||||
/// </summary>
|
||||
public void Exhale(EntityUid uid, float frameTime,
|
||||
LungComponent? lung=null,
|
||||
SharedMechanismComponent? mech=null)
|
||||
MechanismComponent? mech=null)
|
||||
{
|
||||
if (!Resolve(uid, ref lung, ref mech))
|
||||
return;
|
||||
@@ -204,7 +204,7 @@ public class LungSystem : EntitySystem
|
||||
/// </summary>
|
||||
public void PushGasTo(EntityUid uid, GasMixture to,
|
||||
LungComponent? lung=null,
|
||||
SharedMechanismComponent? mech=null)
|
||||
MechanismComponent? mech=null)
|
||||
{
|
||||
if (!Resolve(uid, ref lung, ref mech))
|
||||
return;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Content.Server.Body.Components;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.Database;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.Chemistry.ReactionEffects;
|
||||
using Content.Server.Destructible.Thresholds.Behaviors;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
@@ -9,11 +9,13 @@ using Robust.Shared.Serialization.Manager.Attributes;
|
||||
namespace Content.Server.Ghost.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IGhostOnMove))]
|
||||
public class GhostOnMoveComponent : Component,IGhostOnMove
|
||||
public class GhostOnMoveComponent : Component
|
||||
{
|
||||
public override string Name => "GhostOnMove";
|
||||
|
||||
[DataField("canReturn")] public bool CanReturn { get; set; } = true;
|
||||
|
||||
[DataField("mustBeDead")]
|
||||
public bool MustBeDead = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ using Content.Server.Visible;
|
||||
using Content.Server.Warps;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Ghost;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Movement.EntitySystems;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -53,6 +54,7 @@ namespace Content.Server.Ghost
|
||||
// Let's not ghost if our mind is visiting...
|
||||
if (EntityManager.HasComponent<VisitingMindComponent>(uid)) return;
|
||||
if (!EntityManager.TryGetComponent<MindComponent>(uid, out var mind) || !mind.HasMind || mind.Mind!.IsVisitingEntity) return;
|
||||
if (component.MustBeDead && TryComp<MobStateComponent>(uid, out var state) && !state.IsDead()) return;
|
||||
|
||||
_ticker.OnGhostAttempt(mind.Mind!, component.CanReturn);
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
namespace Content.Server.Ghost
|
||||
{
|
||||
public interface IGhostOnMove
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Server.Player;
|
||||
using Content.Server.Mind.Commands;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Body.Events;
|
||||
using Content.Shared.Body.Events;
|
||||
using Content.Shared.Body.Part;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -8,16 +7,13 @@ using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.Body.Components
|
||||
{
|
||||
public abstract class SharedMechanismComponent : Component, ISerializationHooks
|
||||
[RegisterComponent]
|
||||
public class MechanismComponent : Component, ISerializationHooks
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
public override string Name => "Mechanism";
|
||||
|
||||
protected readonly Dictionary<int, object> OptionsCache = new();
|
||||
protected SharedBodyComponent? BodyCache;
|
||||
protected int IdHash;
|
||||
protected EntityUid? PerformerCache;
|
||||
private SharedBodyPartComponent? _part;
|
||||
|
||||
public SharedBodyComponent? Body => Part?.Body;
|
||||
@@ -74,13 +70,13 @@ namespace Content.Shared.Body.Components
|
||||
// TODO BODY OnSizeChanged
|
||||
/// <summary>
|
||||
/// Determines whether this
|
||||
/// <see cref="SharedMechanismComponent"/> can fit into a <see cref="SharedBodyPartComponent"/>.
|
||||
/// <see cref="MechanismComponent"/> can fit into a <see cref="SharedBodyPartComponent"/>.
|
||||
/// </summary>
|
||||
[DataField("size")] public int Size { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// What kind of <see cref="SharedBodyPartComponent"/> this
|
||||
/// <see cref="SharedMechanismComponent"/> can be easily installed into.
|
||||
/// <see cref="MechanismComponent"/> can be easily installed into.
|
||||
/// </summary>
|
||||
[DataField("compatibility")]
|
||||
public BodyPartCompatibility Compatibility { get; set; } = BodyPartCompatibility.Universal;
|
||||
@@ -22,7 +22,7 @@ namespace Content.Shared.Body.Components
|
||||
// TODO BODY Damage methods for collections of IDamageableComponents
|
||||
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedBodyComponent : Component, IBodyPartContainer, ISerializationHooks
|
||||
public abstract class SharedBodyComponent : Component, ISerializationHooks
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
@@ -58,9 +58,6 @@ namespace Content.Shared.Body.Components
|
||||
[ViewVariables]
|
||||
public IEnumerable<KeyValuePair<SharedBodyPartComponent, BodyPartSlot>> Parts => SlotParts;
|
||||
|
||||
[ViewVariables]
|
||||
public IEnumerable<BodyPartSlot> EmptySlots => Slots.Where(slot => slot.Part == null);
|
||||
|
||||
public BodyPartSlot? CenterSlot =>
|
||||
Template?.CenterSlot is { } centerSlot
|
||||
? SlotIds.GetValueOrDefault(centerSlot)
|
||||
@@ -223,14 +220,6 @@ namespace Content.Shared.Body.Components
|
||||
slot.SetPart(part);
|
||||
}
|
||||
|
||||
public bool HasPart(string slotId)
|
||||
{
|
||||
DebugTools.AssertNotNull(slotId);
|
||||
|
||||
return SlotIds.TryGetValue(slotId, out var slot) &&
|
||||
slot.Part != null;
|
||||
}
|
||||
|
||||
public bool HasPart(SharedBodyPartComponent part)
|
||||
{
|
||||
DebugTools.AssertNotNull(part);
|
||||
@@ -246,34 +235,6 @@ namespace Content.Shared.Body.Components
|
||||
slot.RemovePart();
|
||||
}
|
||||
|
||||
public bool RemovePart(string slotId)
|
||||
{
|
||||
DebugTools.AssertNotNull(slotId);
|
||||
|
||||
return SlotIds.TryGetValue(slotId, out var slot) &&
|
||||
slot.RemovePart();
|
||||
}
|
||||
|
||||
public bool RemovePart(SharedBodyPartComponent part, [NotNullWhen(true)] out BodyPartSlot? slotId)
|
||||
{
|
||||
DebugTools.AssertNotNull(part);
|
||||
|
||||
if (!SlotParts.TryGetValue(part, out var slot))
|
||||
{
|
||||
slotId = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!slot.RemovePart())
|
||||
{
|
||||
slotId = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
slotId = slot;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TryDropPart(BodyPartSlot slot, [NotNullWhen(true)] out Dictionary<BodyPartSlot, SharedBodyPartComponent>? dropped)
|
||||
{
|
||||
DebugTools.AssertNotNull(slot);
|
||||
@@ -333,86 +294,16 @@ namespace Content.Shared.Body.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool HasSlot(string slot)
|
||||
{
|
||||
return SlotIds.ContainsKey(slot);
|
||||
}
|
||||
|
||||
public IEnumerable<SharedBodyPartComponent> GetParts()
|
||||
{
|
||||
foreach (var slot in SlotIds.Values)
|
||||
{
|
||||
if (slot.Part != null)
|
||||
{
|
||||
yield return slot.Part;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetPart(string slotId, [NotNullWhen(true)] out SharedBodyPartComponent? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
return SlotIds.TryGetValue(slotId, out var slot) &&
|
||||
(result = slot.Part) != null;
|
||||
}
|
||||
|
||||
public BodyPartSlot? GetSlot(string id)
|
||||
{
|
||||
return SlotIds.GetValueOrDefault(id);
|
||||
}
|
||||
|
||||
public BodyPartSlot? GetSlot(SharedBodyPartComponent part)
|
||||
{
|
||||
return SlotParts.GetValueOrDefault(part);
|
||||
}
|
||||
|
||||
public bool TryGetSlot(string slotId, [NotNullWhen(true)] out BodyPartSlot? slot)
|
||||
{
|
||||
return (slot = GetSlot(slotId)) != null;
|
||||
}
|
||||
|
||||
public bool TryGetSlot(SharedBodyPartComponent part, [NotNullWhen(true)] out BodyPartSlot? slot)
|
||||
{
|
||||
return (slot = GetSlot(part)) != null;
|
||||
}
|
||||
|
||||
public bool TryGetPartConnections(string slotId, [NotNullWhen(true)] out List<SharedBodyPartComponent>? connections)
|
||||
{
|
||||
if (!SlotIds.TryGetValue(slotId, out var slot))
|
||||
{
|
||||
connections = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
connections = new List<SharedBodyPartComponent>();
|
||||
foreach (var connection in slot.Connections)
|
||||
{
|
||||
if (connection.Part != null)
|
||||
{
|
||||
connections.Add(connection.Part);
|
||||
}
|
||||
}
|
||||
|
||||
if (connections.Count <= 0)
|
||||
{
|
||||
connections = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool HasSlotOfType(BodyPartType type)
|
||||
{
|
||||
foreach (var _ in GetSlotsOfType(type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public IEnumerable<BodyPartSlot> GetSlotsOfType(BodyPartType type)
|
||||
{
|
||||
foreach (var slot in SlotIds.Values)
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.Body.Events;
|
||||
using Content.Shared.Body.Part;
|
||||
using Content.Shared.Body.Surgery;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -16,7 +15,7 @@ using Robust.Shared.ViewVariables;
|
||||
namespace Content.Shared.Body.Components
|
||||
{
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedBodyPartComponent : Component, IBodyPartContainer
|
||||
public abstract class SharedBodyPartComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
@@ -30,7 +29,7 @@ namespace Content.Shared.Body.Components
|
||||
public IReadOnlyList<string> MechanismIds => _mechanismIds;
|
||||
|
||||
[ViewVariables]
|
||||
private readonly HashSet<SharedMechanismComponent> _mechanisms = new();
|
||||
private readonly HashSet<MechanismComponent> _mechanisms = new();
|
||||
|
||||
[ViewVariables]
|
||||
public SharedBodyComponent? Body
|
||||
@@ -58,12 +57,6 @@ namespace Content.Shared.Body.Components
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The string to show when displaying this part's name to players.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public string DisplayName => Name;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="BodyPartType"/> that this <see cref="IBodyPart"/> is considered
|
||||
/// to be.
|
||||
@@ -91,11 +84,11 @@ namespace Content.Shared.Body.Components
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("compatibility")]
|
||||
public BodyPartCompatibility Compatibility { get; private set; } = BodyPartCompatibility.Universal;
|
||||
public BodyPartCompatibility Compatibility = BodyPartCompatibility.Universal;
|
||||
|
||||
// TODO BODY Mechanisms occupying different parts at the body level
|
||||
[ViewVariables]
|
||||
public IReadOnlyCollection<SharedMechanismComponent> Mechanisms => _mechanisms;
|
||||
public IReadOnlyCollection<MechanismComponent> Mechanisms => _mechanisms;
|
||||
|
||||
// TODO BODY Replace with a simulation of organs
|
||||
/// <summary>
|
||||
@@ -104,16 +97,13 @@ namespace Content.Shared.Body.Components
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("vital")]
|
||||
public bool IsVital { get; private set; } = false;
|
||||
public bool IsVital = false;
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("symmetry")]
|
||||
public BodyPartSymmetry Symmetry { get; private set; } = BodyPartSymmetry.None;
|
||||
public BodyPartSymmetry Symmetry = BodyPartSymmetry.None;
|
||||
|
||||
[ViewVariables]
|
||||
public ISurgeryData? SurgeryDataComponent => _entMan.GetComponentOrNull<ISurgeryData>(Owner);
|
||||
|
||||
protected virtual void OnAddMechanism(SharedMechanismComponent mechanism)
|
||||
protected virtual void OnAddMechanism(MechanismComponent mechanism)
|
||||
{
|
||||
var prototypeId = _entMan.GetComponent<MetaDataComponent>(mechanism.Owner).EntityPrototype!.ID;
|
||||
|
||||
@@ -128,7 +118,7 @@ namespace Content.Shared.Body.Components
|
||||
Dirty();
|
||||
}
|
||||
|
||||
protected virtual void OnRemoveMechanism(SharedMechanismComponent mechanism)
|
||||
protected virtual void OnRemoveMechanism(MechanismComponent mechanism)
|
||||
{
|
||||
_mechanismIds.Remove(_entMan.GetComponent<MetaDataComponent>(mechanism.Owner).EntityPrototype!.ID);
|
||||
mechanism.Part = null;
|
||||
@@ -179,39 +169,13 @@ namespace Content.Shared.Body.Components
|
||||
}
|
||||
}
|
||||
|
||||
public bool SurgeryCheck(SurgeryType surgery)
|
||||
public virtual bool CanAddMechanism(MechanismComponent mechanism)
|
||||
{
|
||||
return SurgeryDataComponent?.CheckSurgery(surgery) ?? false;
|
||||
}
|
||||
|
||||
public bool AttemptSurgery(SurgeryType toolType, IBodyPartContainer target, ISurgeon surgeon, EntityUid performer)
|
||||
{
|
||||
DebugTools.AssertNotNull(toolType);
|
||||
DebugTools.AssertNotNull(target);
|
||||
DebugTools.AssertNotNull(surgeon);
|
||||
DebugTools.AssertNotNull(performer);
|
||||
|
||||
return SurgeryDataComponent?.PerformSurgery(toolType, target, surgeon, performer) ?? false;
|
||||
}
|
||||
|
||||
public bool CanAttachPart(SharedBodyPartComponent part)
|
||||
{
|
||||
DebugTools.AssertNotNull(part);
|
||||
|
||||
return SurgeryDataComponent?.CanAttachBodyPart(part) ?? false;
|
||||
}
|
||||
|
||||
public virtual bool CanAddMechanism(SharedMechanismComponent mechanism)
|
||||
{
|
||||
DebugTools.AssertNotNull(mechanism);
|
||||
|
||||
return SurgeryDataComponent != null &&
|
||||
SizeUsed + mechanism.Size <= Size &&
|
||||
SurgeryDataComponent.CanAddMechanism(mechanism);
|
||||
return SizeUsed + mechanism.Size <= Size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to add a <see cref="SharedMechanismComponent"/> to this part.
|
||||
/// Tries to add a <see cref="MechanismComponent"/> to this part.
|
||||
/// </summary>
|
||||
/// <param name="mechanism">The mechanism to add.</param>
|
||||
/// <param name="force">
|
||||
@@ -220,7 +184,7 @@ namespace Content.Shared.Body.Components
|
||||
/// it was already added before.
|
||||
/// </param>
|
||||
/// <returns>true if added, false otherwise even if it was already added.</returns>
|
||||
public bool TryAddMechanism(SharedMechanismComponent mechanism, bool force = false)
|
||||
public bool TryAddMechanism(MechanismComponent mechanism, bool force = false)
|
||||
{
|
||||
DebugTools.AssertNotNull(mechanism);
|
||||
|
||||
@@ -244,7 +208,7 @@ namespace Content.Shared.Body.Components
|
||||
/// </summary>
|
||||
/// <param name="mechanism">The mechanism to remove.</param>
|
||||
/// <returns>True if it was removed, false otherwise.</returns>
|
||||
public bool RemoveMechanism(SharedMechanismComponent mechanism)
|
||||
public bool RemoveMechanism(MechanismComponent mechanism)
|
||||
{
|
||||
DebugTools.AssertNotNull(mechanism);
|
||||
|
||||
@@ -265,7 +229,7 @@ namespace Content.Shared.Body.Components
|
||||
/// <param name="mechanism">The mechanism to remove.</param>
|
||||
/// <param name="coordinates">The coordinates to drop it at.</param>
|
||||
/// <returns>True if it was removed, false otherwise.</returns>
|
||||
public bool RemoveMechanism(SharedMechanismComponent mechanism, EntityCoordinates coordinates)
|
||||
public bool RemoveMechanism(MechanismComponent mechanism, EntityCoordinates coordinates)
|
||||
{
|
||||
if (RemoveMechanism(mechanism))
|
||||
{
|
||||
@@ -277,7 +241,7 @@ namespace Content.Shared.Body.Components
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to destroy the given <see cref="SharedMechanismComponent"/> from
|
||||
/// Tries to destroy the given <see cref="MechanismComponent"/> from
|
||||
/// this part.
|
||||
/// The mechanism won't be deleted if it is not in this body part.
|
||||
/// </summary>
|
||||
@@ -285,7 +249,7 @@ namespace Content.Shared.Body.Components
|
||||
/// True if the mechanism was in this body part and destroyed,
|
||||
/// false otherwise.
|
||||
/// </returns>
|
||||
public bool DeleteMechanism(SharedMechanismComponent mechanism)
|
||||
public bool DeleteMechanism(MechanismComponent mechanism)
|
||||
{
|
||||
DebugTools.AssertNotNull(mechanism);
|
||||
|
||||
@@ -344,7 +308,7 @@ namespace Content.Shared.Body.Components
|
||||
[Serializable, NetSerializable]
|
||||
public class BodyPartComponentState : ComponentState
|
||||
{
|
||||
[NonSerialized] private List<SharedMechanismComponent>? _mechanisms;
|
||||
[NonSerialized] private List<MechanismComponent>? _mechanisms;
|
||||
|
||||
public readonly EntityUid[] MechanismIds;
|
||||
|
||||
@@ -353,7 +317,7 @@ namespace Content.Shared.Body.Components
|
||||
MechanismIds = mechanismIds;
|
||||
}
|
||||
|
||||
public List<SharedMechanismComponent> Mechanisms(IEntityManager? entityManager = null)
|
||||
public List<MechanismComponent> Mechanisms(IEntityManager? entityManager = null)
|
||||
{
|
||||
if (_mechanisms != null)
|
||||
{
|
||||
@@ -362,7 +326,7 @@ namespace Content.Shared.Body.Components
|
||||
|
||||
IoCManager.Resolve(ref entityManager);
|
||||
|
||||
var mechanisms = new List<SharedMechanismComponent>(MechanismIds.Length);
|
||||
var mechanisms = new List<MechanismComponent>(MechanismIds.Length);
|
||||
|
||||
foreach (var id in MechanismIds)
|
||||
{
|
||||
@@ -371,7 +335,7 @@ namespace Content.Shared.Body.Components
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entityManager.TryGetComponent(id, out SharedMechanismComponent? mechanism))
|
||||
if (!entityManager.TryGetComponent(id, out MechanismComponent? mechanism))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Body.Part
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
namespace Content.Shared.Body.Part
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines a component as being capable of containing parts.
|
||||
/// Used during surgery.
|
||||
/// </summary>
|
||||
// TODO BODY Remove
|
||||
public interface IBodyPartContainer
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.Body.Surgery
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface representing an entity capable of performing surgery,
|
||||
/// such as a circular saw.
|
||||
/// </summary>
|
||||
public interface ISurgeon
|
||||
{
|
||||
public delegate void MechanismRequestCallback(
|
||||
SharedMechanismComponent target,
|
||||
IBodyPartContainer container,
|
||||
ISurgeon surgeon,
|
||||
EntityUid performer);
|
||||
|
||||
/// <summary>
|
||||
/// How long it takes to perform a single surgery step in seconds.
|
||||
/// </summary>
|
||||
public float BaseOperationTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// When performing a surgery, the <see cref="SurgeryDataComponent"/>
|
||||
/// may sometimes require selecting from a set of
|
||||
/// <see cref="SharedMechanismComponent"/>s to operate on.
|
||||
/// This function is called in that scenario, and it is expected that you call
|
||||
/// the callback with one <see cref="SharedMechanismComponent"/> from the provided list.
|
||||
/// </summary>
|
||||
public void RequestMechanism(IEnumerable<SharedMechanismComponent> options, MechanismRequestCallback callback);
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Part;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.Body.Surgery
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the current surgery state of a <see cref="SharedBodyPartComponent"/>.
|
||||
/// </summary>
|
||||
public interface ISurgeryData : IComponent
|
||||
{
|
||||
public delegate void SurgeryAction(IBodyPartContainer container, ISurgeon surgeon, EntityUid performer);
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="SharedBodyPartComponent"/> this
|
||||
/// <see cref="ISurgeryData"/> is attached to.
|
||||
/// </summary>
|
||||
public SharedBodyPartComponent? Parent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="BodyPartType"/> of the parent
|
||||
/// <see cref="SharedBodyPartComponent"/>.
|
||||
/// </summary>
|
||||
public BodyPartType? ParentType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a description of this entity.
|
||||
/// </summary>
|
||||
/// <returns>The description shown upon observing this entity.</returns>
|
||||
public string GetDescription();
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether a <see cref="SharedMechanismComponent"/> can be added into the
|
||||
/// <see cref="SharedBodyPartComponent"/> this <see cref="ISurgeryData"/>
|
||||
/// represents.
|
||||
/// </summary>
|
||||
public bool CanAddMechanism(SharedMechanismComponent mechanism);
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the given <see cref="SharedBodyPartComponent"/> can be connected
|
||||
/// to the <see cref="SharedBodyPartComponent"/> this <see cref="ISurgeryData"/>
|
||||
/// represents.
|
||||
/// </summary>
|
||||
public bool CanAttachBodyPart(SharedBodyPartComponent part);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the delegate corresponding to the surgery step using the given
|
||||
/// <see cref="SurgeryType"/>.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// The corresponding surgery action or null if no step can be
|
||||
/// performed.
|
||||
/// </returns>
|
||||
public SurgeryAction? GetSurgeryStep(SurgeryType toolType);
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the given <see cref="SurgeryType"/> can be used to
|
||||
/// perform a surgery on the <see cref="SharedBodyPartComponent"/> this
|
||||
/// <see cref="ISurgeryData"/> represents.
|
||||
/// </summary>
|
||||
public bool CheckSurgery(SurgeryType toolType)
|
||||
{
|
||||
return GetSurgeryStep(toolType) != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to perform surgery of the given <see cref="SurgeryType"/>.
|
||||
/// </summary>
|
||||
/// <param name="surgeryType">
|
||||
/// The <see cref="SurgeryType"/> used for this surgery.
|
||||
/// </param>
|
||||
/// <param name="container">
|
||||
/// The container where the surgery is being done.
|
||||
/// </param>
|
||||
/// <param name="surgeon">
|
||||
/// The entity being used to perform the surgery.
|
||||
/// </param>
|
||||
/// <param name="performer">The entity performing the surgery.</param>
|
||||
/// <returns>True if successful, false otherwise.</returns>
|
||||
public bool PerformSurgery(SurgeryType surgeryType, IBodyPartContainer container, ISurgeon surgeon,
|
||||
EntityUid performer);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Body.Surgery
|
||||
{
|
||||
/// <summary>
|
||||
/// Types of surgery operations that can be performed.
|
||||
/// </summary>
|
||||
// TODO BODY Move this to YAML?
|
||||
[Serializable, NetSerializable]
|
||||
public enum SurgeryType
|
||||
{
|
||||
None = 0,
|
||||
Incision,
|
||||
Retraction,
|
||||
Cauterization,
|
||||
VesselCompression,
|
||||
Drilling,
|
||||
Amputation
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Body.Surgery
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum SurgeryUIKey
|
||||
{
|
||||
Key
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Body.Surgery
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public class RequestBodyPartSurgeryUIMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public Dictionary<string, int> Targets;
|
||||
|
||||
public RequestBodyPartSurgeryUIMessage(Dictionary<string, int> targets)
|
||||
{
|
||||
Targets = targets;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class RequestMechanismSurgeryUIMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public Dictionary<string, int> Targets;
|
||||
|
||||
public RequestMechanismSurgeryUIMessage(Dictionary<string, int> targets)
|
||||
{
|
||||
Targets = targets;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class RequestBodyPartSlotSurgeryUIMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public Dictionary<string, int> Targets;
|
||||
|
||||
public RequestBodyPartSlotSurgeryUIMessage(Dictionary<string, int> targets)
|
||||
{
|
||||
Targets = targets;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class ReceiveBodyPartSurgeryUIMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int SelectedOptionId;
|
||||
|
||||
public ReceiveBodyPartSurgeryUIMessage(int selectedOptionId)
|
||||
{
|
||||
SelectedOptionId = selectedOptionId;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class ReceiveMechanismSurgeryUIMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int SelectedOptionId;
|
||||
|
||||
public ReceiveMechanismSurgeryUIMessage(int selectedOptionId)
|
||||
{
|
||||
SelectedOptionId = selectedOptionId;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class ReceiveBodyPartSlotSurgeryUIMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int SelectedOptionId;
|
||||
|
||||
public ReceiveBodyPartSlotSurgeryUIMessage(int selectedOptionId)
|
||||
{
|
||||
SelectedOptionId = selectedOptionId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@
|
||||
components:
|
||||
- type: Damageable
|
||||
damageContainer: Biological
|
||||
- type: BiologicalSurgeryData
|
||||
|
||||
# For primates mainly
|
||||
- type: entity
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
- OrganHumanStomach
|
||||
- OrganHumanLiver
|
||||
- OrganHumanKidneys
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 100
|
||||
# deadThreshold: 150
|
||||
|
||||
@@ -55,7 +54,6 @@
|
||||
mechanisms:
|
||||
- OrganHumanBrain
|
||||
- OrganHumanEyes
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 50
|
||||
# deadThreshold: 120
|
||||
- type: Input
|
||||
@@ -80,7 +78,6 @@
|
||||
size: 5
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 40
|
||||
# deadThreshold: 80
|
||||
|
||||
@@ -101,7 +98,6 @@
|
||||
size: 5
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 40
|
||||
# deadThreshold: 80
|
||||
|
||||
@@ -122,7 +118,6 @@
|
||||
size: 3
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -143,7 +138,6 @@
|
||||
size: 3
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -164,7 +158,6 @@
|
||||
size: 6
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 45
|
||||
# deadThreshold: 90
|
||||
|
||||
@@ -185,7 +178,6 @@
|
||||
size: 6
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 45
|
||||
# deadThreshold: 90
|
||||
|
||||
@@ -206,7 +198,6 @@
|
||||
size: 2
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -227,6 +218,5 @@
|
||||
size: 2
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
- OrganHumanStomach
|
||||
- OrganHumanLiver
|
||||
- OrganHumanKidneys
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 100
|
||||
# deadThreshold: 150
|
||||
|
||||
@@ -54,7 +53,6 @@
|
||||
mechanisms:
|
||||
- OrganHumanBrain
|
||||
- OrganHumanEyes
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 50
|
||||
# deadThreshold: 120
|
||||
- type: Input
|
||||
@@ -79,7 +77,6 @@
|
||||
size: 5
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 40
|
||||
# deadThreshold: 80
|
||||
|
||||
@@ -100,7 +97,6 @@
|
||||
size: 5
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 40
|
||||
# deadThreshold: 80
|
||||
|
||||
@@ -121,7 +117,6 @@
|
||||
size: 3
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -142,7 +137,6 @@
|
||||
size: 3
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -163,7 +157,6 @@
|
||||
size: 6
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
|
||||
- type: entity
|
||||
id: RightLegSlime
|
||||
@@ -182,7 +175,6 @@
|
||||
size: 6
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 45
|
||||
# deadThreshold: 90
|
||||
|
||||
@@ -203,7 +195,6 @@
|
||||
size: 2
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -224,6 +215,5 @@
|
||||
size: 2
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
- OrganHumanStomach
|
||||
- OrganHumanLiver
|
||||
- OrganHumanKidneys
|
||||
- type: BiologicalSurgeryData
|
||||
# TODO BODY DettachableDamageableComponent?
|
||||
# criticalThreshold: 100
|
||||
# deadThreshold: 150
|
||||
@@ -56,7 +55,6 @@
|
||||
mechanisms:
|
||||
- OrganHumanBrain
|
||||
- OrganHumanEyes
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 50
|
||||
# deadThreshold: 120
|
||||
- type: Input
|
||||
@@ -81,7 +79,6 @@
|
||||
size: 5
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 40
|
||||
# deadThreshold: 80
|
||||
|
||||
@@ -102,7 +99,6 @@
|
||||
size: 5
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 40
|
||||
# deadThreshold: 80
|
||||
|
||||
@@ -123,7 +119,6 @@
|
||||
size: 3
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -144,7 +139,6 @@
|
||||
size: 3
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -165,7 +159,6 @@
|
||||
size: 6
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 45
|
||||
# deadThreshold: 90
|
||||
|
||||
@@ -186,7 +179,6 @@
|
||||
size: 6
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 45
|
||||
# deadThreshold: 90
|
||||
|
||||
@@ -207,7 +199,6 @@
|
||||
size: 2
|
||||
compatibility: Biological
|
||||
symmetry: Left
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -228,6 +219,5 @@
|
||||
size: 2
|
||||
compatibility: Biological
|
||||
symmetry: Right
|
||||
- type: BiologicalSurgeryData
|
||||
# criticalThreshold: 30
|
||||
# deadThreshold: 60
|
||||
|
||||
@@ -240,7 +240,6 @@
|
||||
- PillCanister
|
||||
components:
|
||||
- Hypospray
|
||||
- SurgeryTool
|
||||
- Radio
|
||||
- type: ItemMapper
|
||||
mapLayers:
|
||||
|
||||
@@ -7,10 +7,6 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.SurgeryUIKey.Key
|
||||
type: SurgeryBoundUserInterface
|
||||
|
||||
# Cautery
|
||||
|
||||
@@ -20,9 +16,6 @@
|
||||
parent: BaseToolSurgery
|
||||
description: A surgical tool used to cauterize open wounds.
|
||||
components:
|
||||
- type: SurgeryTool
|
||||
surgeryType: Cauterization
|
||||
baseOperateTime: 3
|
||||
- type: Sprite
|
||||
sprite: Objects/Specific/Medical/Surgery/cautery.rsi
|
||||
state: cautery
|
||||
@@ -38,10 +31,6 @@
|
||||
parent: BaseToolSurgery
|
||||
description: A surgical drill for making holes into hard material.
|
||||
components:
|
||||
# - type: PowerCellSlot
|
||||
- type: SurgeryTool
|
||||
surgeryType: Drilling
|
||||
baseOperateTime: 3
|
||||
- type: Sprite
|
||||
sprite: Objects/Specific/Medical/Surgery/drill.rsi
|
||||
state: drill
|
||||
@@ -66,9 +55,6 @@
|
||||
- type: Utensil
|
||||
types:
|
||||
- Knife
|
||||
- type: SurgeryTool
|
||||
surgeryType: Incision
|
||||
baseOperateTime: 5
|
||||
- type: Sprite
|
||||
sprite: Objects/Specific/Medical/Surgery/scalpel.rsi
|
||||
state: scalpel
|
||||
@@ -88,9 +74,6 @@
|
||||
parent: Scalpel
|
||||
description: A pointy piece of glass, abraded to an edge and wrapped in tape for a handle. # Could become a decent tool or weapon with right tool mods.
|
||||
components:
|
||||
- type: SurgeryTool
|
||||
surgeryType: Incision
|
||||
baseOperateTime: 8
|
||||
- type: Sprite
|
||||
state: shiv
|
||||
- type: Item
|
||||
@@ -102,9 +85,6 @@
|
||||
parent: Scalpel
|
||||
description: Made of more expensive materials, sharper and generally more reliable.
|
||||
components:
|
||||
- type: SurgeryTool
|
||||
surgeryType: Incision
|
||||
baseOperateTime: 4
|
||||
- type: Sprite
|
||||
state: advanced
|
||||
- type: Item
|
||||
@@ -116,10 +96,6 @@
|
||||
parent: Scalpel
|
||||
description: A scalpel which uses a directed laser to slice instead of a blade, for more precise surgery while also cauterizing as it cuts.
|
||||
components:
|
||||
# - type: PowerCellSlot
|
||||
- type: SurgeryTool
|
||||
surgeryType: Incision
|
||||
baseOperateTime: 2
|
||||
- type: Sprite
|
||||
state: laser
|
||||
- type: Item
|
||||
@@ -133,29 +109,12 @@
|
||||
parent: BaseToolSurgery
|
||||
description: A surgical tool used to hold open incisions.
|
||||
components:
|
||||
- type: SurgeryTool
|
||||
surgeryType: Retraction
|
||||
baseOperateTime: 3
|
||||
- type: Sprite
|
||||
sprite: Objects/Specific/Medical/Surgery/scissors.rsi
|
||||
state: retractor
|
||||
- type: Item
|
||||
sprite: Objects/Specific/Medical/Surgery/scissors.rsi
|
||||
- type: ItemCooldown
|
||||
# Would do this, but inhands don't change. Also doesn't work for SurgeryTool yet.
|
||||
# - type: MultiTool
|
||||
# tools:
|
||||
# - behavior: VesselCompression
|
||||
# state: hemostat
|
||||
# useSound:
|
||||
# path: /Audio/Items/jaws_pry.ogg
|
||||
# changeSound:
|
||||
# path: /Audio/Items/change_jaws.ogg
|
||||
# - behavior: Setting
|
||||
# state: setter
|
||||
# useSound:
|
||||
# changeSound:
|
||||
# path: /Audio/Items/change_jaws.ogg
|
||||
|
||||
- type: entity
|
||||
name: hemostat
|
||||
@@ -163,8 +122,6 @@
|
||||
parent: Retractor
|
||||
description: A surgical tool used to compress blood vessels to prevent bleeding.
|
||||
components:
|
||||
- type: SurgeryTool
|
||||
surgeryType: VesselCompression
|
||||
- type: Sprite
|
||||
state: hemostat
|
||||
- type: Item
|
||||
@@ -176,13 +133,6 @@
|
||||
# parent: Retractor
|
||||
# description: A surgical tool used for setting bones.
|
||||
# components:
|
||||
# - type: SurgeryTool
|
||||
# surgeryType: Setting
|
||||
# - type: Sprite
|
||||
# state: setter
|
||||
# - type: Item
|
||||
# HeldPrefix: setter
|
||||
|
||||
# Saws
|
||||
|
||||
- type: entity
|
||||
@@ -194,9 +144,6 @@
|
||||
- type: Utensil
|
||||
types:
|
||||
- Knife
|
||||
- type: SurgeryTool
|
||||
surgeryType: Amputation
|
||||
baseOperateTime: 6
|
||||
- type: Sprite
|
||||
sprite: Objects/Specific/Medical/Surgery/saw.rsi
|
||||
state: saw
|
||||
@@ -211,9 +158,6 @@
|
||||
parent: Saw
|
||||
description: A wicked serrated blade made of whatever nasty sharp things you could find. # It would make a pretty decent weapon, given there are more space for some tool mods too.
|
||||
components:
|
||||
- type: SurgeryTool
|
||||
surgeryType: Amputation
|
||||
baseOperateTime: 8
|
||||
- type: Sprite
|
||||
state: improv
|
||||
- type: Item
|
||||
@@ -231,10 +175,6 @@
|
||||
parent: Saw
|
||||
description: For heavy duty cutting.
|
||||
components:
|
||||
# - type: PowerCellSlot
|
||||
- type: SurgeryTool
|
||||
surgeryType: Amputation
|
||||
baseOperateTime: 4
|
||||
- type: Sprite
|
||||
state: electric
|
||||
- type: Item
|
||||
@@ -252,10 +192,6 @@
|
||||
parent: Saw
|
||||
description: You think you can cut anything with it.
|
||||
components:
|
||||
# - type: PowerCellSlot
|
||||
- type: SurgeryTool
|
||||
surgeryType: Amputation
|
||||
baseOperateTime: 2
|
||||
- type: Sprite
|
||||
state: advanced
|
||||
- type: Item
|
||||
|
||||
Reference in New Issue
Block a user