Skip to content

Commit

Permalink
Ghost Bar!!!! (From Goobstation) (#1675)
Browse files Browse the repository at this point in the history
# 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:
- Goob-Station/Goob-Station#454
- Goob-Station/Goob-Station#464
- Goob-Station/Goob-Station#689 (partially
applied to Ghost bar files only)
- Goob-Station/Goob-Station#963
- Goob-Station/Goob-Station#974
- Goob-Station/Goob-Station#982 (partially
applied to Ghost bar files only)
- Goob-Station/Goob-Station#1288 (partially
applied to Ghost bar files only)

Wizden cherry-picked PRs:
- space-wizards/space-station-14#29103 (for the
foam force rifle that spawns in the Ghost bar)

## Media

**Ghost Bar UI**


![image](https://github.com/user-attachments/assets/e46603b9-1798-4376-8af5-3df518ede76c)

**Ghost Bar In-Game**


![image](https://github.com/user-attachments/assets/14dbdc0a-9d75-487b-994e-1b1eabe7bff3)

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 `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

:cl: 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 <[email protected]>
Co-authored-by: Rank #1 Jonestown partygoer <[email protected]>
Co-authored-by: IProduceWidgets <[email protected]>
Co-authored-by: Aviu00 <[email protected]>
  • Loading branch information
5 people authored Jan 28, 2025
1 parent 2902418 commit 0b4ceb2
Show file tree
Hide file tree
Showing 33 changed files with 15,275 additions and 14 deletions.
5 changes: 5 additions & 0 deletions Content.Client/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ 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;
Expand Down
16 changes: 15 additions & 1 deletion Content.Client/UserInterface/Systems/Ghost/GhostUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ namespace Content.Client.UserInterface.Systems.Ghost;
public sealed class GhostUIController : UIController, IOnSystemChanged<GhostSystem>
{
[Dependency] private readonly IEntityNetworkManager _net = default!;

[UISystemDependency] private readonly GhostSystem? _system = default;

private GhostGui? Gui => UIManager.GetActiveUIWidgetOrNull<GhostGui>();


public override void Initialize()
{
base.Initialize();
Expand Down Expand Up @@ -125,6 +125,8 @@ public void LoadGui()
Gui.RequestWarpsPressed += RequestWarps;
Gui.ReturnToBodyPressed += ReturnToBody;
Gui.GhostRolesPressed += GhostRolesPressed;
Gui.GhostBarPressed += GhostBarPressed; // Goobstation - Ghost Bar
Gui.GhostBarWindow.SpawnButtonPressed += GhostBarSpawnPressed; // Goobstation - Ghost Bar
Gui.TargetWindow.WarpClicked += OnWarpClicked;
Gui.TargetWindow.OnGhostnadoClicked += OnGhostnadoClicked;
Gui.ReturnToRoundPressed += ReturnToRound;
Expand All @@ -140,6 +142,8 @@ public void UnloadGui()
Gui.RequestWarpsPressed -= RequestWarps;
Gui.ReturnToBodyPressed -= ReturnToBody;
Gui.GhostRolesPressed -= GhostRolesPressed;
Gui.GhostBarPressed -= GhostBarPressed; // Goobstation - Ghost Bar
Gui.GhostBarWindow.SpawnButtonPressed -= GhostBarSpawnPressed; // Goobstation - Ghost Bar
Gui.TargetWindow.WarpClicked -= OnWarpClicked;
Gui.ReturnToRoundPressed -= ReturnToRound;

Expand Down Expand Up @@ -167,4 +171,14 @@ private void GhostRolesPressed()
{
_system?.OpenGhostRoles();
}

private void GhostBarPressed() // Goobstation - Ghost Bar
{
Gui?.GhostBarWindow.OpenCentered();
}

private void GhostBarSpawnPressed() // Goobstation - Ghost Bar
{
_system?.GhostBarSpawn();
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<widgets:GhostGui xmlns="https://spacestation14.io"
<widgets:GhostGui xmlns="https://spacestation14.io"
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Ghost.Widgets"
HorizontalAlignment="Center">
<BoxContainer Orientation="Horizontal">
<Button Name="ReturnToBodyButton" Text="{Loc ghost-gui-return-to-body-button}" />
<Button Name="GhostWarpButton" Text="{Loc ghost-gui-ghost-warp-button}" />
<Button Name="GhostRolesButton" />
<Button Name="GhostBarButton" Text="{Loc 'ghost-target-window-ghostbar'}" /> <!-- Goobstation - Ghost Bar -->
<Button Name="ReturnToRound" Text="{Loc ghost-gui-return-to-round-button}" />
</BoxContainer>
</widgets:GhostGui>
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Content.Client._Goobstation.UserInterface.Systems.Ghost.Controls;

namespace Content.Client.UserInterface.Systems.Ghost.Widgets;

[GenerateTypedNameReferences]
public sealed partial class GhostGui : UIWidget
{
public GhostTargetWindow TargetWindow { get; }
public GhostBarRulesWindow GhostBarWindow { get; }

public event Action? RequestWarpsPressed;
public event Action? ReturnToBodyPressed;
public event Action? GhostRolesPressed;
public event Action? GhostBarPressed; // Goobstation - Ghost Bar
public event Action? ReturnToRoundPressed;

public GhostGui()
Expand All @@ -22,17 +25,21 @@ public GhostGui()

TargetWindow = new GhostTargetWindow();

GhostBarWindow = new GhostBarRulesWindow();

MouseFilter = MouseFilterMode.Ignore;

GhostWarpButton.OnPressed += _ => RequestWarpsPressed?.Invoke();
ReturnToBodyButton.OnPressed += _ => ReturnToBodyPressed?.Invoke();
GhostRolesButton.OnPressed += _ => GhostRolesPressed?.Invoke();
GhostBarButton.OnPressed += _ => GhostBarPressed?.Invoke(); // Goobstation - Ghost Bar
ReturnToRound.OnPressed += _ => ReturnToRoundPressed?.Invoke();
}

public void Hide()
{
TargetWindow.Close();
GhostBarWindow.Close(); // Goobstation - Ghost Bar
Visible = false;
}

Expand Down Expand Up @@ -63,6 +70,7 @@ protected override void Dispose(bool disposing)
if (disposing)
{
TargetWindow.Dispose();
GhostBarWindow.Dispose(); // Goobstation - Ghost Bar
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<DefaultWindow xmlns="https://spacestation14.io"
Title="{Loc 'ghost-target-window-ghostbar'}"
MinSize="500 300"
SetSize="500 300">
<BoxContainer Orientation="Vertical"
HorizontalExpand="True">
<RichTextLabel Name="TopBanner" VerticalExpand="True"/>
<Button Name="SpawnButton"
Text="{Loc 'ghost-window-spawn-ghostbar-button'}"
Disabled="True"
TextAlign="Center"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</BoxContainer>
</DefaultWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Content.Shared.CCVar;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client._Goobstation.UserInterface.Systems.Ghost.Controls
{
[GenerateTypedNameReferences]
public sealed partial class GhostBarRulesWindow : DefaultWindow
{
[Dependency] private readonly IConfigurationManager _cfg = IoCManager.Resolve<IConfigurationManager>();
private float _timer;

public event Action? SpawnButtonPressed;
public GhostBarRulesWindow()
{
RobustXamlLoader.Load(this);
var ghostBarTime = _cfg.GetCVar(CCVars.GhostRoleTime);
_timer = ghostBarTime;

if (ghostBarTime > 0f)
{
SpawnButton.Text = Loc.GetString("ghost-window-spawn-ghostbar-button-timer", ("time", $"{_timer:0.0}"));
TopBanner.SetMessage(FormattedMessage.FromMarkupPermissive(Loc.GetString("ghost-bar-rules") + "\n" + Loc.GetString("ghost-roles-window-rules-footer", ("time", ghostBarTime))));
SpawnButton.Disabled = true;
}

SpawnButton.OnPressed += _ => SpawnButtonPressed?.Invoke();
}


protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!SpawnButton.Disabled) return;
if (_timer > 0.0)
{
_timer -= args.DeltaSeconds;
SpawnButton.Text = Loc.GetString("ghost-window-spawn-ghostbar-button-timer", ("time", $"{_timer:0.0}"));
}
else
{
SpawnButton.Disabled = false;
SpawnButton.Text = Loc.GetString("ghost-window-spawn-ghostbar-button");
}
}
}

}
28 changes: 20 additions & 8 deletions Content.Server/Traits/TraitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
using Content.Shared.Customization.Systems;
using Content.Shared.Database;
using Content.Shared.Players;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Content.Shared.Traits;
using Robust.Server.Player;
using Robust.Shared.Configuration;
using Content.Shared.Whitelist;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager;
Expand Down Expand Up @@ -44,15 +46,25 @@ public override void Initialize()
}

// When the player is spawned in, add all trait components selected during character creation
private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args)
private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args) =>
ApplyTraits(args.Mob, args.JobId, args.Profile,
_playTimeTracking.GetTrackerTimes(args.Player), args.Player.ContentData()?.Whitelisted ?? false);

/// <summary>
/// Adds the traits selected by a player to an entity.
/// </summary>
public void ApplyTraits(EntityUid uid, ProtoId<JobPrototype>? jobId, HumanoidCharacterProfile profile,
Dictionary<string, TimeSpan> playTimes, bool whitelisted, bool punishCheater = true)
{
var pointsTotal = _configuration.GetCVar(CCVars.GameTraitsDefaultPoints);
var traitSelections = _configuration.GetCVar(CCVars.GameTraitsMax);
if (args.JobId is not null && !_prototype.TryIndex<JobPrototype>(args.JobId, out var jobPrototype)
if (jobId is not null && !_prototype.TryIndex(jobId, out var jobPrototype)
&& jobPrototype is not null && !jobPrototype.ApplyTraits)
return;

foreach (var traitId in args.Profile.TraitPreferences)
var jobPrototypeToUse = _prototype.Index(jobId ?? _prototype.EnumeratePrototypes<JobPrototype>().First().ID);

foreach (var traitId in profile.TraitPreferences)
{
if (!_prototype.TryIndex<TraitPrototype>(traitId, out var traitPrototype))
{
Expand All @@ -62,8 +74,8 @@ private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args)

if (!_characterRequirements.CheckRequirementsValid(
traitPrototype.Requirements,
_prototype.Index<JobPrototype>(args.JobId ?? _prototype.EnumeratePrototypes<JobPrototype>().First().ID),
args.Profile, _playTimeTracking.GetTrackerTimes(args.Player), args.Player.ContentData()?.Whitelisted ?? false, traitPrototype,
jobPrototypeToUse,
profile, playTimes, whitelisted, traitPrototype,
EntityManager, _prototype, _configuration,
out _))
continue;
Expand All @@ -72,11 +84,11 @@ private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args)
pointsTotal += traitPrototype.Points;
--traitSelections;

AddTrait(args.Mob, traitPrototype);
AddTrait(uid, traitPrototype);
}

if (pointsTotal < 0 || traitSelections < 0)
PunishCheater(args.Mob);
if (punishCheater && (pointsTotal < 0 || traitSelections < 0))
PunishCheater(uid);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Content.Server._Goobstation.Ghostbar.Components;

/// <summary>
/// Tracker for ghostbar players
/// </summary>
[RegisterComponent]
public sealed partial class GhostBarPlayerComponent : Component
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Content.Server._Goobstation.Ghostbar.Components;

/// <summary>
/// Target for ghosts to spawn at
/// </summary>
[RegisterComponent]
public sealed partial class GhostBarSpawnComponent : Component
{

}
Loading

0 comments on commit 0b4ceb2

Please sign in to comment.