Skip to content

Commit ac62aa7

Browse files
committed
add SpeciesMinAge and SpeciesMaxAge in AgeRequirement
1 parent 4a93305 commit ac62aa7

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

Content.Shared/Roles/JobRequirement/AgeRequirement.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Diagnostics.CodeAnalysis;
22
using System.Linq;
33
using Content.Shared._WL.CCVars;
4+
using Content.Shared.Humanoid.Prototypes;
45
using Content.Shared.Preferences;
56
using JetBrains.Annotations;
67
using Robust.Shared.Configuration;
@@ -23,6 +24,13 @@ public sealed partial class AgeRequirement : JobRequirement
2324

2425
[DataField]
2526
public int? MaxAge;
27+
28+
[DataField]
29+
public Dictionary<ProtoId<SpeciesPrototype>, int> SpeciesMinAge { get; private set; } = new();
30+
31+
[DataField]
32+
public Dictionary<ProtoId<SpeciesPrototype>, int> SpeciesMaxAge { get; private set; } = new();
33+
2634
//WL-Changes-end
2735

2836
public override bool Check(
@@ -50,8 +58,31 @@ public override bool Check(
5058
if (profile.JobUnblockings.ContainsKey(job.ID))
5159
isNeeded = false;
5260

61+
var minAgeForSpecies = 0;
62+
var maxAgeForSpecies = 0;
63+
64+
if (SpeciesMinAge.TryGetValue(profile.Species, out var minAge))
65+
minAgeForSpecies = minAge;
66+
67+
if (SpeciesMaxAge.TryGetValue(profile.Species, out var maxAge))
68+
maxAgeForSpecies = maxAge;
69+
70+
5371
if (isNeeded)
5472
{
73+
if (minAgeForSpecies != 0 && profile.Age < minAgeForSpecies)
74+
{
75+
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString("role-timer-age-too-young",
76+
("age", minAgeForSpecies)));
77+
return false;
78+
}
79+
if (maxAgeForSpecies != 0 && profile.Age > maxAgeForSpecies)
80+
{
81+
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString("role-timer-age-too-old",
82+
("age", maxAgeForSpecies)));
83+
return false;
84+
}
85+
5586
if (MinAge != null && profile.Age < MinAge)
5687
{
5788
reason = FormattedMessage.FromMarkupPermissive(Loc.GetString("role-timer-age-too-young",

Resources/Prototypes/Roles/Jobs/Cargo/salvage_specialist.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
# - !type:OverallPlaytimeRequirement
1515
# time: 36000 #10 hrs
1616
- !type:AgeRequirement
17-
minAge: 18
17+
minAge: 20
18+
speciesMaxAge:
19+
Vulpkanin: 30
1820
icon: "JobIconShaftMiner"
1921
startingGear: SalvageSpecialistGear
2022
supervisors: job-supervisors-qm

0 commit comments

Comments
 (0)