[HOTFIX] fixing chameleon projector (#45689)

SpriteSystem.CopySprite instead of direct Copy Component
This commit is contained in:
xsainteer 2026-08-28 18:35:38 +06:00 • committed by GitHub
parent 7aa2e159e5
commit 7b7379e75b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 2 deletions

View file

@ -28,7 +28,7 @@ public sealed partial class ChameleonProjectorSystem : SharedChameleonProjectorS
private void OnHandleState(Entity<ChameleonDisguiseComponent> ent, ref AfterAutoHandleStateEvent args)
{
CopyComp<SpriteComponent>(ent);
CopySprite(ent);
CopyComp<GenericVisualizerComponent>(ent);
CopyComp<SolutionContainerVisualsComponent>(ent);
CopyComp<BurnStateVisualsComponent>(ent);
@ -38,6 +38,18 @@ public sealed partial class ChameleonProjectorSystem : SharedChameleonProjectorS
_appearance.QueueUpdate(ent, appearance);
}
/// <summary>
/// Copies the source entity/prototype's sprite onto the disguise.
/// </summary>
private void CopySprite(Entity<ChameleonDisguiseComponent> ent)
{
if (!GetSrcEntity<SpriteComponent>(ent.Comp, out var src))
return;
var dest = EnsureComp<SpriteComponent>(ent);
_sprite.CopySprite(src, (ent.Owner, dest));
}
private void OnStartup(Entity<ChameleonDisguisedComponent> ent, ref ComponentStartup args)
{
if (!_spriteQuery.TryComp(ent, out var sprite))

View file

@ -338,7 +338,7 @@ public abstract partial class SharedChameleonProjectorSystem : EntitySystem
/// <summary>
/// Try to get a single component from the source entity/prototype.
/// </summary>
private bool GetSrcComp<T>(ChameleonDisguiseComponent comp, [NotNullWhen(true)] out T? src) where T : Component, new()
protected bool GetSrcComp<T>(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);
}
/// <summary>
/// Try to get a single component, paired with its owning entity, from the source entity/prototype.
/// </summary>
protected bool GetSrcEntity<T>(ChameleonDisguiseComponent comp, out Entity<T?> src) where T : Component, new()
{
if (TryComp<T>(comp.SourceEntity, out var liveComp))
{
src = (comp.SourceEntity, liveComp);
return true;
}
if (comp.SourceProto is { } protoId
&& ProtoMan.TryIndex<EntityPrototype>(protoId, out var proto)
&& proto.TryComp<T>(out var protoComp, EntityManager.ComponentFactory))
{
src = (EntityUid.Invalid, protoComp);
return true;
}
src = default;
return false;
}
}
/// <summary>