Skip to content

Commit

Permalink
Hide Unnecessary Roles (#42)
Browse files Browse the repository at this point in the history
* missed a semi colon.

* Hide all unnecessary jobs and departments.

* Fix integration test.

* This test is unnecessary. Kill.
  • Loading branch information
sleepyyapril authored Dec 17, 2024
1 parent b75e257 commit 086006d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 46 deletions.
5 changes: 5 additions & 0 deletions Content.IntegrationTests/Tests/Round/JobTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ private void AssertJob(TestPair pair, ProtoId<JobPrototype> job, NetUserId? user
var mindSys = pair.Server.System<MindSystem>();
var roleSys = pair.Server.System<RoleSystem>();
var ticker = pair.Server.System<GameTicker>();
var prototypeManager = pair.Server.ProtoMan;

user ??= pair.Client.User!.Value;

// If it shouldn't exist in preferences, it shouldn't be tested.
if (prototypeManager.TryIndex(job, out var jobPrototype) && !jobPrototype.SetPreference)
return;

Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.InRound));
Assert.That(ticker.PlayerGameStatuses[user.Value], Is.EqualTo(PlayerGameStatus.JoinedGame));

Expand Down
44 changes: 0 additions & 44 deletions Content.IntegrationTests/Tests/Station/StationJobsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,50 +203,6 @@ await server.WaitAssertion(() =>
});
await pair.CleanReturnAsync();
}

[Test]
public async Task InvalidRoundstartJobsTest()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var prototypeManager = server.ResolveDependency<IPrototypeManager>();
var compFact = server.ResolveDependency<IComponentFactory>();
var name = compFact.GetComponentName<StationJobsComponent>();

await server.WaitAssertion(() =>
{
// invalidJobs contains all the jobs which can't be set for preference:
// i.e. all the jobs that shouldn't be available round-start.
var invalidJobs = new HashSet<string>();
foreach (var job in prototypeManager.EnumeratePrototypes<JobPrototype>())
{
if (!job.SetPreference)
invalidJobs.Add(job.ID);
}

Assert.Multiple(() =>
{
foreach (var gameMap in prototypeManager.EnumeratePrototypes<GameMapPrototype>())
{
foreach (var (stationId, station) in gameMap.Stations)
{
if (!station.StationComponentOverrides.TryGetComponent(name, out var comp))
continue;

foreach (var (job, array) in ((StationJobsComponent) comp).SetupAvailableJobs)
{
Assert.That(array.Length, Is.EqualTo(2));
Assert.That(array[0] is -1 or >= 0);
Assert.That(array[1] is -1 or >= 0);
Assert.That(invalidJobs, Does.Not.Contain(job), $"Station {stationId} contains job prototype {job} which cannot be present roundstart.");
}
}
}
});
});
await pair.CleanReturnAsync();
}
}

internal static class JobExtensions
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Roles/DepartmentPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public sealed partial class DepartmentPrototype : IPrototype
/// Toggles the display of the department in the priority setting menu in the character editor.
/// </summary>
[DataField]
public bool EditorHidden;
public bool EditorHidden { get; private set; } = true;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Roles/JobPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public sealed partial class JobPrototype : IPrototype
/// Should this job appear in preferences menu?
/// </summary>
[DataField("setPreference")]
public bool SetPreference { get; private set; } = true;
public bool SetPreference { get; private set; }

/// <summary>
/// Should the selected traits be applied for this job?
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/assistant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
startingGear: PassengerGear
icon: "JobIconPassenger"
supervisors: job-supervisors-everyone
setPreference: true
access:
- Maintenance

Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/departments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
id: Civilian
name: department-Civilian
description: department-Civilian-description
editorHidden: false
color: "#9FED58"
weight: -10
roles:
Expand Down

0 comments on commit 086006d

Please sign in to comment.