Улучшения ОБР

This commit is contained in:
BIGZi0348
2025-01-12 22:45:08 +03:00
parent 6d5e8e5273
commit a867f549b1
5 changed files with 48 additions and 9 deletions

View File

@@ -104,7 +104,7 @@ public sealed class ERTRecruitmentRule : StationEventSystem<ERTRecruitmentRuleCo
}
*/
_recruitment.StartRecruitment(ERTRecruitmentRuleComponent.EventName);
_recruitment.StartRecruitment(ERTRecruitmentRuleComponent.EventName, component.OverallPlaytime);
}
protected override void Ended(EntityUid uid, ERTRecruitmentRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)

View File

@@ -16,6 +16,11 @@ public sealed partial class ERTRecruitmentRuleComponent : Component
/// </summary>
[DataField] public int MinPlayers = 3;
/// <summary>
/// Minimal playtime to be eligible for recruitment.
/// </summary>
[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");

View File

@@ -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<ICommonSession, GhostRecruitmentEuiAccept> _openUis = new();
/// <summary>
/// starts recruiting ghosts, showing them a menu with a choice to recruit.
/// </summary>
/// <param name="recruitmentName">name of recruitment. <see cref="GhostRecruitmentSpawnPointComponent"/></param>
public void StartRecruitment(string recruitmentName)
/// <param name="recruitmentName">Name of recruitment. <see cref="GhostRecruitmentSpawnPointComponent"/></param>
/// <param name="overallPlaytime">Minimal playtime to be eligible for recruitment.</param>
public void StartRecruitment(string recruitmentName, TimeSpan? overallPlaytime)
{
var query = EntityQueryEnumerator<GhostComponent, ActorComponent>();
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<MetaDataComponent>((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)

View File

@@ -6,11 +6,14 @@ namespace Content.Shared._White.GhostRecruitment;
[RegisterComponent]
public sealed partial class GhostRecruitmentSpawnPointComponent : Component
{
[DataField("prototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>),required:true)]
[DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>), required: true)]
public string EntityPrototype = default!;
[DataField("recruitmentName")]
public string RecruitmentName = "default";
[DataField("priority")] public int Priority = 5;
[DataField]
public string JobId = "Passenger";
}

View File

@@ -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