Skip to content

Commit

Permalink
[Port] Combat Indicator
Browse files Browse the repository at this point in the history
Co-Authored-By: Kayzel <43700376+kayzelw@users.noreply.github.com>
  • Loading branch information
PuroSlavKing and KayzelW committed Nov 17, 2024
1 parent 597f773 commit 21f1a7d
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 3 deletions.
34 changes: 33 additions & 1 deletion Content.Client/CombatMode/CombatModeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
using Robust.Client.Input;
using Robust.Client.Player;
using Robust.Shared.Configuration;
using Robust.Client.GameObjects;
using Content.Shared.StatusIcon.Components;
using Content.Client.Actions;
using System.Numerics;
using Robust.Shared.GameObjects;
using Robust.Shared.Utility;

namespace Content.Client.CombatMode;

Expand All @@ -21,14 +27,17 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
/// Raised whenever combat mode changes.
/// </summary>
public event Action<bool>? LocalPlayerCombatModeUpdated;
private EntityQuery<SpriteComponent> _spriteQuery; // Everwood

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

SubscribeLocalEvent<CombatModeComponent, AfterAutoHandleStateEvent>(OnHandleState);

SubscribeLocalEvent<CombatModeComponent, GetStatusIconsEvent>(UpdateCombatModeIndicator); // Everwood EDIT
Subs.CVar(_cfg, CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged, true);

_spriteQuery = GetEntityQuery<SpriteComponent>(); // Everwood
}

private void OnHandleState(EntityUid uid, CombatModeComponent component, ref AfterAutoHandleStateEvent args)
Expand Down Expand Up @@ -91,4 +100,27 @@ private void OnShowCombatIndicatorsChanged(bool isShow)
_overlayManager.RemoveOverlay<CombatModeIndicatorsOverlay>();
}
}

// Everwood START
private void UpdateCombatModeIndicator(EntityUid uid, CombatModeComponent comp, ref GetStatusIconsEvent _)
{
if (!_spriteQuery.TryComp(uid, out var sprite))
return;

if (comp.IsInCombatMode)
{
if (!sprite.LayerMapTryGet("combat_mode_indicator", out var layer))
{
layer = sprite.AddLayer(new SpriteSpecifier.Rsi(new ResPath("_Everwood/Effects/combat_mode.rsi"), "combat_mode"));
sprite.LayerMapSet("combat_mode_indicator", layer);
}
}
else
{
if (sprite.LayerMapTryGet("combat_mode_indicator", out var layerToRemove))
{
sprite.RemoveLayer(layerToRemove);
}
}
} // Everwood END
}
13 changes: 11 additions & 2 deletions Content.Shared/CombatMode/SharedCombatModeSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using Content.Shared.Actions;
using Content.Shared.CombatMode; // Everwood
using Content.Shared.MouseRotator;
using Content.Shared.Movement.Components;
using Content.Shared.Popups;
using Robust.Shared.Audio; // Everwood
using Robust.Shared.Audio.Systems; // Everwood
using Robust.Shared.GameObjects; // Everwood
using Robust.Shared.Network;
using Robust.Shared.Timing;

Expand All @@ -13,6 +17,7 @@ public abstract class SharedCombatModeSystem : EntitySystem
[Dependency] private readonly INetManager _netMan = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; // Everwood

public override void Initialize()
{
Expand Down Expand Up @@ -50,9 +55,13 @@ private void OnActionPerform(EntityUid uid, CombatModeComponent component, Toggl
if (!_netMan.IsClient || !Timing.IsFirstTimePredicted)
return;

var msg = component.IsInCombatMode ? "action-popup-combat-enabled" : "action-popup-combat-disabled";
_popup.PopupEntity(Loc.GetString(msg), args.Performer, args.Performer);
// Everwood START
_audio.PlayPvs(component.IsInCombatMode ? "/Audio/_Everwood/Effects/CombatMode/on.ogg" : "/Audio/_Ataraxia/Effects/CombatMode/off.ogg", uid);

// var msg = component.IsInCombatMode ? "action-popup-combat-enabled" : "action-popup-combat-disabled";
// _popup.PopupEntity(Loc.GetString(msg), args.Performer, args.Performer);
}
// Everwood END

public void SetCanDisarm(EntityUid entity, bool canDisarm, CombatModeComponent? component = null)
{
Expand Down
4 changes: 4 additions & 0 deletions Resources/Audio/_Everwood/Effects/CombatMode/attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- files: ["on.ogg", "off.ogg"]
license: "CC-BY-NC-SA-3.0"
copyright: 'Taken from /tg/station at commit 87c4c6ae94acd6ac8000bc0c2f43fc2cfc928224 and https://github.com/BlueMoon-Labs/MOLOT-BlueMoon-Station/blob/master/sound/machines/chime.ogg. Converted to mono by PuroSlavKing'
source: "https://github.com/tgstation/tgstation/blob/87c4c6ae94acd6ac8000bc0c2f43fc2cfc928224"
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions Resources/Textures/_Everwood/Effects/combat_mode.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from https://github.com/BlueMoon-Labs/MOLOT-BlueMoon-Station/blob/master/modular_sand/icons/mob/combat_indicator.dmi | Edited by PuroSlavKing (Github)",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "combat_mode",
"delays": [
[
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1,
0.1
]
]
}
]
}

0 comments on commit 21f1a7d

Please sign in to comment.