mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
[HOTFIX] fixing chameleon projector (#45689)
SpriteSystem.CopySprite instead of direct Copy Component
This commit is contained in:
parent
7aa2e159e5
commit
7b7379e75b
2 changed files with 37 additions and 2 deletions
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue