Skip to content

Commit

Permalink
Fix Client RoleSystem not inheriting SharedRoleSystem, network job co…
Browse files Browse the repository at this point in the history
…mponent (space-wizards#21436)
  • Loading branch information
DrSmugleaf authored Nov 7, 2023
1 parent 651dffb commit dc3b6e3
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 24 deletions.
6 changes: 4 additions & 2 deletions Content.Client/Roles/RoleSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
namespace Content.Client.Roles;
using Content.Shared.Roles;

public sealed class RoleSystem : EntitySystem
namespace Content.Client.Roles;

public sealed class RoleSystem : SharedRoleSystem
{
}
2 changes: 1 addition & 1 deletion Content.Server/GameTicking/GameTicker.Spawning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void SpawnPlayer(ICommonSession player, HumanoidCharacterProfile charact
_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);

Expand Down
3 changes: 1 addition & 2 deletions Content.Server/Objectives/Systems/NotJobRequirementSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Content.Server.Objectives.Components;
using Content.Shared.Objectives.Components;
using Content.Shared.Roles.Jobs;

Expand All @@ -25,7 +24,7 @@ private void OnCheck(EntityUid uid, NotJobRequirementComponent comp, ref Require
if (!TryComp<JobComponent>(args.MindId, out var job))
return;

if (job.PrototypeId == comp.Job)
if (job.Prototype == comp.Job)
args.Cancelled = true;
}
}
3 changes: 1 addition & 2 deletions Content.Server/Roles/Jobs/JobSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Content.Shared.Mind;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Robust.Shared.Prototypes;

namespace Content.Server.Roles.Jobs;

Expand Down Expand Up @@ -48,6 +47,6 @@ public void MindAddJob(EntityUid mindId, string jobPrototypeId)
if (MindHasJobWithId(mindId, jobPrototypeId))
return;

_roles.MindAddRole(mindId, new JobComponent { PrototypeId = jobPrototypeId });
_roles.MindAddRole(mindId, new JobComponent { Prototype = jobPrototypeId });
}
}
2 changes: 1 addition & 1 deletion Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void OnSpawnPlayer(PlayerSpawningEvent args)

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);
}
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Station/Systems/StationSpawningSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public EntityUid SpawnPlayerMob(
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)
Expand Down Expand Up @@ -161,7 +161,7 @@ public EntityUid SpawnPlayerMob(

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)
Expand Down
8 changes: 4 additions & 4 deletions Content.Server/Store/Conditions/BuyerDepartmentCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public override bool Condition(ListingConditionArgs args)
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;
}
}
Expand All @@ -52,11 +52,11 @@ public override bool Condition(ListingConditionArgs args)
{
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;
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Store/Conditions/BuyerJobCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ public override bool Condition(ListingConditionArgs args)

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;
}

Expand Down
9 changes: 5 additions & 4 deletions Content.Shared/Roles/Jobs/JobComponent.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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;
}
6 changes: 3 additions & 3 deletions Content.Shared/Roles/Jobs/SharedJobSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public bool TryGetDepartment(string jobProto, [NotNullWhen(true)] out Department

public bool MindHasJobWithId(EntityUid? mindId, string prototypeId)
{
return CompOrNull<JobComponent>(mindId)?.PrototypeId == prototypeId;
return CompOrNull<JobComponent>(mindId)?.Prototype == prototypeId;
}

public bool MindTryGetJob(
Expand All @@ -95,8 +95,8 @@ 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>
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Roles/SharedRoleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private void OnJobGetAllRoles(EntityUid uid, JobComponent component, ref MindGet
{
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;
Expand Down

0 comments on commit dc3b6e3

Please sign in to comment.