using Content.Client.Effects; using Content.Client.Smoking; using Content.Shared.Chemistry.Components; using Content.Shared.Polymorph.Components; using Content.Shared.Polymorph.Systems; using Robust.Client.GameObjects; using Robust.Shared.Player; namespace Content.Client.Polymorph.Systems; public sealed class ChameleonProjectorSystem : SharedChameleonProjectorSystem { [Dependency] private readonly SharedAppearanceSystem _appearance = default!; private EntityQuery _appearanceQuery; private EntityQuery _spriteQuery; public override void Initialize() { base.Initialize(); _appearanceQuery = GetEntityQuery(); _spriteQuery = GetEntityQuery(); SubscribeLocalEvent(OnHandleState); SubscribeLocalEvent(OnStartup); SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnGetFlashEffectTargetEvent); } private void OnHandleState(Entity ent, ref AfterAutoHandleStateEvent args) { CopyComp(ent); CopyComp(ent); CopyComp(ent); CopyComp(ent); // reload appearance to hopefully prevent any invisible layers if (_appearanceQuery.TryComp(ent, out var appearance)) _appearance.QueueUpdate(ent, appearance); } private void OnStartup(Entity ent, ref ComponentStartup args) { if (!_spriteQuery.TryComp(ent, out var sprite)) return; ent.Comp.WasVisible = sprite.Visible; sprite.Visible = false; } private void OnShutdown(Entity ent, ref ComponentShutdown args) { if (_spriteQuery.TryComp(ent, out var sprite)) sprite.Visible = ent.Comp.WasVisible; } private void OnGetFlashEffectTargetEvent(Entity ent, ref GetFlashEffectTargetEvent args) { args.Target = ent.Comp.Disguise; } }