Skip to content

Commit

Permalink
Merge branch 'master' into shadekin-new
Browse files Browse the repository at this point in the history
  • Loading branch information
FaDeOkno authored Aug 5, 2024
2 parents 2202ba6 + 5d84f93 commit a890906
Show file tree
Hide file tree
Showing 192 changed files with 7,009 additions and 29 deletions.
46 changes: 46 additions & 0 deletions Content.Client/ADT/Overlays/Shaders/MonochromacyOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Simple Station

using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Content.Shared.ADT.Traits;
using Matrix3x2 = System.Numerics.Matrix3x2;

namespace Content.Client.ADT.Overlays
{
public sealed partial class MonochromacyOverlay : Overlay
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] IEntityManager _entityManager = default!;


public override bool RequestScreenTexture => true;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _greyscaleShader;

public MonochromacyOverlay()
{
IoCManager.InjectDependencies(this);
_greyscaleShader = _prototypeManager.Index<ShaderPrototype>("GreyscaleFullscreen").InstanceUnique();
}

protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture == null) return;
if (_playerManager.LocalPlayer?.ControlledEntity is not { Valid: true } player) return;
if (!_entityManager.HasComponent<MonochromacyComponent>(player)) return;

_greyscaleShader?.SetParameter("SCREEN_TEXTURE", ScreenTexture);


var worldHandle = args.WorldHandle;
var viewport = args.WorldBounds;
worldHandle.SetTransform(Matrix3x2.Identity);
worldHandle.UseShader(_greyscaleShader);
worldHandle.DrawRect(viewport, Color.White);
worldHandle.UseShader(null);
}
}
}
93 changes: 93 additions & 0 deletions Content.Client/ADT/Overlays/Shaders/StaticOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
using Content.Shared.ADT.Silicon.Components;
using Content.Shared.ADT.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.ADT.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, SharedSeeingStaticSystem.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);
}
}
56 changes: 56 additions & 0 deletions Content.Client/ADT/Overlays/Systems/MonochromacySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Simple Station

using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Network;
using Content.Shared.ADT.Traits;
using Robust.Shared.Player;

namespace Content.Client.ADT.Overlays;
public sealed class MonochromacySystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;

private MonochromacyOverlay _overlay = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<MonochromacyComponent, ComponentStartup>(OnMonochromacyStartup);
SubscribeLocalEvent<MonochromacyComponent, ComponentShutdown>(OnMonochromacyShutdown);

SubscribeLocalEvent<MonochromacyComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<MonochromacyComponent, PlayerDetachedEvent>(OnPlayerDetached);

_overlay = new();
}

private void OnMonochromacyStartup(EntityUid uid, MonochromacyComponent component, ComponentStartup args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
_overlayMan.AddOverlay(_overlay);
}

private void OnMonochromacyShutdown(EntityUid uid, MonochromacyComponent component, ComponentShutdown args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
{
_overlayMan.RemoveOverlay(_overlay);
}
}

private void OnPlayerAttached(EntityUid uid, MonochromacyComponent component, PlayerAttachedEvent args)
{
_overlayMan.AddOverlay(_overlay);
}

private void OnPlayerDetached(EntityUid uid, MonochromacyComponent component, PlayerDetachedEvent args)
{
_overlayMan.RemoveOverlay(_overlay);
}
}
57 changes: 57 additions & 0 deletions Content.Client/ADT/Overlays/Systems/SeeingStaticSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Content.Client.ADT.Overlays.Shaders;
using Content.Shared.ADT.Silicon.Components;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;

namespace Content.Client.ADT.Overlays;

/// <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, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<SeeingStaticComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

_overlay = new();
}

private void OnPlayerAttached(EntityUid uid, SeeingStaticComponent component, LocalPlayerAttachedEvent args)
{
_overlayMan.AddOverlay(_overlay);
}

private void OnPlayerDetached(EntityUid uid, SeeingStaticComponent component, LocalPlayerDetachedEvent 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);
}
}
}
12 changes: 12 additions & 0 deletions Content.Server/ADT/Damage/Components/DamageOnTriggerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Content.Shared.Damage;

namespace Content.Server.Damage.Components;

[RegisterComponent]
public sealed partial class DamageOnTriggerComponent : Component
{
[DataField("ignoreResistances")] public bool IgnoreResistances;

[DataField("damage", required: true)]
public DamageSpecifier Damage = default!;
}
26 changes: 26 additions & 0 deletions Content.Server/ADT/Damage/Systems/DamageOnTriggerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Simple Station

using Content.Server.Damage.Components;
using Content.Server.Explosion.EntitySystems;
using Content.Shared.Damage;
using Content.Shared.StepTrigger.Systems;

namespace Content.Server.Damage.Systems
{
// System for damage that occurs on specific trigger, towards the entity..
public sealed class DamageOnTriggerSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageableSystem = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DamageOnTriggerComponent, TriggerEvent>(DamageOnTrigger);
}

private void DamageOnTrigger(EntityUid uid, DamageOnTriggerComponent component, TriggerEvent args)
{
_damageableSystem.TryChangeDamage(uid, component.Damage, component.IgnoreResistances);
}
}
}
33 changes: 33 additions & 0 deletions Content.Server/ADT/Power/Components/BatteryDrinkerComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Simple Station

namespace Content.Server.ADT.Power;

[RegisterComponent]
public sealed partial class BatteryDrinkerComponent : Component
{
/// <summary>
/// Is this drinker allowed to drink batteries not tagged as <see cref="BatteryDrinkSource"/>?
/// </summary>
[DataField("drinkAll"), ViewVariables(VVAccess.ReadWrite)]
public bool DrinkAll = false;

/// <summary>
/// How long it takes to drink from a battery, in seconds.
/// Is multiplied by the source.
/// </summary>
[DataField("drinkSpeed"), ViewVariables(VVAccess.ReadWrite)]
public float DrinkSpeed = 1.5f;

/// <summary>
/// The multiplier for the amount of power to attempt to drink.
/// Default amount is 1000
/// </summary>
[DataField("drinkMultiplier"), ViewVariables(VVAccess.ReadWrite)]
public float DrinkMultiplier = 5f;

/// <summary>
/// The multiplier for how long it takes to drink a non-source battery, if <see cref="DrinkAll"/> is true.
/// </summary>
[DataField("drinkAllMultiplier"), ViewVariables(VVAccess.ReadWrite)]
public float DrinkAllMultiplier = 2.5f;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Simple Station

using System.ComponentModel.DataAnnotations;
using Robust.Shared.Audio;
using Content.Server.Sound.Components;

namespace Content.Server.ADT.Silicon;

/// <summary>
/// Applies a <see cref="SpamEmitSoundComponent"/> to a Silicon when its battery is drained, and removes it when it's not.
/// </summary>
[RegisterComponent]
public sealed partial class SiliconEmitSoundOnDrainedComponent : Component
{
[DataField("sound"), Required]
public SoundSpecifier Sound = default!;

[DataField("interval")]
public float Interval = 8f;

[DataField("playChance")]
public float PlayChance = 1f;

[DataField("popUp")]
public string? PopUp;
}
Loading

0 comments on commit a890906

Please sign in to comment.