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

@@ -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;
}
}
}