mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Fix Night Vision (#1554)
<!-- This is a semi-strict format, you can add/remove sections as needed but the order/format should be kept the same Remove these comments before submitting --> # Description <!-- Explain this PR in as much detail as applicable Some example prompts to consider: How might this affect the game? The codebase? What might be some alternatives to this? How/Who does this benefit/hurt [the game/codebase]? --> Fixes the bug where you could put a mouse on your head and get free night vision. This works by adding a bool to the SwitchableVisionOverlayComponent `IsEquipment` that will be checked for before granting the thermal/night vision action. Port of https://github.com/Goob-Station/Goob-Station/pull/1448 --- <!-- This is default collapsed, readers click to expand it and see all your media The PR media section can get very large at times, so this is a good way to keep it clean The title is written using HTML tags The title must be within the <summary> tags or you won't see it --> <details><summary><h1>Media</h1></summary> <p> No night vision with the mouse on your head:  Goggles still work:  </p> </details> --- # Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 Piras314, Aviu - fix: Fixed being able to get night vision from putting a mouse on your head. --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: Aviu00 <93730715+Aviu00@users.noreply.github.com> Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit 03b7a8a6bfbbc13bc9b7bd27fe414086500592be)
This commit is contained in:
@@ -93,7 +93,8 @@ public abstract class EquipmentHudSystem<T> : EntitySystem where T : IComponent
|
||||
|
||||
protected virtual void OnRefreshEquipmentHud(EntityUid uid, T component, InventoryRelayedEvent<RefreshEquipmentHudEvent<T>> args)
|
||||
{
|
||||
OnRefreshComponentHud(uid, component, args.Args);
|
||||
args.Args.Active = true;
|
||||
args.Args.Components.Add(component);
|
||||
}
|
||||
|
||||
protected virtual void OnRefreshComponentHud(EntityUid uid, T component, RefreshEquipmentHudEvent<T> args)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Overlays.Switchable;
|
||||
using Robust.Client.Graphics;
|
||||
@@ -20,6 +21,26 @@ public sealed class NightVisionSystem : EquipmentHudSystem<NightVisionComponent>
|
||||
_overlay = new BaseSwitchableOverlay<NightVisionComponent>();
|
||||
}
|
||||
|
||||
protected override void OnRefreshComponentHud(EntityUid uid,
|
||||
NightVisionComponent component,
|
||||
RefreshEquipmentHudEvent<NightVisionComponent> args)
|
||||
{
|
||||
if (component.IsEquipment)
|
||||
return;
|
||||
|
||||
base.OnRefreshComponentHud(uid, component, args);
|
||||
}
|
||||
|
||||
protected override void OnRefreshEquipmentHud(EntityUid uid,
|
||||
NightVisionComponent component,
|
||||
InventoryRelayedEvent<RefreshEquipmentHudEvent<NightVisionComponent>> args)
|
||||
{
|
||||
if (!component.IsEquipment)
|
||||
return;
|
||||
|
||||
base.OnRefreshEquipmentHud(uid, component, args);
|
||||
}
|
||||
|
||||
private void OnToggle(Entity<NightVisionComponent> ent, ref SwitchableOverlayToggledEvent args)
|
||||
{
|
||||
RefreshOverlay(args.User);
|
||||
|
||||
@@ -143,9 +143,9 @@ public sealed class ThermalVisionOverlay : Overlay
|
||||
_stealth.GetVisibility(uid, stealth) > 0.5f);
|
||||
}
|
||||
|
||||
public void ResetLight()
|
||||
public void ResetLight(bool checkFirstTimePredicted = true)
|
||||
{
|
||||
if (_lightEntity == null || !_timing.IsFirstTimePredicted)
|
||||
if (_lightEntity == null || checkFirstTimePredicted && !_timing.IsFirstTimePredicted)
|
||||
return;
|
||||
|
||||
_entity.DeleteEntity(_lightEntity);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Overlays.Switchable;
|
||||
using Robust.Client.Graphics;
|
||||
@@ -21,6 +22,26 @@ public sealed class ThermalVisionSystem : EquipmentHudSystem<ThermalVisionCompon
|
||||
_overlay = new BaseSwitchableOverlay<ThermalVisionComponent>();
|
||||
}
|
||||
|
||||
protected override void OnRefreshComponentHud(EntityUid uid,
|
||||
ThermalVisionComponent component,
|
||||
RefreshEquipmentHudEvent<ThermalVisionComponent> args)
|
||||
{
|
||||
if (component.IsEquipment)
|
||||
return;
|
||||
|
||||
base.OnRefreshComponentHud(uid, component, args);
|
||||
}
|
||||
|
||||
protected override void OnRefreshEquipmentHud(EntityUid uid,
|
||||
ThermalVisionComponent component,
|
||||
InventoryRelayedEvent<RefreshEquipmentHudEvent<ThermalVisionComponent>> args)
|
||||
{
|
||||
if (!component.IsEquipment)
|
||||
return;
|
||||
|
||||
base.OnRefreshEquipmentHud(uid, component, args);
|
||||
}
|
||||
|
||||
private void OnToggle(Entity<ThermalVisionComponent> ent, ref SwitchableOverlayToggledEvent args)
|
||||
{
|
||||
RefreshOverlay(args.User);
|
||||
@@ -54,6 +75,7 @@ public sealed class ThermalVisionSystem : EquipmentHudSystem<ThermalVisionCompon
|
||||
{
|
||||
base.DeactivateInternal();
|
||||
|
||||
_thermalOverlay.ResetLight(false);
|
||||
UpdateOverlay(null);
|
||||
UpdateThermalOverlay(null, 0f);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,12 @@ public abstract partial class SwitchableOverlayComponent : BaseOverlayComponent
|
||||
[DataField]
|
||||
public bool DrawOverlay = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether it should grant equipment enhanced vision or is it mob vision
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool IsEquipment;
|
||||
|
||||
/// <summary>
|
||||
/// If it is greater than 0, overlay isn't toggled but pulsed instead
|
||||
/// </summary>
|
||||
|
||||
@@ -102,18 +102,22 @@ public abstract class SwitchableOverlaySystem<TComp, TEvent> : EntitySystem
|
||||
|
||||
component.IsActive = state.IsActive;
|
||||
|
||||
RaiseSwitchableOverlayToggledEvent(uid, uid, component.IsActive);
|
||||
RaiseSwitchableOverlayToggledEvent(uid, Transform(uid).ParentUid, component.IsActive);
|
||||
RaiseSwitchableOverlayToggledEvent(uid,
|
||||
component.IsEquipment ? Transform(uid).ParentUid : uid,
|
||||
component.IsActive);
|
||||
}
|
||||
|
||||
private void OnGetItemActions(Entity<TComp> ent, ref GetItemActionsEvent args)
|
||||
{
|
||||
if (ent.Comp.ToggleAction != null && args.SlotFlags is not SlotFlags.POCKET and not null)
|
||||
if (ent.Comp.IsEquipment && ent.Comp.ToggleAction != null && args.SlotFlags is not SlotFlags.POCKET and not null)
|
||||
args.AddAction(ref ent.Comp.ToggleActionEntity, ent.Comp.ToggleAction);
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, TComp component, ComponentShutdown args)
|
||||
{
|
||||
if (component.IsEquipment)
|
||||
return;
|
||||
|
||||
_actions.RemoveAction(uid, component.ToggleActionEntity);
|
||||
}
|
||||
|
||||
@@ -124,7 +128,7 @@ public abstract class SwitchableOverlaySystem<TComp, TEvent> : EntitySystem
|
||||
|
||||
private void OnMapInit(EntityUid uid, TComp component, MapInitEvent args)
|
||||
{
|
||||
if (component.ToggleActionEntity == null && component.ToggleAction != null)
|
||||
if (component is { IsEquipment: false, ToggleActionEntity: null, ToggleAction: not null })
|
||||
_actions.AddAction(uid, ref component.ToggleActionEntity, component.ToggleAction);
|
||||
}
|
||||
|
||||
|
||||
@@ -413,6 +413,7 @@
|
||||
sprite: Clothing/Eyes/Glasses/ninjavisor.rsi
|
||||
- type: FlashImmunity
|
||||
- type: NightVision
|
||||
isEquipment: true
|
||||
|
||||
- type: entity #Fake goggles, the latest in anti-valid hunting technology
|
||||
parent: ClothingEyesBase
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
- type: Clothing
|
||||
sprite: Clothing/Eyes/Goggles/nightvision.rsi
|
||||
- type: NightVision
|
||||
isEquipment: true
|
||||
- type: IdentityBlocker
|
||||
coverage: EYES
|
||||
|
||||
@@ -77,6 +78,7 @@
|
||||
- type: Clothing
|
||||
sprite: Clothing/Eyes/Goggles/thermal.rsi
|
||||
- type: ThermalVision
|
||||
isEquipment: true
|
||||
pulseTime: 2
|
||||
toggleAction: PulseThermalVision
|
||||
- type: IdentityBlocker
|
||||
|
||||
@@ -800,6 +800,7 @@
|
||||
maxRange: 0
|
||||
# WD EDIT END
|
||||
- type: ThermalVision
|
||||
isEquipment: true
|
||||
color: "#98EEFB"
|
||||
lightRadius: 15
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
- type: EyeProtection
|
||||
- type: NightVision
|
||||
isActive: true
|
||||
isEquipment: true
|
||||
toggleAction: null
|
||||
activateSound: null
|
||||
deactivateSound: null
|
||||
|
||||
Reference in New Issue
Block a user