-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
19,527 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Content.Client/Goobstation/UserInterface/Systems/Ghost/Controls/GhostBarRulesWindow.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
53 changes: 53 additions & 0 deletions
53
Content.Client/Goobstation/UserInterface/Systems/Ghost/Controls/GhostBarRulesWindow.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Content.Shared.CCVar; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
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"); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
Content.Server/Goobstation/Ghostbar/Components/GhostBarPlayerComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
Content.Server/Goobstation/Ghostbar/Components/GhostBarSpawnComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using Robust.Server.GameObjects; | ||
using Content.Server.GameTicking; | ||
using Content.Server.GameTicking.Events; | ||
using Content.Server.Station.Components; | ||
using Content.Server.Station.Events; | ||
using Content.Server.Station.Systems; | ||
using Robust.Shared.Map; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Server.Maps; | ||
using Robust.Shared.Random; | ||
using Content.Shared.Ghost; | ||
using Content.Server.Goobstation.Ghostbar.Components; | ||
using Content.Server.Mind; | ||
using Content.Shared.Mind; | ||
using Content.Shared.Mind.Components; | ||
using Content.Shared.Roles.Jobs; | ||
using Content.Shared.Roles; | ||
using Content.Shared.Inventory; | ||
|
||
namespace Content.Server.Goobstation.Ghostbar; | ||
|
||
public sealed class GhostBarSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedMapSystem _mapSystem = default!; | ||
[Dependency] private readonly MapLoaderSystem _mapLoader = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
[Dependency] private readonly GameTicker _ticker = default!; | ||
[Dependency] private readonly StationSpawningSystem _spawningSystem = default!; | ||
[Dependency] private readonly MindSystem _mindSystem = default!; | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
|
||
private static readonly List<JobComponent> _jobComponents = new() | ||
{ | ||
new JobComponent { Prototype = "Passenger" }, | ||
new JobComponent { Prototype = "Bartender" }, | ||
new JobComponent { Prototype = "Botanist" }, | ||
new JobComponent { Prototype = "Chef" }, | ||
new JobComponent { Prototype = "Janitor" } | ||
}; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<RoundStartingEvent>(OnRoundStart); | ||
SubscribeNetworkEvent<GhostBarSpawnEvent>(SpawnPlayer); | ||
SubscribeLocalEvent<GhostBarPlayerComponent, MindRemovedMessage>(OnPlayerGhosted); | ||
} | ||
|
||
const string MapPath = "Maps/_LostParadise/LPPghostbar.yml"; | ||
private void OnRoundStart(RoundStartingEvent ev) | ||
{ | ||
_mapSystem.CreateMap(out var mapId); | ||
var options = new MapLoadOptions { LoadMap = true }; | ||
|
||
if (_mapLoader.TryLoad(mapId, MapPath, out _, options)) | ||
_mapSystem.SetPaused(mapId, false); | ||
} | ||
|
||
public void SpawnPlayer(GhostBarSpawnEvent msg, EntitySessionEventArgs args) | ||
{ | ||
if (!_entityManager.HasComponent<GhostComponent>(args.SenderSession.AttachedEntity)) | ||
{ | ||
Log.Warning($"User {args.SenderSession.Name} tried to spawn at ghost bar without being a ghost."); | ||
return; | ||
} | ||
|
||
var spawnPoints = new List<EntityCoordinates>(); | ||
var query = EntityQueryEnumerator<GhostBarSpawnComponent>(); | ||
while (query.MoveNext(out var ent, out _)) | ||
{ | ||
spawnPoints.Add(_entityManager.GetComponent<TransformComponent>(ent).Coordinates); | ||
} | ||
|
||
if (spawnPoints.Count == 0) | ||
{ | ||
Log.Warning("No spawn points found for ghost bar."); | ||
return; | ||
} | ||
|
||
|
||
var randomSpawnPoint = _random.Pick(spawnPoints); | ||
var randomJob = _random.Pick(_jobComponents); | ||
var profile = _ticker.GetPlayerProfile(args.SenderSession); | ||
var mobUid = _spawningSystem.SpawnPlayerMob(randomSpawnPoint, randomJob, profile, null); | ||
|
||
_entityManager.EnsureComponent<GhostBarPlayerComponent>(mobUid); | ||
|
||
var targetMind = _mindSystem.GetMind(args.SenderSession.UserId); | ||
|
||
|
||
if (targetMind != null) | ||
{ | ||
_mindSystem.TransferTo(targetMind.Value, mobUid, true); | ||
} | ||
} | ||
|
||
private void OnPlayerGhosted(EntityUid uid, GhostBarPlayerComponent component, MindRemovedMessage args) | ||
{ | ||
_entityManager.DeleteEntity(uid); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ghost-target-window-ghostbar = Ghost Bar | ||
ghost-window-spawn-ghostbar-button = Spawn at Ghost Bar | ||
ghost-window-spawn-ghostbar-button-timer = Spawn at Ghost Bar ({$time}s) | ||
ghost-bar-rules = Treat this role, and station, as you would just being a regular Ghost. You may talk about all current round events without the need for LOOC, and you remember everything from your previous life. DO NOT attack others, start fights, or attempt to break the station. If you see anyone doing this, please Ahelp and they will be promptly thrown into space. Also, if you decide to leave the bar, you DO NOT remember anything from being here, or your life before it. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ghost-target-window-ghostbar = Призрачный бар | ||
ghost-window-spawn-ghostbar-button = Появится в призрачном баре | ||
ghost-window-spawn-ghostbar-button-timer = Появится в призрачном баре ({$time}s) | ||
ghost-bar-rules = Беря эту роль, относитесь к ней так же, будто вы остались обычным гостом, вы можете говорить обо всём что происходит в раунде без надобности в LOOC, и вы помните всё что с вами произошло. Просим вас НЕ нападать на остальных, не затевать драк и не пытаться сломать станцию или выбраться из неё, если вы увидели кого то, кто делает что либо из этого, пожалуйста, обратитесь в Ahelp (клавиша F1) и нарушители будут успешно выкинуты в бескрайний космос, также, если вы решили покинуть этот бар, вы не помните НИЧЕГО, из того, что тут происходило, как и вашу прошлую жизнь | ||
Oops, something went wrong.