Refactor how jobs are handed out (#5422)

* Completely refactor how job spawning works

* Remove remains of old system.

* Squash the final bug, cleanup.

* Attempt to fix tests

* Adjusts packed's round-start crew roster, re-enables a bunch of old roles.
Also adds the Central Command Official as a proper role.

* pretty up ui

* refactor StationSystem into the correct folder & namespace.

* remove a log, make sure the lobby gets updated if a new map is spontaneously added.

* re-add accidentally removed log

* We do a little logging

* we do a little resolving

* we do a little documenting

* Renamed OverflowJob to FallbackOverflowJob
Allows stations to configure their own roundstart overflow job list.

* narrator: it did not compile

* oops

* support having no overflow jobs

* filescope for consistency

* small fixes

* Bumps a few role counts for Packed, namely engis

* log moment

* E

* Update Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>

* Update Content.Server/Maps/GameMapPrototype.cs

Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>

* factored job logic, cleanup.

* e

* Address reviews

* Remove the concept of a "default" grid.
It has no future in our new multi-station world

* why was clickable using that in the first place

* fix bad evil bug that almost slipped through
also adds chemist

* rms obsolete things from chemist

* Adds a sanity fallback

* address reviews

* adds ability to set name

* fuck

* cleanup joingame
This commit is contained in:
Moony
2021-11-26 03:02:46 -06:00
committed by GitHub
parent dfb329d5db
commit ec68226e99
53 changed files with 1148 additions and 705 deletions

View File

@@ -5,10 +5,12 @@ using Content.Client.RoundEnd;
using Content.Client.Viewport; using Content.Client.Viewport;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.GameWindow; using Content.Shared.GameWindow;
using Content.Shared.Station;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.State; using Robust.Client.State;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -21,7 +23,8 @@ namespace Content.Client.GameTicking.Managers
[Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly IStateManager _stateManager = default!;
[ViewVariables] private bool _initialized; [ViewVariables] private bool _initialized;
private readonly List<string> _jobsAvailable = new(); private Dictionary<StationId, Dictionary<string, int>> _jobsAvailable = new();
private Dictionary<StationId, string> _stationNames = new();
[ViewVariables] public bool AreWeReady { get; private set; } [ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; } [ViewVariables] public bool IsGameStarted { get; private set; }
@@ -31,13 +34,14 @@ namespace Content.Client.GameTicking.Managers
[ViewVariables] public TimeSpan StartTime { get; private set; } [ViewVariables] public TimeSpan StartTime { get; private set; }
[ViewVariables] public bool Paused { get; private set; } [ViewVariables] public bool Paused { get; private set; }
[ViewVariables] public Dictionary<NetUserId, LobbyPlayerStatus> Status { get; private set; } = new(); [ViewVariables] public Dictionary<NetUserId, LobbyPlayerStatus> Status { get; private set; } = new();
[ViewVariables] public IReadOnlyList<string> JobsAvailable => _jobsAvailable; [ViewVariables] public IReadOnlyDictionary<StationId, Dictionary<string, int>> JobsAvailable => _jobsAvailable;
[ViewVariables] public IReadOnlyDictionary<StationId, string> StationNames => _stationNames;
public event Action? InfoBlobUpdated; public event Action? InfoBlobUpdated;
public event Action? LobbyStatusUpdated; public event Action? LobbyStatusUpdated;
public event Action? LobbyReadyUpdated; public event Action? LobbyReadyUpdated;
public event Action? LobbyLateJoinStatusUpdated; public event Action? LobbyLateJoinStatusUpdated;
public event Action<IReadOnlyList<string>>? LobbyJobsAvailableUpdated; public event Action<IReadOnlyDictionary<StationId, Dictionary<string, int>>>? LobbyJobsAvailableUpdated;
public override void Initialize() public override void Initialize()
{ {
@@ -69,8 +73,8 @@ namespace Content.Client.GameTicking.Managers
private void UpdateJobsAvailable(TickerJobsAvailableEvent message) private void UpdateJobsAvailable(TickerJobsAvailableEvent message)
{ {
_jobsAvailable.Clear(); _jobsAvailable = message.JobsAvailableByStation;
_jobsAvailable.AddRange(message.JobsAvailable); _stationNames = message.StationNames;
LobbyJobsAvailableUpdated?.Invoke(JobsAvailable); LobbyJobsAvailableUpdated?.Invoke(JobsAvailable);
} }

View File

@@ -2,9 +2,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Client.GameTicking.Managers; using Content.Client.GameTicking.Managers;
using Content.Client.HUD.UI;
using Content.Shared.Roles; using Content.Shared.Roles;
using Content.Shared.Station;
using Robust.Client.Console; using Robust.Client.Console;
using Robust.Client.Graphics;
using Robust.Client.UserInterface; using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
@@ -25,10 +26,13 @@ namespace Content.Client.LateJoin
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IClientConsoleHost _consoleHost = default!; [Dependency] private readonly IClientConsoleHost _consoleHost = default!;
public event Action<string>? SelectedId; public event Action<(StationId, string)> SelectedId;
private readonly Dictionary<string, JobButton> _jobButtons = new(); private readonly Dictionary<StationId, Dictionary<string, JobButton>> _jobButtons = new();
private readonly Dictionary<string, BoxContainer> _jobCategories = new(); private readonly Dictionary<StationId, Dictionary<string, BoxContainer>> _jobCategories = new();
private readonly List<ScrollContainer> _jobLists = new();
private readonly Control _base;
public LateJoinGui() public LateJoinGui()
{ {
@@ -38,36 +42,112 @@ namespace Content.Client.LateJoin
var gameTicker = EntitySystem.Get<ClientGameTicker>(); var gameTicker = EntitySystem.Get<ClientGameTicker>();
Title = Loc.GetString("late-join-gui-title"); Title = Loc.GetString("late-join-gui-title");
_base = new BoxContainer()
{
Orientation = LayoutOrientation.Vertical,
VerticalExpand = true,
Margin = new Thickness(0),
};
Contents.AddChild(_base);
RebuildUI();
SelectedId += x =>
{
var (station, jobId) = x;
Logger.InfoS("latejoin", $"Late joining as ID: {jobId}");
_consoleHost.ExecuteCommand($"joingame {CommandParsing.Escape(jobId)} {station.Id}");
Close();
};
gameTicker.LobbyJobsAvailableUpdated += JobsAvailableUpdated;
}
private void RebuildUI()
{
_base.RemoveAllChildren();
_jobLists.Clear();
_jobButtons.Clear();
_jobCategories.Clear();
var gameTicker = EntitySystem.Get<ClientGameTicker>();
foreach (var (id, name) in gameTicker.StationNames)
{
var jobList = new BoxContainer var jobList = new BoxContainer
{ {
Orientation = LayoutOrientation.Vertical Orientation = LayoutOrientation.Vertical
}; };
var vBox = new BoxContainer
var collapseButton = new ContainerButton()
{ {
Orientation = LayoutOrientation.Vertical, HorizontalAlignment = HAlignment.Right,
ToggleMode = true,
Children = Children =
{ {
new ScrollContainer new TextureRect
{ {
VerticalExpand = true, StyleClasses = { OptionButton.StyleClassOptionTriangle },
Children = Margin = new Thickness(8, 0),
{ HorizontalAlignment = HAlignment.Center,
jobList VerticalAlignment = VAlignment.Center,
}
} }
} }
}; };
Contents.AddChild(vBox); _base.AddChild(new StripeBack()
{
Children = {
new PanelContainer()
{
Children =
{
new Label()
{
StyleClasses = { "LabelBig" },
Text = $"NTSS {name}",
Align = Label.AlignMode.Center,
},
collapseButton
}
}
}
});
var jobListScroll = new ScrollContainer()
{
VerticalExpand = true,
Children = {jobList},
Visible = false,
};
if (_jobLists.Count == 0)
jobListScroll.Visible = true;
_jobLists.Add(jobListScroll);
_base.AddChild(jobListScroll);
collapseButton.OnToggled += _ =>
{
foreach (var section in _jobLists)
{
section.Visible = false;
}
jobListScroll.Visible = true;
};
var firstCategory = true; var firstCategory = true;
foreach (var job in _prototypeManager.EnumeratePrototypes<JobPrototype>().OrderBy(j => j.Name)) foreach (var job in gameTicker.JobsAvailable[id].OrderBy(x => x.Key))
{ {
foreach (var department in job.Departments) var prototype = _prototypeManager.Index<JobPrototype>(job.Key);
foreach (var department in prototype.Departments)
{ {
if (!_jobCategories.TryGetValue(department, out var category)) if (!_jobCategories.TryGetValue(id, out var _))
_jobCategories[id] = new Dictionary<string, BoxContainer>();
if (!_jobButtons.TryGetValue(id, out var _))
_jobButtons[id] = new Dictionary<string, JobButton>();
if (!_jobCategories[id].TryGetValue(department, out var category))
{ {
category = new BoxContainer category = new BoxContainer
{ {
@@ -91,21 +171,21 @@ namespace Content.Client.LateJoin
category.AddChild(new PanelContainer category.AddChild(new PanelContainer
{ {
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#464966")},
Children = Children =
{ {
new Label new Label
{ {
StyleClasses = { "LabelBig" },
Text = Loc.GetString("late-join-gui-department-jobs-label", ("departmentName", department)) Text = Loc.GetString("late-join-gui-department-jobs-label", ("departmentName", department))
} }
} }
}); });
_jobCategories[department] = category; _jobCategories[id][department] = category;
jobList.AddChild(category); jobList.AddChild(category);
} }
var jobButton = new JobButton(job.ID); var jobButton = new JobButton(prototype.ID, job.Value);
var jobSelector = new BoxContainer var jobSelector = new BoxContainer
{ {
@@ -119,9 +199,9 @@ namespace Content.Client.LateJoin
Stretch = TextureRect.StretchMode.KeepCentered Stretch = TextureRect.StretchMode.KeepCentered
}; };
if (job.Icon != null) if (prototype.Icon != null)
{ {
var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), job.Icon); var specifier = new SpriteSpecifier.Rsi(new ResourcePath("/Textures/Interface/Misc/job_icons.rsi"), prototype.Icon);
icon.Texture = specifier.Frame0(); icon.Texture = specifier.Frame0();
} }
@@ -129,7 +209,9 @@ namespace Content.Client.LateJoin
var jobLabel = new Label var jobLabel = new Label
{ {
Text = job.Name Text = job.Value >= 0 ?
Loc.GetString("late-join-gui-job-slot-capped", ("jobName", prototype.Name), ("amount", job.Value)) :
Loc.GetString("late-join-gui-job-slot-uncapped", ("jobName", prototype.Name))
}; };
jobSelector.AddChild(jobLabel); jobSelector.AddChild(jobLabel);
@@ -138,34 +220,23 @@ namespace Content.Client.LateJoin
jobButton.OnPressed += _ => jobButton.OnPressed += _ =>
{ {
SelectedId?.Invoke(jobButton.JobId); SelectedId?.Invoke((id, jobButton.JobId));
}; };
if (!gameTicker.JobsAvailable.Contains(job.ID)) if (job.Value == 0)
{ {
jobButton.Disabled = true; jobButton.Disabled = true;
} }
_jobButtons[job.ID] = jobButton; _jobButtons[id][prototype.ID] = jobButton;
}
}
} }
} }
SelectedId += jobId => private void JobsAvailableUpdated(IReadOnlyDictionary<StationId, Dictionary<string, int>> _)
{ {
Logger.InfoS("latejoin", $"Late joining as ID: {jobId}"); RebuildUI();
_consoleHost.ExecuteCommand($"joingame {CommandParsing.Escape(jobId)}");
Close();
};
gameTicker.LobbyJobsAvailableUpdated += JobsAvailableUpdated;
}
private void JobsAvailableUpdated(IReadOnlyList<string> jobs)
{
foreach (var (id, button) in _jobButtons)
{
button.Disabled = !jobs.Contains(id);
}
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
@@ -184,10 +255,12 @@ namespace Content.Client.LateJoin
class JobButton : ContainerButton class JobButton : ContainerButton
{ {
public string JobId { get; } public string JobId { get; }
public int Amount { get; }
public JobButton(string jobId) public JobButton(string jobId, int amount)
{ {
JobId = jobId; JobId = jobId;
Amount = amount;
AddStyleClass(StyleClassButton); AddStyleClass(StyleClassButton);
} }
} }

View File

@@ -144,7 +144,7 @@ namespace Content.Client.Lobby.UI
var highPriorityJob = profile.JobPriorities.FirstOrDefault(p => p.Value == JobPriority.High).Key; var highPriorityJob = profile.JobPriorities.FirstOrDefault(p => p.Value == JobPriority.High).Key;
var job = protoMan.Index<JobPrototype>(highPriorityJob ?? SharedGameTicker.OverflowJob); var job = protoMan.Index<JobPrototype>(highPriorityJob ?? SharedGameTicker.FallbackOverflowJob);
inventory.ClearAllSlotVisuals(); inventory.ClearAllSlotVisuals();

View File

@@ -307,7 +307,7 @@ namespace Content.Client.Preferences.UI
(int) PreferenceUnavailableMode.StayInLobby); (int) PreferenceUnavailableMode.StayInLobby);
_preferenceUnavailableButton.AddItem( _preferenceUnavailableButton.AddItem(
Loc.GetString("humanoid-profile-editor-preference-unavailable-spawn-as-overflow-button", Loc.GetString("humanoid-profile-editor-preference-unavailable-spawn-as-overflow-button",
("overflowJob", Loc.GetString(SharedGameTicker.OverflowJobName))), ("overflowJob", Loc.GetString(SharedGameTicker.FallbackOverflowJobName))),
(int) PreferenceUnavailableMode.SpawnAsOverflow); (int) PreferenceUnavailableMode.SpawnAsOverflow);
_preferenceUnavailableButton.OnItemSelected += args => _preferenceUnavailableButton.OnItemSelected += args =>

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Content.Client.Clickable; using Content.Client.Clickable;
using Content.Server.GameTicking; using Content.Server.GameTicking;
@@ -6,10 +7,8 @@ using NUnit.Framework;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared; using Robust.Shared;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Timing;
namespace Content.IntegrationTests.Tests namespace Content.IntegrationTests.Tests
{ {
@@ -76,7 +75,7 @@ namespace Content.IntegrationTests.Tests
await _server.WaitPost(() => await _server.WaitPost(() =>
{ {
var gridEnt = mapManager.GetGrid(gameTicker.DefaultGridId).GridEntityId; var gridEnt = mapManager.GetAllGrids().First().GridEntityId;
worldPos = serverEntManager.GetEntity(gridEnt).Transform.WorldPosition; worldPos = serverEntManager.GetEntity(gridEnt).Transform.WorldPosition;
var ent = serverEntManager.SpawnEntity(prototype, new EntityCoordinates(gridEnt, 0f, 0f)); var ent = serverEntManager.SpawnEntity(prototype, new EntityCoordinates(gridEnt, 0f, 0f));

View File

@@ -0,0 +1,66 @@
using Content.Server.Maps;
using Content.Server.Roles;
using Content.Server.Station;
using Content.Shared.Administration;
using Robust.Server.Maps;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
namespace Content.Server.Administration.Commands
{
[AdminCommand(AdminFlags.Fun)]
public sealed class LoadGameMapCommand : IConsoleCommand
{
public string Command => "loadgamemap";
public string Description => "Loads the given game map at the given coordinates.";
public string Help => "loadgamemap <gamemap> <mapid> [<x> <y> [<name>]] ";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
var mapLoader = IoCManager.Resolve<IMapLoader>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var stationSystem = entityManager.EntitySysManager.GetEntitySystem<StationSystem>();
if (args.Length is not (2 or 4 or 5))
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
return;
}
if (prototypeManager.TryIndex<GameMapPrototype>(args[0], out var gameMap))
{
if (int.TryParse(args[1], out var mapId))
{
var gameMapEnt = mapLoader.LoadBlueprint(new MapId(mapId), gameMap.MapPath);
if (gameMapEnt is null)
{
shell.WriteError($"Failed to create the given game map, is the path {gameMap.MapPath} correct?");
return;
}
if (args.Length >= 4 && int.TryParse(args[2], out var x) && int.TryParse(args[3], out var y))
{
var transform = entityManager.GetComponent<TransformComponent>(gameMapEnt.GridEntityId);
transform.WorldPosition = new Vector2(x, y);
}
var stationName = args.Length == 5 ? args[4] : null;
stationSystem.InitialSetupStationGrid(gameMapEnt.GridEntityId, gameMap, stationName);
}
}
else
{
shell.WriteError($"The given map prototype {args[0]} is invalid.");
}
}
}
}

View File

@@ -1,10 +1,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using Content.Server.Administration; using Content.Server.Administration;
using Content.Server.Roles;
using Content.Server.Station;
using Content.Shared.Roles; using Content.Shared.Roles;
using Content.Shared.Station;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Console; using Robust.Shared.Console;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Server.GameTicking.Commands namespace Content.Server.GameTicking.Commands
@@ -24,35 +28,47 @@ namespace Content.Server.GameTicking.Commands
} }
public void Execute(IConsoleShell shell, string argStr, string[] args) public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 2)
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
return;
}
var player = shell.Player as IPlayerSession; var player = shell.Player as IPlayerSession;
var output = string.Join(".", args);
if (player == null) if (player == null)
{ {
return; return;
} }
var ticker = EntitySystem.Get<GameTicker>(); var ticker = EntitySystem.Get<GameTicker>();
var stationSystem = EntitySystem.Get<StationSystem>();
if (ticker.RunLevel == GameRunLevel.PreRoundLobby) if (ticker.RunLevel == GameRunLevel.PreRoundLobby)
{ {
shell.WriteLine("Round has not started."); shell.WriteLine("Round has not started.");
return; return;
} }
else if(ticker.RunLevel == GameRunLevel.InRound) else if (ticker.RunLevel == GameRunLevel.InRound)
{ {
string ID = args[0]; string id = args[0];
var positions = ticker.GetAvailablePositions();
if(positions.GetValueOrDefault(ID, 0) == 0) //n < 0 is treated as infinite if (!uint.TryParse(args[1], out var sid))
{ {
var jobPrototype = _prototypeManager.Index<JobPrototype>(ID); shell.WriteError(Loc.GetString("shell-argument-must-be-number"));
}
var stationId = new StationId(sid);
if(!stationSystem.IsJobAvailableOnStation(stationId, id))
{
var jobPrototype = _prototypeManager.Index<JobPrototype>(id);
shell.WriteLine($"{jobPrototype.Name} has no available slots."); shell.WriteLine($"{jobPrototype.Name} has no available slots.");
return; return;
} }
ticker.MakeJoinGame(player, args[0]); ticker.MakeJoinGame(player, stationId, id);
return; return;
} }
ticker.MakeJoinGame(player); ticker.MakeJoinGame(player, StationId.Invalid);
} }
} }
} }

View File

@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
@@ -6,6 +5,7 @@ using System.Linq;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Preferences; using Content.Shared.Preferences;
using Content.Shared.Roles; using Content.Shared.Roles;
using Content.Shared.Station;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Network; using Robust.Shared.Network;
@@ -25,25 +25,14 @@ namespace Content.Server.GameTicking
[ViewVariables] [ViewVariables]
private readonly Dictionary<string, int> _spawnedPositions = new(); private readonly Dictionary<string, int> _spawnedPositions = new();
private Dictionary<IPlayerSession, string> AssignJobs(List<IPlayerSession> available, private Dictionary<IPlayerSession, (string, StationId)> AssignJobs(List<IPlayerSession> available,
Dictionary<NetUserId, HumanoidCharacterProfile> profiles) Dictionary<NetUserId, HumanoidCharacterProfile> profiles)
{ {
// Calculate positions available round-start for each job. var assigned = new Dictionary<IPlayerSession, (string, StationId)>();
var availablePositions = GetBasePositions(true);
// Output dictionary of assigned jobs. List<(IPlayerSession, List<string>)> GetPlayersJobCandidates(bool heads, JobPriority i)
var assigned = new Dictionary<IPlayerSession, string>();
// Go over each priority level top to bottom.
for (var i = JobPriority.High; i > JobPriority.Never; i--)
{ {
void ProcessJobs(bool heads) return available.Select(player =>
{
// Get all candidates for this priority & heads combo.
// That is all people with at LEAST one job at this priority & heads level,
// and the jobs they have selected here.
var candidates = available
.Select(player =>
{ {
var profile = profiles[player.UserId]; var profile = profiles[player.UserId];
@@ -56,6 +45,7 @@ namespace Content.Server.GameTicking
// Job doesn't exist, probably old data? // Job doesn't exist, probably old data?
return false; return false;
} }
if (job.IsHead != heads) if (job.IsHead != heads)
{ {
return false; return false;
@@ -70,8 +60,11 @@ namespace Content.Server.GameTicking
}) })
.Where(p => p.availableJobs.Count != 0) .Where(p => p.availableJobs.Count != 0)
.ToList(); .ToList();
}
_robustRandom.Shuffle(candidates); void ProcessJobs(bool heads, Dictionary<string, int> availablePositions, StationId id, JobPriority i)
{
var candidates = GetPlayersJobCandidates(heads, i);
foreach (var (candidate, jobs) in candidates) foreach (var (candidate, jobs) in candidates)
{ {
@@ -87,7 +80,7 @@ namespace Content.Server.GameTicking
} }
availablePositions[picked] -= 1; availablePositions[picked] -= 1;
assigned.Add(candidate, picked); assigned.Add(candidate, (picked, id));
break; break;
} }
} }
@@ -95,61 +88,27 @@ namespace Content.Server.GameTicking
available.RemoveAll(a => assigned.ContainsKey(a)); available.RemoveAll(a => assigned.ContainsKey(a));
} }
// Process heads FIRST. // Current strategy is to fill each station one by one.
// This means that if you have head and non-head roles on the same priority level, foreach (var (id, station) in _stationSystem.StationInfo)
// you will always get picked as head. {
// Unless of course somebody beats you to those head roles. // Get the ROUND-START job list.
ProcessJobs(true); var availablePositions = station.MapPrototype.AvailableJobs.ToDictionary(x => x.Key, x => x.Value[0]);
ProcessJobs(false);
for (var i = JobPriority.High; i > JobPriority.Never; i--)
{
// Process jobs possible for heads...
ProcessJobs(true, availablePositions, id, i);
// and then jobs that are not heads.
ProcessJobs(false, availablePositions, id, i);
}
} }
return assigned; return assigned;
} }
/// <summary> private string PickBestAvailableJob(HumanoidCharacterProfile profile, StationId station)
/// Gets the available positions for all jobs, *not* accounting for the current crew manifest.
/// </summary>
private Dictionary<string, int> GetBasePositions(bool roundStart)
{ {
var availablePositions = _prototypeManager var available = _stationSystem.StationInfo[station].JobList;
.EnumeratePrototypes<JobPrototype>()
// -1 is treated as infinite slots.
.ToDictionary(job => job.ID, job =>
{
if (job.SpawnPositions < 0)
{
return int.MaxValue;
}
if (roundStart)
{
return job.SpawnPositions;
}
return job.TotalPositions;
});
return availablePositions;
}
/// <summary>
/// Gets the remaining available job positions in the current round.
/// </summary>
public Dictionary<string, int> GetAvailablePositions()
{
var basePositions = GetBasePositions(false);
foreach (var (jobId, count) in _spawnedPositions)
{
basePositions[jobId] = Math.Max(0, basePositions[jobId] - count);
}
return basePositions;
}
private string PickBestAvailableJob(HumanoidCharacterProfile profile)
{
var available = GetAvailablePositions();
bool TryPick(JobPriority priority, [NotNullWhen(true)] out string? jobId) bool TryPick(JobPriority priority, [NotNullWhen(true)] out string? jobId)
{ {
@@ -188,18 +147,17 @@ namespace Content.Server.GameTicking
return picked; return picked;
} }
return OverflowJob; var overflows = _stationSystem.StationInfo[station].MapPrototype.OverflowJobs.Clone().ToList();
return _robustRandom.Pick(overflows);
} }
[Conditional("DEBUG")] [Conditional("DEBUG")]
private void InitializeJobController() private void InitializeJobController()
{ {
// Verify that the overflow role exists and has the correct name. // Verify that the overflow role exists and has the correct name.
var role = _prototypeManager.Index<JobPrototype>(OverflowJob); var role = _prototypeManager.Index<JobPrototype>(FallbackOverflowJob);
DebugTools.Assert(role.Name == Loc.GetString(OverflowJobName), DebugTools.Assert(role.Name == Loc.GetString(FallbackOverflowJobName),
"Overflow role does not have the correct name!"); "Overflow role does not have the correct name!");
DebugTools.Assert(role.SpawnPositions < 0, "Overflow role must have infinite spawn positions!");
} }
private void AddSpawnedPosition(string jobId) private void AddSpawnedPosition(string jobId)
@@ -211,17 +169,21 @@ namespace Content.Server.GameTicking
{ {
// If late join is disallowed, return no available jobs. // If late join is disallowed, return no available jobs.
if (DisallowLateJoin) if (DisallowLateJoin)
return new TickerJobsAvailableEvent(Array.Empty<string>()); return new TickerJobsAvailableEvent(new Dictionary<StationId, string>(), new Dictionary<StationId, Dictionary<string, int>>());
var jobs = GetAvailablePositions() var jobs = new Dictionary<StationId, Dictionary<string, int>>();
.Where(e => e.Value > 0) var stationNames = new Dictionary<StationId, string>();
.Select(e => e.Key)
.ToArray();
return new TickerJobsAvailableEvent(jobs); foreach (var (id, station) in _stationSystem.StationInfo)
{
var list = station.JobList.ToDictionary(x => x.Key, x => x.Value);
jobs.Add(id, list);
stationNames.Add(id, station.Name);
}
return new TickerJobsAvailableEvent(stationNames, jobs);
} }
private void UpdateJobsAvailable() public void UpdateJobsAvailable()
{ {
RaiseNetworkEvent(GetJobsAvailable(), Filter.Empty().AddPlayers(_playersInLobby.Keys)); RaiseNetworkEvent(GetJobsAvailable(), Filter.Empty().AddPlayers(_playersInLobby.Keys));
} }

View File

@@ -1,8 +1,11 @@
using System; using System;
using Content.Server.Players; using Content.Server.Players;
using Content.Server.Roles;
using Content.Server.Station;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.GameWindow; using Content.Shared.GameWindow;
using Content.Shared.Preferences; using Content.Shared.Preferences;
using Content.Shared.Station;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.Enums; using Robust.Shared.Enums;
@@ -107,7 +110,7 @@ namespace Content.Server.GameTicking
async void SpawnWaitPrefs() async void SpawnWaitPrefs()
{ {
await _prefsManager.WaitPreferencesLoaded(session); await _prefsManager.WaitPreferencesLoaded(session);
SpawnPlayer(session); SpawnPlayer(session, StationId.Invalid);
} }
async void AddPlayerToDb(Guid id) async void AddPlayerToDb(Guid id)

View File

@@ -6,10 +6,13 @@ using Content.Server.GameTicking.Events;
using Content.Server.Players; using Content.Server.Players;
using Content.Server.Mind; using Content.Server.Mind;
using Content.Server.Ghost; using Content.Server.Ghost;
using Content.Server.Roles;
using Content.Server.Station;
using Content.Shared.CCVar; using Content.Shared.CCVar;
using Content.Shared.Coordinates; using Content.Shared.Coordinates;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Preferences; using Content.Shared.Preferences;
using Content.Shared.Station;
using Prometheus; using Prometheus;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
@@ -64,14 +67,17 @@ namespace Content.Server.GameTicking
{ {
DefaultMap = _mapManager.CreateMap(); DefaultMap = _mapManager.CreateMap();
var startTime = _gameTiming.RealTime; var startTime = _gameTiming.RealTime;
var map = _gameMapManager.GetSelectedMapChecked(true).MapPath; var map = _gameMapManager.GetSelectedMapChecked(true);
var grid = _mapLoader.LoadBlueprint(DefaultMap, map); var grid = _mapLoader.LoadBlueprint(DefaultMap, map.MapPath);
if (grid == null) if (grid == null)
{ {
throw new InvalidOperationException($"No grid found for map {map}"); throw new InvalidOperationException($"No grid found for map {map.MapName}");
} }
_stationSystem.InitialSetupStationGrid(grid.GridEntityId, map);
var stationXform = EntityManager.GetComponent<TransformComponent>(grid.GridEntityId); var stationXform = EntityManager.GetComponent<TransformComponent>(grid.GridEntityId);
if (StationOffset) if (StationOffset)
@@ -87,7 +93,6 @@ namespace Content.Server.GameTicking
stationXform.LocalRotation = _robustRandom.NextFloat(MathF.Tau); stationXform.LocalRotation = _robustRandom.NextFloat(MathF.Tau);
} }
DefaultGridId = grid.Index;
_spawnPoint = grid.ToCoordinates(); _spawnPoint = grid.ToCoordinates();
var timeSpan = _gameTiming.RealTime - startTime; var timeSpan = _gameTiming.RealTime - startTime;
@@ -153,14 +158,36 @@ namespace Content.Server.GameTicking
var profile = profiles[player.UserId]; var profile = profiles[player.UserId];
if (profile.PreferenceUnavailable == PreferenceUnavailableMode.SpawnAsOverflow) if (profile.PreferenceUnavailable == PreferenceUnavailableMode.SpawnAsOverflow)
{ {
assignedJobs.Add(player, OverflowJob); // Pick a random station
var stations = _stationSystem.StationInfo.Keys.ToList();
_robustRandom.Shuffle(stations);
if (stations.Count == 0)
{
assignedJobs.Add(player, (FallbackOverflowJob, StationId.Invalid));
continue;
}
foreach (var station in stations)
{
// Pick a random overflow job from that station
var overflows = _stationSystem.StationInfo[station].MapPrototype.OverflowJobs.Clone();
_robustRandom.Shuffle(overflows);
// Stations with no overflow slots should simply get skipped over.
if (overflows.Count == 0)
continue;
// If the overflow exists, put them in as it.
assignedJobs.Add(player, (overflows[0], stations[0]));
}
} }
} }
// Spawn everybody in! // Spawn everybody in!
foreach (var (player, job) in assignedJobs) foreach (var (player, (job, station)) in assignedJobs)
{ {
SpawnPlayer(player, profiles[player.UserId], job, false); SpawnPlayer(player, profiles[player.UserId], station, job, false);
} }
// Time to start the preset. // Time to start the preset.

View File

@@ -1,9 +1,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq;
using Content.Server.Access.Components; using Content.Server.Access.Components;
using Content.Server.Access.Systems; using Content.Server.Access.Systems;
using Content.Server.CharacterAppearance.Components;
using Content.Server.Ghost; using Content.Server.Ghost;
using Content.Server.Ghost.Components; using Content.Server.Ghost.Components;
using Content.Server.Hands.Components; using Content.Server.Hands.Components;
@@ -14,12 +14,15 @@ using Content.Server.Players;
using Content.Server.Roles; using Content.Server.Roles;
using Content.Server.Spawners.Components; using Content.Server.Spawners.Components;
using Content.Server.Speech.Components; using Content.Server.Speech.Components;
using Content.Server.Station;
using Content.Shared.Administration.Logs;
using Content.Shared.CharacterAppearance.Systems; using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Ghost; using Content.Shared.Ghost;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Preferences; using Content.Shared.Preferences;
using Content.Shared.Roles; using Content.Shared.Roles;
using Content.Shared.Station;
using Robust.Server.Player; using Robust.Server.Player;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -28,6 +31,7 @@ using Robust.Shared.Map;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
using static Content.Server.Station.StationSystem;
namespace Content.Server.GameTicking namespace Content.Server.GameTicking
{ {
@@ -38,22 +42,35 @@ namespace Content.Server.GameTicking
[Dependency] private readonly IdCardSystem _cardSystem = default!; [Dependency] private readonly IdCardSystem _cardSystem = default!;
/// <summary>
/// Can't yet be removed because every test ever seems to depend on it. I'll make removing this a different PR.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
private EntityCoordinates _spawnPoint; private EntityCoordinates _spawnPoint;
// Mainly to avoid allocations. // Mainly to avoid allocations.
private readonly List<EntityCoordinates> _possiblePositions = new(); private readonly List<EntityCoordinates> _possiblePositions = new();
private void SpawnPlayer(IPlayerSession player, string? jobId = null, bool lateJoin = true) private void SpawnPlayer(IPlayerSession player, StationId station, string? jobId = null, bool lateJoin = true)
{ {
var character = GetPlayerProfile(player); var character = GetPlayerProfile(player);
SpawnPlayer(player, character, jobId, lateJoin); SpawnPlayer(player, character, station, jobId, lateJoin);
UpdateJobsAvailable(); UpdateJobsAvailable();
} }
private void SpawnPlayer(IPlayerSession player, HumanoidCharacterProfile character, string? jobId = null, bool lateJoin = true) private void SpawnPlayer(IPlayerSession player, HumanoidCharacterProfile character, StationId station, string? jobId = null, bool lateJoin = true)
{ {
if (station == StationId.Invalid)
{
var stations = _stationSystem.StationInfo.Keys.ToList();
_robustRandom.Shuffle(stations);
if (stations.Count == 0)
station = StationId.Invalid;
else
station = stations[0];
}
// Can't spawn players with a dummy ticker! // Can't spawn players with a dummy ticker!
if (DummyTicker) if (DummyTicker)
return; return;
@@ -78,7 +95,7 @@ namespace Content.Server.GameTicking
newMind.ChangeOwningPlayer(data.UserId); newMind.ChangeOwningPlayer(data.UserId);
// Pick best job best on prefs. // Pick best job best on prefs.
jobId ??= PickBestAvailableJob(character); jobId ??= PickBestAvailableJob(character, station);
var jobPrototype = _prototypeManager.Index<JobPrototype>(jobId); var jobPrototype = _prototypeManager.Index<JobPrototype>(jobId);
var job = new Job(newMind, jobPrototype); var job = new Job(newMind, jobPrototype);
@@ -94,7 +111,7 @@ namespace Content.Server.GameTicking
playDefaultSound: false); playDefaultSound: false);
} }
var mob = SpawnPlayerMob(job, character, lateJoin); var mob = SpawnPlayerMob(job, character, station, lateJoin);
newMind.TransferTo(mob.Uid); newMind.TransferTo(mob.Uid);
if (player.UserId == new Guid("{e887eb93-f503-4b65-95b6-2f282c014192}")) if (player.UserId == new Guid("{e887eb93-f503-4b65-95b6-2f282c014192}"))
@@ -111,20 +128,28 @@ namespace Content.Server.GameTicking
jobSpecial.AfterEquip(mob); jobSpecial.AfterEquip(mob);
} }
_stationSystem.TryAssignJobToStation(station, jobId);
if (lateJoin)
_adminLogSystem.Add(LogType.LateJoin, LogImpact.Medium, $"Player {player.Name} late joined as {character.Name:characterName} on station {_stationSystem.StationInfo[station].Name:stationName} with {mob} as a {job.Name:jobName}.");
else
_adminLogSystem.Add(LogType.RoundStartJoin, LogImpact.Medium, $"Player {player.Name} joined as {character.Name:characterName} on station {_stationSystem.StationInfo[station].Name:stationName} with {mob} as a {job.Name:jobName}.");
Preset?.OnSpawnPlayerCompleted(player, mob, lateJoin); Preset?.OnSpawnPlayerCompleted(player, mob, lateJoin);
} }
public void Respawn(IPlayerSession player) public void Respawn(IPlayerSession player)
{ {
player.ContentData()?.WipeMind(); player.ContentData()?.WipeMind();
_adminLogSystem.Add(LogType.Respawn, LogImpact.Medium, $"Player {player} was respawned.");
if (LobbyEnabled) if (LobbyEnabled)
PlayerJoinLobby(player); PlayerJoinLobby(player);
else else
SpawnPlayer(player); SpawnPlayer(player, StationId.Invalid);
} }
public void MakeJoinGame(IPlayerSession player, string? jobId = null) public void MakeJoinGame(IPlayerSession player, StationId station, string? jobId = null)
{ {
if (!_playersInLobby.ContainsKey(player)) return; if (!_playersInLobby.ContainsKey(player)) return;
@@ -133,7 +158,7 @@ namespace Content.Server.GameTicking
return; return;
} }
SpawnPlayer(player, jobId); SpawnPlayer(player, station, jobId);
} }
public void MakeObserve(IPlayerSession player) public void MakeObserve(IPlayerSession player)
@@ -168,9 +193,9 @@ namespace Content.Server.GameTicking
} }
#region Mob Spawning Helpers #region Mob Spawning Helpers
private IEntity SpawnPlayerMob(Job job, HumanoidCharacterProfile? profile, bool lateJoin = true) private IEntity SpawnPlayerMob(Job job, HumanoidCharacterProfile? profile, StationId station, bool lateJoin = true)
{ {
var coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID); var coordinates = lateJoin ? GetLateJoinSpawnPoint(station) : GetJobSpawnPoint(job.Prototype.ID, station);
var entity = EntityManager.SpawnEntity(PlayerPrototypeName, coordinates); var entity = EntityManager.SpawnEntity(PlayerPrototypeName, coordinates);
if (job.StartingGear != null) if (job.StartingGear != null)
@@ -255,7 +280,7 @@ namespace Content.Server.GameTicking
} }
#region Spawn Points #region Spawn Points
public EntityCoordinates GetJobSpawnPoint(string jobId) public EntityCoordinates GetJobSpawnPoint(string jobId, StationId station)
{ {
var location = _spawnPoint; var location = _spawnPoint;
@@ -263,17 +288,24 @@ namespace Content.Server.GameTicking
foreach (var (point, transform) in EntityManager.EntityQuery<SpawnPointComponent, TransformComponent>()) foreach (var (point, transform) in EntityManager.EntityQuery<SpawnPointComponent, TransformComponent>())
{ {
if (point.SpawnType == SpawnPointType.Job && point.Job?.ID == jobId) var matchingStation =
EntityManager.TryGetComponent<StationComponent>(transform.ParentUid, out var stationComponent) &&
stationComponent.Station == station;
DebugTools.Assert(EntityManager.TryGetComponent<IMapGridComponent>(transform.ParentUid, out _));
if (point.SpawnType == SpawnPointType.Job && point.Job?.ID == jobId && matchingStation)
_possiblePositions.Add(transform.Coordinates); _possiblePositions.Add(transform.Coordinates);
} }
if (_possiblePositions.Count != 0) if (_possiblePositions.Count != 0)
location = _robustRandom.Pick(_possiblePositions); location = _robustRandom.Pick(_possiblePositions);
else
location = GetLateJoinSpawnPoint(station); // We need a sane fallback here, so latejoin it is.
return location; return location;
} }
public EntityCoordinates GetLateJoinSpawnPoint() public EntityCoordinates GetLateJoinSpawnPoint(StationId station)
{ {
var location = _spawnPoint; var location = _spawnPoint;
@@ -281,7 +313,13 @@ namespace Content.Server.GameTicking
foreach (var (point, transform) in EntityManager.EntityQuery<SpawnPointComponent, TransformComponent>()) foreach (var (point, transform) in EntityManager.EntityQuery<SpawnPointComponent, TransformComponent>())
{ {
if (point.SpawnType == SpawnPointType.LateJoin) _possiblePositions.Add(transform.Coordinates); var matchingStation =
EntityManager.TryGetComponent<StationComponent>(transform.ParentUid, out var stationComponent) &&
stationComponent.Station == station;
DebugTools.Assert(EntityManager.TryGetComponent<IMapGridComponent>(transform.ParentUid, out _));
if (point.SpawnType == SpawnPointType.LateJoin && matchingStation)
_possiblePositions.Add(transform.Coordinates);
} }
if (_possiblePositions.Count != 0) if (_possiblePositions.Count != 0)

View File

@@ -1,6 +1,9 @@
using Content.Server.Administration.Logs;
using Content.Server.Chat.Managers; using Content.Server.Chat.Managers;
using Content.Server.Maps; using Content.Server.Maps;
using Content.Server.Preferences.Managers; using Content.Server.Preferences.Managers;
using Content.Server.Roles;
using Content.Server.Station;
using Content.Shared.Chat; using Content.Shared.Chat;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.GameWindow; using Content.Shared.GameWindow;
@@ -27,7 +30,6 @@ namespace Content.Server.GameTicking
[ViewVariables] private bool _postInitialized; [ViewVariables] private bool _postInitialized;
[ViewVariables] public MapId DefaultMap { get; private set; } [ViewVariables] public MapId DefaultMap { get; private set; }
[ViewVariables] public GridId DefaultGridId { get; private set; }
public override void Initialize() public override void Initialize()
{ {
@@ -87,5 +89,7 @@ namespace Content.Server.GameTicking
[Dependency] private readonly IWatchdogApi _watchdogApi = default!; [Dependency] private readonly IWatchdogApi _watchdogApi = default!;
[Dependency] private readonly IReflectionManager _reflectionManager = default!; [Dependency] private readonly IReflectionManager _reflectionManager = default!;
[Dependency] private readonly IGameMapManager _gameMapManager = default!; [Dependency] private readonly IGameMapManager _gameMapManager = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly AdminLogSystem _adminLogSystem = default!;
} }
} }

View File

@@ -11,10 +11,10 @@ using Robust.Shared.Localization;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random; using Robust.Shared.Random;
namespace Content.Server.Maps namespace Content.Server.Maps;
public class GameMapManager : IGameMapManager
{ {
public class GameMapManager : IGameMapManager
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!; [Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPlayerManager _playerManager = default!;
@@ -116,5 +116,4 @@ namespace Content.Server.Maps
{ {
return _prototypeManager.TryIndex(gameMap, out map); return _prototypeManager.TryIndex(gameMap, out map);
} }
}
} }

View File

@@ -1,53 +1,70 @@
using System.Collections.Generic;
using Content.Shared.Roles;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Server.Maps namespace Content.Server.Maps;
/// <summary>
/// Prototype data for a game map.
/// </summary>
[Prototype("gameMap")]
public class GameMapPrototype : IPrototype
{ {
/// <summary>
/// Prototype data for a game map.
/// </summary>
[Prototype("gameMap")]
public class GameMapPrototype : IPrototype
{
/// <inheritdoc/> /// <inheritdoc/>
[ViewVariables, DataField("id", required: true)] [DataField("id", required: true)]
public string ID { get; } = default!; public string ID { get; } = default!;
/// <summary> /// <summary>
/// Minimum players for the given map. /// Minimum players for the given map.
/// </summary> /// </summary>
[ViewVariables, DataField("minPlayers", required: true)] [DataField("minPlayers", required: true)]
public uint MinPlayers { get; } public uint MinPlayers { get; }
/// <summary> /// <summary>
/// Maximum players for the given map. /// Maximum players for the given map.
/// </summary> /// </summary>
[ViewVariables, DataField("maxPlayers")] [DataField("maxPlayers")]
public uint MaxPlayers { get; } = uint.MaxValue; public uint MaxPlayers { get; } = uint.MaxValue;
/// <summary> /// <summary>
/// Name of the given map. /// Name of the given map.
/// </summary> /// </summary>
[ViewVariables, DataField("mapName", required: true)] [DataField("mapName", required: true)]
public string MapName { get; } = default!; public string MapName { get; } = default!;
/// <summary> /// <summary>
/// Relative directory path to the given map, i.e. `Maps/saltern.yml` /// Relative directory path to the given map, i.e. `Maps/saltern.yml`
/// </summary> /// </summary>
[ViewVariables, DataField("mapPath", required: true)] [DataField("mapPath", required: true)]
public string MapPath { get; } = default!; public string MapPath { get; } = default!;
/// <summary> /// <summary>
/// Controls if the map can be used as a fallback if no maps are eligible. /// Controls if the map can be used as a fallback if no maps are eligible.
/// </summary> /// </summary>
[ViewVariables, DataField("fallback")] [DataField("fallback")]
public bool Fallback { get; } public bool Fallback { get; }
/// <summary> /// <summary>
/// Controls if the map can be voted for. /// Controls if the map can be voted for.
/// </summary> /// </summary>
[ViewVariables, DataField("votable")] [DataField("votable")]
public bool Votable { get; } = true; public bool Votable { get; } = true;
}
/// <summary>
/// Jobs used at round start should the station run out of job slots.
/// Doesn't necessarily mean the station has infinite slots for the given jobs midround!
/// </summary>
[DataField("overflowJobs", required: true, customTypeSerializer:typeof(PrototypeIdListSerializer<JobPrototype>))]
public List<string> OverflowJobs { get; } = default!;
/// <summary>
/// Index of all jobs available on the station, of form
/// jobname: [roundstart, midround]
/// </summary>
[DataField("availableJobs", required: true, customTypeSerializer:typeof(PrototypeIdDictionarySerializer<List<int>, JobPrototype>))]
public Dictionary<string, List<int>> AvailableJobs { get; } = default!;
} }

View File

@@ -1,12 +1,12 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace Content.Server.Maps namespace Content.Server.Maps;
/// <summary>
/// Manages which station map will be used for the next round.
/// </summary>
public interface IGameMapManager
{ {
/// <summary>
/// Manages which station map will be used for the next round.
/// </summary>
public interface IGameMapManager
{
void Initialize(); void Initialize();
/// <summary> /// <summary>
@@ -64,5 +64,4 @@ namespace Content.Server.Maps
/// <param name="gameMap">name of the map</param> /// <param name="gameMap">name of the map</param>
/// <returns>existence</returns> /// <returns>existence</returns>
bool CheckMapExists(string gameMap); bool CheckMapExists(string gameMap);
}
} }

View File

@@ -0,0 +1,13 @@
using Content.Shared.Station;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
namespace Content.Server.Station;
[RegisterComponent, Friend(typeof(StationSystem))]
public class StationComponent : Component
{
public override string Name => "Station";
public StationId Station = StationId.Invalid;
}

View File

@@ -0,0 +1,165 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameTicking;
using Content.Server.Maps;
using Content.Shared.Station;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Log;
namespace Content.Server.Station;
/// <summary>
/// System that manages the jobs available on a station, and maybe other things later.
/// </summary>
public class StationSystem : EntitySystem
{
[Dependency] private GameTicker _gameTicker = default!;
private uint _idCounter = 1;
private Dictionary<StationId, StationInfoData> _stationInfo = new();
/// <summary>
/// List of stations for the current round.
/// </summary>
public IReadOnlyDictionary<StationId, StationInfoData> StationInfo => _stationInfo;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GameRunLevelChangedEvent>(OnRoundEnd);
}
/// <summary>
/// Cleans up station info.
/// </summary>
private void OnRoundEnd(GameRunLevelChangedEvent eventArgs)
{
if (eventArgs.New == GameRunLevel.PostRound)
_stationInfo = new();
}
public class StationInfoData
{
public readonly string Name;
/// <summary>
/// Job list associated with the game map.
/// </summary>
public readonly GameMapPrototype MapPrototype;
/// <summary>
/// The round job list.
/// </summary>
private readonly Dictionary<string, int> _jobList;
public IReadOnlyDictionary<string, int> JobList => _jobList;
public StationInfoData(string name, GameMapPrototype mapPrototype, Dictionary<string, int> jobList)
{
Name = name;
MapPrototype = mapPrototype;
_jobList = jobList;
}
public bool TryAssignJob(string jobName)
{
if (_jobList.ContainsKey(jobName))
{
switch (_jobList[jobName])
{
case > 0:
_jobList[jobName]--;
return true;
case -1:
return true;
default:
return false;
}
}
else
{
return false;
}
}
}
/// <summary>
/// Creates a new station and attaches it to the given grid.
/// </summary>
/// <param name="mapGrid">grid to attach to</param>
/// <param name="mapPrototype">game map prototype of the station</param>
/// <param name="stationName">name of the station to assign, if not the default</param>
/// <param name="gridComponent">optional grid component of the grid.</param>
/// <returns>The ID of the resulting station</returns>
/// <exception cref="ArgumentException">Thrown when the given entity is not a grid.</exception>
public StationId InitialSetupStationGrid(EntityUid mapGrid, GameMapPrototype mapPrototype, string? stationName = null, IMapGridComponent? gridComponent = null)
{
if (!Resolve(mapGrid, ref gridComponent))
throw new ArgumentException("Tried to initialize a station on a non-grid entity!");
var jobListDict = mapPrototype.AvailableJobs.ToDictionary(x => x.Key, x => x.Value[1]);
var id = AllocateStationInfo();
_stationInfo[id] = new StationInfoData(stationName ?? mapPrototype.MapName, mapPrototype, jobListDict);
var station = EntityManager.AddComponent<StationComponent>(mapGrid);
station.Station = id;
_gameTicker.UpdateJobsAvailable(); // new station means new jobs, tell any lobby-goers.
Logger.InfoS("stations",
$"Setting up new {mapPrototype.ID} called {mapPrototype.MapName} on grid {mapGrid}:{gridComponent.GridIndex}");
return id;
}
/// <summary>
/// Adds the given grid to the given station.
/// </summary>
/// <param name="mapGrid">grid to attach</param>
/// <param name="station">station to attach the grid to</param>
/// <param name="gridComponent">optional grid component of the grid.</param>
/// <exception cref="ArgumentException">Thrown when the given entity is not a grid.</exception>
public void AddGridToStation(EntityUid mapGrid, StationId station, IMapGridComponent? gridComponent = null)
{
if (!Resolve(mapGrid, ref gridComponent))
throw new ArgumentException("Tried to initialize a station on a non-grid entity!");
var stationComponent = EntityManager.AddComponent<StationComponent>(mapGrid);
stationComponent.Station = station;
Logger.InfoS("stations", $"Adding grid {mapGrid}:{gridComponent.GridIndex} to station {station} named {_stationInfo[station].Name}");
}
/// <summary>
/// Attempts to assign a job on the given station.
/// </summary>
/// <param name="stationId">station to assign to</param>
/// <param name="jobName">name of the job</param>
/// <returns>assignment success</returns>
public bool TryAssignJobToStation(StationId stationId, string jobName)
{
if (stationId != StationId.Invalid)
return _stationInfo[stationId].TryAssignJob(jobName);
else
return false;
}
/// <summary>
/// Checks if the given job is available.
/// </summary>
/// <param name="stationId">station to check</param>
/// <param name="jobName">name of the job</param>
/// <returns>job availability</returns>
public bool IsJobAvailableOnStation(StationId stationId, string jobName)
{
if (_stationInfo[stationId].JobList.TryGetValue(jobName, out var amount))
return amount != 0;
return false;
}
private StationId AllocateStationInfo()
{
return new StationId(_idCounter++);
}
}

View File

@@ -1,7 +1,8 @@
using Content.Server.Atmos.Components; using System.Linq;
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Server.GameTicking; using Content.Server.Station;
using Content.Shared.Atmos; using Content.Shared.Atmos;
using Content.Shared.Station;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -15,6 +16,9 @@ namespace Content.Server.StationEvents.Events
{ {
internal sealed class GasLeak : StationEvent internal sealed class GasLeak : StationEvent
{ {
[Dependency] private IRobustRandom _robustRandom = default!;
[Dependency] private IEntityManager _entityManager = default!;
public override string Name => "GasLeak"; public override string Name => "GasLeak";
public override string? StartAnnouncement => public override string? StartAnnouncement =>
@@ -56,6 +60,8 @@ namespace Content.Server.StationEvents.Events
// Event variables // Event variables
private StationId _targetStation;
private IEntity? _targetGrid; private IEntity? _targetGrid;
private Vector2i _targetTile; private Vector2i _targetTile;
@@ -84,17 +90,16 @@ namespace Content.Server.StationEvents.Events
public override void Startup() public override void Startup()
{ {
base.Startup(); base.Startup();
var robustRandom = IoCManager.Resolve<IRobustRandom>();
// Essentially we'll pick out a target amount of gas to leak, then a rate to leak it at, then work out the duration from there. // Essentially we'll pick out a target amount of gas to leak, then a rate to leak it at, then work out the duration from there.
if (TryFindRandomTile(out _targetTile, robustRandom)) if (TryFindRandomTile(out _targetTile))
{ {
_foundTile = true; _foundTile = true;
_leakGas = robustRandom.Pick(LeakableGases); _leakGas = _robustRandom.Pick(LeakableGases);
// Was 50-50 on using normal distribution. // Was 50-50 on using normal distribution.
var totalGas = (float) robustRandom.Next(MinimumGas, MaximumGas); var totalGas = (float) _robustRandom.Next(MinimumGas, MaximumGas);
_molesPerSecond = robustRandom.Next(MinimumMolesPerSecond, MaximumMolesPerSecond); _molesPerSecond = _robustRandom.Next(MinimumMolesPerSecond, MaximumMolesPerSecond);
EndAfter = totalGas / _molesPerSecond + StartAfter; EndAfter = totalGas / _molesPerSecond + StartAfter;
Logger.InfoS("stationevents", $"Leaking {totalGas} of {_leakGas} over {EndAfter - StartAfter} seconds at {_targetTile}"); Logger.InfoS("stationevents", $"Leaking {totalGas} of {_leakGas} over {EndAfter - StartAfter} seconds at {_targetTile}");
} }
@@ -147,8 +152,7 @@ namespace Content.Server.StationEvents.Events
private void Spark() private void Spark()
{ {
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>(); var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
var robustRandom = IoCManager.Resolve<IRobustRandom>(); if (_robustRandom.NextFloat() <= SparkChance)
if (robustRandom.NextFloat() <= SparkChance)
{ {
if (!_foundTile || if (!_foundTile ||
_targetGrid == null || _targetGrid == null ||
@@ -165,27 +169,31 @@ namespace Content.Server.StationEvents.Events
} }
} }
private bool TryFindRandomTile(out Vector2i tile, IRobustRandom? robustRandom = null) private bool TryFindRandomTile(out Vector2i tile)
{ {
tile = default; tile = default;
var defaultGridId = EntitySystem.Get<GameTicker>().DefaultGridId;
if (!IoCManager.Resolve<IMapManager>().TryGetGrid(defaultGridId, out var grid) || _targetStation = _robustRandom.Pick(_entityManager.EntityQuery<StationComponent>().ToArray()).Station;
!IoCManager.Resolve<IEntityManager>().TryGetEntity(grid.GridEntityId, out _targetGrid)) return false; var possibleTargets = _entityManager.EntityQuery<StationComponent>()
.Where(x => x.Station == _targetStation).ToArray();
_targetGrid = _robustRandom.Pick(possibleTargets).Owner;
if (!_entityManager.TryGetComponent<IMapGridComponent>(_targetGrid!.Uid, out var gridComp))
return false;
var grid = gridComp.Grid;
var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>(); var atmosphereSystem = EntitySystem.Get<AtmosphereSystem>();
robustRandom ??= IoCManager.Resolve<IRobustRandom>();
var found = false; var found = false;
var gridBounds = grid.WorldBounds; var gridBounds = grid.WorldBounds;
var gridPos = grid.WorldPosition; var gridPos = grid.WorldPosition;
for (var i = 0; i < 10; i++) for (var i = 0; i < 10; i++)
{ {
var randomX = robustRandom.Next((int) gridBounds.Left, (int) gridBounds.Right); var randomX = _robustRandom.Next((int) gridBounds.Left, (int) gridBounds.Right);
var randomY = robustRandom.Next((int) gridBounds.Bottom, (int) gridBounds.Top); var randomY = _robustRandom.Next((int) gridBounds.Bottom, (int) gridBounds.Top);
tile = new Vector2i(randomX - (int) gridPos.X, randomY - (int) gridPos.Y); tile = new Vector2i(randomX - (int) gridPos.X, randomY - (int) gridPos.Y);
if (atmosphereSystem.IsTileSpace(defaultGridId, tile) || atmosphereSystem.IsTileAirBlocked(defaultGridId, tile)) continue; if (atmosphereSystem.IsTileSpace(grid, tile) || atmosphereSystem.IsTileAirBlocked(grid, tile)) continue;
found = true; found = true;
_targetCoords = grid.GridTileToLocal(tile); _targetCoords = grid.GridTileToLocal(tile);
break; break;

View File

@@ -1,6 +1,8 @@
using Content.Server.GameTicking; using System.Linq;
using Content.Server.Radiation; using Content.Server.Radiation;
using Content.Server.Station;
using Content.Shared.Coordinates; using Content.Shared.Coordinates;
using Content.Shared.Station;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -29,6 +31,7 @@ namespace Content.Server.StationEvents.Events
private float _timeUntilPulse; private float _timeUntilPulse;
private const float MinPulseDelay = 0.2f; private const float MinPulseDelay = 0.2f;
private const float MaxPulseDelay = 0.8f; private const float MaxPulseDelay = 0.8f;
private StationId _target = StationId.Invalid;
private void ResetTimeUntilPulse() private void ResetTimeUntilPulse()
{ {
@@ -44,6 +47,7 @@ namespace Content.Server.StationEvents.Events
public override void Startup() public override void Startup()
{ {
ResetTimeUntilPulse(); ResetTimeUntilPulse();
_target = _robustRandom.Pick(_entityManager.EntityQuery<StationComponent>().ToArray()).Station;
base.Startup(); base.Startup();
} }
@@ -63,12 +67,18 @@ namespace Content.Server.StationEvents.Events
if (_timeUntilPulse <= 0.0f) if (_timeUntilPulse <= 0.0f)
{ {
var pauseManager = IoCManager.Resolve<IPauseManager>(); var pauseManager = IoCManager.Resolve<IPauseManager>();
var defaultGrid = IoCManager.Resolve<IMapManager>().GetGrid(EntitySystem.Get<GameTicker>().DefaultGridId); // Account for split stations by just randomly picking a piece of it.
var possibleTargets = _entityManager.EntityQuery<StationComponent>()
.Where(x => x.Station == _target).ToArray();
var stationEnt = _robustRandom.Pick(possibleTargets).OwnerUid;
if (pauseManager.IsGridPaused(defaultGrid)) if (!_entityManager.TryGetComponent<IMapGridComponent>(stationEnt, out var grid))
return; return;
SpawnPulse(defaultGrid); if (pauseManager.IsGridPaused(grid.GridIndex))
return;
SpawnPulse(grid.Grid);
} }
} }

View File

@@ -16,6 +16,9 @@ public enum LogType
ShuttleCalled = 8, ShuttleCalled = 8,
ShuttleRecalled = 9, ShuttleRecalled = 9,
ExplosiveDepressurization = 10, ExplosiveDepressurization = 10,
Respawn = 13,
RoundStartJoin = 14,
LateJoin = 15,
ChemicalReaction = 17, ChemicalReaction = 17,
ReagentEffect = 18, ReagentEffect = 18,
CanisterValve = 20, CanisterValve = 20,

View File

@@ -1,6 +1,7 @@
 
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using Content.Shared.Station;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
@@ -11,8 +12,8 @@ namespace Content.Shared.GameTicking
{ {
// See ideally these would be pulled from the job definition or something. // See ideally these would be pulled from the job definition or something.
// But this is easier, and at least it isn't hardcoded. // But this is easier, and at least it isn't hardcoded.
public const string OverflowJob = "Assistant"; public const string FallbackOverflowJob = "Assistant";
public const string OverflowJobName = "assistant"; public const string FallbackOverflowJobName = "assistant";
} }
[Serializable, NetSerializable] [Serializable, NetSerializable]
@@ -109,11 +110,13 @@ namespace Content.Shared.GameTicking
/// <summary> /// <summary>
/// The Status of the Player in the lobby (ready, observer, ...) /// The Status of the Player in the lobby (ready, observer, ...)
/// </summary> /// </summary>
public string[] JobsAvailable { get; } public Dictionary<StationId, Dictionary<string, int>> JobsAvailableByStation { get; }
public Dictionary<StationId, string> StationNames { get; }
public TickerJobsAvailableEvent(string[] jobsAvailable) public TickerJobsAvailableEvent(Dictionary<StationId, string> stationNames, Dictionary<StationId, Dictionary<string, int>> jobsAvailableByStation)
{ {
JobsAvailable = jobsAvailable; StationNames = stationNames;
JobsAvailableByStation = jobsAvailableByStation;
} }
} }

View File

@@ -99,7 +99,7 @@ namespace Content.Shared.Preferences
BackpackPreference.Backpack, BackpackPreference.Backpack,
new Dictionary<string, JobPriority> new Dictionary<string, JobPriority>
{ {
{SharedGameTicker.OverflowJob, JobPriority.High} {SharedGameTicker.FallbackOverflowJob, JobPriority.High}
}, },
PreferenceUnavailableMode.SpawnAsOverflow, PreferenceUnavailableMode.SpawnAsOverflow,
new List<string>()); new List<string>());
@@ -120,7 +120,7 @@ namespace Content.Shared.Preferences
return new HumanoidCharacterProfile(name, age, sex, gender, HumanoidCharacterAppearance.Random(sex), ClothingPreference.Jumpsuit, BackpackPreference.Backpack, return new HumanoidCharacterProfile(name, age, sex, gender, HumanoidCharacterAppearance.Random(sex), ClothingPreference.Jumpsuit, BackpackPreference.Backpack,
new Dictionary<string, JobPriority> new Dictionary<string, JobPriority>
{ {
{SharedGameTicker.OverflowJob, JobPriority.High} {SharedGameTicker.FallbackOverflowJob, JobPriority.High}
}, PreferenceUnavailableMode.StayInLobby, new List<string>()); }, PreferenceUnavailableMode.StayInLobby, new List<string>());
} }

View File

@@ -43,20 +43,6 @@ namespace Content.Shared.Roles
[DataField("head")] [DataField("head")]
public bool IsHead { get; private set; } public bool IsHead { get; private set; }
/// <summary>
/// The total amount of people that can start with this job round-start.
/// </summary>
public int SpawnPositions => _spawnPositions ?? TotalPositions;
[DataField("spawnPositions")]
private int? _spawnPositions;
/// <summary>
/// The total amount of positions available.
/// </summary>
[DataField("positions")]
public int TotalPositions { get; private set; }
[DataField("startingGear")] [DataField("startingGear")]
public string? StartingGear { get; private set; } public string? StartingGear { get; private set; }

View File

@@ -0,0 +1,10 @@
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.Station;
[NetSerializable, Serializable]
public readonly record struct StationId(uint Id)
{
public static StationId Invalid => new(0);
}

View File

@@ -57,7 +57,7 @@ namespace Content.Tests.Server.Preferences
BackpackPreference.Backpack, BackpackPreference.Backpack,
new Dictionary<string, JobPriority> new Dictionary<string, JobPriority>
{ {
{SharedGameTicker.OverflowJob, JobPriority.High} {SharedGameTicker.FallbackOverflowJob, JobPriority.High}
}, },
PreferenceUnavailableMode.StayInLobby, PreferenceUnavailableMode.StayInLobby,
new List<string> () new List<string> ()

View File

@@ -1,3 +1,5 @@
late-join-gui-title = Late Join late-join-gui-title = Late Join
late-join-gui-jobs-amount-in-department-tooltip = Jobs in the {$departmentName} department late-join-gui-jobs-amount-in-department-tooltip = Jobs in the {$departmentName} department
late-join-gui-department-jobs-label = {$departmentName} jobs late-join-gui-department-jobs-label = {$departmentName} jobs
late-join-gui-job-slot-capped = {$jobName} ({$amount} open)
late-join-gui-job-slot-uncapped = {$jobName} (No limit)

View File

@@ -152,35 +152,35 @@
- type: Icon - type: Icon
state: pda-mime state: pda-mime
#- type: entity - type: entity
# name: Chaplain PDA name: Chaplain PDA
# parent: BasePDA parent: BasePDA
# id: ChaplainPDA id: ChaplainPDA
# description: God's chosen PDA. description: God's chosen PDA.
# components: components:
# - type: PDA - type: PDA
# idCard: ChaplainIDCard idCard: ChaplainIDCard
# - type: Appearance - type: Appearance
# visuals: visuals:
# - type: PDAVisualizer - type: PDAVisualizer
# state: pda-chaplain state: pda-chaplain
# - type: Icon - type: Icon
# state: pda-chaplain state: pda-chaplain
#- type: entity - type: entity
# name: Quartermaster PDA name: Quartermaster PDA
# parent: BasePDA parent: BasePDA
# id: QuartermasterPDA id: QuartermasterPDA
# description: PDA for the guy that orders the guns. description: PDA for the guy that orders the guns.
# components: components:
# - type: PDA - type: PDA
# idCard: QuartermasterIDCard idCard: QuartermasterIDCard
# - type: Appearance - type: Appearance
# visuals: visuals:
# - type: PDAVisualizer - type: PDAVisualizer
# state: pda-qm state: pda-qm
# - type: Icon - type: Icon
# state: pda-qm state: pda-qm
- type: entity - type: entity
parent: BasePDA parent: BasePDA
@@ -291,7 +291,6 @@
- type: Icon - type: Icon
state: pda-engineer state: pda-engineer
- type: entity - type: entity
parent: BasePDA parent: BasePDA
id: CMOPDA id: CMOPDA
@@ -382,20 +381,20 @@
- type: Icon - type: Icon
state: pda-hos state: pda-hos
# - type: entity - type: entity
# parent: BasePDA parent: BasePDA
# id: WardenPDA id: WardenPDA
# name: warden PDA name: warden PDA
# description: The OS appears to have been jailbroken. description: The OS appears to have been jailbroken.
# components: components:
# - type: PDA - type: PDA
# idCard: WardenIDCard idCard: WardenIDCard
# - type: Appearance - type: Appearance
# visuals: visuals:
# - type: PDAVisualizer - type: PDAVisualizer
# state: pda-warden state: pda-warden
# - type: Icon - type: Icon
# state: pda-warden state: pda-warden
- type: entity - type: entity
parent: BasePDA parent: BasePDA

View File

@@ -56,17 +56,17 @@
- type: PresetIdCard - type: PresetIdCard
job: SecurityOfficer job: SecurityOfficer
# - type: entity - type: entity
# parent: IDCardStandard parent: IDCardStandard
# id: WardenIDCard id: WardenIDCard
# name: warden ID card name: warden ID card
# components: components:
# - type: Sprite - type: Sprite
# layers: layers:
# - state: default - state: default
# - state: idwarden - state: idwarden
# - type: PresetIdCard - type: PresetIdCard
# job: Warden job: Warden
- type: entity - type: entity
parent: IDCardStandard parent: IDCardStandard
@@ -116,17 +116,17 @@
- type: PresetIdCard - type: PresetIdCard
job: CargoTechnician job: CargoTechnician
#- type: entity - type: entity
# parent: IDCardStandard parent: IDCardStandard
# id: QuartermasterIDCard id: QuartermasterIDCard
# name: quartermaster ID card name: quartermaster ID card
# components: components:
# - type: Sprite - type: Sprite
# layers: layers:
# - state: default - state: default
# - state: idquartermaster - state: idquartermaster
# - type: PresetIdCard - type: PresetIdCard
# job: Quartermaster job: Quartermaster
- type: entity - type: entity
parent: IDCardStandard parent: IDCardStandard
@@ -164,19 +164,17 @@
- type: PresetIdCard - type: PresetIdCard
job: Mime job: Mime
#- type: entity - type: entity
# parent: IDCardStandard parent: IDCardStandard
# id: ChaplainIDCard id: ChaplainIDCard
# name: chaplain ID card name: chaplain ID card
# components: components:
# - type: Sprite - type: Sprite
# layers: layers:
# - state: default - state: default
# - state: idchaplain
# - state: idchaplain - type: PresetIdCard
# job: Chaplain
# - type: PresetIdCard
# job: Chaplain
- type: entity - type: entity
parent: IDCardStandard parent: IDCardStandard

View File

@@ -5,12 +5,57 @@
minPlayers: 0 minPlayers: 0
maxPlayers: 20 maxPlayers: 20
fallback: true fallback: true
overflowJobs:
- Assistant
availableJobs:
CargoTechnician: [ 1, 2 ]
Assistant: [ -1, -1 ]
Bartender: [ 1, 1 ]
Botanist: [ 2, 2 ]
Chef: [ 1, 1 ]
Clown: [ 1, 1 ]
Janitor: [ 1, 1 ]
Mime: [ 1, 1 ]
Captain: [ 1, 1 ]
HeadOfPersonnel: [ 1, 1 ]
ChiefEngineer: [ 1, 1 ]
StationEngineer: [ 2, 3 ]
ChiefMedicalOfficer: [ 1, 1 ]
MedicalDoctor: [ 2, 3 ]
Chemist: [ 1, 1 ]
ResearchDirector: [ 1, 1 ]
Scientist: [ 2, 3 ]
HeadOfSecurity: [ 1, 1 ]
SecurityOfficer: [ 2, 3 ]
- type: gameMap - type: gameMap
id: packedstation id: packedstation
mapName: Packedstation mapName: Packedstation
mapPath: Maps/packedstation.yml mapPath: Maps/packedstation.yml
minPlayers: 15 minPlayers: 15
overflowJobs:
- Assistant
availableJobs:
CargoTechnician: [ 2, 3 ]
Assistant: [ -1, -1 ]
Bartender: [ 1, 1 ]
Botanist: [ 2, 2 ]
Chef: [ 1, 1 ]
Clown: [ 1, 1 ]
Janitor: [ 1, 1 ]
Mime: [ 1, 1 ]
Captain: [ 1, 1 ]
HeadOfPersonnel: [ 1, 1 ]
ChiefEngineer: [ 1, 1 ]
StationEngineer: [ 4, 6 ]
ChiefMedicalOfficer: [ 1, 1 ]
MedicalDoctor: [ 3, 4 ]
Chemist: [ 2, 2 ]
ResearchDirector: [ 1, 1 ]
Scientist: [ 3, 4 ]
HeadOfSecurity: [ 1, 1 ]
SecurityOfficer: [ 2, 3 ]
Chaplain: [ 1, 1 ]
- type: gameMap - type: gameMap
id: knightship id: knightship
@@ -18,3 +63,13 @@
mapPath: Maps/knightship.yml mapPath: Maps/knightship.yml
minPlayers: 0 minPlayers: 0
maxPlayers: 8 maxPlayers: 8
overflowJobs: []
availableJobs:
Bartender: [ 1, 1 ]
Captain: [ 1, 1 ]
ChiefEngineer: [ 1, 1 ]
StationEngineer: [ 1, 1 ]
ChiefMedicalOfficer: [ 1, 1 ]
MedicalDoctor: [ 1, 1 ]
ResearchDirector: [ 1, 1 ]
Botanist: [ 1, 1 ]

View File

@@ -3,5 +3,8 @@
mapName: Empty mapName: Empty
mapPath: Maps/Test/empty.yml mapPath: Maps/Test/empty.yml
minPlayers: 0 minPlayers: 0
maxPlayers: 0
votable: false votable: false
overflowJobs:
- Assistant
availableJobs:
Assistant: [ -1, -1 ]

View File

@@ -1,8 +1,6 @@
- type: job - type: job
id: CargoTechnician id: CargoTechnician
name: "cargo technician" name: "cargo technician"
positions: 2
spawnPositions: 1
startingGear: CargoTechGear startingGear: CargoTechGear
departments: departments:
- Cargo - Cargo

View File

@@ -1,27 +1,25 @@
#- type: job - type: job
# id: Quartermaster id: Quartermaster
# name: "quartermaster" name: "quartermaster"
# positions: 1 startingGear: QuartermasterGear
# spawnPositions: 1 departments:
# startingGear: QuartermasterGear - Cargo
# departments: icon: "QuarterMaster"
# - Cargo supervisors: "the head of personnel"
# icon: "QuarterMaster" access:
# supervisors: "the head of personnel" - Cargo
# access: - Quartermaster
# - Cargo - Maintenance
# - Quartermaster
# - Maintenance - type: startingGear
# id: QuartermasterGear
#- type: startingGear equipment:
# id: QuartermasterGear head: ClothingHeadHatCargosoft
# equipment: innerclothing: ClothingUniformJumpsuitQM
# head: ClothingHeadHatCargosoft backpack: ClothingBackpackFilled
# innerclothing: ClothingUniformJumpsuitQM shoes: ClothingShoesColorBrown
# backpack: ClothingBackpackFilled idcard: QuartermasterPDA
# shoes: ClothingShoesColorBrown ears: ClothingHeadsetCargo
# idcard: QuartermasterPDA innerclothingskirt: ClothingUniformJumpskirtQM
# ears: ClothingHeadsetCargo satchel: ClothingBackpackSatchelFilled
# innerclothingskirt: ClothingUniformJumpskirtQM duffelbag: ClothingBackpackDuffelFilled
# satchel: ClothingBackpackSatchelFilled
# duffelbag: ClothingBackpackDuffelFilled

View File

@@ -1,7 +1,6 @@
- type: job - type: job
id: Assistant id: Assistant
name: "assistant" name: "assistant"
positions: -1 # Treated as infinite.
startingGear: AssistantGear startingGear: AssistantGear
departments: departments:
- Civilian - Civilian

View File

@@ -1,7 +1,6 @@
- type: job - type: job
id: Bartender id: Bartender
name: "bartender" name: "bartender"
positions: 1
startingGear: BartenderGear startingGear: BartenderGear
departments: departments:
- Civilian - Civilian

View File

@@ -1,8 +1,6 @@
- type: job - type: job
id: Botanist id: Botanist
name: "botanist" name: "botanist"
positions: 2
spawnPositions: 2
startingGear: BotanistGear startingGear: BotanistGear
departments: departments:
- Civilian - Civilian

View File

@@ -1,22 +1,21 @@
#- type: job - type: job
# id: Chaplain id: Chaplain
# name: "chaplain" name: "chaplain"
# positions: 1 startingGear: ChaplainGear
# startingGear: ChaplainGear departments:
# departments: - Civilian
# - Civilian icon: "Chaplain"
# icon: "Chaplain" supervisors: "the head of personnel"
# supervisors: "the head of personnel" access:
# access: - Chapel
# - Chapel - Maintenance
# - Maintenance - type: startingGear
#- type: startingGear id: ChaplainGear
# id: ChaplainGear equipment:
# equipment: innerclothing: ClothingUniformJumpsuitChaplain
# innerclothing: ClothingUniformJumpsuitChaplain backpack: ClothingBackpack
# backpack: ClothingBackpack shoes: ClothingShoesColorBlack
# shoes: ClothingShoesColorBlack idcard: ChaplainPDA
# idcard: ChaplainPDA ears: ClothingHeadsetService
# ears: ClothingHeadsetService innerclothingskirt: ClothingUniformJumpskirtChaplain
# innerclothingskirt: ClothingUniformJumpskirtChaplain

View File

@@ -1,7 +1,6 @@
- type: job - type: job
id: Chef id: Chef
name: "chef" name: "chef"
positions: 1
startingGear: ChefGear startingGear: ChefGear
departments: departments:
- Civilian - Civilian

View File

@@ -1,7 +1,6 @@
- type: job - type: job
id: Clown id: Clown
name: "clown" name: "clown"
positions: 1
startingGear: ClownGear startingGear: ClownGear
departments: departments:
- Civilian - Civilian

View File

@@ -1,7 +1,6 @@
- type: job - type: job
id: Janitor id: Janitor
name: "janitor" name: "janitor"
positions: 1
startingGear: JanitorGear startingGear: JanitorGear
departments: departments:
- Civilian - Civilian

View File

@@ -1,7 +1,6 @@
- type: job - type: job
id: Mime id: Mime
name: "mime" name: "mime"
positions: 1
startingGear: MimeGear startingGear: MimeGear
departments: departments:
- Civilian - Civilian

View File

@@ -2,7 +2,6 @@
id: Captain id: Captain
name: "captain" name: "captain"
head: true head: true
positions: 1
startingGear: CaptainGear startingGear: CaptainGear
departments: departments:
- Command - Command

View File

@@ -1,3 +1,15 @@
- type: job
id: CentralCommandOffical
name: "centcom official"
startingGear: CentcomGear
departments:
- Command
icon: "Nanotrasen"
supervisors: "the head of security"
access:
- Command
- Maintenence
- type: startingGear - type: startingGear
id: CentcomGear id: CentcomGear
equipment: equipment:

View File

@@ -1,7 +1,6 @@
- type: job - type: job
id: HeadOfPersonnel id: HeadOfPersonnel
name: "head of personnel" name: "head of personnel"
positions: 1
startingGear: HoPGear startingGear: HoPGear
departments: departments:
- Command - Command

View File

@@ -2,7 +2,6 @@
id: ChiefEngineer id: ChiefEngineer
name: "chief engineer" name: "chief engineer"
head: true head: true
positions: 1
startingGear: ChiefEngineerGear startingGear: ChiefEngineerGear
departments: departments:
- Command - Command

View File

@@ -1,8 +1,6 @@
- type: job - type: job
id: StationEngineer id: StationEngineer
name: "station engineer" name: "station engineer"
positions: 3
spawnPositions: 2
startingGear: StationEngineerGear startingGear: StationEngineerGear
departments: departments:
- Engineering - Engineering

View File

@@ -1,8 +1,6 @@
- type: job - type: job
id: Chemist id: Chemist
name: "chemist" name: "chemist"
positions: 2
spawnPositions: 2
startingGear: ChemistGear startingGear: ChemistGear
departments: departments:
- Medical - Medical

View File

@@ -4,7 +4,6 @@
id: ChiefMedicalOfficer id: ChiefMedicalOfficer
name: "chief medical officer" name: "chief medical officer"
head: true head: true
positions: 1
startingGear: CMOGear startingGear: CMOGear
departments: departments:
- Command - Command

View File

@@ -1,8 +1,6 @@
- type: job - type: job
id: MedicalDoctor id: MedicalDoctor
name: "medical doctor" name: "medical doctor"
positions: 3
spawnPositions: 2
startingGear: DoctorGear startingGear: DoctorGear
departments: departments:
- Medical - Medical

View File

@@ -2,7 +2,6 @@
id: ResearchDirector id: ResearchDirector
name: "research director" name: "research director"
head: true head: true
positions: 1
startingGear: ResearchDirectorGear startingGear: ResearchDirectorGear
departments: departments:
- Command - Command

View File

@@ -1,8 +1,6 @@
- type: job - type: job
id: Scientist id: Scientist
name: "scientist" name: "scientist"
positions: 3
spawnPositions: 2
startingGear: ScientistGear startingGear: ScientistGear
departments: departments:
- Science - Science

View File

@@ -2,7 +2,6 @@
id: HeadOfSecurity id: HeadOfSecurity
name: "head of security" name: "head of security"
head: true head: true
positions: 1
startingGear: HoSGear startingGear: HoSGear
departments: departments:
- Command - Command

View File

@@ -1,8 +1,6 @@
- type: job - type: job
id: SecurityOfficer id: SecurityOfficer
name: "security officer" name: "security officer"
positions: 3
spawnPositions: 2
startingGear: SecurityOfficerGear startingGear: SecurityOfficerGear
departments: departments:
- Security - Security

View File

@@ -1,31 +1,29 @@
# - type: job - type: job
# id: Warden id: Warden
# name: "warden" name: "warden"
# positions: 1 startingGear: WardenGear
# spawnPositions: 1 departments:
# startingGear: WardenGear - Security
# departments: icon: "Warden"
# - Security supervisors: "the head of security"
# icon: "Warden" access:
# supervisors: "the head of security" - Security
# access: - Brig
# - Security - Maintenance
# - Brig - Service
# - Maintenance
# - Service - type: startingGear
# id: WardenGear
# - type: startingGear equipment:
# id: WardenGear head: ClothingHeadHatWarden
# equipment: innerclothing: ClothingUniformJumpsuitWarden
# head: ClothingHeadHatWarden backpack: ClothingBackpackSecurityFilled
# innerclothing: ClothingUniformJumpsuitWarden shoes: ClothingShoesBootsJack
# backpack: ClothingBackpackSecurityFilled eyes: ClothingEyesGlassesSecurity
# shoes: ClothingShoesBootsJack outerclothing: ClothingOuterCoatWarden
# eyes: ClothingEyesGlassesSecurity idcard: WardenPDA
# outerclothing: ClothingOuterCoatWarden ears: ClothingHeadsetSecurity
# idcard: WardenPDA belt: ClothingBeltSecurityFilled
# ears: ClothingHeadsetSecurity innerclothingskirt: ClothingUniformJumpskirtWarden
# belt: ClothingBeltSecurityFilled satchel: ClothingBackpackSatchelSecurityFilled
# innerclothingskirt: ClothingUniformJumpskirtWarden duffelbag: ClothingBackpackDuffelSecurityFilled
# satchel: ClothingBackpackSatchelSecurityFilled
# duffelbag: ClothingBackpackDuffelSecurityFilled