-namespace Content.Client.Roles;
+using Content.Shared.Roles;
-public sealed class RoleSystem : EntitySystem
+namespace Content.Client.Roles;
+
+public sealed class RoleSystem : SharedRoleSystem
{
}
_mind.SetUserId(newMind, data.UserId);
var jobPrototype = _prototypeManager.Index<JobPrototype>(jobId);
- var job = new JobComponent { PrototypeId = jobId };
+ var job = new JobComponent { Prototype = jobId };
_roles.MindAddRole(newMind, job, silent: silent);
var jobName = _jobs.MindTryGetJobName(newMind);
-using Content.Server.Objectives.Components;
using Content.Shared.Objectives.Components;
using Content.Shared.Roles.Jobs;
if (!TryComp<JobComponent>(args.MindId, out var job))
return;
- if (job.PrototypeId == comp.Job)
+ if (job.Prototype == comp.Job)
args.Cancelled = true;
}
}
using Content.Shared.Mind;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
-using Robust.Shared.Prototypes;
namespace Content.Server.Roles.Jobs;
if (MindHasJobWithId(mindId, jobPrototypeId))
return;
- _roles.MindAddRole(mindId, new JobComponent { PrototypeId = jobPrototypeId });
+ _roles.MindAddRole(mindId, new JobComponent { Prototype = jobPrototypeId });
}
}
if (_gameTicker.RunLevel != GameRunLevel.InRound &&
spawnPoint.SpawnType == SpawnPointType.Job &&
- (args.Job == null || spawnPoint.Job?.ID == args.Job.PrototypeId))
+ (args.Job == null || spawnPoint.Job?.ID == args.Job.Prototype))
{
possiblePositions.Add(xform.Coordinates);
}
EntityUid? station,
EntityUid? entity = null)
{
- _prototypeManager.TryIndex(job?.PrototypeId ?? string.Empty, out JobPrototype? prototype);
+ _prototypeManager.TryIndex(job?.Prototype ?? string.Empty, out JobPrototype? prototype);
// If we're not spawning a humanoid, we're gonna exit early without doing all the humanoid stuff.
if (prototype?.JobEntity != null)
private void DoJobSpecials(JobComponent? job, EntityUid entity)
{
- if (!_prototypeManager.TryIndex(job?.PrototypeId ?? string.Empty, out JobPrototype? prototype))
+ if (!_prototypeManager.TryIndex(job?.Prototype ?? string.Empty, out JobPrototype? prototype))
return;
foreach (var jobSpecial in prototype.Special)
var jobs = ent.System<SharedJobSystem>();
jobs.MindTryGetJob(mindId, out var job, out _);
- if (Blacklist != null && job?.PrototypeId != null)
+ if (Blacklist != null && job?.Prototype != null)
{
foreach (var department in prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{
- if (department.Roles.Contains(job.PrototypeId) && Blacklist.Contains(department.ID))
+ if (department.Roles.Contains(job.Prototype) && Blacklist.Contains(department.ID))
return false;
}
}
{
var found = false;
- if (job?.PrototypeId != null)
+ if (job?.Prototype != null)
{
foreach (var department in prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{
- if (department.Roles.Contains(job.PrototypeId) && Whitelist.Contains(department.ID))
+ if (department.Roles.Contains(job.Prototype) && Whitelist.Contains(department.ID))
{
found = true;
break;
if (Blacklist != null)
{
- if (job?.PrototypeId != null && Blacklist.Contains(job.PrototypeId))
+ if (job?.Prototype != null && Blacklist.Contains(job.Prototype))
return false;
}
if (Whitelist != null)
{
- if (job?.PrototypeId == null || !Whitelist.Contains(job.PrototypeId))
+ if (job?.Prototype == null || !Whitelist.Contains(job.Prototype))
return false;
}
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
+using Robust.Shared.GameStates;
+using Robust.Shared.Prototypes;
namespace Content.Shared.Roles.Jobs;
/// <summary>
/// Added to mind entities to hold the data for the player's current job.
/// </summary>
-[RegisterComponent]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class JobComponent : Component
{
- [DataField("prototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer<JobPrototype>))]
- public string? PrototypeId;
+ [DataField(required: true), AutoNetworkedField]
+ public ProtoId<JobPrototype>? Prototype;
}
public bool MindHasJobWithId(EntityUid? mindId, string prototypeId)
{
- return CompOrNull<JobComponent>(mindId)?.PrototypeId == prototypeId;
+ return CompOrNull<JobComponent>(mindId)?.Prototype == prototypeId;
}
public bool MindTryGetJob(
prototype = null;
return TryComp(mindId, out comp) &&
- comp.PrototypeId != null &&
- _prototypes.TryIndex(comp.PrototypeId, out prototype);
+ comp.Prototype != null &&
+ _prototypes.TryIndex(comp.Prototype, out prototype);
}
/// <summary>
{
var name = "game-ticker-unknown-role";
string? playTimeTracker = null;
- if (component.PrototypeId != null && _prototypes.TryIndex(component.PrototypeId, out JobPrototype? job))
+ if (component.Prototype != null && _prototypes.TryIndex(component.Prototype, out JobPrototype? job))
{
name = job.Name;
playTimeTracker = job.PlayTimeTracker;