mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 21:48:58 +03:00
# Description Adds the Ghost Bar from Goob LRP. Upon spawn, the character's loadouts and traits will also be applied as if their job was their Ghost Bar job. Adjusts the weights for kill objectives, re-enabling the kill objective and reducing the weight of Teach a Lesson now that there's more things to do after getting round removed. Goobstation cherry-picked PRs: - https://github.com/Goob-Station/Goob-Station/pull/454 - https://github.com/Goob-Station/Goob-Station/pull/464 - https://github.com/Goob-Station/Goob-Station/pull/689 (partially applied to Ghost bar files only) - https://github.com/Goob-Station/Goob-Station/pull/963 - https://github.com/Goob-Station/Goob-Station/pull/974 - https://github.com/Goob-Station/Goob-Station/pull/982 (partially applied to Ghost bar files only) - https://github.com/Goob-Station/Goob-Station/pull/1288 (partially applied to Ghost bar files only) Wizden cherry-picked PRs: - https://github.com/space-wizards/space-station-14/pull/29103 (for the foam force rifle that spawns in the Ghost bar) ## Media **Ghost Bar UI**  **Ghost Bar In-Game**  Notice how the Ghost Bar character has loadout items in the backpack and the Skeleton Accent trait. ## Changelog <!-- You can add an author after the `🆑` to change the name that appears in the changelog (ex: `🆑 Death`) Leaving it blank will default to your GitHub display name This includes all available types for the changelog --> 🆑 Skubman - add: Ghost Bar! When you die, you can now go to the Ghost Bar to chill and talk about the round with other ghosts. (by Aidenkrz) - add: Foam Force rifle to cargo lottery! (by IProduceWidgets) - add: Re-enabled the Kill objective for traitors. - tweak: Reduced the chances of traitors getting the "Teach a Lesson" objective. --------- Co-authored-by: Aiden <aiden@djkraz.com> Co-authored-by: Rank #1 Jonestown partygoer <mary@thughunt.ing> Co-authored-by: IProduceWidgets <107586145+IProduceWidgets@users.noreply.github.com> Co-authored-by: Aviu00 <93730715+Aviu00@users.noreply.github.com> (cherry picked from commit 0b4ceb21cc406cd39b894afe79decf40c2366369)
196 lines
6.7 KiB
C#
196 lines
6.7 KiB
C#
using Content.Client.Movement.Systems;
|
|
using Content.Shared.Actions;
|
|
using Content.Shared.Ghost;
|
|
using Robust.Client.Console;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.Player;
|
|
using Robust.Shared.Player;
|
|
|
|
namespace Content.Client.Ghost
|
|
{
|
|
public sealed class GhostSystem : SharedGhostSystem
|
|
{
|
|
[Dependency] private readonly IClientConsoleHost _console = default!;
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
[Dependency] private readonly SharedActionsSystem _actions = default!;
|
|
[Dependency] private readonly ContentEyeSystem _contentEye = default!;
|
|
|
|
public int AvailableGhostRoleCount { get; private set; }
|
|
|
|
private bool _ghostVisibility = true;
|
|
|
|
private bool GhostVisibility
|
|
{
|
|
get => _ghostVisibility;
|
|
set
|
|
{
|
|
if (_ghostVisibility == value)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_ghostVisibility = value;
|
|
|
|
var query = AllEntityQuery<GhostComponent, SpriteComponent>();
|
|
while (query.MoveNext(out var uid, out _, out var sprite))
|
|
{
|
|
sprite.Visible = value || uid == _playerManager.LocalEntity;
|
|
}
|
|
}
|
|
}
|
|
|
|
public GhostComponent? Player => CompOrNull<GhostComponent>(_playerManager.LocalEntity);
|
|
public bool IsGhost => Player != null;
|
|
|
|
public event Action<GhostComponent>? PlayerRemoved;
|
|
public event Action<GhostComponent>? PlayerUpdated;
|
|
public event Action<GhostComponent>? PlayerAttached;
|
|
public event Action? PlayerDetached;
|
|
public event Action<GhostWarpsResponseEvent>? GhostWarpsResponse;
|
|
public event Action<GhostUpdateGhostRoleCountEvent>? GhostRoleCountUpdated;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<GhostComponent, ComponentStartup>(OnStartup);
|
|
SubscribeLocalEvent<GhostComponent, ComponentRemove>(OnGhostRemove);
|
|
SubscribeLocalEvent<GhostComponent, AfterAutoHandleStateEvent>(OnGhostState);
|
|
|
|
SubscribeLocalEvent<GhostComponent, LocalPlayerAttachedEvent>(OnGhostPlayerAttach);
|
|
SubscribeLocalEvent<GhostComponent, LocalPlayerDetachedEvent>(OnGhostPlayerDetach);
|
|
|
|
SubscribeNetworkEvent<GhostWarpsResponseEvent>(OnGhostWarpsResponse);
|
|
SubscribeNetworkEvent<GhostUpdateGhostRoleCountEvent>(OnUpdateGhostRoleCount);
|
|
|
|
SubscribeLocalEvent<EyeComponent, ToggleLightingActionEvent>(OnToggleLighting);
|
|
SubscribeLocalEvent<EyeComponent, ToggleFoVActionEvent>(OnToggleFoV);
|
|
SubscribeLocalEvent<GhostComponent, ToggleGhostsActionEvent>(OnToggleGhosts);
|
|
}
|
|
|
|
private void OnStartup(EntityUid uid, GhostComponent component, ComponentStartup args)
|
|
{
|
|
if (TryComp(uid, out SpriteComponent? sprite))
|
|
sprite.Visible = GhostVisibility || uid == _playerManager.LocalEntity;
|
|
}
|
|
|
|
private void OnToggleLighting(EntityUid uid, EyeComponent component, ToggleLightingActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-lighting-manager-popup"), args.Performer);
|
|
_contentEye.RequestToggleLight(uid, component);
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void OnToggleFoV(EntityUid uid, EyeComponent component, ToggleFoVActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-fov-popup"), args.Performer);
|
|
_contentEye.RequestToggleFov(uid, component);
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void OnToggleGhosts(EntityUid uid, GhostComponent component, ToggleGhostsActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-ghost-visibility-popup"), args.Performer);
|
|
|
|
if (uid == _playerManager.LocalEntity)
|
|
ToggleGhostVisibility();
|
|
|
|
args.Handled = true;
|
|
}
|
|
|
|
private void OnGhostRemove(EntityUid uid, GhostComponent component, ComponentRemove args)
|
|
{
|
|
_actions.RemoveAction(uid, component.ToggleLightingActionEntity);
|
|
_actions.RemoveAction(uid, component.ToggleFoVActionEntity);
|
|
_actions.RemoveAction(uid, component.ToggleGhostsActionEntity);
|
|
_actions.RemoveAction(uid, component.ToggleGhostHearingActionEntity);
|
|
|
|
if (uid != _playerManager.LocalEntity)
|
|
return;
|
|
|
|
GhostVisibility = false;
|
|
PlayerRemoved?.Invoke(component);
|
|
}
|
|
|
|
private void OnGhostPlayerAttach(EntityUid uid, GhostComponent component, LocalPlayerAttachedEvent localPlayerAttachedEvent)
|
|
{
|
|
GhostVisibility = true;
|
|
PlayerAttached?.Invoke(component);
|
|
}
|
|
|
|
private void OnGhostState(EntityUid uid, GhostComponent component, ref AfterAutoHandleStateEvent args)
|
|
{
|
|
if (TryComp<SpriteComponent>(uid, out var sprite))
|
|
sprite.LayerSetColor(0, component.color);
|
|
|
|
if (uid != _playerManager.LocalEntity)
|
|
return;
|
|
|
|
PlayerUpdated?.Invoke(component);
|
|
}
|
|
|
|
private void OnGhostPlayerDetach(EntityUid uid, GhostComponent component, LocalPlayerDetachedEvent args)
|
|
{
|
|
GhostVisibility = false;
|
|
PlayerDetached?.Invoke();
|
|
}
|
|
|
|
private void OnGhostWarpsResponse(GhostWarpsResponseEvent msg)
|
|
{
|
|
if (!IsGhost)
|
|
{
|
|
return;
|
|
}
|
|
|
|
GhostWarpsResponse?.Invoke(msg);
|
|
}
|
|
|
|
private void OnUpdateGhostRoleCount(GhostUpdateGhostRoleCountEvent msg)
|
|
{
|
|
AvailableGhostRoleCount = msg.AvailableGhostRoles;
|
|
GhostRoleCountUpdated?.Invoke(msg);
|
|
}
|
|
|
|
public void RequestWarps()
|
|
{
|
|
RaiseNetworkEvent(new GhostWarpsRequestEvent());
|
|
}
|
|
|
|
public void ReturnToBody()
|
|
{
|
|
var msg = new GhostReturnToBodyRequest();
|
|
RaiseNetworkEvent(msg);
|
|
}
|
|
|
|
public void OpenGhostRoles()
|
|
{
|
|
_console.RemoteExecuteCommand(null, "ghostroles");
|
|
}
|
|
|
|
public void GhostBarSpawn() // Goobstation - Ghost Bar
|
|
{
|
|
RaiseNetworkEvent(new GhostBarSpawnEvent());
|
|
}
|
|
|
|
public void ToggleGhostVisibility(bool? visibility = null)
|
|
{
|
|
GhostVisibility = visibility ?? !GhostVisibility;
|
|
}
|
|
|
|
public void ReturnToRound()
|
|
{
|
|
var msg = new GhostReturnToRoundRequest();
|
|
RaiseNetworkEvent(msg);
|
|
}
|
|
}
|
|
}
|