Fixed not tracking job playtime (#19639)

This commit is contained in:
DrSmugleaf
2023-08-29 13:39:16 -07:00
committed by GitHub
parent b2672bdd3b
commit 9567ae3b7f
3 changed files with 6 additions and 4 deletions

View File

@@ -80,7 +80,7 @@ public sealed class PlayTimeTrackingSystem : EntitySystem
public IEnumerable<string> GetTimedRoles(EntityUid mindId) public IEnumerable<string> GetTimedRoles(EntityUid mindId)
{ {
var ev = new MindGetAllRolesEvent(new List<RoleInfo>()); var ev = new MindGetAllRolesEvent(new List<RoleInfo>());
RaiseLocalEvent(ref ev); RaiseLocalEvent(mindId, ref ev);
foreach (var role in ev.Roles) foreach (var role in ev.Roles)
{ {

View File

@@ -16,4 +16,4 @@ public readonly record struct MindGetAllRolesEvent(List<RoleInfo> Roles);
/// <param name="Name">Name of the role.</param> /// <param name="Name">Name of the role.</param>
/// <param name="Antagonist">Whether or not this role makes this player an antagonist.</param> /// <param name="Antagonist">Whether or not this role makes this player an antagonist.</param>
/// <param name="PlayTimeTrackerId">The <see cref="PlayTimeTrackerPrototype"/> id associated with the role.</param> /// <param name="PlayTimeTrackerId">The <see cref="PlayTimeTrackerPrototype"/> id associated with the role.</param>
public readonly record struct RoleInfo(Component Component, string Name, bool Antagonist, string? PlayTimeTrackerId = null); public readonly record struct RoleInfo(Component Component, string Name, bool Antagonist, string? PlayTimeTrackerId);

View File

@@ -30,14 +30,16 @@ public sealed class RoleSystem : EntitySystem
private void OnJobGetAllRoles(EntityUid uid, JobComponent component, ref MindGetAllRolesEvent args) private void OnJobGetAllRoles(EntityUid uid, JobComponent component, ref MindGetAllRolesEvent args)
{ {
var name = "game-ticker-unknown-role"; var name = "game-ticker-unknown-role";
string? playTimeTracker = null;
if (component.PrototypeId != null && _prototypes.TryIndex(component.PrototypeId, out JobPrototype? job)) if (component.PrototypeId != null && _prototypes.TryIndex(component.PrototypeId, out JobPrototype? job))
{ {
name = job.Name; name = job.Name;
playTimeTracker = job.PlayTimeTracker;
} }
name = Loc.GetString(name); name = Loc.GetString(name);
args.Roles.Add(new RoleInfo(component, name, false)); args.Roles.Add(new RoleInfo(component, name, false, playTimeTracker));
} }
private void SubscribeAntagEvents<T>() where T : AntagonistRoleComponent private void SubscribeAntagEvents<T>() where T : AntagonistRoleComponent
@@ -51,7 +53,7 @@ public sealed class RoleSystem : EntitySystem
} }
name = Loc.GetString(name); name = Loc.GetString(name);
args.Roles.Add(new RoleInfo(component, name, true)); args.Roles.Add(new RoleInfo(component, name, true, null));
}); });
SubscribeLocalEvent((EntityUid _, T _, ref MindIsAntagonistEvent args) => args.IsAntagonist = true); SubscribeLocalEvent((EntityUid _, T _, ref MindIsAntagonistEvent args) => args.IsAntagonist = true);