Fixed not tracking job playtime (#19639)
This commit is contained in:
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user