Улучшения ОБР
This commit is contained in:
@@ -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)
|
protected override void Ended(EntityUid uid, ERTRecruitmentRuleComponent component, GameRuleComponent gameRule, GameRuleEndedEvent args)
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ public sealed partial class ERTRecruitmentRuleComponent : Component
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField] public int MinPlayers = 3;
|
[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 ERTYes = new SoundPathSpecifier("/Audio/Announcements/ert_yes.ogg");
|
||||||
public static SoundSpecifier ERTNo = new SoundPathSpecifier("/Audio/Announcements/ert_no.ogg");
|
public static SoundSpecifier ERTNo = new SoundPathSpecifier("/Audio/Announcements/ert_no.ogg");
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,12 @@ using Robust.Server.GameObjects;
|
|||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Random;
|
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;
|
namespace Content.Server._White.GhostRecruitment;
|
||||||
|
|
||||||
@@ -23,18 +29,26 @@ public sealed class GhostRecruitmentSystem : EntitySystem
|
|||||||
[Dependency] private readonly MindSystem _mind = default!;
|
[Dependency] private readonly MindSystem _mind = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = 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();
|
private readonly Dictionary<ICommonSession, GhostRecruitmentEuiAccept> _openUis = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// starts recruiting ghosts, showing them a menu with a choice to recruit.
|
/// starts recruiting ghosts, showing them a menu with a choice to recruit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="recruitmentName">name of recruitment. <see cref="GhostRecruitmentSpawnPointComponent"/></param>
|
/// <param name="recruitmentName">Name of recruitment. <see cref="GhostRecruitmentSpawnPointComponent"/></param>
|
||||||
public void StartRecruitment(string recruitmentName)
|
/// <param name="overallPlaytime">Minimal playtime to be eligible for recruitment.</param>
|
||||||
|
public void StartRecruitment(string recruitmentName, TimeSpan? overallPlaytime)
|
||||||
{
|
{
|
||||||
var query = EntityQueryEnumerator<GhostComponent, ActorComponent>();
|
var query = EntityQueryEnumerator<GhostComponent, ActorComponent>();
|
||||||
while (query.MoveNext(out var uid, out _, out var actorComponent))
|
while (query.MoveNext(out var uid, out _, out var actorComponent))
|
||||||
{
|
{
|
||||||
|
if (overallPlaytime != null && _playTimeTracking.GetOverallPlaytime(actorComponent.PlayerSession) < overallPlaytime)
|
||||||
|
continue;
|
||||||
|
|
||||||
OpenEui(uid, recruitmentName, actorComponent);
|
OpenEui(uid, recruitmentName, actorComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,13 +135,20 @@ public sealed class GhostRecruitmentSystem : EntitySystem
|
|||||||
if (!entityUid.HasValue)
|
if (!entityUid.HasValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var mind = actorComponent.PlayerSession.GetMind();
|
var userId = actorComponent.PlayerSession.UserId;
|
||||||
|
var entityName = EntityManager.GetComponent<MetaDataComponent>((EntityUid) entityUid).EntityName;
|
||||||
|
|
||||||
if (!mind.HasValue)
|
var newMind = _mind.CreateMind(userId, entityName);
|
||||||
return;
|
|
||||||
|
|
||||||
_mind.TransferTo(mind.Value, entityUid.Value);
|
var job = new JobComponent { Prototype = component.JobId };
|
||||||
_mind.UnVisit(mind.Value);
|
|
||||||
|
_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)
|
private EntityUid? Spawn(EntityUid spawnerUid, GhostRecruitmentSpawnPointComponent? component = null)
|
||||||
|
|||||||
@@ -6,11 +6,14 @@ namespace Content.Shared._White.GhostRecruitment;
|
|||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed partial class GhostRecruitmentSpawnPointComponent : Component
|
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!;
|
public string EntityPrototype = default!;
|
||||||
|
|
||||||
[DataField("recruitmentName")]
|
[DataField("recruitmentName")]
|
||||||
public string RecruitmentName = "default";
|
public string RecruitmentName = "default";
|
||||||
|
|
||||||
[DataField("priority")] public int Priority = 5;
|
[DataField("priority")] public int Priority = 5;
|
||||||
|
|
||||||
|
[DataField]
|
||||||
|
public string JobId = "Passenger";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
prototype: RandomHumanoidSpawnerERTLeader
|
prototype: RandomHumanoidSpawnerERTLeader
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
priority: 1
|
priority: 1
|
||||||
|
jobId: ERTLeader
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
prototype: RandomHumanoidSpawnerERTLeaderEVA
|
prototype: RandomHumanoidSpawnerERTLeaderEVA
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
priority: 1
|
priority: 1
|
||||||
|
jobId: ERTLeader
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
@@ -44,6 +46,7 @@
|
|||||||
- type: GhostRecruitmentSpawnPoint
|
- type: GhostRecruitmentSpawnPoint
|
||||||
prototype: RandomHumanoidSpawnerERTJanitor
|
prototype: RandomHumanoidSpawnerERTJanitor
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
|
jobId: ERTJanitor
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
@@ -57,6 +60,7 @@
|
|||||||
- type: GhostRecruitmentSpawnPoint
|
- type: GhostRecruitmentSpawnPoint
|
||||||
prototype: RandomHumanoidSpawnerERTJanitorEVA
|
prototype: RandomHumanoidSpawnerERTJanitorEVA
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
|
jobId: ERTJanitor
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
@@ -71,6 +75,7 @@
|
|||||||
prototype: RandomHumanoidSpawnerERTEngineer
|
prototype: RandomHumanoidSpawnerERTEngineer
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
priority: 2
|
priority: 2
|
||||||
|
jobId: ERTEngineer
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
@@ -85,6 +90,7 @@
|
|||||||
prototype: RandomHumanoidSpawnerERTEngineerEVA
|
prototype: RandomHumanoidSpawnerERTEngineerEVA
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
priority: 2
|
priority: 2
|
||||||
|
jobId: ERTEngineer
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
@@ -99,6 +105,7 @@
|
|||||||
prototype: RandomHumanoidSpawnerERTSecurity
|
prototype: RandomHumanoidSpawnerERTSecurity
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
priority: 2
|
priority: 2
|
||||||
|
jobId: ERTSecurity
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
@@ -113,6 +120,7 @@
|
|||||||
prototype: RandomHumanoidSpawnerERTSecurityEVA
|
prototype: RandomHumanoidSpawnerERTSecurityEVA
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
priority: 2
|
priority: 2
|
||||||
|
jobId: ERTSecurity
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
@@ -127,6 +135,7 @@
|
|||||||
prototype: RandomHumanoidSpawnerERTMedical
|
prototype: RandomHumanoidSpawnerERTMedical
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
priority: 2
|
priority: 2
|
||||||
|
jobId: ERTMedical
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
@@ -141,6 +150,7 @@
|
|||||||
prototype: RandomHumanoidSpawnerERTMedicalEVA
|
prototype: RandomHumanoidSpawnerERTMedicalEVA
|
||||||
recruitmentName: ERTRecruitment
|
recruitmentName: ERTRecruitment
|
||||||
priority: 2
|
priority: 2
|
||||||
|
jobId: ERTMedical
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- state: green
|
- state: green
|
||||||
|
|||||||
Reference in New Issue
Block a user