Fix jobs not getting their round start message (#19643)

This commit is contained in:
DrSmugleaf
2023-08-29 15:50:23 -07:00
committed by GitHub
parent f4503864d5
commit 084ad5415c
4 changed files with 16 additions and 6 deletions

View File

@@ -21,10 +21,10 @@ public sealed class JobSystem : EntitySystem
public override void Initialize() public override void Initialize()
{ {
SubscribeLocalEvent<JobComponent, RoleAddedEvent>(MindOnDoGreeting); SubscribeLocalEvent<MindComponent, MindRoleAddedEvent>(MindOnDoGreeting);
} }
private void MindOnDoGreeting(EntityUid mindId, JobComponent component, RoleAddedEvent args) private void MindOnDoGreeting(EntityUid mindId, MindComponent component, ref MindRoleAddedEvent args)
{ {
if (!_mind.TryGetSession(mindId, out var session)) if (!_mind.TryGetSession(mindId, out var session))
return; return;
@@ -38,9 +38,7 @@ public sealed class JobSystem : EntitySystem
if (prototype.RequireAdminNotify) if (prototype.RequireAdminNotify)
_chat.DispatchServerMessage(session, Loc.GetString("job-greet-important-disconnect-admin-notify")); _chat.DispatchServerMessage(session, Loc.GetString("job-greet-important-disconnect-admin-notify"));
_chat.DispatchServerMessage(session, Loc.GetString("job-greet-supervisors-warning", _chat.DispatchServerMessage(session, Loc.GetString("job-greet-supervisors-warning", ("jobName", prototype.LocalizedName), ("supervisors", Loc.GetString(prototype.Supervisors))));
("jobName", Name),
("supervisors", Loc.GetString(prototype.Supervisors))));
} }
public void MindAddJob(EntityUid mindId, string jobPrototypeId) public void MindAddJob(EntityUid mindId, string jobPrototypeId)

View File

@@ -0,0 +1,8 @@
namespace Content.Server.Roles;
/// <summary>
/// Raised on mind entities when a role is added to them.
/// <see cref="RoleAddedEvent"/> for the one raised on player entities.
/// </summary>
[ByRefEvent]
public readonly record struct MindRoleAddedEvent;

View File

@@ -3,7 +3,8 @@
namespace Content.Server.Roles; namespace Content.Server.Roles;
/// <summary> /// <summary>
/// Event raised on player entities to indicate that a role was added to their mind. /// Raised on player entities when a role is added to them.
/// <see cref="RoleAddedEvent"/> for the one raised on mind entities.
/// </summary> /// </summary>
/// <param name="MindId">The mind id associated with the player.</param> /// <param name="MindId">The mind id associated with the player.</param>
/// <param name="Mind">The mind component associated with the mind id.</param> /// <param name="Mind">The mind component associated with the mind id.</param>

View File

@@ -83,6 +83,9 @@ public sealed class RoleSystem : EntitySystem
AddComp(mindId, component); AddComp(mindId, component);
var antagonist = IsAntagonistRole<T>(); var antagonist = IsAntagonistRole<T>();
var mindEv = new MindRoleAddedEvent();
RaiseLocalEvent(mindId, ref mindEv);
var message = new RoleAddedEvent(mindId, mind, antagonist); var message = new RoleAddedEvent(mindId, mind, antagonist);
if (mind.OwnedEntity != null) if (mind.OwnedEntity != null)
{ {