-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into holograms
- Loading branch information
Showing
126 changed files
with
1,269 additions
and
703 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
92 changes: 92 additions & 0 deletions
92
Content.Client/SimpleStation14/Overlays/Shaders/StaticOverlay.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,92 @@ | ||
using Content.Shared.SimpleStation14.Silicon.Components; | ||
using Content.Shared.SimpleStation14.Silicon.Systems; | ||
using Content.Shared.StatusEffect; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Shared.Enums; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.SimpleStation14.Overlays.Shaders; | ||
|
||
public sealed class StaticOverlay : Overlay | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
||
public override OverlaySpace Space => OverlaySpace.WorldSpace; | ||
public override bool RequestScreenTexture => true; | ||
private readonly ShaderInstance _staticShader; | ||
|
||
private (TimeSpan, TimeSpan)? _time; | ||
private float? _fullTimeLeft; | ||
private float? _curTimeLeft; | ||
|
||
public float MixAmount = 0; | ||
|
||
public StaticOverlay() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
_staticShader = _prototypeManager.Index<ShaderPrototype>("SeeingStatic").InstanceUnique(); | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; | ||
|
||
if (playerEntity == null) | ||
return; | ||
|
||
if (!_entityManager.TryGetComponent<SeeingStaticComponent>(playerEntity, out var staticComp) | ||
|| !_entityManager.TryGetComponent<StatusEffectsComponent>(playerEntity, out var statusComp)) | ||
return; | ||
|
||
var status = _entityManager.EntitySysManager.GetEntitySystem<StatusEffectsSystem>(); | ||
|
||
if (playerEntity == null || statusComp == null) | ||
return; | ||
|
||
if (!status.TryGetTime(playerEntity.Value, SeeingStaticSystem.StaticKey, out var timeTemp, statusComp)) | ||
return; | ||
|
||
if (_time != timeTemp) // Resets the shader if the times change. This should factor in wheather it's a reset, or a increase, but I have a lot of cough syrup in me, so TODO. | ||
{ | ||
_time = timeTemp; | ||
_fullTimeLeft = null; | ||
_curTimeLeft = null; | ||
} | ||
|
||
_fullTimeLeft ??= (float) (timeTemp.Value.Item2 - timeTemp.Value.Item1).TotalSeconds; | ||
_curTimeLeft ??= _fullTimeLeft; | ||
|
||
_curTimeLeft -= args.DeltaSeconds; | ||
|
||
MixAmount = Math.Clamp(_curTimeLeft.Value / _fullTimeLeft.Value * staticComp.Multiplier, 0, 1); | ||
} | ||
|
||
protected override bool BeforeDraw(in OverlayDrawArgs args) | ||
{ | ||
if (!_entityManager.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out EyeComponent? eyeComp)) | ||
return false; | ||
|
||
if (args.Viewport.Eye != eyeComp.Eye) | ||
return false; | ||
|
||
return MixAmount > 0; | ||
} | ||
|
||
protected override void Draw(in OverlayDrawArgs args) | ||
{ | ||
if (ScreenTexture == null) | ||
return; | ||
|
||
var handle = args.WorldHandle; | ||
_staticShader.SetParameter("SCREEN_TEXTURE", ScreenTexture); | ||
_staticShader.SetParameter("mixAmount", MixAmount); | ||
handle.UseShader(_staticShader); | ||
handle.DrawRect(args.WorldBounds, Color.White); | ||
handle.UseShader(null); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
Content.Client/SimpleStation14/Silicon/Systems/SeeingStaticSystem.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,57 @@ | ||
using Content.Client.SimpleStation14.Overlays.Shaders; | ||
using Content.Shared.SimpleStation14.Silicon.Components; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
|
||
namespace Content.Client.SimpleStation14.Silicon.Systems; | ||
|
||
/// <summary> | ||
/// System to handle the SeeingStatic overlay. | ||
/// </summary> | ||
public sealed class SeeingStaticSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPlayerManager _player = default!; | ||
[Dependency] private readonly IOverlayManager _overlayMan = default!; | ||
|
||
private StaticOverlay _overlay = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SeeingStaticComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<SeeingStaticComponent, ComponentShutdown>(OnShutdown); | ||
|
||
SubscribeLocalEvent<SeeingStaticComponent, PlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<SeeingStaticComponent, PlayerDetachedEvent>(OnPlayerDetached); | ||
|
||
_overlay = new(); | ||
} | ||
|
||
private void OnPlayerAttached(EntityUid uid, SeeingStaticComponent component, PlayerAttachedEvent args) | ||
{ | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void OnPlayerDetached(EntityUid uid, SeeingStaticComponent component, PlayerDetachedEvent args) | ||
{ | ||
_overlay.MixAmount = 0; | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
|
||
private void OnInit(EntityUid uid, SeeingStaticComponent component, ComponentInit args) | ||
{ | ||
if (_player.LocalPlayer?.ControlledEntity == uid) | ||
_overlayMan.AddOverlay(_overlay); | ||
} | ||
|
||
private void OnShutdown(EntityUid uid, SeeingStaticComponent component, ComponentShutdown args) | ||
{ | ||
if (_player.LocalPlayer?.ControlledEntity == uid) | ||
{ | ||
_overlay.MixAmount = 0; | ||
_overlayMan.RemoveOverlay(_overlay); | ||
} | ||
} | ||
} |
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
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
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
68 changes: 68 additions & 0 deletions
68
Content.Server/SimpleStation14/Silicon/Systems/SiliconEmpSystem.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,68 @@ | ||
using Content.Server.Emp; | ||
using Content.Server.Speech.Muting; | ||
using Content.Server.Stunnable; | ||
using Content.Shared.CombatMode.Pacification; | ||
using Content.Shared.Eye.Blinding.Components; | ||
using Content.Shared.Eye.Blinding.Systems; | ||
using Content.Shared.SimpleStation14.Silicon.Components; | ||
using Content.Shared.SimpleStation14.Silicon.Systems; | ||
using Content.Shared.Speech.EntitySystems; | ||
using Content.Shared.StatusEffect; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Server.SimpleStation14.Silicon.Systems; | ||
|
||
public sealed class SiliconEmpSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly StatusEffectsSystem _status = default!; | ||
[Dependency] private readonly StunSystem _stun = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly SharedStutteringSystem _stuttering = default!; | ||
[Dependency] private readonly SharedSlurredSystem _slurredSystem = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SiliconComponent, EmpPulseEvent>(OnEmpPulse); | ||
} | ||
|
||
private void OnEmpPulse(EntityUid uid, SiliconComponent component, ref EmpPulseEvent args) | ||
{ | ||
args.EnergyConsumption *= 0.25f; // EMPs drain a lot of freakin power. | ||
|
||
if (!TryComp<StatusEffectsComponent>(uid, out var statusComp)) | ||
return; | ||
|
||
args.Affected = true; | ||
args.Disabled = true; | ||
|
||
var duration = args.Duration / 1.5; // We divide the duration since EMPs are balanced for structures, not people. | ||
|
||
if (duration.TotalSeconds * 0.25 >= 3) // If the EMP blast is strong enough, we stun them. | ||
// This is mostly to prevent flickering in/out of being stunned. We also cap how long they can be stunned for. | ||
{ | ||
_stun.TryParalyze(uid, TimeSpan.FromSeconds(Math.Min(duration.TotalSeconds * 0.25f, 15f)), true, statusComp); | ||
} | ||
|
||
_stun.TrySlowdown(uid, duration, true, _random.NextFloat(0.50f, 0.70f), _random.NextFloat(0.35f, 0.70f), statusComp); | ||
|
||
_status.TryAddStatusEffect<SeeingStaticComponent>(uid, SeeingStaticSystem.StaticKey, duration, true, statusComp); | ||
|
||
if (_random.Prob(0.60f)) | ||
_stuttering.DoStutter(uid, duration * 2, false, statusComp); | ||
else if (_random.Prob(0.80f)) | ||
_slurredSystem.DoSlur(uid, duration * 2, statusComp); | ||
|
||
if (_random.Prob(0.02f)) | ||
_status.TryAddStatusEffect<MutedComponent>(uid, "Muted", duration * 0.5, true, statusComp); | ||
|
||
if (_random.Prob(0.02f)) | ||
_status.TryAddStatusEffect<TemporaryBlindnessComponent>(uid, TemporaryBlindnessSystem.BlindingStatusEffect, duration * 0.5, true, statusComp); | ||
|
||
if (_random.Prob(0.08f)) | ||
_status.TryAddStatusEffect<PacifiedComponent>(uid, "Pacified", duration * 0.5, true, statusComp); | ||
|
||
args.EnergyConsumption = 0; | ||
} | ||
} |
Oops, something went wrong.