Cloning rework (#3808)
* Fix cloning * Fix cloning after clone dies and remove unneeded code * Fix ignored Co-authored-by: Silver <silvertorch5@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#nullable enable
|
||||
using Content.Server.Eui;
|
||||
using Content.Server.Players;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Server.Mobs;
|
||||
using Content.Shared.Eui;
|
||||
using Content.Shared.GameObjects.Components.Observer;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -9,28 +9,26 @@ namespace Content.Server.GameObjects.Components.Observer
|
||||
{
|
||||
public class AcceptCloningEui : BaseEui
|
||||
{
|
||||
private readonly IEntity _newMob;
|
||||
private readonly Mind _mind;
|
||||
|
||||
public AcceptCloningEui(IEntity newMob)
|
||||
public AcceptCloningEui(Mind mind)
|
||||
{
|
||||
_newMob = newMob;
|
||||
_mind = mind;
|
||||
}
|
||||
|
||||
public override void HandleMessage(EuiMessageBase msg)
|
||||
{
|
||||
base.HandleMessage(msg);
|
||||
|
||||
if (msg is not AcceptCloningChoiceMessage choice
|
||||
|| choice.Button == AcceptCloningUiButton.Deny
|
||||
|| _newMob.Deleted)
|
||||
if (msg is not AcceptCloningChoiceMessage choice ||
|
||||
choice.Button == AcceptCloningUiButton.Deny ||
|
||||
!EntitySystem.TryGet<CloningSystem>(out var cloningSystem))
|
||||
{
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
var mind = Player.ContentData()?.Mind;
|
||||
mind?.TransferTo(_newMob);
|
||||
mind?.UnVisit();
|
||||
cloningSystem.TransferMindToClone(_mind);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,13 +95,6 @@ namespace Content.Server.GameObjects.Components.Observer
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ReturnToCloneComponentMessage _:
|
||||
|
||||
if (Owner.TryGetComponent(out VisitingMindComponent? mind) && mind.Mind != null)
|
||||
{
|
||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new GhostReturnMessage(mind.Mind));
|
||||
}
|
||||
break;
|
||||
case GhostWarpToLocationRequestMessage warp:
|
||||
{
|
||||
if (session?.AttachedEntity != Owner)
|
||||
@@ -191,15 +184,5 @@ namespace Content.Server.GameObjects.Components.Observer
|
||||
|
||||
message.AddMarkup(Loc.GetString("Died [color=yellow]{0}[/color].", deathTimeInfo));
|
||||
}
|
||||
|
||||
public class GhostReturnMessage : EntityEventArgs
|
||||
{
|
||||
public GhostReturnMessage(Mind sender)
|
||||
{
|
||||
Sender = sender;
|
||||
}
|
||||
|
||||
public Mind Sender { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user