- fix: Chameleon projector. (#484)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Content.Client.Smoking;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Polymorph.Components;
|
||||
using Content.Shared.Polymorph.Systems;
|
||||
@@ -10,14 +11,19 @@ public sealed class ChameleonProjectorSystem : SharedChameleonProjectorSystem
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = 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);
|
||||
}
|
||||
|
||||
private void OnHandleState(Entity<ChameleonDisguiseComponent> ent, ref AfterAutoHandleStateEvent args)
|
||||
@@ -25,9 +31,25 @@ public sealed class ChameleonProjectorSystem : SharedChameleonProjectorSystem
|
||||
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.Visible = false;
|
||||
}
|
||||
|
||||
private void OnShutdown(Entity<ChameleonDisguisedComponent> ent, ref ComponentShutdown args)
|
||||
{
|
||||
if (_spriteQuery.TryComp(ent, out var sprite))
|
||||
sprite.Visible = ent.Comp.WasVisible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
var entities = _entity.EntityQueryEnumerator<BodyComponent, SpriteComponent, TransformComponent>();
|
||||
while (entities.MoveNext(out var uid, out _, out var sprite, out var xform))
|
||||
{
|
||||
if (!CanSee(uid))
|
||||
if (!CanSee(uid, sprite))
|
||||
continue;
|
||||
|
||||
var entity = uid;
|
||||
@@ -114,7 +114,7 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
Angle eyeRot)
|
||||
{
|
||||
var (uid, sprite, xform) = ent;
|
||||
if (xform.MapID != map || HasOccluders(uid) || !CanSee(uid))
|
||||
if (xform.MapID != map || HasOccluders(uid) || !CanSee(uid, sprite))
|
||||
return;
|
||||
|
||||
var position = _transform.GetWorldPosition(xform);
|
||||
@@ -123,9 +123,9 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
sprite.Render(handle, eyeRot, rotation, position: position);
|
||||
}
|
||||
|
||||
private bool CanSee(EntityUid ent)
|
||||
private bool CanSee(EntityUid ent, SpriteComponent sprite)
|
||||
{
|
||||
return !_entity.HasComponent<ThermalBlockerComponent>(ent);
|
||||
return sprite.Visible && !_entity.HasComponent<ThermalBlockerComponent>(ent);
|
||||
}
|
||||
|
||||
private bool HasOccluders(EntityUid ent)
|
||||
|
||||
Reference in New Issue
Block a user