Ghost hearing action (#19722)

This commit is contained in:
Kara
2023-09-24 13:34:08 -07:00
committed by GitHub
parent 5e405380ef
commit fb175a520d
11 changed files with 97 additions and 28 deletions

View File

@@ -16,6 +16,7 @@ using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events;
using Content.Shared.Popups;
using Content.Shared.Storage.Components;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -64,11 +65,35 @@ namespace Content.Server.Ghost
SubscribeNetworkEvent<GhostWarpToTargetRequestEvent>(OnGhostWarpToTargetRequest);
SubscribeLocalEvent<GhostComponent, BooActionEvent>(OnActionPerform);
SubscribeLocalEvent<GhostComponent, ToggleGhostHearingActionEvent>(OnGhostHearingAction);
SubscribeLocalEvent<GhostComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);
SubscribeLocalEvent<RoundEndTextAppendEvent>(_ => MakeVisible(true));
}
private void OnGhostHearingAction(EntityUid uid, GhostComponent component, ToggleGhostHearingActionEvent args)
{
args.Handled = true;
if (HasComp<GhostHearingComponent>(uid))
{
RemComp<GhostHearingComponent>(uid);
_actions.SetToggled(component.ToggleGhostHearingActionEntity, true);
}
else
{
AddComp<GhostHearingComponent>(uid);
_actions.SetToggled(component.ToggleGhostHearingActionEntity, false);
}
var str = HasComp<GhostHearingComponent>(uid)
? Loc.GetString("ghost-gui-toggle-hearing-popup-on")
: Loc.GetString("ghost-gui-toggle-hearing-popup-off");
Popup.PopupEntity(str, uid, uid);
Dirty(uid, component);
}
private void OnActionPerform(EntityUid uid, GhostComponent component, BooActionEvent args)
{
if (args.Handled)
@@ -164,6 +189,7 @@ namespace Content.Server.Ghost
_actions.SetCooldown(component.BooActionEntity.Value, start, end);
}
_actions.AddAction(uid, ref component.ToggleGhostHearingActionEntity, component.ToggleGhostHearingAction);
_actions.AddAction(uid, ref component.ToggleLightingActionEntity, component.ToggleLightingAction);
_actions.AddAction(uid, ref component.ToggleFoVActionEntity, component.ToggleFoVAction);
_actions.AddAction(uid, ref component.ToggleGhostsActionEntity, component.ToggleGhostsAction);