Cloning Rework (#8972)

Co-authored-by: fishfish458 <fishfish458>
This commit is contained in:
Rane
2022-08-04 00:05:17 -04:00
committed by GitHub
parent 37f9e825ea
commit 2f4849eae1
41 changed files with 928 additions and 1227 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Content.Shared.Body.Components;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

View File

@@ -1,56 +0,0 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using static Content.Shared.Cloning.SharedCloningPodComponent;
namespace Content.Client.Cloning.UI
{
[UsedImplicitly]
public sealed class CloningPodBoundUserInterface : BoundUserInterface
{
public CloningPodBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
}
private CloningPodWindow? _window;
protected override void Open()
{
base.Open();
_window = new CloningPodWindow(new Dictionary<int, string?>());
_window.OnClose += Close;
_window.CloneButton.OnPressed += _ =>
{
if (_window.SelectedScan != null)
{
SendMessage(new CloningPodUiButtonPressedMessage(UiButton.Clone, (int) _window.SelectedScan));
}
};
_window.EjectButton.OnPressed += _ =>
{
SendMessage(new CloningPodUiButtonPressedMessage(UiButton.Eject, null));
};
_window.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
_window?.Populate((CloningPodBoundUserInterfaceState) state);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_window?.Dispose();
}
}
}
}

View File

@@ -1,254 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
using static Content.Shared.Cloning.SharedCloningPodComponent;
using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Content.Client.Cloning.UI
{
public sealed class CloningPodWindow : DefaultWindow
{
private Dictionary<int, string?> _scanManager;
private readonly BoxContainer _scanList;
public readonly Button CloneButton;
public readonly Button EjectButton;
private CloningScanButton? _selectedButton;
private readonly Label _progressLabel;
private readonly ProgressBar _cloningProgressBar;
private readonly Label _mindState;
private CloningPodBoundUserInterfaceState? _lastUpdate;
public int? SelectedScan;
public CloningPodWindow(Dictionary<int, string?> scanManager)
{
SetSize = MinSize = (250, 300);
_scanManager = scanManager;
Title = Loc.GetString("cloning-pod-window-title");
Contents.AddChild(new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Children =
{
new ScrollContainer
{
MinSize = new Vector2(200.0f, 0.0f),
VerticalExpand = true,
Children =
{
(_scanList = new BoxContainer
{
Orientation = LayoutOrientation.Vertical
})
}
},
new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Children =
{
(CloneButton = new Button
{
Text = Loc.GetString("cloning-pod-clone-button")
})
}
},
(_cloningProgressBar = new ProgressBar
{
MinSize = (200, 20),
MinValue = 0,
MaxValue = 120,
Page = 0,
Value = 0.5f,
Children =
{
(_progressLabel = new Label())
}
}),
(EjectButton = new Button
{
Text = Loc.GetString("cloning-pod-eject-body-button")
}),
new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
Children =
{
new Label()
{
Text = Loc.GetString($"{Loc.GetString("cloning-pod-neural-interface-label")} ")
},
(_mindState = new Label()
{
Text = Loc.GetString("cloning-pod-no-activity-text"),
FontColorOverride = Color.Red
}),
}
}
}
});
BuildCloneList();
}
public void Populate(CloningPodBoundUserInterfaceState state)
{
//Ignore useless updates or we can't interact with the UI
//TODO: come up with a better comparision, probably write a comparator because '.Equals' doesn't work
if (_lastUpdate == null || _lastUpdate.MindIdName.Count != state.MindIdName.Count)
{
_scanManager = state.MindIdName;
BuildCloneList();
}
_lastUpdate = state;
_cloningProgressBar.MaxValue = state.Maximum;
UpdateProgress();
_mindState.Text = Loc.GetString(state.MindPresent ? "cloning-pod-mind-present-text" : "cloning-pod-no-activity-text");
_mindState.FontColorOverride = state.MindPresent ? Color.LimeGreen : Color.Red;
}
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
UpdateProgress();
}
private void UpdateProgress()
{
if (_lastUpdate == null)
return;
float simulatedProgress = _lastUpdate.Progress;
if (_lastUpdate.Progressing)
{
TimeSpan sinceReference = IoCManager.Resolve<IGameTiming>().CurTime - _lastUpdate.ReferenceTime;
simulatedProgress += (float) sinceReference.TotalSeconds;
simulatedProgress = MathHelper.Clamp(simulatedProgress, 0f, _lastUpdate.Maximum);
}
var percentage = simulatedProgress / _cloningProgressBar.MaxValue * 100;
_progressLabel.Text = $"{percentage:0}%";
_cloningProgressBar.Value = simulatedProgress;
}
private void BuildCloneList()
{
_scanList.RemoveAllChildren();
_selectedButton = null;
foreach (var scan in _scanManager)
{
var button = new CloningScanButton
{
Scan = scan.Value ?? string.Empty,
Id = scan.Key
};
button.ActualButton.OnToggled += OnItemButtonToggled;
var entityLabelText = scan.Value;
button.EntityLabel.Text = entityLabelText;
if (scan.Key == SelectedScan)
{
_selectedButton = button;
_selectedButton.ActualButton.Pressed = true;
}
//TODO: replace with body's face
/*var tex = IconComponent.GetScanIcon(scan, resourceCache);
var rect = button.EntityTextureRect;
if (tex != null)
{
rect.Texture = tex.Default;
}
else
{
rect.Dispose();
}
rect.Dispose();
*/
_scanList.AddChild(button);
}
//TODO: set up sort
//_filteredScans.Sort((a, b) => string.Compare(a.ToString(), b.ToString(), StringComparison.Ordinal));
}
private void OnItemButtonToggled(BaseButton.ButtonToggledEventArgs args)
{
var item = (CloningScanButton) args.Button.Parent!;
if (_selectedButton == item)
{
_selectedButton = null;
SelectedScan = null;
return;
}
else if (_selectedButton != null)
{
_selectedButton.ActualButton.Pressed = false;
}
_selectedButton = null;
SelectedScan = null;
_selectedButton = item;
SelectedScan = item.Id;
}
[DebuggerDisplay("cloningbutton {" + nameof(Index) + "}")]
private sealed class CloningScanButton : Control
{
public string Scan { get; set; } = default!;
public int Id { get; set; }
public Button ActualButton { get; private set; }
public Label EntityLabel { get; private set; }
public TextureRect EntityTextureRect { get; private set; }
public int Index { get; set; }
public CloningScanButton()
{
AddChild(ActualButton = new Button
{
HorizontalExpand = true,
VerticalExpand = true,
ToggleMode = true,
});
AddChild(new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
Children =
{
(EntityTextureRect = new TextureRect
{
MinSize = (32, 32),
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
Stretch = TextureRect.StretchMode.KeepAspectCentered,
CanShrink = true
}),
(EntityLabel = new Label
{
VerticalAlignment = VAlignment.Center,
HorizontalExpand = true,
Text = string.Empty,
ClipText = true
})
}
});
}
}
}
}

View File

@@ -0,0 +1,51 @@
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Content.Shared.Cloning.CloningConsole;
namespace Content.Client.CloningConsole.UI
{
[UsedImplicitly]
public sealed class CloningConsoleBoundUserInterface : BoundUserInterface
{
private CloningConsoleWindow? _window;
public CloningConsoleBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new CloningConsoleWindow
{
Title = Loc.GetString("cloning-console-window-title")
};
_window.OnClose += Close;
_window.CloneButton.OnPressed += _ => SendMessage(new UiButtonPressedMessage(UiButton.Clone));
_window.EjectButton.OnPressed += _ => SendMessage(new UiButtonPressedMessage(UiButton.Eject));
_window.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
_window?.Populate((CloningConsoleBoundUserInterfaceState) state);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
if (_window != null)
{
_window.OnClose -= Close;
_window.CloneButton.OnPressed -= _ => SendMessage(new UiButtonPressedMessage(UiButton.Clone));
_window.EjectButton.OnPressed -= _ => SendMessage(new UiButtonPressedMessage(UiButton.Eject));
}
_window?.Dispose();
}
}
}

View File

@@ -0,0 +1,65 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'comp-pda-ui-menu-title'}"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
SetSize="400 400"
MinSize="400 400">
<TabContainer Name="MasterTabContainer">
<BoxContainer Name="Scanner"
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True"
MinSize="100 150">
<PanelContainer VerticalExpand="True" StyleClasses="Inset">
<BoxContainer Name="GeneticScannerContents" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" Text="{Loc 'cloning-console-window-scanner-details-label'}" />
<BoxContainer Orientation="Horizontal" VerticalExpand="True" HorizontalExpand="True">
<RichTextLabel Name="ScannerInfoLabel"
Access="Public"
HorizontalExpand="True" />
<Button Name="CloneButton"
Access="Public"
Text="{Loc 'cloning-console-window-clone-button-text'}"
HorizontalAlignment="Right"
VerticalAlignment="Center" />
</BoxContainer>
<Label Name="CloningActivity"
Text="{Loc 'cloning-console-component-msg-empty'}"
Access="Public"
HorizontalAlignment="Center"
HorizontalExpand="True" />
</BoxContainer>
<BoxContainer Name="GeneticScannerMissing" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'cloning-console-window-no-scanner-detected-label'}" />
</BoxContainer>
<BoxContainer Name="GeneticScannerFar" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'cloning-console-window-scanner-far-label'}" />
</BoxContainer>
</PanelContainer>
<Control MinSize="50 5" />
<PanelContainer VerticalExpand="True" StyleClasses="Inset">
<BoxContainer Name="CloningPodContents" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" Text="{Loc 'cloning-console-window-pod-details-label'}" />
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<RichTextLabel Name="ClonerInfoLabel"
Access="Public"
HorizontalExpand="True" />
<RichTextLabel Name="ClonerBrainActivity"
Access="Public"
HorizontalExpand="True"/>
<Button Name="EjectButton"
Access="Public"
Text="{Loc 'cloning-console-eject-body-button'}"
HorizontalAlignment="Right"
VerticalAlignment="Center" />
</BoxContainer>
</BoxContainer>
<BoxContainer Name="CloningPodMissing" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'cloning-console-window-no-clone-pod-detected-label'}" />
</BoxContainer>
<BoxContainer Name="CloningPodFar" Margin="5 5 5 5" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'cloning-console-window-clone-pod-far-label'}" />
</BoxContainer>
</PanelContainer>
</BoxContainer>
</TabContainer>
</DefaultWindow>

View File

@@ -0,0 +1,113 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Content.Client.Message;
using Robust.Shared.Timing;
using Content.Shared.Cloning.CloningConsole;
namespace Content.Client.CloningConsole.UI
{
[GenerateTypedNameReferences]
public partial class CloningConsoleWindow : DefaultWindow
{
[Dependency] private readonly IGameTiming _timing = default!;
public CloningConsoleWindow()
{
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
}
private CloningConsoleBoundUserInterfaceState? _lastUpdate;
protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
}
public void Populate(CloningConsoleBoundUserInterfaceState state)
{
_lastUpdate = state;
// BUILD SCANNER UI
if (state.ScannerConnected)
{
if (!state.ScannerInRange)
{
GeneticScannerFar.Visible = true;
GeneticScannerContents.Visible = false;
GeneticScannerMissing.Visible = false;
return;
}
GeneticScannerContents.Visible = true;
GeneticScannerFar.Visible = false;
GeneticScannerMissing.Visible = false;
CloneButton.Disabled = state.CloningStatus != ClonerStatus.Ready;
switch (state.CloningStatus)
{
case ClonerStatus.NoClonerDetected:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-no-cloner"));
break;
case ClonerStatus.Ready:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-ready"));
break;
case ClonerStatus.ClonerOccupied:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-occupied"));
break;
case ClonerStatus.ScannerEmpty:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-empty"));
break;
case ClonerStatus.ScannerOccupantAlive:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-scanner-occupant-alive"));
break;
case ClonerStatus.OccupantMetaphyiscal:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-already-alive"));
break;
case ClonerStatus.NoMindDetected:
CloningActivity.Text = (Loc.GetString("cloning-console-component-msg-no-mind"));
break;
}
// Set label depending on if scanner is occupied or not.
ScannerInfoLabel.SetMarkup(state.ScannerBodyInfo != null ?
Loc.GetString("cloning-console-window-scanner-id", ("scannerOccupantName", state.ScannerBodyInfo)) :
Loc.GetString("cloning-console-window-id-blank"));
}
else
{
// Scanner is missing, set error message visible
GeneticScannerContents.Visible = false;
GeneticScannerFar.Visible = false;
GeneticScannerMissing.Visible = true;
}
// BUILD ClONER UI
if (state.ClonerConnected)
{
if (!state.ClonerInRange)
{
CloningPodFar.Visible = true;
CloningPodContents.Visible = false;
CloningPodMissing.Visible = false;
return;
}
CloningPodContents.Visible = true;
CloningPodFar.Visible = false;
CloningPodMissing.Visible = false;
ClonerBrainActivity.SetMarkup(Loc.GetString(state.MindPresent ? "cloning-console-mind-present-text" : "cloning-console-no-mind-activity-text"));
// Set label depending if clonepod is occupied or not
ClonerInfoLabel.SetMarkup(state.ClonerBodyInfo != null ?
Loc.GetString("cloning-console-window-pod-id", ("podOccupantName", state.ClonerBodyInfo)) :
Loc.GetString("cloning-console-window-id-blank"));
}
else
{
// Clone pod is missing, set error message visible
CloningPodContents.Visible = false;
CloningPodFar.Visible = false;
CloningPodMissing.Visible = true;
}
}
}
}

View File

@@ -1,51 +0,0 @@
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
namespace Content.Client.MedicalScanner.UI
{
[UsedImplicitly]
public sealed class MedicalScannerBoundUserInterface : BoundUserInterface
{
private MedicalScannerWindow? _window;
public MedicalScannerBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
{
}
protected override void Open()
{
base.Open();
_window = new MedicalScannerWindow
{
Title = IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(Owner.Owner).EntityName,
};
_window.OnClose += Close;
_window.ScanButton.OnPressed += _ => SendMessage(new ScanButtonPressedMessage());
_window.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not MedicalScannerBoundUserInterfaceState cast)
return;
_window?.Populate(cast);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
if (_window != null)
_window.OnClose -= Close;
_window?.Dispose();
}
}
}

View File

@@ -1,11 +0,0 @@
<DefaultWindow xmlns="https://spacestation14.io"
MinSize="200 100"
SetSize="200 100">
<BoxContainer Orientation="Vertical">
<Label Name="OccupantName"/>
<Button Name="ScanButton"
Disabled="True"
Access="Public"
Text="{Loc 'medical-scanner-window-save-button-text'}" />
</BoxContainer>
</DefaultWindow>

View File

@@ -1,22 +0,0 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
namespace Content.Client.MedicalScanner.UI
{
[GenerateTypedNameReferences]
public sealed partial class MedicalScannerWindow : DefaultWindow
{
public MedicalScannerWindow()
{
RobustXamlLoader.Load(this);
}
public void Populate(MedicalScannerBoundUserInterfaceState state)
{
ScanButton.Disabled = !state.IsScannable;
}
}
}

View File

@@ -1,35 +0,0 @@
using System.Threading;
using Content.Server.Cloning;
using Content.Shared.Actions.ActionTypes;
namespace Content.Server.Body.Components
{
[RegisterComponent]
public sealed class BodyReassembleComponent : Component
{
/// <summary>
/// The dna entry used for reassembling the skeleton
/// updated before the entity is gibbed.
/// </summary>
[ViewVariables]
public ClonerDNAEntry? DNA = null;
/// <summary>
/// The default time it takes to reassemble itself
/// </summary>
[ViewVariables]
[DataField("delay")]
public float DoAfterTime = 5f;
/// <summary>
/// The list of body parts that are needed for reassembly
/// </summary>
[ViewVariables]
public HashSet<EntityUid>? BodyParts = null;
[DataField("action")]
public InstantAction? ReassembleAction = null;
public CancellationTokenSource? CancelToken = null;
}
}

View File

@@ -1,229 +0,0 @@
using Content.Server.Body.Components;
using Content.Server.Cloning;
using Content.Server.DoAfter;
using Content.Server.Mind.Components;
using Content.Server.Popups;
using Content.Server.Preferences.Managers;
using Content.Shared.Actions;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.IdentityManagement;
using Content.Shared.Preferences;
using Content.Shared.Species;
using Content.Shared.Verbs;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using System.Threading;
/// <remarks>
/// Fair warning, this is all kinda shitcode, but it'll have to wait for a major
/// refactor until proper body systems get added. The current implementation is
/// definitely not ideal and probably will be prone to weird bugs.
/// </remarks>
namespace Content.Server.Body.Systems
{
public sealed class BodyReassembleSystem : EntitySystem
{
[Dependency] private readonly IServerPreferencesManager _prefsManager = null!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly SharedHumanoidAppearanceSystem _humanoidAppearance = default!;
private const float SelfReassembleMultiplier = 2f;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BodyReassembleComponent, PartGibbedEvent>(OnPartGibbed);
SubscribeLocalEvent<BodyReassembleComponent, ReassembleActionEvent>(StartReassemblyAction);
SubscribeLocalEvent<BodyReassembleComponent, GetVerbsEvent<AlternativeVerb>>(AddReassembleVerbs);
SubscribeLocalEvent<BodyReassembleComponent, ReassembleCompleteEvent>(ReassembleComplete);
SubscribeLocalEvent<BodyReassembleComponent, ReassembleCancelledEvent>(ReassembleCancelled);
}
private void StartReassemblyAction(EntityUid uid, BodyReassembleComponent component, ReassembleActionEvent args)
{
args.Handled = true;
StartReassembly(uid, component, SelfReassembleMultiplier);
}
private void ReassembleCancelled(EntityUid uid, BodyReassembleComponent component, ReassembleCancelledEvent args)
{
component.CancelToken = null;
}
private void OnPartGibbed(EntityUid uid, BodyReassembleComponent component, PartGibbedEvent args)
{
if (!TryComp<MindComponent>(args.EntityToGib, out var mindComp) || mindComp?.Mind == null)
return;
component.BodyParts = args.GibbedParts;
UpdateDNAEntry(uid, args.EntityToGib);
mindComp.Mind.TransferTo(uid);
if (component.ReassembleAction == null)
return;
_actions.AddAction(uid, component.ReassembleAction, null);
}
private void StartReassembly(EntityUid uid, BodyReassembleComponent component, float multiplier = 1f)
{
if (component.CancelToken != null)
return;
if (!GetNearbyParts(uid, component, out var partList))
return;
if (partList == null)
return;
var doAfterTime = component.DoAfterTime * multiplier;
var cancelToken = new CancellationTokenSource();
component.CancelToken = cancelToken;
var doAfterEventArgs = new DoAfterEventArgs(component.Owner, doAfterTime, cancelToken.Token, component.Owner)
{
BreakOnTargetMove = true,
BreakOnUserMove = true,
BreakOnDamage = true,
BreakOnStun = true,
NeedHand = false,
TargetCancelledEvent = new ReassembleCancelledEvent(),
TargetFinishedEvent = new ReassembleCompleteEvent(uid, uid, partList),
};
_doAfterSystem.DoAfter(doAfterEventArgs);
}
/// <summary>
/// Adds the custom verb for reassembling body parts
/// </summary>
private void AddReassembleVerbs(EntityUid uid, BodyReassembleComponent component, GetVerbsEvent<AlternativeVerb> args)
{
if (!args.CanAccess || !args.CanInteract)
return;
if (!TryComp<MindComponent>(uid, out var mind) ||
!mind.HasMind ||
component.CancelToken != null)
return;
// doubles the time if you reconstruct yourself
var multiplier = args.User == uid ? SelfReassembleMultiplier : 1f;
// Custom verb
AlternativeVerb custom = new()
{
Text = Loc.GetString("reassemble-action"),
Act = () =>
{
StartReassembly(uid, component, multiplier);
},
IconEntity = uid,
Priority = 1
};
args.Verbs.Add(custom);
}
private bool GetNearbyParts(EntityUid uid, BodyReassembleComponent component, out HashSet<EntityUid>? partList)
{
partList = new HashSet<EntityUid>();
if (component.BodyParts == null)
return false;
// Ensures all of the old body part pieces are there
var xformQuery = GetEntityQuery<TransformComponent>();
var bodyXform = xformQuery.GetComponent(uid);
foreach (var part in component.BodyParts)
{
if (!xformQuery.TryGetComponent(part, out var xform) ||
!bodyXform.Coordinates.InRange(EntityManager, xform.Coordinates,2f))
{
_popupSystem.PopupEntity(Loc.GetString("reassemble-fail"), uid, Filter.Entities(uid));
return false;
}
partList.Add(part);
}
return true;
}
private void ReassembleComplete(EntityUid uid, BodyReassembleComponent component, ReassembleCompleteEvent args)
{
component.CancelToken = null;
if (component.DNA == null || component.BodyParts == null)
return;
// Creates the new entity and transfers the mind component
var speciesProto = _prototype.Index<SpeciesPrototype>(component.DNA.Value.Profile.Species).Prototype;
var mob = EntityManager.SpawnEntity(speciesProto, EntityManager.GetComponent<TransformComponent>(component.Owner).MapPosition);
_humanoidAppearance.UpdateFromProfile(mob, component.DNA.Value.Profile);
MetaData(mob).EntityName = component.DNA.Value.Profile.Name;
if (TryComp<MindComponent>(uid, out var mindcomp) && mindcomp.Mind != null)
mindcomp.Mind.TransferTo(mob);
// Cleans up all the body part pieces
foreach (var entity in component.BodyParts)
{
EntityManager.DeleteEntity(entity);
}
_popupSystem.PopupEntity(Loc.GetString("reassemble-success", ("user", Identity.Entity(mob, EntityManager))), mob, Filter.Entities(mob));
}
/// <summary>
/// Called before the skeleton entity is gibbed in order to save
/// the dna for reassembly later
/// </summary>
/// <param name="uid"> the entity that the player will transfer to</param>
/// <param name="body"> the entity whose DNA is being saved</param>
private void UpdateDNAEntry(EntityUid uid, EntityUid body)
{
if (!TryComp<BodyReassembleComponent>(uid, out var skelBodyComp) || !TryComp<MindComponent>(body, out var mindcomp))
return;
if (mindcomp.Mind == null)
return;
if (mindcomp.Mind.UserId == null)
return;
var profile = (HumanoidCharacterProfile) _prefsManager.GetPreferences(mindcomp.Mind.UserId.Value).SelectedCharacter;
skelBodyComp.DNA = new ClonerDNAEntry(mindcomp.Mind, profile);
}
private sealed class ReassembleCompleteEvent : EntityEventArgs
{
/// <summary>
/// The entity being reassembled
/// </summary>
public readonly EntityUid Uid;
/// <summary>
/// The user performing the reassembly
/// </summary>
public readonly EntityUid User;
public readonly HashSet<EntityUid> PartList;
public ReassembleCompleteEvent(EntityUid uid, EntityUid user, HashSet<EntityUid> partList)
{
Uid = uid;
User = user;
PartList = partList;
}
}
private sealed class ReassembleCancelledEvent : EntityEventArgs {}
}
}
public sealed class ReassembleActionEvent : InstantActionEvent { }

View File

@@ -1,16 +1,19 @@
using Content.Server.EUI;
using Content.Shared.Cloning;
using Content.Shared.Eui;
using Content.Server.Cloning.Systems;
namespace Content.Server.Cloning
{
public sealed class AcceptCloningEui : BaseEui
{
private readonly CloningSystem _cloningSystem;
private readonly Mind.Mind _mind;
public AcceptCloningEui(Mind.Mind mind)
public AcceptCloningEui(Mind.Mind mind, CloningSystem cloningSys)
{
_mind = mind;
_cloningSystem = cloningSys;
}
public override void HandleMessage(EuiMessageBase msg)
@@ -18,14 +21,13 @@ namespace Content.Server.Cloning
base.HandleMessage(msg);
if (msg is not AcceptCloningChoiceMessage choice ||
choice.Button == AcceptCloningUiButton.Deny ||
!EntitySystem.TryGet<CloningSystem>(out var cloningSystem))
choice.Button == AcceptCloningUiButton.Deny)
{
Close();
return;
}
cloningSystem.TransferMindToClone(_mind);
_cloningSystem.TransferMindToClone(_mind);
Close();
}
}

View File

@@ -0,0 +1,249 @@
using JetBrains.Annotations;
using Robust.Shared.Timing;
using Content.Server.Medical.Components;
using Content.Server.Cloning.Components;
using Content.Server.Power.Components;
using Content.Server.Mind.Components;
using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.UserInterface;
using Content.Shared.MobState.Components;
using Content.Server.MobState;
using Content.Server.Power.EntitySystems;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Content.Shared.Cloning.CloningConsole;
using Content.Shared.Cloning;
using Content.Shared.MachineLinking.Events;
using Content.Shared.IdentityManagement;
namespace Content.Server.Cloning.Systems
{
[UsedImplicitly]
public sealed class CloningConsoleSystem : EntitySystem
{
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly CloningSystem _cloningSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CloningConsoleComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<CloningConsoleComponent, UiButtonPressedMessage>(OnButtonPressed);
SubscribeLocalEvent<CloningConsoleComponent, AfterActivatableUIOpenEvent>(OnUIOpen);
SubscribeLocalEvent<CloningConsoleComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<CloningConsoleComponent, NewLinkEvent>(OnNewLink);
SubscribeLocalEvent<CloningConsoleComponent, PortDisconnectedEvent>(OnPortDisconnected);
SubscribeLocalEvent<CloningConsoleComponent, AnchorStateChangedEvent>(OnAnchorChanged);
}
private void OnInit(EntityUid uid, CloningConsoleComponent component, ComponentInit args)
{
_signalSystem.EnsureTransmitterPorts(uid, CloningConsoleComponent.ScannerPort, CloningConsoleComponent.PodPort);
}
private void OnButtonPressed(EntityUid uid, CloningConsoleComponent consoleComponent, UiButtonPressedMessage args)
{
if (!_powerReceiverSystem.IsPowered(uid))
return;
switch (args.Button)
{
case UiButton.Clone:
if (consoleComponent.GeneticScanner != null && consoleComponent.CloningPod != null)
TryClone(uid, consoleComponent.CloningPod.Value, consoleComponent.GeneticScanner.Value, consoleComponent: consoleComponent);
break;
case UiButton.Eject:
if (consoleComponent.CloningPod != null)
TryEject(uid, consoleComponent.CloningPod.Value, consoleComponent: consoleComponent);
break;
}
UpdateUserInterface(consoleComponent);
}
private void OnPowerChanged(EntityUid uid, CloningConsoleComponent component, PowerChangedEvent args)
{
UpdateUserInterface(component);
}
private void OnNewLink(EntityUid uid, CloningConsoleComponent component, NewLinkEvent args)
{
if (TryComp<MedicalScannerComponent>(args.Receiver, out var scanner) && args.TransmitterPort == CloningConsoleComponent.ScannerPort)
{
component.GeneticScanner = args.Receiver;
scanner.ConnectedConsole = uid;
}
if (TryComp<CloningPodComponent>(args.Receiver, out var pod) && args.TransmitterPort == CloningConsoleComponent.PodPort)
{
component.CloningPod = args.Receiver;
pod.ConnectedConsole = uid;
}
RecheckConnections(uid, component.CloningPod, component.GeneticScanner, component);
}
private void OnPortDisconnected(EntityUid uid, CloningConsoleComponent component, PortDisconnectedEvent args)
{
if (args.Port == CloningConsoleComponent.ScannerPort)
component.GeneticScanner = null;
if (args.Port == CloningConsoleComponent.PodPort)
component.CloningPod = null;
UpdateUserInterface(component);
}
private void OnUIOpen(EntityUid uid, CloningConsoleComponent component, AfterActivatableUIOpenEvent args)
{
UpdateUserInterface(component);
}
private void OnAnchorChanged(EntityUid uid, CloningConsoleComponent component, ref AnchorStateChangedEvent args)
{
if (args.Anchored)
{
RecheckConnections(uid, component.CloningPod, component.GeneticScanner, component);
return;
}
UpdateUserInterface(component);
}
public void UpdateUserInterface(CloningConsoleComponent consoleComponent)
{
if (!_powerReceiverSystem.IsPowered(consoleComponent.Owner))
{
_uiSystem.GetUiOrNull(consoleComponent.Owner, CloningConsoleUiKey.Key)?.CloseAll();
return;
}
var newState = GetUserInterfaceState(consoleComponent);
_uiSystem.GetUiOrNull(consoleComponent.Owner, CloningConsoleUiKey.Key)?.SetState(newState);
}
public void TryEject(EntityUid uid, EntityUid clonePodUid, CloningPodComponent? cloningPod = null, CloningConsoleComponent? consoleComponent = null)
{
if (!Resolve(uid, ref consoleComponent) || !Resolve(clonePodUid, ref cloningPod))
return;
_cloningSystem.Eject(clonePodUid, cloningPod);
}
public void TryClone(EntityUid uid, EntityUid cloningPodUid, EntityUid scannerUid, CloningPodComponent? cloningPod = null, MedicalScannerComponent? scannerComp = null, CloningConsoleComponent? consoleComponent = null)
{
if (!Resolve(uid, ref consoleComponent) || !Resolve(cloningPodUid, ref cloningPod) || !Resolve(scannerUid, ref scannerComp))
return;
if (!Transform(cloningPodUid).Anchored || !Transform(scannerUid).Anchored)
return;
if (!consoleComponent.CloningPodInRange || !consoleComponent.GeneticScannerInRange)
return;
if (scannerComp.BodyContainer.ContainedEntity is null)
return;
if (!TryComp<MindComponent>(scannerComp.BodyContainer.ContainedEntity.Value, out var mindComp))
return;
var mind = mindComp.Mind;
if (mind == null || mind.UserId.HasValue == false || mind.Session == null)
return;
bool cloningSuccessful = _cloningSystem.TryCloning(cloningPodUid, scannerComp.BodyContainer.ContainedEntity.Value, mind, cloningPod);
}
public void RecheckConnections(EntityUid console, EntityUid? cloningPod, EntityUid? scanner, CloningConsoleComponent? consoleComp = null)
{
if (!Resolve(console, ref consoleComp))
return;
if (scanner != null)
{
Transform(scanner.Value).Coordinates.TryDistance(EntityManager, Transform((console)).Coordinates, out float scannerDistance);
consoleComp.GeneticScannerInRange = scannerDistance <= consoleComp.MaxDistance;
}
if (cloningPod != null)
{
Transform(cloningPod.Value).Coordinates.TryDistance(EntityManager, Transform((console)).Coordinates, out float podDistance);
consoleComp.CloningPodInRange = podDistance <= consoleComp.MaxDistance;
}
UpdateUserInterface(consoleComp);
}
private CloningConsoleBoundUserInterfaceState GetUserInterfaceState(CloningConsoleComponent consoleComponent)
{
ClonerStatus clonerStatus = ClonerStatus.Ready;
// genetic scanner info
string scanBodyInfo = Loc.GetString("generic-unknown");
bool scannerConnected = false;
bool scannerInRange = consoleComponent.GeneticScannerInRange;
if (consoleComponent.GeneticScanner != null && TryComp<MedicalScannerComponent>(consoleComponent.GeneticScanner, out var scanner)) {
scannerConnected = true;
EntityUid? scanBody = scanner.BodyContainer.ContainedEntity;
// GET STATE
if (scanBody == null || !HasComp<MobStateComponent>(scanBody))
clonerStatus = ClonerStatus.ScannerEmpty;
else
{
scanBodyInfo = MetaData(scanBody.Value).EntityName;
TryComp<MindComponent>(scanBody, out var mindComp);
if (!_mobStateSystem.IsDead(scanBody.Value))
{
clonerStatus = ClonerStatus.ScannerOccupantAlive;
}
else
{
if (mindComp == null || mindComp.Mind == null || mindComp.Mind.UserId == null || !_playerManager.TryGetSessionById(mindComp.Mind.UserId.Value, out var client))
{
clonerStatus = ClonerStatus.NoMindDetected;
}
}
}
}
// cloning pod info
var cloneBodyInfo = Loc.GetString("generic-unknown");
bool clonerConnected = false;
bool clonerMindPresent = false;
bool clonerInRange = consoleComponent.CloningPodInRange;
if (consoleComponent.CloningPod != null && TryComp<CloningPodComponent>(consoleComponent.CloningPod, out var clonePod)
&& Transform(consoleComponent.CloningPod.Value).Anchored)
{
clonerConnected = true;
EntityUid? cloneBody = clonePod.BodyContainer.ContainedEntity;
clonerMindPresent = clonePod.Status == CloningPodStatus.Cloning;
if (cloneBody != null)
{
cloneBodyInfo = Identity.Name(cloneBody.Value, EntityManager);
clonerStatus = ClonerStatus.ClonerOccupied;
}
}
else
{
clonerStatus = ClonerStatus.NoClonerDetected;
}
return new CloningConsoleBoundUserInterfaceState(
scanBodyInfo,
cloneBodyInfo,
clonerMindPresent,
clonerStatus,
scannerConnected,
scannerInRange,
clonerConnected,
clonerInRange
);
}
}
}

View File

@@ -1,36 +1,63 @@
using System.Linq;
using Content.Server.Cloning.Components;
using Content.Server.Mind.Components;
using Content.Server.Power.Components;
using Content.Shared.Audio;
using Content.Server.Power.EntitySystems;
using Content.Shared.GameTicking;
using Content.Shared.Preferences;
using Robust.Shared.Timing;
using static Content.Shared.Cloning.SharedCloningPodComponent;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.Species;
using Robust.Server.Player;
using Robust.Shared.Prototypes;
using Content.Server.EUI;
using Robust.Shared.Containers;
using Robust.Server.Containers;
using Content.Shared.Cloning;
using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.MobState;
namespace Content.Server.Cloning
namespace Content.Server.Cloning.Systems
{
internal sealed class CloningSystem : EntitySystem
public sealed class CloningSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;
public readonly Dictionary<Mind.Mind, int> MindToId = new();
public readonly Dictionary<int, ClonerDNAEntry> IdToDNA = new();
private int _nextAllocatedMindId = 0;
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
[Dependency] private readonly IPlayerManager _playerManager = null!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly EuiManager _euiManager = null!;
[Dependency] private readonly CloningConsoleSystem _cloningConsoleSystem = default!;
[Dependency] private readonly SharedHumanoidAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly PowerReceiverSystem _powerReceiverSystem = default!;
public readonly Dictionary<Mind.Mind, EntityUid> ClonesWaitingForMind = new();
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CloningPodComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<BeingClonedComponent, MindAddedMessage>(HandleMindAdded);
SubscribeLocalEvent<CloningPodComponent, PortDisconnectedEvent>(OnPortDisconnected);
SubscribeLocalEvent<CloningPodComponent, AnchorStateChangedEvent>(OnAnchor);
}
private void OnComponentInit(EntityUid uid, CloningPodComponent clonePod, ComponentInit args)
{
clonePod.BodyContainer = _containerSystem.EnsureContainer<ContainerSlot>(clonePod.Owner, $"{Name}-bodyContainer");
_signalSystem.EnsureReceiverPorts(uid, CloningPodComponent.PodPort);
}
private void UpdateAppearance(CloningPodComponent clonePod)
{
if (TryComp<AppearanceComponent>(clonePod.Owner, out var appearance))
appearance.SetData(CloningPodVisuals.Status, clonePod.Status);
}
internal void TransferMindToClone(Mind.Mind mind)
{
if (!ClonesWaitingForMind.TryGetValue(mind, out var entity) ||
!EntityManager.EntityExists(entity) ||
!EntityManager.TryGetComponent(entity, out MindComponent? mindComp) ||
!TryComp<MindComponent>(entity, out var mindComp) ||
mindComp.Mind != null)
return;
@@ -39,33 +66,94 @@ namespace Content.Server.Cloning
ClonesWaitingForMind.Remove(mind);
}
private void HandleMindAdded(EntityUid uid, BeingClonedComponent component, MindAddedMessage message)
private void HandleMindAdded(EntityUid uid, BeingClonedComponent clonedComponent, MindAddedMessage message)
{
if (component.Parent == EntityUid.Invalid ||
!EntityManager.EntityExists(component.Parent) ||
!EntityManager.TryGetComponent<CloningPodComponent?>(component.Parent, out var cloningPodComponent) ||
component.Owner != cloningPodComponent.BodyContainer?.ContainedEntity)
if (clonedComponent.Parent == EntityUid.Invalid ||
!EntityManager.EntityExists(clonedComponent.Parent) ||
!TryComp<CloningPodComponent>(clonedComponent.Parent, out var cloningPodComponent) ||
clonedComponent.Owner != cloningPodComponent.BodyContainer?.ContainedEntity)
{
EntityManager.RemoveComponent<BeingClonedComponent>(component.Owner);
EntityManager.RemoveComponent<BeingClonedComponent>(clonedComponent.Owner);
return;
}
UpdateStatus(CloningPodStatus.Cloning, cloningPodComponent);
}
cloningPodComponent.UpdateStatus(CloningPodStatus.Cloning);
private void OnPortDisconnected(EntityUid uid, CloningPodComponent pod, PortDisconnectedEvent args)
{
pod.ConnectedConsole = null;
}
private void OnAnchor(EntityUid uid, CloningPodComponent component, ref AnchorStateChangedEvent args)
{
if (component.ConnectedConsole == null || !TryComp<CloningConsoleComponent>(component.ConnectedConsole, out var console))
return;
if (args.Anchored)
{
_cloningConsoleSystem.RecheckConnections(component.ConnectedConsole.Value, uid, console.GeneticScanner, console);
return;
}
_cloningConsoleSystem.UpdateUserInterface(console);
}
public bool TryCloning(EntityUid uid, EntityUid bodyToClone, Mind.Mind mind, CloningPodComponent? clonePod)
{
if (!Resolve(uid, ref clonePod) || bodyToClone == null)
return false;
if (ClonesWaitingForMind.TryGetValue(mind, out var clone))
{
if (EntityManager.EntityExists(clone) &&
!_mobStateSystem.IsDead(clone) &&
TryComp<MindComponent>(clone, out var cloneMindComp) &&
(cloneMindComp.Mind == null || cloneMindComp.Mind == mind))
return false; // Mind already has clone
ClonesWaitingForMind.Remove(mind);
}
if (mind.OwnedEntity != null && !_mobStateSystem.IsDead(mind.OwnedEntity.Value))
return false; // Body controlled by mind is not dead
// Yes, we still need to track down the client because we need to open the Eui
if (mind.UserId == null || !_playerManager.TryGetSessionById(mind.UserId.Value, out var client))
return false; // If we can't track down the client, we can't offer transfer. That'd be quite bad.
if (!TryComp<HumanoidAppearanceComponent>(bodyToClone, out var humanoid))
return false; // whatever body was to be cloned, was not a humanoid
var speciesProto = _prototype.Index<SpeciesPrototype>(humanoid.Species).Prototype;
var mob = Spawn(speciesProto, Transform(clonePod.Owner).MapPosition);
_appearanceSystem.UpdateAppearance(mob, humanoid.Appearance);
_appearanceSystem.UpdateSexGender(mob, humanoid.Sex, humanoid.Gender);
MetaData(mob).EntityName = MetaData(bodyToClone).EntityName;
var cloneMindReturn = EntityManager.AddComponent<BeingClonedComponent>(mob);
cloneMindReturn.Mind = mind;
cloneMindReturn.Parent = clonePod.Owner;
clonePod.BodyContainer.Insert(mob);
clonePod.CapturedMind = mind;
ClonesWaitingForMind.Add(mind, mob);
UpdateStatus(CloningPodStatus.NoMind, clonePod);
_euiManager.OpenEui(new AcceptCloningEui(mind, this), client);
AddComp<ActiveCloningPodComponent>(uid);
return true;
}
public void UpdateStatus(CloningPodStatus status, CloningPodComponent cloningPod)
{
cloningPod.Status = status;
UpdateAppearance(cloningPod);
}
public override void Update(float frameTime)
{
// TODO: Make this stateful
foreach (var (cloning, power) in EntityManager.EntityQuery<CloningPodComponent, ApcPowerReceiverComponent>())
foreach (var (_, cloning) in EntityManager.EntityQuery<ActiveCloningPodComponent, CloningPodComponent>())
{
if (cloning.UiKnownPowerState != power.Powered)
{
// Must be *before* update
cloning.UiKnownPowerState = power.Powered;
UpdateUserInterface(cloning);
}
if (!power.Powered)
if (!_powerReceiverSystem.IsPowered(cloning.Owner))
continue;
if (cloning.BodyContainer.ContainedEntity != null)
@@ -76,77 +164,30 @@ namespace Content.Server.Cloning
if (cloning.CapturedMind?.Session?.AttachedEntity == cloning.BodyContainer.ContainedEntity)
{
cloning.Eject();
Eject(cloning.Owner, cloning);
}
}
}
public void UpdateUserInterface(CloningPodComponent comp)
public void Eject(EntityUid uid, CloningPodComponent? clonePod)
{
var idToUser = GetIdToUser();
comp.UserInterface?.SetState(
new CloningPodBoundUserInterfaceState(
idToUser,
// now
_timing.CurTime,
// progress, time, progressing
comp.CloningProgress,
comp.CloningTime,
// this is duplicate w/ the above check that actually updates progress
// better here than on client though
comp.UiKnownPowerState && (comp.BodyContainer.ContainedEntity != null),
comp.Status == CloningPodStatus.Cloning));
}
if (!Resolve(uid, ref clonePod))
return;
public void AddToDnaScans(ClonerDNAEntry dna)
{
if (!MindToId.ContainsKey(dna.Mind))
{
int id = _nextAllocatedMindId++;
MindToId.Add(dna.Mind, id);
IdToDNA.Add(id, dna);
}
OnChangeMadeToDnaScans();
}
if (clonePod.BodyContainer.ContainedEntity is not {Valid: true} entity || clonePod.CloningProgress < clonePod.CloningTime)
return;
public void OnChangeMadeToDnaScans()
{
foreach (var cloning in EntityManager.EntityQuery<CloningPodComponent>())
UpdateUserInterface(cloning);
}
public bool HasDnaScan(Mind.Mind mind)
{
return MindToId.ContainsKey(mind);
}
public Dictionary<int, string?> GetIdToUser()
{
return IdToDNA.ToDictionary(m => m.Key, m => m.Value.Mind.CharacterName);
EntityManager.RemoveComponent<BeingClonedComponent>(entity);
clonePod.BodyContainer.Remove(entity);
clonePod.CapturedMind = null;
clonePod.CloningProgress = 0f;
UpdateStatus(CloningPodStatus.Idle, clonePod);
RemCompDeferred<ActiveCloningPodComponent>(uid);
}
public void Reset(RoundRestartCleanupEvent ev)
{
MindToId.Clear();
IdToDNA.Clear();
ClonesWaitingForMind.Clear();
_nextAllocatedMindId = 0;
// We PROBABLY don't need to send out UI interface updates for the dna scan changes during a reset
}
}
// TODO: This needs to be moved to Content.Server.Mobs and made a global point of reference.
// For example, GameTicker should be using this, and this should be using ICharacterProfile rather than HumanoidCharacterProfile.
// It should carry a reference or copy of itself with the mobs that it affects.
// See TODO in MedicalScannerComponent.
public struct ClonerDNAEntry {
public Mind.Mind Mind;
public HumanoidCharacterProfile Profile;
public ClonerDNAEntry(Mind.Mind m, HumanoidCharacterProfile hcp)
{
Mind = m;
Profile = hcp;
}
}
}

View File

@@ -0,0 +1,9 @@
namespace Content.Server.Cloning.Components
{
[RegisterComponent]
/// <summary>
/// Shrimply a tracking component for pods that are cloning.
/// </summary>
public sealed class ActiveCloningPodComponent : Component
{}
}

View File

@@ -0,0 +1,24 @@
namespace Content.Server.Cloning.Components
{
[RegisterComponent]
public sealed class CloningConsoleComponent : Component
{
public const string ScannerPort = "MedicalScannerSender";
public const string PodPort = "CloningPodSender";
[ViewVariables]
public EntityUid? GeneticScanner = null;
[ViewVariables]
public EntityUid? CloningPod = null;
/// Maximum distance between console and one if its machines
[DataField("maxDistance")]
public float MaxDistance = 4f;
public bool GeneticScannerInRange = true;
public bool CloningPodInRange = true;
}
}

View File

@@ -1,208 +1,18 @@
using Content.Server.Climbing;
using Content.Server.EUI;
using Content.Server.Mind.Components;
using Content.Server.Power.Components;
using Content.Server.UserInterface;
using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.Cloning;
using Content.Shared.MobState.Components;
using Content.Shared.Popups;
using Content.Shared.Species;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
namespace Content.Server.Cloning.Components
{
[RegisterComponent]
public sealed class CloningPodComponent : SharedCloningPodComponent
public sealed class CloningPodComponent : Component
{
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly EuiManager _euiManager = null!;
[ViewVariables]
public BoundUserInterface? UserInterface =>
Owner.GetUIOrNull(CloningPodUIKey.Key);
public const string PodPort = "CloningPodReceiver";
[ViewVariables] public ContainerSlot BodyContainer = default!;
[ViewVariables] public Mind.Mind? CapturedMind;
[ViewVariables] public float CloningProgress = 0;
[DataField("cloningTime")]
[ViewVariables] public float CloningTime = 30f;
// Used to prevent as many duplicate UI messages as possible
[ViewVariables] public bool UiKnownPowerState = false;
[ViewVariables(VVAccess.ReadWrite), DataField("soundCloneStart")]
public SoundSpecifier? CloneStartSound = new SoundPathSpecifier("/Audio/Machines/genetics.ogg");
[ViewVariables]
public CloningPodStatus Status;
protected override void Initialize()
{
base.Initialize();
if (UserInterface != null)
{
UserInterface.OnReceiveMessage += OnUiReceiveMessage;
}
BodyContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-bodyContainer");
//TODO: write this so that it checks for a change in power events for GORE POD cases
EntitySystem.Get<CloningSystem>().UpdateUserInterface(this);
}
protected override void OnRemove()
{
if (UserInterface != null)
{
UserInterface.OnReceiveMessage -= OnUiReceiveMessage;
}
base.OnRemove();
}
private void UpdateAppearance()
{
if (_entities.TryGetComponent(Owner, out AppearanceComponent? appearance))
{
appearance.SetData(CloningPodVisuals.Status, Status);
}
}
private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj)
{
if (obj.Message is not CloningPodUiButtonPressedMessage message || obj.Session.AttachedEntity == null)
return;
switch (message.Button)
{
case UiButton.Clone:
if (BodyContainer.ContainedEntity != null)
{
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-occupied"));
return;
}
if (message.ScanId == null)
{
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-no-selection"));
return;
}
var cloningSystem = EntitySystem.Get<CloningSystem>();
if (!cloningSystem.IdToDNA.TryGetValue(message.ScanId.Value, out var dna))
{
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-bad-selection"));
return; // ScanId is not in database
}
var mind = dna.Mind;
if (cloningSystem.ClonesWaitingForMind.TryGetValue(mind, out var clone))
{
if (_entities.EntityExists(clone) &&
_entities.TryGetComponent<MobStateComponent?>(clone, out var cloneState) &&
!cloneState.IsDead() &&
_entities.TryGetComponent(clone, out MindComponent? cloneMindComp) &&
(cloneMindComp.Mind == null || cloneMindComp.Mind == mind))
{
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-cloning"));
return; // Mind already has clone
}
cloningSystem.ClonesWaitingForMind.Remove(mind);
}
if (mind.OwnedEntity != null &&
_entities.TryGetComponent<MobStateComponent?>(mind.OwnedEntity.Value, out var state) &&
!state.IsDead())
{
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-already-alive"));
return; // Body controlled by mind is not dead
}
// Yes, we still need to track down the client because we need to open the Eui
if (mind.UserId == null || !_playerManager.TryGetSessionById(mind.UserId.Value, out var client))
{
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-user-offline"));
return; // If we can't track down the client, we can't offer transfer. That'd be quite bad.
}
// Cloning confirmed now.
var speciesProto = _prototype.Index<SpeciesPrototype>(dna.Profile.Species).Prototype;
var mob = _entities.SpawnEntity(speciesProto, _entities.GetComponent<TransformComponent>(Owner).MapPosition);
EntitySystem.Get<SharedHumanoidAppearanceSystem>().UpdateFromProfile(mob, dna.Profile);
_entities.GetComponent<MetaDataComponent>(mob).EntityName = dna.Profile.Name;
// TODO: Ideally client knows about this and plays it on its own
// Send them a sound to know it happened
if (CloneStartSound != null)
SoundSystem.Play(CloneStartSound.GetSound(), Filter.SinglePlayer(client));
var cloneMindReturn = _entities.AddComponent<BeingClonedComponent>(mob);
cloneMindReturn.Mind = mind;
cloneMindReturn.Parent = Owner;
BodyContainer.Insert(mob);
CapturedMind = mind;
cloningSystem.ClonesWaitingForMind.Add(mind, mob);
UpdateStatus(CloningPodStatus.NoMind);
var acceptMessage = new AcceptCloningEui(mind);
_euiManager.OpenEui(acceptMessage, client);
break;
case UiButton.Eject:
if (BodyContainer.ContainedEntity == null)
{
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-empty"));
return;
}
if (CloningProgress < CloningTime)
{
obj.Session.AttachedEntity.Value.PopupMessageCursor(Loc.GetString("cloning-pod-component-msg-incomplete"));
return;
}
Eject();
break;
default:
throw new ArgumentOutOfRangeException();
}
}
public void Eject()
{
if (BodyContainer.ContainedEntity is not {Valid: true} entity || CloningProgress < CloningTime)
return;
_entities.RemoveComponent<BeingClonedComponent>(entity);
BodyContainer.Remove(entity);
CapturedMind = null;
CloningProgress = 0f;
UpdateStatus(CloningPodStatus.Idle);
EntitySystem.Get<ClimbSystem>().ForciblySetClimbing(entity, Owner);
}
public void UpdateStatus(CloningPodStatus status)
{
Status = status;
UpdateAppearance();
EntitySystem.Get<CloningSystem>().UpdateUserInterface(this);
}
[ViewVariables] public CloningPodStatus Status;
public EntityUid? ConnectedConsole;
}
}

View File

@@ -326,6 +326,10 @@ namespace Content.Server.MachineLinking.System
("machine2", receiver.Owner), ("port2", PortName<ReceiverPortPrototype>(args.ReceiverPort))),
Filter.Entities(user), PopupType.Medium);
var newLink = new NewLinkEvent(user, transmitter.Owner, args.TransmitterPort, receiver.Owner, args.ReceiverPort);
RaiseLocalEvent(receiver.Owner, newLink);
RaiseLocalEvent(transmitter.Owner, newLink);
return true;
}

View File

@@ -1,17 +1,15 @@
using Content.Server.UserInterface;
using Content.Shared.DragDrop;
using Content.Shared.MedicalScanner;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
namespace Content.Server.Medical.Components
{
[RegisterComponent]
[ComponentReference(typeof(SharedMedicalScannerComponent))]
public sealed class MedicalScannerComponent : SharedMedicalScannerComponent
{
public const string ScannerPort = "MedicalScannerReceiver";
public ContainerSlot BodyContainer = default!;
public BoundUserInterface? UserInterface => Owner.GetUIOrNull(MedicalScannerUiKey.Key);
public EntityUid? ConnectedConsole;
// ECS this out!, when DragDropSystem and InteractionSystem refactored
public override bool DragDropOn(DragDropEvent eventArgs)

View File

@@ -1,36 +1,32 @@
using Content.Server.Climbing;
using Content.Server.Cloning;
using Content.Server.Medical.Components;
using Content.Server.Mind.Components;
using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Preferences.Managers;
using Content.Shared.ActionBlocker;
using Content.Shared.CharacterAppearance.Components;
using Content.Shared.Damage;
using Content.Shared.Destructible;
using Content.Shared.ActionBlocker;
using Content.Shared.DragDrop;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Movement;
using Content.Shared.Movement.Events;
using Content.Shared.Preferences;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.Network;
using Robust.Shared.Player;
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent;
using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.Cloning.Systems;
using Content.Server.Cloning.Components;
using Content.Server.MobState;
using Robust.Server.Containers;
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent; /// Hmm...
namespace Content.Server.Medical
{
public sealed class MedicalScannerSystem : EntitySystem
{
[Dependency] private readonly IServerPreferencesManager _prefsManager = null!;
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly ClimbSystem _climbSystem = default!;
[Dependency] private readonly CloningSystem _cloningSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly CloningConsoleSystem _cloningConsoleSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
private const float UpdateRate = 1f;
private float _updateDif;
@@ -40,29 +36,20 @@ namespace Content.Server.Medical
base.Initialize();
SubscribeLocalEvent<MedicalScannerComponent, ComponentInit>(OnComponentInit);
SubscribeLocalEvent<MedicalScannerComponent, ActivateInWorldEvent>(OnActivated);
SubscribeLocalEvent<MedicalScannerComponent, ContainerRelayMovementEntityEvent>(OnRelayMovement);
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<InteractionVerb>>(AddInsertOtherVerb);
SubscribeLocalEvent<MedicalScannerComponent, GetVerbsEvent<AlternativeVerb>>(AddAlternativeVerbs);
SubscribeLocalEvent<MedicalScannerComponent, DestructionEventArgs>(OnDestroyed);
SubscribeLocalEvent<MedicalScannerComponent, DragDropEvent>(HandleDragDropOn);
SubscribeLocalEvent<MedicalScannerComponent, ScanButtonPressedMessage>(OnScanButtonPressed);
SubscribeLocalEvent<MedicalScannerComponent, PortDisconnectedEvent>(OnPortDisconnected);
SubscribeLocalEvent<MedicalScannerComponent, AnchorStateChangedEvent>(OnAnchorChanged);
}
private void OnComponentInit(EntityUid uid, MedicalScannerComponent scannerComponent, ComponentInit args)
{
base.Initialize();
scannerComponent.BodyContainer = scannerComponent.Owner.EnsureContainer<ContainerSlot>($"{scannerComponent.Name}-bodyContainer");
UpdateUserInterface(uid, scannerComponent);
}
private void OnActivated(EntityUid uid, MedicalScannerComponent scannerComponent, ActivateInWorldEvent args)
{
if (!this.IsPowered(uid, EntityManager))
return;
UpdateUserInterface(uid, scannerComponent);
scannerComponent.BodyContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, $"{scannerComponent.Name}-bodyContainer");
_signalSystem.EnsureReceiverPorts(uid, MedicalScannerComponent.ScannerPort);
}
private void OnRelayMovement(EntityUid uid, MedicalScannerComponent scannerComponent, ref ContainerRelayMovementEntityEvent args)
@@ -132,50 +119,26 @@ namespace Content.Server.Medical
InsertBody(uid, args.Dragged, scannerComponent);
}
private void OnScanButtonPressed(EntityUid uid, MedicalScannerComponent scannerComponent, ScanButtonPressedMessage args)
private void OnPortDisconnected(EntityUid uid, MedicalScannerComponent component, PortDisconnectedEvent args)
{
TrySaveCloningData(uid, scannerComponent);
component.ConnectedConsole = null;
}
private static readonly MedicalScannerBoundUserInterfaceState EmptyUIState =
new(false);
private MedicalScannerBoundUserInterfaceState GetUserInterfaceState(EntityUid uid, MedicalScannerComponent scannerComponent)
private void OnAnchorChanged(EntityUid uid, MedicalScannerComponent component, ref AnchorStateChangedEvent args)
{
EntityUid? containedBody = scannerComponent.BodyContainer.ContainedEntity;
if (containedBody == null)
{
UpdateAppearance(uid, scannerComponent);
return EmptyUIState;
}
if (!HasComp<DamageableComponent>(containedBody))
return EmptyUIState;
if (!HasComp<HumanoidAppearanceComponent>(containedBody))
return EmptyUIState;
if (!TryComp<MindComponent>(containedBody, out var mindComponent) || mindComponent.Mind == null)
return EmptyUIState;
bool isScanned = _cloningSystem.HasDnaScan(mindComponent.Mind);
return new MedicalScannerBoundUserInterfaceState(!isScanned);
}
private void UpdateUserInterface(EntityUid uid, MedicalScannerComponent scannerComponent)
{
if (!this.IsPowered(uid, EntityManager))
if (component.ConnectedConsole == null || !TryComp<CloningConsoleComponent>(component.ConnectedConsole, out var console))
return;
var newState = GetUserInterfaceState(uid, scannerComponent);
scannerComponent.UserInterface?.SetState(newState);
if (args.Anchored)
{
_cloningConsoleSystem.RecheckConnections(component.ConnectedConsole.Value, console.CloningPod, uid, console);
return;
}
_cloningConsoleSystem.UpdateUserInterface(console);
}
private MedicalScannerStatus GetStatus(MedicalScannerComponent scannerComponent)
{
if (this.IsPowered(scannerComponent.Owner, EntityManager))
if (TryComp<ApcPowerReceiverComponent>(scannerComponent.Owner, out var power) && power.Powered)
{
var body = scannerComponent.BodyContainer.ContainedEntity;
if (body == null)
@@ -186,7 +149,7 @@ namespace Content.Server.Medical
return MedicalScannerStatus.Open;
}
return GetStatusFromDamageState(state);
return GetStatusFromDamageState(body.Value, state);
}
return MedicalScannerStatus.Off;
}
@@ -196,15 +159,15 @@ namespace Content.Server.Medical
return scannerComponent.BodyContainer.ContainedEntity != null;
}
private MedicalScannerStatus GetStatusFromDamageState(MobStateComponent state)
private MedicalScannerStatus GetStatusFromDamageState(EntityUid uid, MobStateComponent state)
{
if (state.IsAlive())
if (_mobStateSystem.IsAlive(uid, state))
return MedicalScannerStatus.Green;
if (state.IsCritical())
if (_mobStateSystem.IsCritical(uid, state))
return MedicalScannerStatus.Red;
if (state.IsDead())
if (_mobStateSystem.IsDead(uid, state))
return MedicalScannerStatus.Death;
return MedicalScannerStatus.Yellow;
@@ -246,7 +209,6 @@ namespace Content.Server.Medical
return;
scannerComponent.BodyContainer.Insert(user);
UpdateUserInterface(uid, scannerComponent);
UpdateAppearance(scannerComponent.Owner, scannerComponent);
}
@@ -259,57 +221,7 @@ namespace Content.Server.Medical
scannerComponent.BodyContainer.Remove(contained);
_climbSystem.ForciblySetClimbing(contained, uid);
UpdateUserInterface(uid, scannerComponent);
UpdateAppearance(scannerComponent.Owner, scannerComponent);
}
public void TrySaveCloningData(EntityUid uid, MedicalScannerComponent? scannerComponent)
{
if (!Resolve(uid, ref scannerComponent))
return;
EntityUid? body = scannerComponent.BodyContainer.ContainedEntity;
if (body == null)
return;
// Check to see if they are humanoid
if (!TryComp<HumanoidAppearanceComponent>(body, out var humanoid))
{
_popupSystem.PopupEntity(Loc.GetString("medical-scanner-component-msg-no-humanoid-component"), uid, Filter.Pvs(uid));
return;
}
if (!TryComp<MindComponent>(body, out var mindComp) || mindComp.Mind == null)
{
_popupSystem.PopupEntity(Loc.GetString("medical-scanner-component-msg-no-soul"), uid, Filter.Pvs(uid));
return;
}
// Null suppression based on above check. Yes, it's explicitly needed
var mind = mindComp.Mind;
// We need the HumanoidCharacterProfile
// TODO: Move this further 'outwards' into a DNAComponent or somesuch.
// Ideally this ends with GameTicker & CloningSystem handing DNA to a function that sets up a body for that DNA.
var mindUser = mind.UserId;
if (mindUser.HasValue == false || mind.Session == null)
{
// For now assume this means soul departed
_popupSystem.PopupEntity(Loc.GetString("medical-scanner-component-msg-soul-broken"), uid, Filter.Pvs(uid));
return;
}
// TODO get synchronously
// This must be changed to grab the details of the mob itself, not session preferences
var profile = GetPlayerProfileAsync(mindUser.Value);
_cloningSystem.AddToDnaScans(new ClonerDNAEntry(mind, profile));
UpdateUserInterface(uid, scannerComponent);
}
private HumanoidCharacterProfile GetPlayerProfileAsync(NetUserId userId)
{
return (HumanoidCharacterProfile) _prefsManager.GetPreferences(userId).SelectedCharacter;
}
}
}

View File

@@ -51,15 +51,6 @@ public sealed class RenameCommand : IConsoleCommand
{
// Mind
mind.Mind.CharacterName = name;
// Cloner entries
if (entSysMan.TryGetEntitySystem<CloningSystem>(out var cloningSystem)
&& cloningSystem.MindToId.TryGetValue(mind.Mind, out var cloningId)
&& cloningSystem.IdToDNA.ContainsKey(cloningId))
{
cloningSystem.IdToDNA[cloningId] =
new ClonerDNAEntry(mind.Mind, cloningSystem.IdToDNA[cloningId].Profile.WithName(name));
}
}
// Id Cards

View File

@@ -83,5 +83,18 @@ namespace Content.Server.Power.EntitySystems
if (TryComp(receiver.Owner, out AppearanceComponent? appearance))
appearance.SetData(PowerDeviceVisuals.Powered, receiver.Powered);
}
/// <summary>
/// If this takes power, it returns whether it has power.
/// Otherwise, it returns 'true' because if something doesn't take power
/// it's effectively always powered.
/// </summary>
public bool IsPowered(EntityUid uid, ApcPowerReceiverComponent? receiver = null)
{
if (!Resolve(uid, ref receiver, false))
return true;
return receiver.Powered;
}
}
}

View File

@@ -0,0 +1,64 @@
using Robust.Shared.Serialization;
namespace Content.Shared.Cloning.CloningConsole
{
[Serializable, NetSerializable]
public sealed class CloningConsoleBoundUserInterfaceState : BoundUserInterfaceState
{
public readonly string? ScannerBodyInfo;
public readonly string? ClonerBodyInfo;
public readonly bool MindPresent;
public readonly ClonerStatus CloningStatus;
public readonly bool ScannerConnected;
public readonly bool ScannerInRange;
public readonly bool ClonerConnected;
public readonly bool ClonerInRange;
public CloningConsoleBoundUserInterfaceState(string? scannerBodyInfo, string? cloningBodyInfo, bool mindPresent, ClonerStatus cloningStatus, bool scannerConnected, bool scannerInRange, bool clonerConnected, bool clonerInRange)
{
ScannerBodyInfo = scannerBodyInfo;
ClonerBodyInfo = cloningBodyInfo;
MindPresent = mindPresent;
CloningStatus = cloningStatus;
ScannerConnected = scannerConnected;
ScannerInRange = scannerInRange;
ClonerConnected = clonerConnected;
ClonerInRange = clonerInRange;
}
}
[Serializable, NetSerializable]
public enum ClonerStatus : byte
{
Ready,
ScannerEmpty,
ScannerOccupantAlive,
OccupantMetaphyiscal,
ClonerOccupied,
NoClonerDetected,
NoMindDetected
}
[Serializable, NetSerializable]
public enum CloningConsoleUiKey : byte
{
Key
}
[Serializable, NetSerializable]
public enum UiButton : byte
{
Clone,
Eject
}
[Serializable, NetSerializable]
public sealed class UiButtonPressedMessage : BoundUserInterfaceMessage
{
public readonly UiButton Button;
public UiButtonPressedMessage(UiButton button)
{
Button = button;
}
}
}

View File

@@ -1,78 +1,18 @@
using Robust.Shared.Serialization;
using Robust.Shared.Serialization;
namespace Content.Shared.Cloning
{
[Virtual]
public class SharedCloningPodComponent : Component
[Serializable, NetSerializable]
public enum CloningPodVisuals : byte
{
[Serializable, NetSerializable]
public sealed class CloningPodBoundUserInterfaceState : BoundUserInterfaceState
{
public readonly Dictionary<int, string?> MindIdName;
// When this state was created.
// The reason this is used rather than a start time is because cloning can be interrupted.
public readonly TimeSpan ReferenceTime;
// Both of these are in seconds.
// They're not TimeSpans because of complicated reasons.
// CurTime of receipt is combined with Progress.
public readonly float Progress;
public readonly float Maximum;
// If true, cloning is progressing (predict clone progress)
public readonly bool Progressing;
public readonly bool MindPresent;
public CloningPodBoundUserInterfaceState(Dictionary<int, string?> mindIdName, TimeSpan refTime, float progress, float maximum, bool progressing, bool mindPresent)
{
MindIdName = mindIdName;
ReferenceTime = refTime;
Progress = progress;
Maximum = maximum;
Progressing = progressing;
MindPresent = mindPresent;
}
}
[Serializable, NetSerializable]
public enum CloningPodUIKey
{
Key
}
[Serializable, NetSerializable]
public enum CloningPodVisuals : byte
{
Status
}
[Serializable, NetSerializable]
public enum CloningPodStatus : byte
{
Idle,
Cloning,
Gore,
NoMind
}
[Serializable, NetSerializable]
public enum UiButton
{
Clone,
Eject
}
[Serializable, NetSerializable]
public sealed class CloningPodUiButtonPressedMessage : BoundUserInterfaceMessage
{
public readonly UiButton Button;
public readonly int? ScanId;
public CloningPodUiButtonPressedMessage(UiButton button, int? scanId)
{
Button = button;
ScanId = scanId;
}
}
Status
}
[Serializable, NetSerializable]
public enum CloningPodStatus : byte
{
Idle,
Cloning,
Gore,
NoMind
}
}

View File

@@ -0,0 +1,20 @@
namespace Content.Shared.MachineLinking.Events
{
public sealed class NewLinkEvent : EntityEventArgs
{
public readonly EntityUid Transmitter;
public readonly EntityUid Receiver;
public readonly EntityUid User;
public readonly string TransmitterPort;
public readonly string ReceiverPort;
public NewLinkEvent(EntityUid user, EntityUid transmitter, string transmitterPort, EntityUid receiver, string receiverPort)
{
User = user;
Transmitter = transmitter;
TransmitterPort = transmitterPort;
Receiver = receiver;
ReceiverPort = receiverPort;
}
}
}

View File

@@ -6,23 +6,6 @@ namespace Content.Shared.MedicalScanner
{
public abstract class SharedMedicalScannerComponent : Component, IDragDropOn
{
[Serializable, NetSerializable]
public sealed class MedicalScannerBoundUserInterfaceState : BoundUserInterfaceState
{
public readonly bool IsScannable;
public MedicalScannerBoundUserInterfaceState(bool isScannable)
{
IsScannable = isScannable;
}
}
[Serializable, NetSerializable]
public enum MedicalScannerUiKey
{
Key
}
[Serializable, NetSerializable]
public enum MedicalScannerVisuals
{
@@ -40,11 +23,6 @@ namespace Content.Shared.MedicalScanner
Yellow,
}
[Serializable, NetSerializable]
public sealed class ScanButtonPressedMessage : BoundUserInterfaceMessage
{
}
public bool CanInsert(EntityUid entity)
{
return IoCManager.Resolve<IEntityManager>().HasComponent<SharedBodyComponent>(entity);

View File

@@ -1,20 +0,0 @@
## UI
cloning-pod-window-title = Cloning Machine
cloning-pod-clone-button = Clone
cloning-pod-eject-body-button = Eject Body
cloning-pod-neural-interface-label = Neural Interface:
cloning-pod-no-activity-text = No Activity
cloning-pod-mind-present-text = Consciousness Detected
### yup etc
cloning-pod-component-msg-occupied = ERROR: The pod already contains a clone
cloning-pod-component-msg-no-selection = ERROR: You didn't select someone to clone
cloning-pod-component-msg-bad-selection = ERROR: Entry Removed During Selection // System Error
cloning-pod-component-msg-already-cloning = ERROR: Pod Network Conflict
cloning-pod-component-msg-already-alive = ERROR: Metaphysical Conflict
cloning-pod-component-msg-user-offline = ERROR: Metaphysical Disturbance
cloning-pod-component-msg-incomplete = ERROR: Cloning in progress
cloning-pod-component-msg-empty = ERROR: The pod is empty

View File

@@ -2,4 +2,8 @@
generic-not-available-shorthand = N/A
generic-article-a = a
generic-article-an = an
generic-article-an = an
generic-unknown = unknown
generic-error = error
generic-invalid = invalid

View File

@@ -33,3 +33,15 @@ signal-port-description-pressurize = Causes the device to starts releasing air u
signal-port-name-depressurize = Depressurize
signal-port-description-depressurize = Causes the device to starts siphoning air until some target pressure is reached.
signal-port-name-pod-sender = Cloning pod
signal-port-description-pod-sender = Cloning pod signal sender
signal-port-name-pod-receiver = Cloning pod
signal-port-description-pod-receiver = Cloning pod signal receiver
signal-port-name-med-scanner-sender = Medical scanner
signal-port-description-med-scanner-sender = Medical scanner signal sender
signal-port-name-med-scanner-receiver = Medical scanner
signal-port-description-med-scanner-receiver = Medical scanner signal receiver

View File

@@ -0,0 +1,26 @@
## UI
cloning-console-window-title = Cloning Console
cloning-console-window-clone-button-text = Clone
cloning-console-window-scanner-id = ID: [color=white]{$scannerOccupantName}[/color]
cloning-console-window-pod-id = ID: [color=white]{$podOccupantName}[/color]
cloning-console-window-no-patient-data-text = No patient data.
cloning-console-window-id-blank = ID:
cloning-console-window-scanner-details-label = Genetic Scanner Status
cloning-console-window-pod-details-label = Cloning Pod Status
cloning-console-window-no-scanner-detected-label = No Genetic Scanner Detected
cloning-console-window-no-clone-pod-detected-label = No Cloning Pod Detected
cloning-console-window-scanner-far-label = Genetic Scanner Too Far Away
cloning-console-window-clone-pod-far-label = Cloning Pod Too Far Away
cloning-console-eject-body-button = Eject Body
cloning-console-neural-interface-label = Neural Interface:
cloning-console-no-mind-activity-text = Neural Interface: [color=red]No Activity[/color]
cloning-console-mind-present-text = Neural Interface: [color=green]Consciousness Detected[/color]
cloning-console-component-msg-ready = Ready To Clone
cloning-console-component-msg-empty = No Body Detected
cloning-console-component-msg-scanner-occupant-alive = Not Ready: Scanner Occupant Living
cloning-console-component-msg-already-alive = Not Ready: Metaphysical Conflict
cloning-console-component-msg-occupied = Not Ready: The Pod Already Contains A Clone
cloning-console-component-msg-already-cloning = Not Ready: Pod Network Conflict
cloning-console-component-msg-incomplete = Not Ready: Cloning In Progress
cloning-console-component-msg-no-cloner = Not Ready: No Cloner Detected
cloning-console-component-msg-no-mind = Not Ready: No Soul Activity Detected

View File

@@ -1,14 +1,4 @@
## Entity
medical-scanner-component-msg-no-soul = ERROR: Body is completely devoid of soul
medical-scanner-component-msg-soul-broken = ERROR: Soul present, but defunct / departed
medical-scanner-component-msg-no-humanoid-component = ERROR: Body is incompatible
## EnterVerb
medical-scanner-verb-enter = Enter
medical-scanner-verb-noun-occupant = occupant
## UI
medical-scanner-window-save-button-text = Scan and Save DNA

View File

@@ -44,14 +44,6 @@
partType: Head
size: 7
compatibility: Biological
#Unique stuff the skull has for one a skelly gets "boned" nyeheheh
- type: BodyReassemble
action:
icon: Mobs/Species/Skeleton/parts.rsi/full.png
name: reassemble-action
description: reassemble-description
itemIconStyle: NoItem
event: !type:ReassembleActionEvent
- type: Input
context: "human"
- type: Speech

View File

@@ -126,6 +126,7 @@
- VaccinatorMachineCircuitboard
- DiagnoserMachineCircuitboard
- HandheldCrewMonitor
- CloningConsoleComputerCircuitboard
- type: technology
name: "advanced life support systems"

View File

@@ -222,3 +222,12 @@
components:
- type: ComputerBoard
prototype: ComputerShuttleSyndie
- type: entity
parent: BaseComputerCircuitboard
id: CloningConsoleComputerCircuitboard
name: cloning console computer board
description: A computer printed circuit board for a cloning console
components:
- type: ComputerBoard
prototype: ComputerCloningConsole

View File

@@ -11,6 +11,7 @@
screen: "alert-2"
- type: Computer
board: AlertsComputerCircuitboard
- type: Sprite
- type: entity
parent: BaseComputer
@@ -491,6 +492,41 @@
- type: AccessReader
access: [["Cargo"]]
- type: entity
parent: BaseComputer
id: ComputerCloningConsole
name: cloning console computer
description: The centerpiece of the cloning system, medicine's greatest accomplishment. It has lots of ports and wires.
components:
- type: CloningConsole
- type: DeviceList
- type: DeviceNetwork
deviceNetId: Wired
- type: Appearance
visuals:
- type: ComputerVisualizer
key: generic_key
screen: dna
- type: ApcPowerReceiver
powerLoad: 3100 #We want this to fail first so I transferred most of the scanner and pod's power here. (3500 in total)
- type: ExtensionCableProvider #See above
transferRange: 4
- type: Computer
board: CloningConsoleComputerCircuitboard
- type: PointLight
radius: 1.5
energy: 1.6
color: "#1f8c28"
- type: SignalTransmitter
transmissionRange: 4
- type: ActivatableUI
key: enum.CloningConsoleUiKey.Key
- type: ActivatableUIRequiresPower
- type: UserInterface
interfaces:
- key: enum.CloningConsoleUiKey.Key
type: CloningConsoleBoundUserInterface
- type: entity
parent: BaseComputer
id: ComputerSurveillanceCameraMonitor

View File

@@ -5,6 +5,9 @@
description: A Cloning Pod. 50% reliable.
components:
- type: CloningPod
- type: DeviceList
- type: DeviceNetwork
deviceNetId: Wired
- type: Sprite
netsync: false
sprite: Structures/Machines/cloning.rsi
@@ -42,7 +45,7 @@
BoardName: "CloningPod"
LayoutId: CloningPod
- type: ApcPowerReceiver
powerLoad: 2000
powerLoad: 200 #Receives most of its power from the console
- type: Appearance
visuals:
- type: GenericEnumVisualizer
@@ -53,10 +56,4 @@
enum.CloningPodStatus.NoMind: pod_e
enum.CloningPodStatus.Gore: pod_g
enum.CloningPodStatus.Idle: pod_0
- type: ActivatableUI
key: enum.CloningPodUIKey.Key #Ejecting doesn't require power so I didn't give it that component
- type: UserInterface
interfaces:
- key: enum.CloningPodUIKey.Key
type: CloningPodBoundUserInterface
- type: Climbable

View File

@@ -265,6 +265,7 @@
- ShuttleConsoleCircuitboard
- CircuitImprinterMachineCircuitboard
- DawInstrumentMachineCircuitboard
- CloningConsoleComputerCircuitboard
- StasisBedMachineCircuitboard
- OreProcessorMachineCircuitboard
- GeneratorPlasmaMachineCircuitboard

View File

@@ -5,6 +5,9 @@
description: A bulky medical scanner.
components:
- type: MedicalScanner
- type: DeviceNetwork
deviceNetId: Wired
- type: DeviceList
- type: Sprite
netsync: false
sprite: Structures/Machines/scanner.rsi
@@ -47,11 +50,6 @@
- type: Appearance
visuals:
- type: MedicalScannerVisualizer
- type: ActivatableUI
key: enum.MedicalScannerUiKey.Key
- type: ActivatableUIRequiresPower
- type: UserInterface
interfaces:
- key: enum.MedicalScannerUiKey.Key
type: MedicalScannerBoundUserInterface
- type: Climbable
- type: ApcPowerReceiver
powerLoad: 200 #Receives most of its power from the console

View File

@@ -52,3 +52,13 @@
id: Depressurize
name: signal-port-name-depressurize
description: signal-port-description-depressurize
- type: receiverPort
id: CloningPodReceiver
name: signal-port-name-pod-receiver
description: signal-port-description-pod-receiver
- type: receiverPort
id: MedicalScannerReceiver
name: signal-port-name-med-scanner-receiver
description: signal-port-description-med-scanner-receiver

View File

@@ -39,3 +39,13 @@
name: signal-port-name-order-sender
description: signal-port-description-order-sender
defaultLinks: [ OrderReceiver ]
- type: transmitterPort
id: CloningPodSender
name: signal-port-name-pod-receiver
description: signal-port-description-pod-sender
- type: transmitterPort
id: MedicalScannerSender
name: signal-port-name-med-scanner-sender
description: signal-port-description-med-scanner-sender

View File

@@ -296,6 +296,15 @@
Steel: 100
Glass: 900
- type: latheRecipe
id: CloningConsoleComputerCircuitboard
icon: Objects/Misc/module.rsi/id_mod.png
result: CloningConsoleComputerCircuitboard
completetime: 4
materials:
Steel: 100
Glass: 900
- type: latheRecipe
id: MicrowaveMachineCircuitboard
icon: Objects/Misc/module.rsi/id_mod.png