- tweak: Thermal tweaks. (#477)
This commit is contained in:
@@ -18,6 +18,7 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
private readonly ContainerSystem _container;
|
||||
private readonly TransformSystem _transform;
|
||||
private readonly OccluderSystem _occluder;
|
||||
private readonly PointLightSystem _pointLight;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
|
||||
@@ -31,6 +32,7 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
_container = _entity.System<ContainerSystem>();
|
||||
_transform = _entity.System<TransformSystem>();
|
||||
_occluder = _entity.System<OccluderSystem>();
|
||||
_pointLight = _entity.System<PointLightSystem>();
|
||||
ZIndex = -1;
|
||||
}
|
||||
|
||||
@@ -51,7 +53,8 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
if (_pointLightEntity == default)
|
||||
{
|
||||
_pointLightEntity = _entity.SpawnAttachedTo(null, transform.Coordinates);
|
||||
_entity.EnsureComponent<PointLightComponent>(_pointLightEntity);
|
||||
var pointLight = _entity.EnsureComponent<PointLightComponent>(_pointLightEntity);
|
||||
_pointLight.SetRadius(_pointLightEntity, 3f, pointLight);
|
||||
_transform.SetParent(_pointLightEntity, ent);
|
||||
}
|
||||
else
|
||||
@@ -59,6 +62,7 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
var pointLightXForm = _entity.GetComponent<TransformComponent>(_pointLightEntity);
|
||||
if (pointLightXForm.ParentUid != ent)
|
||||
_transform.SetParent(_pointLightEntity, pointLightXForm, ent, transform);
|
||||
_transform.SetLocalPosition(_pointLightEntity, Vector2.Zero, pointLightXForm);
|
||||
}
|
||||
|
||||
if (HasOccluders(ent))
|
||||
@@ -73,6 +77,9 @@ 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))
|
||||
continue;
|
||||
|
||||
var entity = uid;
|
||||
|
||||
if (_container.TryGetOuterContainer(uid, xform, out var container))
|
||||
@@ -107,7 +114,7 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
Angle eyeRot)
|
||||
{
|
||||
var (uid, sprite, xform) = ent;
|
||||
if (xform.MapID != map || HasOccluders(uid))
|
||||
if (xform.MapID != map || HasOccluders(uid) || !CanSee(uid))
|
||||
return;
|
||||
|
||||
var position = _transform.GetWorldPosition(xform);
|
||||
@@ -116,6 +123,11 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
sprite.Render(handle, eyeRot, rotation, position: position);
|
||||
}
|
||||
|
||||
private bool CanSee(EntityUid ent)
|
||||
{
|
||||
return !_entity.HasComponent<ThermalBlockerComponent>(ent);
|
||||
}
|
||||
|
||||
private bool HasOccluders(EntityUid ent)
|
||||
{
|
||||
var mapCoordinates = _transform.GetMapCoordinates(ent);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Content.Shared._White.Overlays;
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared._Miracle.Systems;
|
||||
@@ -13,6 +15,7 @@ public abstract class SharedEnhancedVisionSystem<TComp, TTempComp, TEvent> : Ent
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly INetManager _net = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -52,7 +55,8 @@ public abstract class SharedEnhancedVisionSystem<TComp, TTempComp, TEvent> : Ent
|
||||
|
||||
component.IsActive = !component.IsActive;
|
||||
|
||||
_audio.PlayPredicted(component.IsActive ? component.ActivateSound : component.DeactivateSound, uid, uid);
|
||||
if (_net.IsClient)
|
||||
_audio.PlayEntity(component.IsActive ? component.ActivateSound : component.DeactivateSound, Filter.Local(), uid, false);
|
||||
|
||||
args.Handled = true;
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared._White.Overlays;
|
||||
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class ThermalBlockerComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -155,6 +155,9 @@
|
||||
name: power-cell-slot-component-slot-name-default
|
||||
startingItem: PowerCellSmall
|
||||
disableEject: true
|
||||
- type: ClothingGrantComponent
|
||||
component:
|
||||
- type: ThermalBlocker
|
||||
|
||||
- type: entity
|
||||
parent: ClothingOuterBase
|
||||
|
||||
Reference in New Issue
Block a user