-
Notifications
You must be signed in to change notification settings - Fork 6
Dreamer #294
base: master
Are you sure you want to change the base?
Dreamer #294
Changes from all commits
d9732c6
e8a9779
6eb3f5e
dd2f539
b8385ea
a7f0c23
442cafc
e943e95
cda9713
5871980
151a298
ccdb56f
e26aa11
96676ea
49845d0
d8650b7
ccbe005
a16e86d
b28bc52
883ecf4
4da83a4
0a6f7b1
fb4d219
f1a3985
6aa27e8
3161fc4
d6bceaa
430a60a
8d83b9a
2e36e6b
33c25c7
7bba975
78860e1
54b177b
7cb188a
b216759
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| using Content.Client.Audio; | ||
| using Content.Client.CombatMode; | ||
| using Content.Shared.CombatMode; | ||
| using Content.Shared.GameTicking; | ||
| using Robust.Client.Player; | ||
| using Robust.Client.ResourceManagement; | ||
| using Robust.Shared.Audio; | ||
| using Robust.Shared.Audio.Systems; | ||
| using Robust.Shared.Player; | ||
| using Robust.Shared.Prototypes; | ||
|
|
||
| namespace Content.Client._Lfwb; | ||
|
|
||
| public sealed class CombatMusic : EntitySystem | ||
| { | ||
| #region Values | ||
|
|
||
| private EntityUid? _combatMusicStream; | ||
|
|
||
| #endregion | ||
|
|
||
| #region Dependencies | ||
|
|
||
| [Dependency] private readonly SharedAudioSystem _audio = default!; | ||
| [Dependency] private readonly ContentAudioSystem _contentAudio = default!; | ||
| [Dependency] private readonly CombatModeSystem _combat = default!; | ||
| [Dependency] private readonly IResourceCache _resource = default!; | ||
| [Dependency] private readonly IPrototypeManager _proto = default!; | ||
| [Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
|
||
| #endregion | ||
|
|
||
| #region Event Handling | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| base.Initialize(); | ||
|
|
||
| PreloadTracks(); | ||
|
|
||
| SubscribeLocalEvent<CombatModeComponent, PlayerDetachedEvent>(OnPlayerDetached); | ||
|
|
||
| SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRestart); | ||
|
|
||
| _combat.LocalPlayerCombatModeUpdated += OnCombatModeUpdated; | ||
| } | ||
|
|
||
| public override void Shutdown() | ||
| { | ||
| base.Shutdown(); | ||
|
|
||
| _combat.LocalPlayerCombatModeUpdated -= OnCombatModeUpdated; | ||
|
|
||
| _audio.Stop(_combatMusicStream); | ||
| } | ||
|
|
||
| #endregion | ||
|
|
||
|
|
||
| #region Main Process | ||
|
|
||
| private void OnCombatModeUpdated(bool inCombatMode) | ||
| { | ||
| (inCombatMode ? (Action) StartCombatMusic : StopCombatMusic).Invoke(); | ||
| } | ||
|
|
||
| private void OnPlayerDetached(EntityUid uid, CombatModeComponent component, PlayerDetachedEvent args) | ||
| { | ||
| if (args.Player != _playerManager.LocalSession) | ||
| return; | ||
|
|
||
| StopCombatMusic(); | ||
| } | ||
|
|
||
| private void OnRestart(RoundRestartCleanupEvent args) | ||
| { | ||
| StopCombatMusic(); | ||
| } | ||
|
|
||
| #endregion | ||
|
|
||
|
|
||
| #region Helpers | ||
|
|
||
| private void PreloadTracks() | ||
| { | ||
| foreach (var audio in _proto.Index<SoundCollectionPrototype>("CombatMusic").PickFiles) | ||
| { | ||
| _resource.GetResource<AudioResource>(audio.ToString()); | ||
| } | ||
| } | ||
|
|
||
| private void StartCombatMusic() | ||
| { | ||
| var stream = _audio.PlayGlobal(new SoundCollectionSpecifier("CombatMusic"), Filter.Local(), false, AudioParams.Default.WithLoop(true).WithVolume(-4)); | ||
|
|
||
| if (!stream.HasValue) | ||
| return; | ||
|
|
||
| _combatMusicStream = stream.Value.Entity; | ||
| _contentAudio.FadeIn(_combatMusicStream, stream.Value.Component, 3f); | ||
| } | ||
|
|
||
| private void StopCombatMusic() | ||
| { | ||
| _contentAudio.FadeOut(_combatMusicStream); | ||
| _combatMusicStream = null; | ||
| } | ||
|
|
||
| #endregion | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Server.Player; | ||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Asynchronous; | ||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Configuration; | ||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Console; | ||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Network; | ||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Player; | ||||||||||||||||||||||||||||||||||||||||||||||||
| using Robust.Shared.Replays; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -58,6 +59,7 @@ internal sealed partial class ChatManager : IChatManager | |||||||||||||||||||||||||||||||||||||||||||||||
| [Dependency] private readonly IGameTiming _timing = default!; | ||||||||||||||||||||||||||||||||||||||||||||||||
| [Dependency] private readonly ReputationManager _repManager = default!; | ||||||||||||||||||||||||||||||||||||||||||||||||
| [Dependency] private readonly ITaskManager _taskManager = default!; | ||||||||||||||||||||||||||||||||||||||||||||||||
| [Dependency] private readonly IConsoleHost _consoleHost = default!; | ||||||||||||||||||||||||||||||||||||||||||||||||
| /// WD-EDIT | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -407,6 +409,18 @@ public void ChatMessageToOne(ChatChannel channel, string message, string wrapped | |||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| public void ChatMessageToManyButHueta(Filter filter, string message) | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (!filter.Recipients.Any()) | ||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| var clients = filter.Recipients.ToList(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| foreach (var client in clients) | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| _consoleHost.RemoteExecuteCommand(client, $"notice [font size=15][color=#890000]{message}[/color][/font]"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+412
to
+422
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Introduced new method - _consoleHost.RemoteExecuteCommand(client, $"notice [font size=15][color=#890000]{message}[/color][/font]");
+ // Ensure to sanitize the message or validate user permissions before executing commands.
+ _consoleHost.RemoteExecuteCommand(client, $"notice [font size=15][color=#890000]{Security.Escape(message)}[/color][/font]");Consider sanitizing the Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| public void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, IEnumerable<INetChannel> clients, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0, NetUserId? author = null) | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ChatMessageToMany(channel, message, wrappedMessage, source, hideChat, recordReplay, clients.ToList(), | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,8 @@ public interface IChatManager | |
| void ChatMessageToOne(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, | ||
| INetChannel client, Color? colorOverride = null, bool recordReplay = false, string? audioPath = null, float audioVolume = 0, NetUserId? author = null); | ||
|
|
||
| void ChatMessageToManyButHueta(Filter filter, string message); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider renaming
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ну так подскажи название человеку There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RavMorgan, considering the functionality of the method If you have any more specific functionalities or behaviors of this method that should be reflected in the name, please let me know! |
||
|
|
||
| void ChatMessageToMany(ChatChannel channel, string message, string wrappedMessage, EntityUid source, bool hideChat, bool recordReplay, | ||
| IEnumerable<INetChannel> clients, Color? colorOverride = null, string? audioPath = null, float audioVolume = 0, NetUserId? author = null); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ | |
| using Content.Server.Popups; | ||
| using Content.Server.PowerCell; | ||
| using Content.Server.Traits.Assorted; | ||
| using Content.Shared._Lfwb.Skills; | ||
| using Content.Shared._Lfwb.Stats; | ||
| using Content.Shared.Damage; | ||
| using Content.Shared.DoAfter; | ||
| using Content.Shared.Interaction; | ||
|
|
@@ -46,6 +48,8 @@ public sealed class DefibrillatorSystem : EntitySystem | |
| [Dependency] private readonly SharedAudioSystem _audio = default!; | ||
| [Dependency] private readonly UseDelaySystem _useDelay = default!; | ||
| [Dependency] private readonly SharedMindSystem _mind = default!; | ||
| [Dependency] private readonly SharedSkillsSystem _skillsSystem = default!; | ||
| [Dependency] private readonly SharedStatsSystem _statsSystem = default!; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override void Initialize() | ||
|
|
@@ -174,7 +178,7 @@ public bool TryStartZap(EntityUid uid, EntityUid target, EntityUid user, Defibri | |
| return false; | ||
|
|
||
| _audio.PlayPvs(component.ChargeSound, uid); | ||
| return _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.DoAfterDuration, new DefibrillatorZapDoAfterEvent(), | ||
| return _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, _skillsSystem.SkillLevelToDelay[_skillsSystem.GetSkillLevel(user, Skill.Medicine)], new DefibrillatorZapDoAfterEvent(), | ||
| uid, target, uid) | ||
| { | ||
| BlockDuplicate = true, | ||
|
|
@@ -188,11 +192,17 @@ public void Zap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorCo | |
| if (!Resolve(uid, ref component) || !Resolve(target, ref mob, ref thresholds, false)) | ||
| return; | ||
|
|
||
| // clowns zap themselves | ||
| if (HasComp<ClumsyComponent>(user) && user != target) | ||
| if (_skillsSystem.GetSkillLevel(user, Skill.Medicine) == SkillLevel.Weak) | ||
| { | ||
| Zap(uid, user, user, component); | ||
| return; | ||
| var intStat = _statsSystem.GetStat(user, Stat.Intelligence); | ||
| var (_, response, result) = _statsSystem.D20(intStat); | ||
|
|
||
| if (!result) | ||
| { | ||
| _popup.PopupEntity(response, user, user); | ||
| _electrocution.TryDoElectrocution(user, null, component.ZapDamage, component.WritheDuration, true, ignoreInsulation: true); | ||
| return; | ||
| } | ||
|
Comment on lines
+197
to
+205
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding detailed logging for the failure scenario in the defibrillation process. + AdminLogger.Add(LogType.FailedAction, $"{ToPrettyString(user):user} failed to defibrillate {ToPrettyString(target):target} due to low skill level.");Adding detailed logging for when defibrillation fails due to a low skill level can help in debugging and understanding user interactions with the system.
|
||
| } | ||
|
|
||
| if (!_powerCell.TryUseActivatableCharge(uid, user: user)) | ||
|
|
@@ -251,6 +261,8 @@ public void Zap(EntityUid uid, EntityUid target, EntityUid user, DefibrillatorCo | |
| : component.SuccessSound; | ||
| _audio.PlayPvs(sound, uid); | ||
|
|
||
| _skillsSystem.ApplySkillThreshold(user, Skill.Medicine, 10); | ||
|
|
||
| // if we don't have enough power left for another shot, turn it off | ||
| if (!_powerCell.HasActivatableCharge(uid)) | ||
| TryDisable(uid, component); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translation tags are missing for new labels. This might affect localization support.
Also applies to: 25-25, 28-28, 31-31