Skip to content

Commit

Permalink
rev
Browse files Browse the repository at this point in the history
  • Loading branch information
21Melkuu committed Feb 27, 2025
1 parent 828b39b commit b33b2c0
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 33 deletions.
5 changes: 2 additions & 3 deletions Content.Client/SS220/SmartGasMask/SmartGasMaskMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ private void RefreshUI()

foreach (var smartProtoString in comp.SelectablePrototypes)
{
if (!_prototypeManager.TryIndex<AlertSmartGasMaskPrototype>(smartProtoString, out var alertProto))
if (!_prototypeManager.TryIndex(smartProtoString, out var alertProto))
continue;

var button = new SmartGasMaskMenuButton()
{
StyleClasses = { "RadialMenuButton" },
SetSize = new Vector2(64, 64),
ToolTip = Loc.GetString(alertProto.Name),
};
Expand Down Expand Up @@ -72,7 +71,7 @@ private void RefreshUI()
}
}

public sealed class SmartGasMaskMenuButton : RadialMenuTextureButton
public sealed class SmartGasMaskMenuButton : RadialMenuTextureButtonWithSector
{
}

60 changes: 45 additions & 15 deletions Content.Server/SS220/SmartGasMask/SmartGasMaskSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
using Content.Shared.Clothing;
using Content.Shared.SS220.SmartGasMask;
using Content.Shared.SS220.SmartGasMask.Events;
using Robust.Shared.Audio.Systems;
using Content.Shared.SS220.SmartGasMask.Prototype;
using Robust.Server.Audio;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Timer = Robust.Shared.Timing.Timer;

namespace Content.Server.SS220.SmartGasMask;

Expand All @@ -19,13 +21,14 @@ namespace Content.Server.SS220.SmartGasMask;
public sealed class SmartGasMaskSystem : EntitySystem
{
[Dependency] private readonly SharedUserInterfaceSystem _userInterface = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly NavMapSystem _navMap = default!;
[Dependency] private readonly ChatSystem _chatSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<SmartGasMaskComponent, SmartGasMaskOpenEvent>(OnAction);
Expand Down Expand Up @@ -56,30 +59,57 @@ private void OnAction(Entity<SmartGasMaskComponent> ent, ref SmartGasMaskOpenEve

private void OnChoose(Entity<SmartGasMaskComponent> ent, ref SmartGasMaskMessage args)
{
var curTime = _timing.CurTime;

if (args.ProtoId == ent.Comp.SelectablePrototypes[0] && !ent.Comp.OnCdHalt) //AlertSmartGasMaskHalt
if (!_prototypeManager.TryIndex(args.ProtoId, out var alertProto))
return;

if (alertProto.NotificationType == NotificationType.Halt && !ent.Comp.HaltInRecharge) //AlertSmartGasMaskHalt
{
ent.Comp.OnCdHalt = true;
ent.Comp.HaltInRecharge = true;

ent.Comp.NextChargeTimeHalt = ent.Comp.WaitingForChargeHalt + curTime;

_audio.PlayPvs(alertProto.AlertSound, ent.Owner);

var haltMes = Loc.GetString(_random.Pick(ent.Comp.LocIdHaltMessage));
if(alertProto.LocIdMessage.Count == 0)
return;

_chatSystem.TrySendInGameICMessage(args.Actor, haltMes, InGameICChatType.Speak, ChatTransmitRange.Normal, checkRadioPrefix: false, ignoreActionBlocker: true);
_audio.PlayPvs(ent.Comp.HaltSound, ent.Owner);
var haltMessage = Loc.GetString(_random.Pick(alertProto.LocIdMessage));

Timer.Spawn(ent.Comp.CdTimeHalt, () => ent.Comp.OnCdHalt = false);
_chatSystem.TrySendInGameICMessage(args.Actor, haltMessage, InGameICChatType.Speak, ChatTransmitRange.Normal, checkRadioPrefix: false, ignoreActionBlocker: true);
}

if (args.ProtoId == ent.Comp.SelectablePrototypes[1] && !ent.Comp.OnCdSupp) //AlertSmartGasMaskSupport
if (alertProto.NotificationType == NotificationType.Support && !ent.Comp.SupportInRecharge) //AlertSmartGasMaskSupport
{
ent.Comp.OnCdSupp = true;
ent.Comp.SupportInRecharge = true;

ent.Comp.NextChargeTimeSupport = ent.Comp.WaitingForChargeSupport + curTime;

if(alertProto.LocIdMessage.Count == 0)
return;

var currentHelpMessage = _random.Pick(alertProto.LocIdMessage);
var posText = FormattedMessage.RemoveMarkupOrThrow(_navMap.GetNearestBeaconString(ent.Owner));
var helpMess = Loc.GetString(ent.Comp.LocIdSupportMessage, ("user", args.Actor), ("position", posText));
var helpMessage = Loc.GetString(currentHelpMessage, ("user", args.Actor), ("position", posText));

//The message is sent with a prefix ".о". This is necessary so that everyone understands that reinforcements have been called in
_chatSystem.TrySendInGameICMessage(args.Actor, helpMess, InGameICChatType.Whisper, ChatTransmitRange.Normal, checkRadioPrefix: true, ignoreActionBlocker: true);
_chatSystem.TrySendInGameICMessage(args.Actor, helpMessage, InGameICChatType.Whisper, ChatTransmitRange.Normal, checkRadioPrefix: true, ignoreActionBlocker: true);
}
}

public override void Update(float frameTime)
{
var query = EntityQueryEnumerator<SmartGasMaskComponent>();
var curTime = _timing.CurTime;

while (query.MoveNext(out var smartGasMaskComp))
{
if (smartGasMaskComp.HaltInRecharge && curTime >= smartGasMaskComp.NextChargeTimeHalt)
smartGasMaskComp.HaltInRecharge = false;

Timer.Spawn(ent.Comp.CdTimeSupp, () => ent.Comp.OnCdSupp = false);
if (smartGasMaskComp.SupportInRecharge && curTime >= smartGasMaskComp.NextChargeTimeSupport)
smartGasMaskComp.SupportInRecharge = false;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using Robust.Shared.Audio;
using Robust.Shared.Prototypes;

namespace Content.Shared.SS220.SmartGasMask.Prototype;
Expand All @@ -18,4 +20,22 @@ public sealed partial class AlertSmartGasMaskPrototype : IPrototype

[DataField(required: true)]
public EntProtoId IconPrototype;

//To understand what exactly the player chose
[DataField(required: true)]
public NotificationType NotificationType;

//Sound that will be played when selecting an action
[DataField, ViewVariables]
public SoundSpecifier AlertSound { get; set; } = new SoundPathSpecifier("/Audio/SS220/Items/SmartGasMask/sound_voice_complionator_halt.ogg");

//Message that will be played when selecting an action
[DataField]
public List<LocId> LocIdMessage = new List<LocId>() { };
}

public enum NotificationType : byte
{
Halt,
Support,
}
22 changes: 8 additions & 14 deletions Content.Shared/SS220/SmartGasMask/SmartGasMaskComponent.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
using Content.Shared.Actions;
using Content.Shared.SS220.SmartGasMask.Prototype;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;

namespace Content.Shared.SS220.SmartGasMask;
Expand All @@ -15,29 +14,24 @@ public sealed partial class SmartGasMaskComponent : Component
[DataField]
public List<ProtoId<AlertSmartGasMaskPrototype>> SelectablePrototypes = [];

[DataField, ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier HaltSound = new SoundPathSpecifier("/Audio/SS220/Items/SmartGasMask/sound_voice_complionator_halt.ogg");

[DataField]
public LocId LocIdSupportMessage = "smartgasmask-support-message";
public EntProtoId SmartGasMaskAction = "ActionSmartGasMask";

[DataField]
public List <LocId> LocIdHaltMessage = new List<LocId>() {"smartgasmask-halt-message-1", "smartgasmask-halt-message-2", "smartgasmask-halt-message-3"};
[DataField] public EntityUid? SmartGasMaskActionEntity;

[DataField]
public TimeSpan CdTimeHalt = TimeSpan.FromSeconds(10); //prevents spam
public TimeSpan WaitingForChargeHalt { get; set; } = TimeSpan.FromSeconds(10);

[DataField]
public TimeSpan CdTimeSupp = TimeSpan.FromSeconds(60); //prevents spam and adds a little balance
public TimeSpan NextChargeTimeHalt = TimeSpan.Zero;

[DataField]
public EntProtoId SmartGasMaskAction = "ActionSmartGasMask";
public TimeSpan WaitingForChargeSupport { get; set; } = TimeSpan.FromSeconds(60);

[DataField] public EntityUid? SmartGasMaskActionEntity;
public TimeSpan NextChargeTimeSupport = TimeSpan.Zero;

public bool OnCdHalt = false;
public bool HaltInRecharge = false;

public bool OnCdSupp = false;
public bool SupportInRecharge = false;
}

public sealed partial class SmartGasMaskOpenEvent : InstantActionEvent;
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
id: AlertSmartGasMaskSupport
name: alert-smart-gas-mask-support
iconPrototype: ClothingMaskGasSecurity
notificationType: Support
locIdMessage: ["smartgasmask-support-message"]

- type: alertSmartGasMask
id: AlertSmartGasMaskHalt
name: alert-smart-gas-mask-halt
iconPrototype: ClothingMaskGasSecurity
iconPrototype: ClothingMaskGasSecurity
notificationType: Halt
alertSound: /Audio/SS220/Items/SmartGasMask/sound_voice_complionator_halt.ogg
locIdMessage: ["smartgasmask-halt-message-1", "smartgasmask-halt-message-2", "smartgasmask-halt-message-3"]

0 comments on commit b33b2c0

Please sign in to comment.