From a867f549b160cb5c0fdc37521d0724c2364a7f39 Mon Sep 17 00:00:00 2001 From: BIGZi0348 Date: Sun, 12 Jan 2025 22:45:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=9E=D0=91=D0=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ERTRecruitment/ERTRecruitmentRule.cs | 2 +- .../ERTRecruitmentRuleComponent.cs | 5 +++ .../GhostRecruitmentSystem.cs | 35 +++++++++++++++---- .../GhostRecruitmentSpawnPointComponent.cs | 5 ++- .../_White/Entities/Markers/Spawners/ERT.yml | 10 ++++++ 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/Content.Server/_White/ERTRecruitment/ERTRecruitmentRule.cs b/Content.Server/_White/ERTRecruitment/ERTRecruitmentRule.cs index 70d4c2b002..03fa050b42 100644 --- a/Content.Server/_White/ERTRecruitment/ERTRecruitmentRule.cs +++ b/Content.Server/_White/ERTRecruitment/ERTRecruitmentRule.cs @@ -104,7 +104,7 @@ public sealed class ERTRecruitmentRule : StationEventSystem [DataField] public int MinPlayers = 3; + /// + /// Minimal playtime to be eligible for recruitment. + /// + [DataField] public TimeSpan OverallPlaytime = TimeSpan.FromHours(10); + public static SoundSpecifier ERTYes = new SoundPathSpecifier("/Audio/Announcements/ert_yes.ogg"); public static SoundSpecifier ERTNo = new SoundPathSpecifier("/Audio/Announcements/ert_no.ogg"); diff --git a/Content.Server/_White/GhostRecruitment/GhostRecruitmentSystem.cs b/Content.Server/_White/GhostRecruitment/GhostRecruitmentSystem.cs index c917ec24cf..27b9e98f71 100644 --- a/Content.Server/_White/GhostRecruitment/GhostRecruitmentSystem.cs +++ b/Content.Server/_White/GhostRecruitment/GhostRecruitmentSystem.cs @@ -11,6 +11,12 @@ using Robust.Server.GameObjects; using Robust.Server.Player; using Robust.Shared.Player; using Robust.Shared.Random; +using Content.Shared.Roles; +using Content.Server.Roles; +using Content.Shared.Roles.Jobs; +using Content.Server.Station.Systems; +using Robust.Shared.Prototypes; +using Content.Server.Players.PlayTimeTracking; namespace Content.Server._White.GhostRecruitment; @@ -23,18 +29,26 @@ public sealed class GhostRecruitmentSystem : EntitySystem [Dependency] private readonly MindSystem _mind = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IPlayerManager _playerManager = default!; + [Dependency] private readonly SharedRoleSystem _roleSystem = default!; + [Dependency] private readonly StationSpawningSystem _spawningSystem = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly IPlayTimeTrackingManager _playTimeTracking = default!; private readonly Dictionary _openUis = new(); /// /// starts recruiting ghosts, showing them a menu with a choice to recruit. /// - /// name of recruitment. - public void StartRecruitment(string recruitmentName) + /// Name of recruitment. + /// Minimal playtime to be eligible for recruitment. + public void StartRecruitment(string recruitmentName, TimeSpan? overallPlaytime) { var query = EntityQueryEnumerator(); while (query.MoveNext(out var uid, out _, out var actorComponent)) { + if (overallPlaytime != null && _playTimeTracking.GetOverallPlaytime(actorComponent.PlayerSession) < overallPlaytime) + continue; + OpenEui(uid, recruitmentName, actorComponent); } } @@ -121,13 +135,20 @@ public sealed class GhostRecruitmentSystem : EntitySystem if (!entityUid.HasValue) return; - var mind = actorComponent.PlayerSession.GetMind(); + var userId = actorComponent.PlayerSession.UserId; + var entityName = EntityManager.GetComponent((EntityUid) entityUid).EntityName; - if (!mind.HasValue) - return; + var newMind = _mind.CreateMind(userId, entityName); - _mind.TransferTo(mind.Value, entityUid.Value); - _mind.UnVisit(mind.Value); + var job = new JobComponent { Prototype = component.JobId }; + + _roleSystem.MindAddRole(newMind, job); + _mind.SetUserId(newMind, userId); + _mind.TransferTo(newMind, entityUid); + + _prototypeManager.TryIndex(job.Prototype, out var jobProto); + if (jobProto != null) + _spawningSystem.SetPdaAndIdCardData((EntityUid) entityUid, entityName, jobProto, null); } private EntityUid? Spawn(EntityUid spawnerUid, GhostRecruitmentSpawnPointComponent? component = null) diff --git a/Content.Shared/_White/GhostRecruitment/GhostRecruitmentSpawnPointComponent.cs b/Content.Shared/_White/GhostRecruitment/GhostRecruitmentSpawnPointComponent.cs index fe3d68ee0e..53905900a0 100644 --- a/Content.Shared/_White/GhostRecruitment/GhostRecruitmentSpawnPointComponent.cs +++ b/Content.Shared/_White/GhostRecruitment/GhostRecruitmentSpawnPointComponent.cs @@ -6,11 +6,14 @@ namespace Content.Shared._White.GhostRecruitment; [RegisterComponent] public sealed partial class GhostRecruitmentSpawnPointComponent : Component { - [DataField("prototype", customTypeSerializer:typeof(PrototypeIdSerializer),required:true)] + [DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer), required: true)] public string EntityPrototype = default!; [DataField("recruitmentName")] public string RecruitmentName = "default"; [DataField("priority")] public int Priority = 5; + + [DataField] + public string JobId = "Passenger"; } diff --git a/Resources/Prototypes/_White/Entities/Markers/Spawners/ERT.yml b/Resources/Prototypes/_White/Entities/Markers/Spawners/ERT.yml index b3e1804323..430a1291a4 100644 --- a/Resources/Prototypes/_White/Entities/Markers/Spawners/ERT.yml +++ b/Resources/Prototypes/_White/Entities/Markers/Spawners/ERT.yml @@ -17,6 +17,7 @@ prototype: RandomHumanoidSpawnerERTLeader recruitmentName: ERTRecruitment priority: 1 + jobId: ERTLeader - type: Sprite layers: - state: green @@ -31,6 +32,7 @@ prototype: RandomHumanoidSpawnerERTLeaderEVA recruitmentName: ERTRecruitment priority: 1 + jobId: ERTLeader - type: Sprite layers: - state: green @@ -44,6 +46,7 @@ - type: GhostRecruitmentSpawnPoint prototype: RandomHumanoidSpawnerERTJanitor recruitmentName: ERTRecruitment + jobId: ERTJanitor - type: Sprite layers: - state: green @@ -57,6 +60,7 @@ - type: GhostRecruitmentSpawnPoint prototype: RandomHumanoidSpawnerERTJanitorEVA recruitmentName: ERTRecruitment + jobId: ERTJanitor - type: Sprite layers: - state: green @@ -71,6 +75,7 @@ prototype: RandomHumanoidSpawnerERTEngineer recruitmentName: ERTRecruitment priority: 2 + jobId: ERTEngineer - type: Sprite layers: - state: green @@ -85,6 +90,7 @@ prototype: RandomHumanoidSpawnerERTEngineerEVA recruitmentName: ERTRecruitment priority: 2 + jobId: ERTEngineer - type: Sprite layers: - state: green @@ -99,6 +105,7 @@ prototype: RandomHumanoidSpawnerERTSecurity recruitmentName: ERTRecruitment priority: 2 + jobId: ERTSecurity - type: Sprite layers: - state: green @@ -113,6 +120,7 @@ prototype: RandomHumanoidSpawnerERTSecurityEVA recruitmentName: ERTRecruitment priority: 2 + jobId: ERTSecurity - type: Sprite layers: - state: green @@ -127,6 +135,7 @@ prototype: RandomHumanoidSpawnerERTMedical recruitmentName: ERTRecruitment priority: 2 + jobId: ERTMedical - type: Sprite layers: - state: green @@ -141,6 +150,7 @@ prototype: RandomHumanoidSpawnerERTMedicalEVA recruitmentName: ERTRecruitment priority: 2 + jobId: ERTMedical - type: Sprite layers: - state: green