From a8ffd3280a1892f96d375a0e924c5a8b14f4ae9c Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Mon, 22 Jul 2024 14:24:00 +0000 Subject: [PATCH] - tweak: Thermal tweaks. (#477) --- .../_White/Overlays/ThermalVisionOverlay.cs | 16 ++++++++++++++-- .../Systems/SharedEnhancedVisionSystem.cs | 6 +++++- .../_White/Overlays/ThermalBlockerComponent.cs | 8 ++++++++ .../Entities/Clothing/OuterClothing/suits.yml | 3 +++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 Content.Shared/_White/Overlays/ThermalBlockerComponent.cs diff --git a/Content.Client/_White/Overlays/ThermalVisionOverlay.cs b/Content.Client/_White/Overlays/ThermalVisionOverlay.cs index 04ed047b23..72b6619d1a 100644 --- a/Content.Client/_White/Overlays/ThermalVisionOverlay.cs +++ b/Content.Client/_White/Overlays/ThermalVisionOverlay.cs @@ -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(); _transform = _entity.System(); _occluder = _entity.System(); + _pointLight = _entity.System(); ZIndex = -1; } @@ -51,7 +53,8 @@ public sealed class ThermalVisionOverlay : Overlay if (_pointLightEntity == default) { _pointLightEntity = _entity.SpawnAttachedTo(null, transform.Coordinates); - _entity.EnsureComponent(_pointLightEntity); + var pointLight = _entity.EnsureComponent(_pointLightEntity); + _pointLight.SetRadius(_pointLightEntity, 3f, pointLight); _transform.SetParent(_pointLightEntity, ent); } else @@ -59,6 +62,7 @@ public sealed class ThermalVisionOverlay : Overlay var pointLightXForm = _entity.GetComponent(_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(); 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(ent); + } + private bool HasOccluders(EntityUid ent) { var mapCoordinates = _transform.GetMapCoordinates(ent); diff --git a/Content.Shared/_Miracle/Systems/SharedEnhancedVisionSystem.cs b/Content.Shared/_Miracle/Systems/SharedEnhancedVisionSystem.cs index b9920a3fd8..62f4c42252 100644 --- a/Content.Shared/_Miracle/Systems/SharedEnhancedVisionSystem.cs +++ b/Content.Shared/_Miracle/Systems/SharedEnhancedVisionSystem.cs @@ -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 : 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 : 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; diff --git a/Content.Shared/_White/Overlays/ThermalBlockerComponent.cs b/Content.Shared/_White/Overlays/ThermalBlockerComponent.cs new file mode 100644 index 0000000000..2c246aff4d --- /dev/null +++ b/Content.Shared/_White/Overlays/ThermalBlockerComponent.cs @@ -0,0 +1,8 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared._White.Overlays; + +[RegisterComponent, NetworkedComponent] +public sealed partial class ThermalBlockerComponent : Component +{ +} diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml index 1661727cb2..991fa93c5c 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml @@ -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