2023-08-30 21:46:11 -07:00
|
|
|
|
using System.Globalization;
|
2023-08-28 16:53:24 -07:00
|
|
|
|
using Content.Server.Chat.Managers;
|
|
|
|
|
|
using Content.Server.Mind;
|
2023-08-30 21:46:11 -07:00
|
|
|
|
using Content.Shared.Mind;
|
2023-08-28 16:53:24 -07:00
|
|
|
|
using Content.Shared.Roles;
|
2023-08-30 21:46:11 -07:00
|
|
|
|
using Content.Shared.Roles.Jobs;
|
2023-08-28 16:53:24 -07:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Roles.Jobs;
|
|
|
|
|
|
|
2023-09-11 15:44:21 +10:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Handles the job data on mind entities.
|
|
|
|
|
|
/// </summary>
|
2023-08-30 21:46:11 -07:00
|
|
|
|
public sealed class JobSystem : SharedJobSystem
|
2023-08-28 16:53:24 -07:00
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IChatManager _chat = default!;
|
2023-09-11 15:44:21 +10:00
|
|
|
|
[Dependency] private readonly MindSystem _mind = default!;
|
|
|
|
|
|
[Dependency] private readonly RoleSystem _roles = default!;
|
2023-08-28 16:53:24 -07:00
|
|
|
|
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
2023-09-11 17:42:25 +10:00
|
|
|
|
base.Initialize();
|
2023-08-29 15:50:23 -07:00
|
|
|
|
SubscribeLocalEvent<MindComponent, MindRoleAddedEvent>(MindOnDoGreeting);
|
2023-08-28 16:53:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-08-29 15:50:23 -07:00
|
|
|
|
private void MindOnDoGreeting(EntityUid mindId, MindComponent component, ref MindRoleAddedEvent args)
|
2023-08-28 16:53:24 -07:00
|
|
|
|
{
|
2023-08-30 21:06:15 -04:00
|
|
|
|
if (args.Silent)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2023-09-11 15:44:21 +10:00
|
|
|
|
if (!_mind.TryGetSession(mindId, out var session))
|
2023-08-28 16:53:24 -07:00
|
|
|
|
return;
|
|
|
|
|
|
|
2024-10-10 10:48:56 +02:00
|
|
|
|
if (!MindTryGetJob(mindId, out var prototype))
|
2023-08-28 16:53:24 -07:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
_chat.DispatchServerMessage(session, Loc.GetString("job-greet-introduce-job-name",
|
|
|
|
|
|
("jobName", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(prototype.LocalizedName))));
|
|
|
|
|
|
|
|
|
|
|
|
if (prototype.RequireAdminNotify)
|
|
|
|
|
|
_chat.DispatchServerMessage(session, Loc.GetString("job-greet-important-disconnect-admin-notify"));
|
|
|
|
|
|
|
2023-08-29 15:50:23 -07:00
|
|
|
|
_chat.DispatchServerMessage(session, Loc.GetString("job-greet-supervisors-warning", ("jobName", prototype.LocalizedName), ("supervisors", Loc.GetString(prototype.Supervisors))));
|
2023-08-28 16:53:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void MindAddJob(EntityUid mindId, string jobPrototypeId)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (MindHasJobWithId(mindId, jobPrototypeId))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-10-10 10:48:56 +02:00
|
|
|
|
_roles.MindAddJobRole(mindId, null, false, jobPrototypeId);
|
2023-08-28 16:53:24 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|