Ghost hearing action (#19722)
This commit is contained in:
@@ -15,7 +15,6 @@ namespace Content.Client.Ghost
|
|||||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||||
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
||||||
[Dependency] private readonly ILightManager _lightManager = default!;
|
[Dependency] private readonly ILightManager _lightManager = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
||||||
[Dependency] private readonly ContentEyeSystem _contentEye = default!;
|
[Dependency] private readonly ContentEyeSystem _contentEye = default!;
|
||||||
|
|
||||||
public int AvailableGhostRoleCount { get; private set; }
|
public int AvailableGhostRoleCount { get; private set; }
|
||||||
@@ -83,7 +82,7 @@ namespace Content.Client.Ghost
|
|||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_popup.PopupEntity(Loc.GetString("ghost-gui-toggle-lighting-manager-popup"), args.Performer);
|
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-lighting-manager-popup"), args.Performer);
|
||||||
_lightManager.Enabled = !_lightManager.Enabled;
|
_lightManager.Enabled = !_lightManager.Enabled;
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
@@ -93,7 +92,7 @@ namespace Content.Client.Ghost
|
|||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_popup.PopupEntity(Loc.GetString("ghost-gui-toggle-fov-popup"), args.Performer);
|
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-fov-popup"), args.Performer);
|
||||||
_contentEye.RequestToggleFov(uid);
|
_contentEye.RequestToggleFov(uid);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
@@ -103,7 +102,7 @@ namespace Content.Client.Ghost
|
|||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_popup.PopupEntity(Loc.GetString("ghost-gui-toggle-ghost-visibility-popup"), args.Performer);
|
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-ghost-visibility-popup"), args.Performer);
|
||||||
ToggleGhostVisibility();
|
ToggleGhostVisibility();
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
}
|
}
|
||||||
@@ -113,6 +112,7 @@ namespace Content.Client.Ghost
|
|||||||
_actions.RemoveAction(uid, component.ToggleLightingActionEntity);
|
_actions.RemoveAction(uid, component.ToggleLightingActionEntity);
|
||||||
_actions.RemoveAction(uid, component.ToggleFoVActionEntity);
|
_actions.RemoveAction(uid, component.ToggleFoVActionEntity);
|
||||||
_actions.RemoveAction(uid, component.ToggleGhostsActionEntity);
|
_actions.RemoveAction(uid, component.ToggleGhostsActionEntity);
|
||||||
|
_actions.RemoveAction(uid, component.ToggleGhostHearingActionEntity);
|
||||||
|
|
||||||
if (uid != _playerManager.LocalPlayer?.ControlledEntity)
|
if (uid != _playerManager.LocalPlayer?.ControlledEntity)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -739,7 +739,7 @@ public sealed partial class ChatSystem : SharedChatSystem
|
|||||||
// TODO proper speech occlusion
|
// TODO proper speech occlusion
|
||||||
|
|
||||||
var recipients = new Dictionary<ICommonSession, ICChatRecipientData>();
|
var recipients = new Dictionary<ICommonSession, ICChatRecipientData>();
|
||||||
var ghosts = GetEntityQuery<GhostComponent>();
|
var ghostHearing = GetEntityQuery<GhostHearingComponent>();
|
||||||
var xforms = GetEntityQuery<TransformComponent>();
|
var xforms = GetEntityQuery<TransformComponent>();
|
||||||
|
|
||||||
var transformSource = xforms.GetComponent(source);
|
var transformSource = xforms.GetComponent(source);
|
||||||
@@ -756,9 +756,9 @@ public sealed partial class ChatSystem : SharedChatSystem
|
|||||||
if (transformEntity.MapID != sourceMapId)
|
if (transformEntity.MapID != sourceMapId)
|
||||||
continue;
|
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)
|
if (sourceCoords.TryDistance(EntityManager, transformEntity.Coordinates, out var distance) && distance < voiceGetRange)
|
||||||
{
|
{
|
||||||
recipients.Add(player, new ICChatRecipientData(distance, observer));
|
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.Components;
|
||||||
using Content.Shared.Mobs.Systems;
|
using Content.Shared.Mobs.Systems;
|
||||||
using Content.Shared.Movement.Events;
|
using Content.Shared.Movement.Events;
|
||||||
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Storage.Components;
|
using Content.Shared.Storage.Components;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
@@ -64,11 +65,35 @@ namespace Content.Server.Ghost
|
|||||||
SubscribeNetworkEvent<GhostWarpToTargetRequestEvent>(OnGhostWarpToTargetRequest);
|
SubscribeNetworkEvent<GhostWarpToTargetRequestEvent>(OnGhostWarpToTargetRequest);
|
||||||
|
|
||||||
SubscribeLocalEvent<GhostComponent, BooActionEvent>(OnActionPerform);
|
SubscribeLocalEvent<GhostComponent, BooActionEvent>(OnActionPerform);
|
||||||
|
SubscribeLocalEvent<GhostComponent, ToggleGhostHearingActionEvent>(OnGhostHearingAction);
|
||||||
SubscribeLocalEvent<GhostComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);
|
SubscribeLocalEvent<GhostComponent, InsertIntoEntityStorageAttemptEvent>(OnEntityStorageInsertAttempt);
|
||||||
|
|
||||||
SubscribeLocalEvent<RoundEndTextAppendEvent>(_ => MakeVisible(true));
|
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)
|
private void OnActionPerform(EntityUid uid, GhostComponent component, BooActionEvent args)
|
||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
@@ -164,6 +189,7 @@ namespace Content.Server.Ghost
|
|||||||
_actions.SetCooldown(component.BooActionEntity.Value, start, end);
|
_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.ToggleLightingActionEntity, component.ToggleLightingAction);
|
||||||
_actions.AddAction(uid, ref component.ToggleFoVActionEntity, component.ToggleFoVAction);
|
_actions.AddAction(uid, ref component.ToggleFoVActionEntity, component.ToggleFoVAction);
|
||||||
_actions.AddAction(uid, ref component.ToggleGhostsActionEntity, component.ToggleGhostsAction);
|
_actions.AddAction(uid, ref component.ToggleGhostsActionEntity, component.ToggleGhostsAction);
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
using Content.Shared.Actions;
|
using Content.Shared.Actions;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
||||||
|
|
||||||
namespace Content.Shared.Ghost;
|
namespace Content.Shared.Ghost;
|
||||||
|
|
||||||
@@ -14,25 +12,40 @@ public sealed partial class GhostComponent : Component
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool IsAttached;
|
public bool IsAttached;
|
||||||
|
|
||||||
[DataField("toggleLightingAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
// Actions
|
||||||
public string ToggleLightingAction = "ActionToggleLighting";
|
[DataField]
|
||||||
|
public EntProtoId ToggleLightingAction = "ActionToggleLighting";
|
||||||
|
|
||||||
[DataField, AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public EntityUid? ToggleLightingActionEntity;
|
public EntityUid? ToggleLightingActionEntity;
|
||||||
|
|
||||||
[DataField("toggleFovAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
[DataField]
|
||||||
public string ToggleFoVAction = "ActionToggleFov";
|
public EntProtoId ToggleFoVAction = "ActionToggleFov";
|
||||||
|
|
||||||
[DataField, AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public EntityUid? ToggleFoVActionEntity;
|
public EntityUid? ToggleFoVActionEntity;
|
||||||
|
|
||||||
[DataField("toggleGhostsAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
[DataField]
|
||||||
public string ToggleGhostsAction = "ActionToggleGhosts";
|
public EntProtoId ToggleGhostsAction = "ActionToggleGhosts";
|
||||||
|
|
||||||
[DataField, AutoNetworkedField]
|
[DataField, AutoNetworkedField]
|
||||||
public EntityUid? ToggleGhostsActionEntity;
|
public EntityUid? ToggleGhostsActionEntity;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("timeOfDeath", customTypeSerializer:typeof(TimeOffsetSerializer))]
|
[DataField]
|
||||||
|
public EntProtoId ToggleGhostHearingAction = "ActionToggleGhostHearing";
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public EntityUid? ToggleGhostHearingActionEntity;
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public EntProtoId BooAction = "ActionGhostBoo";
|
||||||
|
|
||||||
|
[DataField, AutoNetworkedField]
|
||||||
|
public EntityUid? BooActionEntity;
|
||||||
|
|
||||||
|
// End actions
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||||
public TimeSpan TimeOfDeath = TimeSpan.Zero;
|
public TimeSpan TimeOfDeath = TimeSpan.Zero;
|
||||||
|
|
||||||
[DataField("booRadius")]
|
[DataField("booRadius")]
|
||||||
@@ -41,12 +54,6 @@ public sealed partial class GhostComponent : Component
|
|||||||
[DataField("booMaxTargets")]
|
[DataField("booMaxTargets")]
|
||||||
public int BooMaxTargets = 3;
|
public int BooMaxTargets = 3;
|
||||||
|
|
||||||
[DataField]
|
|
||||||
public EntProtoId BooAction = "ActionGhostBoo";
|
|
||||||
|
|
||||||
[DataField, AutoNetworkedField]
|
|
||||||
public EntityUid? BooActionEntity;
|
|
||||||
|
|
||||||
// TODO: instead of this funny stuff just give it access and update in system dirtying when needed
|
// TODO: instead of this funny stuff just give it access and update in system dirtying when needed
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool CanGhostInteract
|
public bool CanGhostInteract
|
||||||
@@ -90,10 +97,12 @@ public sealed partial class GhostComponent : Component
|
|||||||
private bool _canReturnToBody;
|
private bool _canReturnToBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed partial class ToggleFoVActionEvent : InstantActionEvent { }
|
||||||
|
|
||||||
|
public sealed partial class ToggleGhostsActionEvent : InstantActionEvent { }
|
||||||
|
|
||||||
|
public sealed partial class ToggleLightingActionEvent : InstantActionEvent { }
|
||||||
|
|
||||||
|
public sealed partial class ToggleGhostHearingActionEvent : InstantActionEvent { }
|
||||||
|
|
||||||
public sealed partial class BooActionEvent : InstantActionEvent { }
|
public sealed partial class BooActionEvent : InstantActionEvent { }
|
||||||
|
|
||||||
public sealed partial class ToggleFoVActionEvent : InstantActionEvent { };
|
|
||||||
|
|
||||||
public sealed partial class ToggleGhostsActionEvent : InstantActionEvent { };
|
|
||||||
|
|
||||||
public sealed partial class ToggleLightingActionEvent : InstantActionEvent { };
|
|
||||||
|
|||||||
9
Content.Shared/Ghost/GhostHearingComponent.cs
Normal file
9
Content.Shared/Ghost/GhostHearingComponent.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Content.Shared.Ghost;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is used for marking entities which should receive all local chat message, even when out of range
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent]
|
||||||
|
public sealed partial class GhostHearingComponent : Component
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ using Content.Shared.Emoting;
|
|||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
|
using Content.Shared.Popups;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Ghost
|
namespace Content.Shared.Ghost
|
||||||
@@ -12,6 +13,8 @@ namespace Content.Shared.Ghost
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SharedGhostSystem : EntitySystem
|
public abstract class SharedGhostSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ ghost-gui-toggle-ghost-visibility-popup = Toggled visibility of ghosts.
|
|||||||
ghost-gui-toggle-lighting-manager-popup = Toggled all lighting.
|
ghost-gui-toggle-lighting-manager-popup = Toggled all lighting.
|
||||||
ghost-gui-toggle-fov-popup = Toggled field-of-view.
|
ghost-gui-toggle-fov-popup = Toggled field-of-view.
|
||||||
|
|
||||||
|
ghost-gui-toggle-hearing-popup-on = You can now hear all messages.
|
||||||
|
ghost-gui-toggle-hearing-popup-off = You can now only hear radio and nearby messages.
|
||||||
|
|
||||||
ghost-target-window-title = Ghost Warp
|
ghost-target-window-title = Ghost Warp
|
||||||
ghost-target-window-current-button = Warp: {$name}
|
ghost-target-window-current-button = Warp: {$name}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
context: "aghost"
|
context: "aghost"
|
||||||
- type: Ghost
|
- type: Ghost
|
||||||
canInteract: true
|
canInteract: true
|
||||||
|
- type: GhostHearing
|
||||||
- type: Hands
|
- type: Hands
|
||||||
- type: Puller
|
- type: Puller
|
||||||
- type: CombatMode
|
- type: CombatMode
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
- type: Examiner
|
- type: Examiner
|
||||||
skipChecks: true
|
skipChecks: true
|
||||||
- type: Ghost
|
- type: Ghost
|
||||||
|
- type: GhostHearing
|
||||||
- type: MovementSpeedModifier
|
- type: MovementSpeedModifier
|
||||||
baseSprintSpeed: 12
|
baseSprintSpeed: 12
|
||||||
baseWalkSpeed: 8
|
baseWalkSpeed: 8
|
||||||
@@ -106,3 +107,17 @@
|
|||||||
clientExclusive: true
|
clientExclusive: true
|
||||||
checkCanInteract: false
|
checkCanInteract: false
|
||||||
event: !type:ToggleGhostsActionEvent
|
event: !type:ToggleGhostsActionEvent
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
id: ActionToggleGhostHearing
|
||||||
|
name: Toggle Ghost Hearing
|
||||||
|
description: Toggle between hearing all messages and hearing only radio & nearby messages.
|
||||||
|
noSpawn: true
|
||||||
|
components:
|
||||||
|
- type: InstantAction
|
||||||
|
checkCanInteract: false
|
||||||
|
icon:
|
||||||
|
sprite: Clothing/Ears/Headsets/base.rsi
|
||||||
|
state: icon
|
||||||
|
iconOn: Interface/Actions/ghostHearingToggled.png
|
||||||
|
event: !type:ToggleGhostHearingActionEvent
|
||||||
|
|||||||
BIN
Resources/Textures/Interface/Actions/ghostHearingToggled.png
Normal file
BIN
Resources/Textures/Interface/Actions/ghostHearingToggled.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 654 B |
@@ -48,6 +48,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "web"
|
"name": "web"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ghostHearingToggled"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user