From 7b7379e75bb85f584d601153cbe2ccf3f0fa692f Mon Sep 17 00:00:00 2001 From: xsainteer <156868231+xsainteer@users.noreply.github.com> Date: Fri, 28 Aug 2026 18:35:38 +0600 Subject: [PATCH] [HOTFIX] fixing chameleon projector (#45689) SpriteSystem.CopySprite instead of direct Copy Component --- .../Systems/ChameleonProjectorSystem.cs | 14 ++++++++++- .../Systems/SharedChameleonProjectorSystem.cs | 25 ++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/Content.Client/Polymorph/Systems/ChameleonProjectorSystem.cs b/Content.Client/Polymorph/Systems/ChameleonProjectorSystem.cs index 9a25277b3f..3600e54864 100644 --- a/Content.Client/Polymorph/Systems/ChameleonProjectorSystem.cs +++ b/Content.Client/Polymorph/Systems/ChameleonProjectorSystem.cs @@ -28,7 +28,7 @@ public sealed partial class ChameleonProjectorSystem : SharedChameleonProjectorS private void OnHandleState(Entity ent, ref AfterAutoHandleStateEvent args) { - CopyComp(ent); + CopySprite(ent); CopyComp(ent); CopyComp(ent); CopyComp(ent); @@ -38,6 +38,18 @@ public sealed partial class ChameleonProjectorSystem : SharedChameleonProjectorS _appearance.QueueUpdate(ent, appearance); } + /// + /// Copies the source entity/prototype's sprite onto the disguise. + /// + private void CopySprite(Entity ent) + { + if (!GetSrcEntity(ent.Comp, out var src)) + return; + + var dest = EnsureComp(ent); + _sprite.CopySprite(src, (ent.Owner, dest)); + } + private void OnStartup(Entity ent, ref ComponentStartup args) { if (!_spriteQuery.TryComp(ent, out var sprite)) diff --git a/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs b/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs index f57c81451d..6d18027b4e 100644 --- a/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs +++ b/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs @@ -338,7 +338,7 @@ public abstract partial class SharedChameleonProjectorSystem : EntitySystem /// /// Try to get a single component from the source entity/prototype. /// - private bool GetSrcComp(ChameleonDisguiseComponent comp, [NotNullWhen(true)] out T? src) where T : Component, new() + protected bool GetSrcComp(ChameleonDisguiseComponent comp, [NotNullWhen(true)] out T? src) where T : Component, new() { if (TryComp(comp.SourceEntity, out src)) return true; @@ -351,6 +351,29 @@ public abstract partial class SharedChameleonProjectorSystem : EntitySystem return proto.TryComp(out src, EntityManager.ComponentFactory); } + + /// + /// Try to get a single component, paired with its owning entity, from the source entity/prototype. + /// + protected bool GetSrcEntity(ChameleonDisguiseComponent comp, out Entity src) where T : Component, new() + { + if (TryComp(comp.SourceEntity, out var liveComp)) + { + src = (comp.SourceEntity, liveComp); + return true; + } + + if (comp.SourceProto is { } protoId + && ProtoMan.TryIndex(protoId, out var proto) + && proto.TryComp(out var protoComp, EntityManager.ComponentFactory)) + { + src = (EntityUid.Invalid, protoComp); + return true; + } + + src = default; + return false; + } } ///