From dc3b6e31b20c405f32c66d28641fbfb3f8482fb5 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Tue, 7 Nov 2023 14:44:53 -0800 Subject: [PATCH] Fix Client RoleSystem not inheriting SharedRoleSystem, network job component (#21436) --- Content.Client/Roles/RoleSystem.cs | 6 ++++-- Content.Server/GameTicking/GameTicker.Spawning.cs | 2 +- .../Objectives/Systems/NotJobRequirementSystem.cs | 3 +-- Content.Server/Roles/Jobs/JobSystem.cs | 3 +-- .../Spawners/EntitySystems/SpawnPointSystem.cs | 2 +- Content.Server/Station/Systems/StationSpawningSystem.cs | 4 ++-- .../Store/Conditions/BuyerDepartmentCondition.cs | 8 ++++---- Content.Server/Store/Conditions/BuyerJobCondition.cs | 4 ++-- Content.Shared/Roles/Jobs/JobComponent.cs | 9 +++++---- Content.Shared/Roles/Jobs/SharedJobSystem.cs | 6 +++--- Content.Shared/Roles/SharedRoleSystem.cs | 2 +- 11 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Content.Client/Roles/RoleSystem.cs b/Content.Client/Roles/RoleSystem.cs index 6a98320af4..5c27e173d3 100644 --- a/Content.Client/Roles/RoleSystem.cs +++ b/Content.Client/Roles/RoleSystem.cs @@ -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 { } diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index c2bf523657..81b8c6e5f6 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -200,7 +200,7 @@ namespace Content.Server.GameTicking _mind.SetUserId(newMind, data.UserId); var jobPrototype = _prototypeManager.Index(jobId); - var job = new JobComponent { PrototypeId = jobId }; + var job = new JobComponent { Prototype = jobId }; _roles.MindAddRole(newMind, job, silent: silent); var jobName = _jobs.MindTryGetJobName(newMind); diff --git a/Content.Server/Objectives/Systems/NotJobRequirementSystem.cs b/Content.Server/Objectives/Systems/NotJobRequirementSystem.cs index c9539fcbf1..5c2b040463 100644 --- a/Content.Server/Objectives/Systems/NotJobRequirementSystem.cs +++ b/Content.Server/Objectives/Systems/NotJobRequirementSystem.cs @@ -1,4 +1,3 @@ -using Content.Server.Objectives.Components; using Content.Shared.Objectives.Components; using Content.Shared.Roles.Jobs; @@ -25,7 +24,7 @@ public sealed class NotJobRequirementSystem : EntitySystem if (!TryComp(args.MindId, out var job)) return; - if (job.PrototypeId == comp.Job) + if (job.Prototype == comp.Job) args.Cancelled = true; } } diff --git a/Content.Server/Roles/Jobs/JobSystem.cs b/Content.Server/Roles/Jobs/JobSystem.cs index 7bee6da755..9f0dd7ae32 100644 --- a/Content.Server/Roles/Jobs/JobSystem.cs +++ b/Content.Server/Roles/Jobs/JobSystem.cs @@ -4,7 +4,6 @@ using Content.Server.Mind; using Content.Shared.Mind; using Content.Shared.Roles; using Content.Shared.Roles.Jobs; -using Robust.Shared.Prototypes; namespace Content.Server.Roles.Jobs; @@ -48,6 +47,6 @@ public sealed class JobSystem : SharedJobSystem if (MindHasJobWithId(mindId, jobPrototypeId)) return; - _roles.MindAddRole(mindId, new JobComponent { PrototypeId = jobPrototypeId }); + _roles.MindAddRole(mindId, new JobComponent { Prototype = jobPrototypeId }); } } diff --git a/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs b/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs index 755153d309..c96e3c5c38 100644 --- a/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs +++ b/Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs @@ -39,7 +39,7 @@ public sealed class SpawnPointSystem : EntitySystem 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); } diff --git a/Content.Server/Station/Systems/StationSpawningSystem.cs b/Content.Server/Station/Systems/StationSpawningSystem.cs index 4aa1b117e5..9beccd06df 100644 --- a/Content.Server/Station/Systems/StationSpawningSystem.cs +++ b/Content.Server/Station/Systems/StationSpawningSystem.cs @@ -97,7 +97,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem 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) @@ -161,7 +161,7 @@ public sealed class StationSpawningSystem : SharedStationSpawningSystem 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) diff --git a/Content.Server/Store/Conditions/BuyerDepartmentCondition.cs b/Content.Server/Store/Conditions/BuyerDepartmentCondition.cs index a71adc4e77..4e5e504aec 100644 --- a/Content.Server/Store/Conditions/BuyerDepartmentCondition.cs +++ b/Content.Server/Store/Conditions/BuyerDepartmentCondition.cs @@ -39,11 +39,11 @@ public sealed partial class BuyerDepartmentCondition : ListingCondition var jobs = ent.System(); 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()) { - if (department.Roles.Contains(job.PrototypeId) && Blacklist.Contains(department.ID)) + if (department.Roles.Contains(job.Prototype) && Blacklist.Contains(department.ID)) return false; } } @@ -52,11 +52,11 @@ public sealed partial class BuyerDepartmentCondition : ListingCondition { var found = false; - if (job?.PrototypeId != null) + if (job?.Prototype != null) { foreach (var department in prototypeManager.EnumeratePrototypes()) { - if (department.Roles.Contains(job.PrototypeId) && Whitelist.Contains(department.ID)) + if (department.Roles.Contains(job.Prototype) && Whitelist.Contains(department.ID)) { found = true; break; diff --git a/Content.Server/Store/Conditions/BuyerJobCondition.cs b/Content.Server/Store/Conditions/BuyerJobCondition.cs index f5013008ab..6a53af188c 100644 --- a/Content.Server/Store/Conditions/BuyerJobCondition.cs +++ b/Content.Server/Store/Conditions/BuyerJobCondition.cs @@ -38,13 +38,13 @@ public sealed partial class BuyerJobCondition : ListingCondition 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; } diff --git a/Content.Shared/Roles/Jobs/JobComponent.cs b/Content.Shared/Roles/Jobs/JobComponent.cs index c9053c1c6f..7191e8b397 100644 --- a/Content.Shared/Roles/Jobs/JobComponent.cs +++ b/Content.Shared/Roles/Jobs/JobComponent.cs @@ -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; /// /// Added to mind entities to hold the data for the player's current job. /// -[RegisterComponent] +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class JobComponent : Component { - [DataField("prototype", required: true, customTypeSerializer: typeof(PrototypeIdSerializer))] - public string? PrototypeId; + [DataField(required: true), AutoNetworkedField] + public ProtoId? Prototype; } diff --git a/Content.Shared/Roles/Jobs/SharedJobSystem.cs b/Content.Shared/Roles/Jobs/SharedJobSystem.cs index af97ea1350..0acda7425f 100644 --- a/Content.Shared/Roles/Jobs/SharedJobSystem.cs +++ b/Content.Shared/Roles/Jobs/SharedJobSystem.cs @@ -83,7 +83,7 @@ public abstract class SharedJobSystem : EntitySystem public bool MindHasJobWithId(EntityUid? mindId, string prototypeId) { - return CompOrNull(mindId)?.PrototypeId == prototypeId; + return CompOrNull(mindId)?.Prototype == prototypeId; } public bool MindTryGetJob( @@ -95,8 +95,8 @@ public abstract class SharedJobSystem : EntitySystem 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); } /// diff --git a/Content.Shared/Roles/SharedRoleSystem.cs b/Content.Shared/Roles/SharedRoleSystem.cs index ebd6730bbe..9ba625305c 100644 --- a/Content.Shared/Roles/SharedRoleSystem.cs +++ b/Content.Shared/Roles/SharedRoleSystem.cs @@ -25,7 +25,7 @@ public abstract class SharedRoleSystem : EntitySystem { 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; -- 2.51.2