diff --git a/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs b/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs index 63479297fa9c..8130ccb3de86 100644 --- a/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs +++ b/Content.Client/Players/PlayTimeTracking/JobRequirementsManager.cs @@ -151,7 +151,7 @@ public bool CheckSpeciesRestrict(JobPrototype job, HumanoidCharacterProfile prof if (species is not null) { - if (JobRequirements.TryRequirementsSpeciesMet(job, species, out var reason, _prototypeManager)) + if (JobRequirements.TryRequirementsSpeciesMet(job, species, profile.Sex, out var reason, _prototypeManager)) //ss220-arahFix return true; reasons.Add(reason.ToMarkup()); diff --git a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs index 63a8410a52cf..18dd2f5a0b4b 100644 --- a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs +++ b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs @@ -13,6 +13,7 @@ using Robust.Shared.Network; using Robust.Shared.Player; using Robust.Shared.Prototypes; +using Content.Server.SS220.RoleSpeciesRestrict; namespace Content.Server.Preferences.Managers @@ -28,6 +29,8 @@ public sealed class ServerPreferencesManager : IServerPreferencesManager [Dependency] private readonly IServerDbManager _db = default!; [Dependency] private readonly IPrototypeManager _protos = default!; [Dependency] private readonly SponsorsManager _sponsors = default!; + [Dependency] private readonly IEntitySystemManager _iEntitySystemManager = default!; + [Dependency] private readonly ISharedPlayerManager _iSharedPlayerManager = default!; // Cache player prefs on the server so we don't need as much async hell related to them. private readonly Dictionary _cachedPlayerPrefs = @@ -106,6 +109,27 @@ private async void HandleUpdateCharacterMessage(MsgUpdateCharacter message) var allowedMarkings = _sponsors.TryGetInfo(message.MsgChannel.UserId, out var sponsor) ? sponsor.AllowedMarkings : new string[]{}; profile.EnsureValid(_cfg, _protos, allowedMarkings); // Corvax-Sponsors-End + + //ss-220 arahFix + if (!_iSharedPlayerManager.TryGetSessionById(userId, out var session)) + return; + + if (profile is HumanoidCharacterProfile human){ + + foreach (var (k,v) in human.JobPriorities) + { + if(session == null) + continue; + if(!_iEntitySystemManager.GetEntitySystem().IsAllowed(session, k)) + { + human = human.WithJobPriority(k, JobPriority.Never); + } + } + profile = human; + message.Profile = human; + } + //ss-220 arahFixend + var profiles = new Dictionary(curPrefs.Characters) { [slot] = profile diff --git a/Content.Server/SS220/RoleSpeciesRestrict/RoleSpeciesRestrictSystem.cs b/Content.Server/SS220/RoleSpeciesRestrict/RoleSpeciesRestrictSystem.cs index a38812374e92..56bf01327e57 100644 --- a/Content.Server/SS220/RoleSpeciesRestrict/RoleSpeciesRestrictSystem.cs +++ b/Content.Server/SS220/RoleSpeciesRestrict/RoleSpeciesRestrictSystem.cs @@ -1,5 +1,6 @@ // © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt // Created specially for SS200 with love by Alan Wake (https://github.com/aw-c) + using Content.Shared.Roles; using Robust.Shared.Prototypes; using Content.Shared.Humanoid.Prototypes; @@ -21,7 +22,7 @@ public bool IsAllowed(ICommonSession player, string jobId) { var profile = (_serverPreferences.GetPreferences(player.UserId).SelectedCharacter as HumanoidCharacterProfile)!; var species = _prototypes.Index(profile.Species); - if (JobRequirements.TryRequirementsSpeciesMet(job, species, out _, _prototypes)) + if (JobRequirements.TryRequirementsSpeciesMet(job, species, profile.Sex, out _, _prototypes)) //ss220-arahFix return true; } return false; diff --git a/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs b/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs index 1a69aa54b922..1c597bfb5276 100644 --- a/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs +++ b/Content.Shared/Humanoid/Prototypes/SpeciesPrototype.cs @@ -1,6 +1,7 @@ using Robust.Shared.Prototypes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic; using Content.Shared.Roles; namespace Content.Shared.Humanoid.Prototypes; @@ -135,8 +136,8 @@ public sealed partial class SpeciesPrototype : IPrototype public string ButtScanTexture = "/Textures/SS220/Interface/Butts/human.png"; //SS220 Species-Job-Requirement - [DataField("blockedJobs", required: false, customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List BlockedJobs { get; } = new(); + [DataField(customTypeSerializer: typeof(DictionarySerializer))] + public Dictionary BlockedJobsByAccessor { get; } = new(); /// /// The Style used for the guidebook info link in the character profile editor diff --git a/Content.Shared/Roles/JobRequirements.cs b/Content.Shared/Roles/JobRequirements.cs index e209e0110165..981b3a42d634 100644 --- a/Content.Shared/Roles/JobRequirements.cs +++ b/Content.Shared/Roles/JobRequirements.cs @@ -7,6 +7,7 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Utility; using Content.Shared.Humanoid.Prototypes; +using Content.Shared.Humanoid; namespace Content.Shared.Roles { @@ -76,16 +77,45 @@ public static class JobRequirements public static bool TryRequirementsSpeciesMet( JobPrototype job, SpeciesPrototype species, + Sex selected_sex, [NotNullWhen(false)] out FormattedMessage? reason, IPrototypeManager prototypes) { reason = null; - if (species.BlockedJobs is not null && species.BlockedJobs.Contains(job.ID)) + if (species.BlockedJobsByAccessor.ContainsKey(job.ID)) { + if (species.BlockedJobsByAccessor[job.ID] is null || species.BlockedJobsByAccessor[job.ID].Length == 0) + goto not_allowed; + + foreach (var looking_sex in species.BlockedJobsByAccessor[job.ID]) + { + Sex sex = 0; + switch (looking_sex) + { + case "female": + sex = Sex.Female; + break; + case "male": + sex = Sex.Male; + break; + case "unsexed": + sex = Sex.Unsexed; + break; + } + + if (selected_sex == sex) + goto not_allowed; + } + + return true; + + not_allowed: + reason = FormattedMessage.FromMarkup(Loc.GetString("role-restrict-specie")); return false; } + return true; } //SS220 Species-Job-Requirement end @@ -181,7 +211,7 @@ public static bool TryRequirementMet( return true; reason = FormattedMessage.FromMarkup(Loc.GetString( - "role-timer-overall-insufficient", + "role-timer-overall-insufficient", ("time", Math.Ceiling(overallDiff)))); return false; } diff --git a/Resources/Prototypes/SS220/spo9k/Species/felinid.yml b/Resources/Prototypes/SS220/spo9k/Species/felinid.yml index 9c71a299365c..379ea77f7011 100644 --- a/Resources/Prototypes/SS220/spo9k/Species/felinid.yml +++ b/Resources/Prototypes/SS220/spo9k/Species/felinid.yml @@ -10,23 +10,23 @@ youngAge: 20 oldAge: 40 maxAge: 40 - blockedJobs: - - Captain - - BlueShield - - HeadOfPersonnel - - Quartermaster - - ChiefEngineer - - Chemist - - ChiefMedicalOfficer - - Paramedic - - ResearchDirector - - Brigmedic - - Detective - - HeadOfSecurity - - SecurityCadet - - SecurityOfficer - - Warden - - Boxer + blockedJobsByAccessor: # we are deny all sex if don't put anytihng inside the [], but when we put something inside, we deny just this sex +#Командование + Captain: [ ] + HeadOfPersonnel: [ ] + ChiefEngineer: [ ] + ResearchDirector: [ ] + HeadOfSecurity: [ ] + ChiefMedicalOfficer: [ ] +#ЦК + IAA: [ ] + BlueShield: [ ] +#Служба Безопасности + SecurityCadet: [ ] + SecurityOfficer: [ ] + SecurityPilot: [ ] + Warden: [ ] + - type: markingPoints id: MobFelinidMarkingLimits points: diff --git a/Resources/Prototypes/Species/arachnid.yml b/Resources/Prototypes/Species/arachnid.yml index 92bce581d0de..4f8c275744c8 100644 --- a/Resources/Prototypes/Species/arachnid.yml +++ b/Resources/Prototypes/Species/arachnid.yml @@ -12,8 +12,50 @@ femaleFirstNames: names_arachnid_first maleLastNames: names_arachnid_last # Corvax-LastnameGender femaleLastNames: names_arachnid_last # Corvax-LastnameGender - sexes: - - Unsexed + blockedJobsByAccessor: #SS220-Job-Restrictions-start +#Командование + Captain: [ ] + HeadOfPersonnel: [ male ] + HeadOfSecurity: [ male ] + ChiefEngineer: [ male ] + Quartermaster: [ male ] + ChiefMedicalOfficer: [ male ] + ResearchDirector: [ male ] +#ЦК + IAA: [ ] + BlueShield: [ male ] +#Служба Безопасности + Warden: [ male ] + SecurityOfficer: [ male ] + SecurityPilot: [ male ] + SecurityCadet: [ male ] + Brigmedic: [ female ] +#Инженерный отдел + AtmosphericTechnician: [ female ] + StationEngineer: [ female ] + TechnicalAssistant: [ female ] +#Медицинский отдел + Psychologist: [ ] + Chemist: [ female ] + MedicalDoctor: [ female ] + MedicalIntern: [ female ] + Paramedic: [ female ] +#Научный отдел + Scientist: [ female ] + ResearchAssistant: [ female ] +#Отдел снабжения + CargoTechnician: [ female ] + SalvageSpecialist: [ female ] +#Сервис + Chef: [ female ] + Bartender: [ female ] + Detective: [ male ] + Librarian: [ female ] + Janitor: [ female ] + Botanist: [ female ] + Clown: [ ] + Mime: [ ] +#SS220-Job-Restrictions-end - type: speciesBaseSprites id: MobArachnidSprites diff --git a/Resources/Prototypes/Species/diona.yml b/Resources/Prototypes/Species/diona.yml index a854a0833e00..bd837b507726 100644 --- a/Resources/Prototypes/Species/diona.yml +++ b/Resources/Prototypes/Species/diona.yml @@ -14,6 +14,30 @@ femaleLastNames: DionaLast # Corvax-LastnameGender naming: TheFirstofLast buttScanTexture: /Textures/SS220/Interface/Butts/diona.png + blockedJobsByAccessor: #SS220-Job-Restrictions-start +#Командование + Captain: [ ] + HeadOfSecurity: [ ] + Quartermaster: [ ] +#ЦК + BlueShield: [ ] + IAA: [ ] +#Служба Безопасности + Warden: [ ] + SecurityOfficer: [ ] + SecurityPilot: [ ] + SecurityCadet: [ ] + Brigmedic: [ ] +#Мединский отдел + Paramedic: [ ] +#Отдел снабжения + CargoTechnician: [ ] + SalvageSpecialist: [ ] +#Сервис + Detective: [ ] + Chef: [ ] + Boxer: [ ] +#SS220-Job-Restrictions-end - type: speciesBaseSprites id: MobDionaSprites diff --git a/Resources/Prototypes/Species/dwarf.yml b/Resources/Prototypes/Species/dwarf.yml index fc800213c19f..d3e2b49daf0a 100644 --- a/Resources/Prototypes/Species/dwarf.yml +++ b/Resources/Prototypes/Species/dwarf.yml @@ -7,3 +7,14 @@ markingLimits: MobHumanMarkingLimits dollPrototype: MobDwarfDummy skinColoration: HumanToned + blockedJobsByAccessor: #SS220-Job-Restrictions-start +#Командование + Captain: [ ] + HeadOfPersonnel: [ ] + HeadOfSecurity: [ ] + ResearchDirector: [ ] +#ЦК + IAA: [ ] +#Сервис + Chaplain: [ ] +#SS220-Job-Restrictions-end diff --git a/Resources/Prototypes/Species/moth.yml b/Resources/Prototypes/Species/moth.yml index 1dd80d4f5d2e..71eccc3e92ce 100644 --- a/Resources/Prototypes/Species/moth.yml +++ b/Resources/Prototypes/Species/moth.yml @@ -12,6 +12,18 @@ femaleFirstNames: names_moth_first_female maleLastNames: names_moth_last_male femaleLastNames: names_moth_last_female + blockedJobsByAccessor: #SS220-Job-Restrictions-start +#Командование + Captain: [ ] + HeadOfSecurity: [ ] + ChiefEngineer: [ ] +#ЦК + BlueShield: [ ] + IAA: [ ] +#Инженерный отдел + StationEngineer: [ ] + TechnicalAssistant: [ ] +#SS220-Job-Restrictions-end - type: speciesBaseSprites id: MobMothSprites diff --git a/Resources/Prototypes/Species/reptilian.yml b/Resources/Prototypes/Species/reptilian.yml index d5a776bbf6fb..d8522f857d05 100644 --- a/Resources/Prototypes/Species/reptilian.yml +++ b/Resources/Prototypes/Species/reptilian.yml @@ -12,6 +12,20 @@ femaleFirstNames: names_reptilian_female naming: FirstDashFirst buttScanTexture: /Textures/SS220/Interface/Butts/unathi.png + blockedJobsByAccessor: #SS220-Job-Restrictions-start +#Командование + Captain: [ ] +#ЦК + IAA: [ ] +#Служба Безопасности + Brigmedic: [ ] +#Медицинский отдел + Psychologist: [ ] +#Сервис + Chef: [ ] + Bartender: [ ] + Botanist: [ ] +#SS220-Job-Restrictions-end - type: speciesBaseSprites id: MobReptilianSprites diff --git a/Resources/Prototypes/Species/slime.yml b/Resources/Prototypes/Species/slime.yml index ae60a9d427cd..d0666828ff4d 100644 --- a/Resources/Prototypes/Species/slime.yml +++ b/Resources/Prototypes/Species/slime.yml @@ -9,6 +9,19 @@ dollPrototype: MobSlimePersonDummy skinColoration: Hues buttScanTexture: /Textures/SS220/Interface/Butts/slime.png + blockedJobsByAccessor: #SS220-Job-Restrictions-start +#Командование + Captain: [ ] +#ЦК + IAA: [ ] +#Медицинский отдел + Chemist: [ ] +#Сервис + Janitor: [ ] + Chef: [ ] + Bartender: [ ] + Botanist: [ ] +#SS220-Job-Restrictions-end - type: speciesBaseSprites id: MobSlimeSprites