Files
tbd-station-14/Content.Client/Polymorph/Systems/ChameleonProjectorSystem.cs
Tayrtahn 818d047449 Cleanup more SpriteComponent warnings (part 5) (#37590)
* 1 warning in KudzuVisualizerSystem

* 2 warnings in ChameleonProjectorSystem

* 1 warning in MarkerSystem

* 2 warnings in ItemSystem

* 1 warning in GhostToggleSelfVisibility

* 1 warning in FoamVisualizerSystem

* 1 warning in ClickableTest

* 1 warning in ThrownItemVisualizerSystem

* 2 warnings in InfantSystem

* 1 warning in ChasmFallingVisualsSystem

* 1 warning in PotencyVisualsSystem

* 2 warnings in OrbitVisualsSystem

* 2 warnings in BeamSystem

* 1 warning in JitteringSystem

* 1 warning in CardboardBoxSystem

* 2 warnings in StationAiSystem

* 2 warnings in FirelockSystem

* 2 warnings in CargoSystem.Telepad

* 1 warning in StasisBedSystem

* 2 warnings in WeldableVisualizerSystem

* 2 warnings in DeliveryVisualizerSystem

* 1 warning in TimerTriggerVisualizerSystem

* 1 warning in StorageFillVisualizerSystem

* 2 warnings in RadiationCollectorSystem

* 2 warnings in BorgSwitchableTypeSystem

* 1 warning in TurnstileSystem

* 1 warning in SurveillanceCameraVisualsSystem

* 1 warning in BurnStateVisualizerSystem

* 2 warnings in CableVisualizerSystem

* 1 warning in JetpackSystem
2025-05-19 03:09:47 +02:00

65 lines
2.4 KiB
C#

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!;
[Dependency] private readonly SpriteSystem _sprite = default!;
private EntityQuery<AppearanceComponent> _appearanceQuery;
private EntityQuery<SpriteComponent> _spriteQuery;
public override void Initialize()
{
base.Initialize();
_appearanceQuery = GetEntityQuery<AppearanceComponent>();
_spriteQuery = GetEntityQuery<SpriteComponent>();
SubscribeLocalEvent<ChameleonDisguiseComponent, AfterAutoHandleStateEvent>(OnHandleState);
SubscribeLocalEvent<ChameleonDisguisedComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ChameleonDisguisedComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<ChameleonDisguisedComponent, GetFlashEffectTargetEvent>(OnGetFlashEffectTargetEvent);
}
private void OnHandleState(Entity<ChameleonDisguiseComponent> ent, ref AfterAutoHandleStateEvent args)
{
CopyComp<SpriteComponent>(ent);
CopyComp<GenericVisualizerComponent>(ent);
CopyComp<SolutionContainerVisualsComponent>(ent);
CopyComp<BurnStateVisualsComponent>(ent);
// reload appearance to hopefully prevent any invisible layers
if (_appearanceQuery.TryComp(ent, out var appearance))
_appearance.QueueUpdate(ent, appearance);
}
private void OnStartup(Entity<ChameleonDisguisedComponent> ent, ref ComponentStartup args)
{
if (!_spriteQuery.TryComp(ent, out var sprite))
return;
ent.Comp.WasVisible = sprite.Visible;
_sprite.SetVisible((ent.Owner, sprite), false);
}
private void OnShutdown(Entity<ChameleonDisguisedComponent> ent, ref ComponentShutdown args)
{
if (_spriteQuery.TryComp(ent, out var sprite))
_sprite.SetVisible((ent.Owner, sprite), ent.Comp.WasVisible);
}
private void OnGetFlashEffectTargetEvent(Entity<ChameleonDisguisedComponent> ent, ref GetFlashEffectTargetEvent args)
{
args.Target = ent.Comp.Disguise;
}
}