Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ивент-контент (в процессе) #425

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions Content.Client/ADT/AnomStaticOverlay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using Content.Shared.StatusEffect;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Shared.Anomaly.Effects;
using Content.Shared.ADT.Components;

namespace Content.Client.ADT.Overlays.Shaders;

public sealed class AnomStaticOverlay : 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 AnomStaticOverlay()
{
IoCManager.InjectDependencies(this);
_staticShader = _prototypeManager.Index<ShaderPrototype>("AnomStatic").InstanceUnique();
}

protected override void FrameUpdate(FrameEventArgs args)
{
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;

if (playerEntity == null)
return;

if (!_entityManager.TryGetComponent<AnomStaticComponent>(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, AnomStaticSystem.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 Content.Client/ADT/AnomStaticSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Shared.Player;
using Content.Shared.ADT.Components;
using Content.Client.ADT.Overlays.Shaders;

namespace Content.Client.ADT.Systems;

/// <summary>
/// System to handle the SeeingStatic overlay.
/// </summary>
public sealed class AnomStaticSystem : EntitySystem
{
[Dependency] private readonly IPlayerManager _player = default!;
[Dependency] private readonly IOverlayManager _overlayMan = default!;

private AnomStaticOverlay _overlay = default!;

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

SubscribeLocalEvent<AnomStaticComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<AnomStaticComponent, ComponentShutdown>(OnShutdown);

SubscribeLocalEvent<AnomStaticComponent, LocalPlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<AnomStaticComponent, LocalPlayerDetachedEvent>(OnPlayerDetached);

_overlay = new();
}

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

private void OnPlayerDetached(EntityUid uid, AnomStaticComponent component, LocalPlayerDetachedEvent args)
{
_overlay.MixAmount = 0;
_overlayMan.RemoveOverlay(_overlay);
}

private void OnInit(EntityUid uid, AnomStaticComponent component, ComponentInit args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
_overlayMan.AddOverlay(_overlay);
}

private void OnShutdown(EntityUid uid, AnomStaticComponent component, ComponentShutdown args)
{
if (_player.LocalPlayer?.ControlledEntity == uid)
{
_overlay.MixAmount = 0;
_overlayMan.RemoveOverlay(_overlay);
}
}
}
106 changes: 106 additions & 0 deletions Content.Server/Anomaly/Effects/OldTVAnomalySystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Anomaly.Components;
using Content.Shared.Anomaly.Effects.Components;
using Content.Shared.Mind;
using Robust.Shared.Map;
using Content.Server.Stunnable;
using Content.Shared.SimpleStation14.Silicon.Components;
using Content.Shared.SimpleStation14.Silicon.Systems;
using Content.Shared.StatusEffect;
using Robust.Shared.Random;
using Content.Server.Electrocution;
using Robust.Shared.Timing;
using Content.Shared.ADT.Components;
using Content.Shared.Anomaly.Effects;

namespace Content.Server.Anomaly.Effects;

/// <summary>
/// This handles <see cref="PyroclasticAnomalyComponent"/> and the events from <seealso cref="AnomalySystem"/>
/// </summary>

public sealed class OldTVAnomalySystem : EntitySystem
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly FlammableSystem _flammable = default!;
[Dependency] private readonly StatusEffectsSystem _status = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly ElectrocutionSystem _electrocution = default!;


/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<OldTVAnomalyComponent, TVAnomalyPulseEvent>(OnPulse);
SubscribeLocalEvent<OldTVAnomalyComponent, TVAnomalySupercriticalEvent>(OnSupercritical);
}
public void StunNearby(EntityUid uid, EntityCoordinates coordinates, TimeSpan time, float severity, float radius)
{
var players = new HashSet<Entity<MindComponent>>();
_lookup.GetEntitiesInRange(coordinates, radius, players);

foreach (var player in players)
{
if (!TryComp<StatusEffectsComponent>(uid, out var statusComp))
return;

var duration = TimeSpan.FromSeconds(10);
_stun.TrySlowdown(player, duration, true, _random.NextFloat(0.50f, 0.70f), _random.NextFloat(0.35f, 0.70f), statusComp);
_status.TryAddStatusEffect<SeeingStaticComponent>(player, SeeingStaticSystem.StaticKey, duration, true, statusComp);
}
}


private void OnPulse(EntityUid uid, OldTVAnomalyComponent component, ref TVAnomalyPulseEvent args)
{
var duration = component.MaxPulseStaticDuration;

var xform = Transform(uid);
var staticRadius = component.MaximumStaticRadius * args.Stability;
StunNearby(uid, xform.Coordinates, duration, args.Severity, staticRadius);
}

private void OnSupercritical(EntityUid uid, OldTVAnomalyComponent component, ref TVAnomalySupercriticalEvent args)
{
var duration = component.MaxSupercritStaticDuration;

var xform = Transform(uid);
StunNearby(uid, xform.Coordinates, duration, 1, component.CritStaticRadius);
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<OldTVAnomalyComponent, AnomalyComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var stat, out var anom, out var xform))
{
if (_timing.CurTime < stat.NextSecond)
continue;
stat.NextSecond = _timing.CurTime + TimeSpan.FromSeconds(0.5);

if (!_random.Prob(stat.PassiveStaticChance * anom.Stability))
continue;

var range = stat.MaxStaticRange * anom.Stability * 4;
var duration = stat.MaxPassiveStaticDuration * anom.Severity * 1;

foreach (var (ent, comp) in _lookup.GetEntitiesInRange<StatusEffectsComponent>(xform.MapPosition, range))
{
_status.TryAddStatusEffect<AnomStaticComponent>(ent, AnomStaticSystem.StaticKey, duration, true, comp);
}
var closerange = stat.MaxStaticRange * anom.Stability * 2;
var closeduration = stat.MaxPassiveStaticDuration * anom.Severity * 3;

foreach (var (ent, comp) in _lookup.GetEntitiesInRange<StatusEffectsComponent>(xform.MapPosition, closerange))
{
_status.TryAddStatusEffect<AnomStaticComponent>(ent, AnomStaticSystem.StaticKey, closeduration, true, comp);
}

}
}


}
18 changes: 18 additions & 0 deletions Content.Shared/ADT/AnomalyStatic/AnomStaticComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Robust.Shared.GameStates;

namespace Content.Shared.ADT.Components;

/// <summary>
/// Exists for use as a status effect. Adds a tv static shader to the client.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class AnomStaticComponent : Component
{
/// <summary>
/// The multiplier applied to the effect.
/// Setting this to 0.5 will halve the effect throughout its entire duration, meaning it will never be fully opaque.
/// Setting this to 2 will double the effect throughout its entire duration, meaning it will be fully opaque for twice as long.
/// </summary>
[AutoNetworkedField]
public float Multiplier = 1f;
}
1 change: 1 addition & 0 deletions Content.Shared/Anomaly/Components/AnomalyComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,4 @@ public sealed partial class AnomalyComponent : Component
/// <param name="Anomaly">The anomaly being changed</param>
[ByRefEvent]
public readonly record struct AnomalyHealthChangedEvent(EntityUid Anomaly, float Health);

6 changes: 6 additions & 0 deletions Content.Shared/Anomaly/Effects/AnomalyStaticSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Content.Shared.Anomaly.Effects;

public sealed class AnomStaticSystem : EntitySystem
{
public const string StaticKey = "AnomStatic";
}
46 changes: 46 additions & 0 deletions Content.Shared/Anomaly/Effects/Components/OldTVAnomalyComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;

namespace Content.Shared.Anomaly.Effects.Components;

[RegisterComponent]
public sealed partial class OldTVAnomalyComponent : Component
{
/// <summary>
/// The maximum distance from which you can be blind by the anomaly.
/// </summary>
[DataField("maximumStaticRadius")]
public float MaximumStaticRadius = 7f;

[DataField("supercriticalStaticRadius")]
public float CritStaticRadius = 20f;

[DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxStaticRange = 7f;

[DataField, ViewVariables(VVAccess.ReadWrite)]
public float MaxStaticDamage = 20f;

[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan MaxPassiveStaticDuration = TimeSpan.FromSeconds(4);

[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan MaxPulseStaticDuration = TimeSpan.FromSeconds(10);

[DataField, ViewVariables(VVAccess.ReadWrite)]
public TimeSpan MaxSupercritStaticDuration = TimeSpan.FromSeconds(20);

[DataField, ViewVariables(VVAccess.ReadWrite)]
public float PassiveStaticChance = 0.85f;

[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextSecond = TimeSpan.Zero;

}


[ByRefEvent]
public readonly record struct TVAnomalyPulseEvent(EntityUid Anomaly, float Stability, float Severity, TimeSpan Duration);

[ByRefEvent]
public readonly record struct TVAnomalySupercriticalEvent(EntityUid Anomaly, TimeSpan Duration);

8 changes: 4 additions & 4 deletions Content.Shared/Preferences/HumanoidCharacterProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ public void EnsureValid(string[] sponsorMarkings)
name = name.Trim();

var configManager = IoCManager.Resolve<IConfigurationManager>();
if (configManager.GetCVar(CCVars.RestrictedNames))
{
name = Regex.Replace(name, @"[^.А-Яа-яёЁ0-9' -]", string.Empty); // Corvax: Only cyrillic names
}
///if (configManager.GetCVar(CCVars.RestrictedNames))
///{
/// name = Regex.Replace(name, @"[^.А-Яа-яёЁ0-9' -]", string.Empty); // Corvax: Only cyrillic names
///}

if (configManager.GetCVar(CCVars.ICNameCase))
{
Expand Down
Binary file added Resources/Audio/ADT/TVAnom/tv-morse-tihoe.ogg
Binary file not shown.
Binary file added Resources/Audio/ADT/TVAnom/tv-morse.ogg
Binary file not shown.
32 changes: 32 additions & 0 deletions Resources/Locale/ru-RU/ADT/paper/doc-printer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -883,3 +883,35 @@ ent-ADTFormPrinterMachineCircuitboard = принтер документов (м

ent-PrinterDoc = Принтер документов
.desc = Уникальная разработка Nanotrasen со всеми основными формами.



doc-text-printer-redspace =
⠀[color=#E0D89A]░░██████████░░[/color]
⠀[color=#E0D89A]██░░░░░░░░░░██[/color] [head=3]Бланк документа[/head]
⠀[color=#E0D89A]██░░██░░██░░██[/color] [head=3]G16[/head]
⠀[color=#E0D89A]░██░░░░░░░░██░[/color] [bold]Complex TX5 RS-610 НИО-СВТ[/bold]
⠀[color=#E0D89A]░░░████████░░░[/color]
=============================================
ОТЧЁТ
=============================================
Время от начала смены и дата: 14.21.2416
Составитель документа: ░░░░░░░░░░
Должность составителя: ░░░░░░░░░░
Код уровня угрозы: Тритон
Причина установления кода: ░░░░░░░░░░
Активные угрозы: Неконтролируемый пространственный коллапс.
Потери среди экипажа: 100%
Текущая ситуация: ░░░░░░░░░░

Статус сканирования:
Результат 1:
Результат 2:
Результат 3:
Результат 4:
Результат 5:
=============================================
⠀[italic]Место для печатей[/italic]



2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/ADT/tv.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-ADTAnomalyTV = старинный телевизор
.desc = Может получится просто переключить канал на что-то получше?
Loading
Loading