[feat] Species lock for jobs

This commit is contained in:
rhailrake
2023-04-27 22:57:51 +06:00
committed by Aviu00
parent d65bc9a0d0
commit df7aadd830
14 changed files with 140 additions and 0 deletions

72
.github/workflows/update-wiki.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
name: Update Wiki
on:
workflow_dispatch:
push:
branches: [ master, jsondump ]
paths:
- '.github/workflows/update-wiki.yml'
- 'Content.Shared/Chemistry/**.cs'
- 'Content.Server/Chemistry/**.cs'
- 'Content.Server/GuideGenerator/**.cs'
- 'Resources/Prototypes/Reagents/**.yml'
- 'Resources/Prototypes/Chemistry/**.yml'
- 'Resources/Prototypes/Recipes/Reactions/**.yml'
- 'RobustToolbox/'
jobs:
update-wiki:
name: Build and Publish JSON blobs to wiki
runs-on: ubuntu-latest
steps:
- name: Checkout Master
uses: actions/checkout@v2
- name: Setup Submodule
run: |
git submodule update --init --recursive
- name: Pull Engine Updates
uses: space-wizards/submodule-dependency@v0.1.5
- name: Update Engine Submodules
run: |
cd RobustToolbox/
git submodule update --init --recursive
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.100
- name: Install Dependencies
run: dotnet restore
- name: Build Project
run: dotnet build --configuration Release --no-restore /p:WarningsAsErrors=nullable /m
- name: Generate JSON blobs for prototypes
run: dotnet ./bin/Content.Server/Content.Server.dll --cvar autogen.destination_file=prototypes.json
continue-on-error: true
- name: Upload chem_prototypes.json to wiki
uses: jtmullen/mediawiki-edit-action@v0.1.1
with:
wiki_text_file: ./bin/Content.Server/data/chem_prototypes.json
edit_summary: Update chem_prototypes.json via GitHub Actions
page_name: "${{ secrets.WIKI_PAGE_ROOT }}/chem_prototypes.json"
api_url: https://wiki.ss14.su/api.php
username: ${{ secrets.WIKI_BOT_USER }}
password: ${{ secrets.WIKI_BOT_PASS }}
- name: Upload react_prototypes.json to wiki
uses: jtmullen/mediawiki-edit-action@v0.1.1
with:
wiki_text_file: ./bin/Content.Server/data/react_prototypes.json
edit_summary: Update react_prototypes.json via GitHub Actions
page_name: "${{ secrets.WIKI_PAGE_ROOT }}/react_prototypes.json"
api_url: https://wiki.ss14.su/api.php
username: ${{ secrets.WIKI_BOT_USER }}
password: ${{ secrets.WIKI_BOT_PASS }}

View File

@@ -2,6 +2,7 @@ using System.Globalization;
using System.Linq;
using System.Numerics;
using Content.Server.Administration.Managers;
using System.Text;
using Content.Server.Ghost;
using Content.Server.Spawners.Components;
using Content.Server.Speech.Components;
@@ -210,6 +211,36 @@ namespace Content.Server.GameTicking
_playTimeTrackings.PlayerRolesChanged(player);
var whitelistedSpecies = jobPrototype.WhitelistedSpecies;
if (whitelistedSpecies.Count > 0 && !whitelistedSpecies.Contains(character.Species))
{
var playerProfiles = _prefsManager.GetPreferences(player.UserId).Characters.Values.Cast<HumanoidCharacterProfile>().ToList();
var existedAllowedProfile = playerProfiles.FindAll(x => whitelistedSpecies.Contains(x.Species));
if (existedAllowedProfile.Count == 0)
{
character = HumanoidCharacterProfile.RandomWithSpecies(_robustRandom.Pick(whitelistedSpecies));
_chatManager.DispatchServerMessage(player, "Данному виду запрещено играть на этой профессии. Вам была выдана случайная внешность.");
}
else
{
character = _robustRandom.Pick(existedAllowedProfile);
_chatManager.DispatchServerMessage(player, "Данному виду запрещено играть на этой профессии. Вам была выдана случайная внешность с подходящим видом из вашего профиля.");
}
StringBuilder availableSpeciesLoc = new StringBuilder();
foreach (var specie in whitelistedSpecies)
{
availableSpeciesLoc.AppendLine("-" + Loc.GetString($"species-name-{specie.ToLower()}"));
}
_chatManager.DispatchServerMessage(player, $"Доступные виды: \n {availableSpeciesLoc}");
}
var mobMaybe = _stationSpawning.SpawnPlayerCharacterOnStation(station, job, character);
DebugTools.AssertNotNull(mobMaybe);
var mob = mobMaybe!.Value;

View File

@@ -1,4 +1,5 @@
using Content.Shared.Access;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Players.PlayTimeTracking;
using Content.Shared.StatusIcon;
using Robust.Shared.Prototypes;
@@ -98,5 +99,9 @@ namespace Content.Shared.Roles
[DataField("extendedAccessGroups", customTypeSerializer: typeof(PrototypeIdListSerializer<AccessGroupPrototype>))]
public IReadOnlyCollection<string> ExtendedAccessGroups { get; private set; } = Array.Empty<string>();
[DataField("whitelistedSpecies", customTypeSerializer: typeof(PrototypeIdListSerializer<SpeciesPrototype>))]
public IReadOnlyCollection<string> WhitelistedSpecies { get; private set; } = Array.Empty<string>();
}
}

View File

@@ -19,6 +19,9 @@
startingGear: QuartermasterGear
icon: "JobIconQuarterMaster"
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
access:
- Cargo

View File

@@ -22,6 +22,9 @@
requireAdminNotify: true
joinNotifyCrew: true
supervisors: job-supervisors-centcom
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
accessGroups:
- AllAccess

View File

@@ -21,6 +21,8 @@
icon: "JobIconHeadOfPersonnel"
requireAdminNotify: true
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human
canBeAntag: false
access:
- Command

View File

@@ -20,6 +20,9 @@
icon: "JobIconChiefEngineer"
requireAdminNotify: true
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
access:
- Maintenance

View File

@@ -22,6 +22,9 @@
icon: "JobIconChiefMedicalOfficer"
requireAdminNotify: true
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
access:
- Medical

View File

@@ -14,6 +14,9 @@
icon: "JobIconResearchDirector"
requireAdminNotify: true
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
access:
- Research

View File

@@ -10,6 +10,9 @@
startingGear: DetectiveGear
icon: "JobIconDetective"
supervisors: job-supervisors-hos
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
access:
- Security

View File

@@ -20,6 +20,9 @@
icon: "JobIconHeadOfSecurity"
requireAdminNotify: true
supervisors: job-supervisors-captain
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
access:
- HeadOfSecurity

View File

@@ -13,6 +13,9 @@
startingGear: SecurityCadetGear
icon: "JobIconSecurityCadet"
supervisors: job-supervisors-security
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
access:
- Security

View File

@@ -10,6 +10,9 @@
startingGear: SecurityOfficerGear
icon: "JobIconSecurityOfficer"
supervisors: job-supervisors-hos
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
access:
- Security

View File

@@ -10,6 +10,9 @@
startingGear: WardenGear
icon: "JobIconWarden"
supervisors: job-supervisors-hos
whitelistedSpecies:
- Human
- Dwarf
canBeAntag: false
access:
- Security