Zombie cloning fix (#12520)

This commit is contained in:
corentt
2023-01-23 00:36:03 +01:00
committed by GitHub
parent 4a1b107ac2
commit 6cebc2d733
5 changed files with 88 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
using System.Linq;
using JetBrains.Annotations;
using Robust.Shared.Timing;
using Content.Server.Administration.Logs;
using Content.Server.Medical.Components;
using Content.Server.Cloning.Components;
using Content.Server.MachineLinking.Components;
@@ -13,6 +15,7 @@ using Robust.Server.GameObjects;
using Robust.Server.Player;
using Content.Shared.Cloning.CloningConsole;
using Content.Shared.Cloning;
using Content.Shared.Database;
using Content.Shared.MachineLinking.Events;
using Content.Shared.IdentityManagement;
using Content.Shared.Mobs.Components;
@@ -24,6 +27,7 @@ namespace Content.Server.Cloning
public sealed class CloningConsoleSystem : EntitySystem
{
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly CloningSystem _cloningSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
@@ -168,7 +172,8 @@ namespace Content.Server.Cloning
if (mind == null || mind.UserId.HasValue == false || mind.Session == null)
return;
_cloningSystem.TryCloning(cloningPodUid, body.Value, mind, cloningPod, scannerComp.CloningFailChanceMultiplier);
if (_cloningSystem.TryCloning(cloningPodUid, body.Value, mind, cloningPod, scannerComp.CloningFailChanceMultiplier))
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(uid)} successfully cloned {ToPrettyString(body.Value)}.");
}
public void RecheckConnections(EntityUid console, EntityUid? cloningPod, EntityUid? scanner, CloningConsoleComponent? consoleComp = null)

View File

@@ -21,6 +21,7 @@ using Content.Server.Stack;
using Content.Server.Jobs;
using Content.Shared.Humanoid;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Zombies;
using Content.Shared.Mobs.Systems;
using Robust.Server.GameObjects;
using Robust.Server.Containers;
@@ -220,7 +221,11 @@ namespace Content.Server.Cloning
var mob = Spawn(speciesPrototype.Prototype, Transform(clonePod.Owner).MapPosition);
_humanoidSystem.CloneAppearance(bodyToClone, mob);
MetaData(mob).EntityName = MetaData(bodyToClone).EntityName;
var ev = new CloningEvent(bodyToClone, mob);
RaiseLocalEvent(bodyToClone, ref ev);
if (!ev.NameHandled)
MetaData(mob).EntityName = MetaData(bodyToClone).EntityName;
var cloneMindReturn = EntityManager.AddComponent<BeingClonedComponent>(mob);
cloneMindReturn.Mind = mind;
@@ -323,4 +328,21 @@ namespace Content.Server.Cloning
ClonesWaitingForMind.Clear();
}
}
/// <summary>
/// Raised after a new mob got spawned when cloning a humanoid
/// </summary>
[ByRefEvent]
public struct CloningEvent
{
public bool NameHandled = false;
public readonly EntityUid Source;
public readonly EntityUid Target;
public CloningEvent(EntityUid source, EntityUid target) {
Source = source;
Target = target;
}
}
}