-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🆑 TCJ, sleepyyapril - add: Added Station AI - add: Station AI was added to Saltern, RadStation, and Gax Station.
- Loading branch information
Showing
402 changed files
with
44,152 additions
and
37,143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
Content.Client/Electrocution/ElectrocutionHUDVisualizerSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using Content.Shared.Electrocution; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Client.Electrocution; | ||
|
||
/// <summary> | ||
/// Shows the Electrocution HUD to entities with the ShowElectrocutionHUDComponent. | ||
/// </summary> | ||
public sealed class ElectrocutionHUDVisualizerSystem : VisualizerSystem<ElectrocutionHUDVisualsComponent> | ||
{ | ||
[Dependency] private readonly IPlayerManager _playerMan = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<ShowElectrocutionHUDComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<ShowElectrocutionHUDComponent, ComponentShutdown>(OnShutdown); | ||
SubscribeLocalEvent<ShowElectrocutionHUDComponent, LocalPlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<ShowElectrocutionHUDComponent, LocalPlayerDetachedEvent>(OnPlayerDetached); | ||
} | ||
|
||
private void OnPlayerAttached(Entity<ShowElectrocutionHUDComponent> ent, ref LocalPlayerAttachedEvent args) | ||
{ | ||
ShowHUD(); | ||
} | ||
|
||
private void OnPlayerDetached(Entity<ShowElectrocutionHUDComponent> ent, ref LocalPlayerDetachedEvent args) | ||
{ | ||
RemoveHUD(); | ||
} | ||
|
||
private void OnInit(Entity<ShowElectrocutionHUDComponent> ent, ref ComponentInit args) | ||
{ | ||
if (_playerMan.LocalEntity == ent) | ||
{ | ||
ShowHUD(); | ||
} | ||
} | ||
|
||
private void OnShutdown(Entity<ShowElectrocutionHUDComponent> ent, ref ComponentShutdown args) | ||
{ | ||
if (_playerMan.LocalEntity == ent) | ||
{ | ||
RemoveHUD(); | ||
} | ||
} | ||
|
||
// Show the HUD to the client. | ||
// We have to look for all current entities that can be electrified and toggle the HUD layer on if they are. | ||
private void ShowHUD() | ||
{ | ||
var electrifiedQuery = AllEntityQuery<ElectrocutionHUDVisualsComponent, AppearanceComponent, SpriteComponent>(); | ||
while (electrifiedQuery.MoveNext(out var uid, out var _, out var appearanceComp, out var spriteComp)) | ||
{ | ||
if (!AppearanceSystem.TryGetData<bool>(uid, ElectrifiedVisuals.IsElectrified, out var electrified, appearanceComp)) | ||
continue; | ||
|
||
if (electrified) | ||
spriteComp.LayerSetVisible(ElectrifiedLayers.HUD, true); | ||
else | ||
spriteComp.LayerSetVisible(ElectrifiedLayers.HUD, false); | ||
} | ||
} | ||
|
||
// Remove the HUD from the client. | ||
// Find all current entities that can be electrified and hide the HUD layer. | ||
private void RemoveHUD() | ||
{ | ||
var electrifiedQuery = AllEntityQuery<ElectrocutionHUDVisualsComponent, AppearanceComponent, SpriteComponent>(); | ||
while (electrifiedQuery.MoveNext(out var uid, out var _, out var appearanceComp, out var spriteComp)) | ||
{ | ||
|
||
spriteComp.LayerSetVisible(ElectrifiedLayers.HUD, false); | ||
} | ||
} | ||
|
||
// Toggle the HUD layer if an entity becomes (de-)electrified | ||
protected override void OnAppearanceChange(EntityUid uid, ElectrocutionHUDVisualsComponent comp, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite == null) | ||
return; | ||
|
||
if (!AppearanceSystem.TryGetData<bool>(uid, ElectrifiedVisuals.IsElectrified, out var electrified, args.Component)) | ||
return; | ||
|
||
var player = _playerMan.LocalEntity; | ||
if (electrified && HasComp<ShowElectrocutionHUDComponent>(player)) | ||
args.Sprite.LayerSetVisible(ElectrifiedLayers.HUD, true); | ||
else | ||
args.Sprite.LayerSetVisible(ElectrifiedLayers.HUD, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Content.Client/Overlays/Switchable/BaseSwitchableOverlay.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Numerics; | ||
using Content.Shared.Overlays.Switchable; | ||
using Robust.Client.Graphics; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Overlays.Switchable; | ||
|
||
public sealed class BaseSwitchableOverlay<TComp> : Overlay where TComp : SwitchableOverlayComponent | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
|
||
public override bool RequestScreenTexture => true; | ||
public override OverlaySpace Space => OverlaySpace.WorldSpace; | ||
|
||
private readonly ShaderInstance _shader; | ||
|
||
public TComp? Comp = null; | ||
|
||
public bool IsActive = true; | ||
|
||
public BaseSwitchableOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
_shader = _prototype.Index<ShaderPrototype>("NightVision").InstanceUnique(); | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (ScreenTexture is null || Comp is null || !IsActive) | ||
return; | ||
|
||
_shader.SetParameter("SCREEN_TEXTURE", ScreenTexture); | ||
_shader.SetParameter("tint", Comp.Tint); | ||
_shader.SetParameter("luminance_threshold", Comp.Strength); | ||
_shader.SetParameter("noise_amount", Comp.Noise); | ||
|
||
var worldHandle = args.WorldHandle; | ||
|
||
var accumulator = Math.Clamp(Comp.PulseAccumulator, 0f, Comp.PulseTime); | ||
var alpha = Comp.PulseTime <= 0f ? 1f : float.Lerp(1f, 0f, accumulator / Comp.PulseTime); | ||
|
||
worldHandle.SetTransform(Matrix3x2.Identity); | ||
worldHandle.UseShader(_shader); | ||
worldHandle.DrawRect(args.WorldBounds, Comp.Color.WithAlpha(alpha)); | ||
worldHandle.UseShader(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using Content.Shared.Inventory.Events; | ||
using Content.Shared.Overlays.Switchable; | ||
using Robust.Client.Graphics; | ||
|
||
namespace Content.Client.Overlays.Switchable; | ||
|
||
public sealed class NightVisionSystem : EquipmentHudSystem<NightVisionComponent> | ||
{ | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
[Dependency] private readonly ILightManager _lightManager = default!; | ||
|
||
private BaseSwitchableOverlay<NightVisionComponent> _overlay = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<NightVisionComponent, SwitchableOverlayToggledEvent>(OnToggle); | ||
|
||
_overlay = new BaseSwitchableOverlay<NightVisionComponent>(); | ||
} | ||
|
||
private void OnToggle(Entity<NightVisionComponent> ent, ref SwitchableOverlayToggledEvent args) | ||
{ | ||
RefreshOverlay(args.User); | ||
} | ||
|
||
protected override void UpdateInternal(RefreshEquipmentHudEvent<NightVisionComponent> args) | ||
{ | ||
base.UpdateInternal(args); | ||
|
||
var active = false; | ||
NightVisionComponent? nvComp = null; | ||
foreach (var comp in args.Components) | ||
{ | ||
if (comp.IsActive || comp.PulseTime > 0f && comp.PulseAccumulator < comp.PulseTime) | ||
active = true; | ||
else | ||
continue; | ||
|
||
if (comp.DrawOverlay) | ||
{ | ||
if (nvComp == null) | ||
nvComp = comp; | ||
else if (nvComp.PulseTime > 0f && comp.PulseTime <= 0f) | ||
nvComp = comp; | ||
} | ||
|
||
if (active && nvComp is { PulseTime: <= 0 }) | ||
break; | ||
} | ||
|
||
UpdateNightVision(active); | ||
UpdateOverlay(nvComp); | ||
} | ||
|
||
protected override void DeactivateInternal() | ||
{ | ||
base.DeactivateInternal(); | ||
|
||
UpdateNightVision(false); | ||
UpdateOverlay(null); | ||
} | ||
|
||
private void UpdateNightVision(bool active) | ||
{ | ||
_lightManager.DrawLighting = !active; | ||
} | ||
|
||
private void UpdateOverlay(NightVisionComponent? nvComp) | ||
{ | ||
_overlay.Comp = nvComp; | ||
|
||
switch (nvComp) | ||
{ | ||
case not null when !_overlayMan.HasOverlay<BaseSwitchableOverlay<NightVisionComponent>>(): | ||
_overlayMan.AddOverlay(_overlay); | ||
break; | ||
case null: | ||
_overlayMan.RemoveOverlay(_overlay); | ||
break; | ||
} | ||
|
||
if (_overlayMan.TryGetOverlay<BaseSwitchableOverlay<ThermalVisionComponent>>(out var overlay)) | ||
overlay.IsActive = nvComp == null; | ||
} | ||
} |
Oops, something went wrong.