Ghost hearing action (#19722)
This commit is contained in:
@@ -739,7 +739,7 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
// TODO proper speech occlusion
|
||||
|
||||
var recipients = new Dictionary<ICommonSession, ICChatRecipientData>();
|
||||
var ghosts = GetEntityQuery<GhostComponent>();
|
||||
var ghostHearing = GetEntityQuery<GhostHearingComponent>();
|
||||
var xforms = GetEntityQuery<TransformComponent>();
|
||||
|
||||
var transformSource = xforms.GetComponent(source);
|
||||
@@ -756,9 +756,9 @@ public sealed partial class ChatSystem : SharedChatSystem
|
||||
if (transformEntity.MapID != sourceMapId)
|
||||
continue;
|
||||
|
||||
var observer = ghosts.HasComponent(playerEntity);
|
||||
var observer = ghostHearing.HasComponent(playerEntity);
|
||||
|
||||
// even if they are an observer, in some situations we still need the range
|
||||
// even if they are a ghost hearer, in some situations we still need the range
|
||||
if (sourceCoords.TryDistance(EntityManager, transformEntity.Coordinates, out var distance) && distance < voiceGetRange)
|
||||
{
|
||||
recipients.Add(player, new ICChatRecipientData(distance, observer));
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user