]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix Client RoleSystem not inheriting SharedRoleSystem, network job component (#21436)
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Tue, 7 Nov 2023 22:44:53 +0000 (14:44 -0800)
committerGitHub <noreply@github.com>
Tue, 7 Nov 2023 22:44:53 +0000 (14:44 -0800)
Content.Client/Roles/RoleSystem.cs
Content.Server/GameTicking/GameTicker.Spawning.cs
Content.Server/Objectives/Systems/NotJobRequirementSystem.cs
Content.Server/Roles/Jobs/JobSystem.cs
Content.Server/Spawners/EntitySystems/SpawnPointSystem.cs
Content.Server/Station/Systems/StationSpawningSystem.cs
Content.Server/Store/Conditions/BuyerDepartmentCondition.cs
Content.Server/Store/Conditions/BuyerJobCondition.cs
Content.Shared/Roles/Jobs/JobComponent.cs
Content.Shared/Roles/Jobs/SharedJobSystem.cs
Content.Shared/Roles/SharedRoleSystem.cs

index 6a98320af4e25f1aba3b4b1006cefa8cd8c1e787..5c27e173d388404865b79288a7ea05d364115007 100644 (file)
@@ -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
 {
 }
index c2bf523657ca3516bf71e70e79ba41e99f54fc1a..81b8c6e5f609e508f998d99e3217767bf94eb5e6 100644 (file)
@@ -200,7 +200,7 @@ namespace Content.Server.GameTicking
             _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);
 
index c9539fcbf14b465f25f535106391eb71f6ba199e..5c2b04046342db0d3c36d2d12592b1c717985fb3 100644 (file)
@@ -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<JobComponent>(args.MindId, out var job))
             return;
 
-        if (job.PrototypeId == comp.Job)
+        if (job.Prototype == comp.Job)
             args.Cancelled = true;
     }
 }
index 7bee6da7554f3789a7120ea12f84b2e62bb80381..9f0dd7ae32b5b78891ea4126697c7eab25d4e311 100644 (file)
@@ -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 });
     }
 }
index 755153d309b6525ed105fd3d3725558afe3db91c..c96e3c5c385502ce5a771977533c9661a247d7ce 100644 (file)
@@ -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);
             }
index 4aa1b117e572565095326ed5f9182de5feffb478..9beccd06df445589203ca1c5aa04d42970d5251b 100644 (file)
@@ -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)
index a71adc4e7797ac0b44254b8bd987cbfa79218158..4e5e504aec4be6568416935b4068b028583a3742 100644 (file)
@@ -39,11 +39,11 @@ public sealed partial class BuyerDepartmentCondition : ListingCondition
         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;
             }
         }
@@ -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<DepartmentPrototype>())
                 {
-                    if (department.Roles.Contains(job.PrototypeId) && Whitelist.Contains(department.ID))
+                    if (department.Roles.Contains(job.Prototype) && Whitelist.Contains(department.ID))
                     {
                         found = true;
                         break;
index f5013008abf23e4923bfb4a8e93653f37ff9ca07..6a53af188c2d992f9a4e22d8997c97057ffa072a 100644 (file)
@@ -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;
         }
 
index c9053c1c6fd5da31527d73a7f3d3d76707dae1b0..7191e8b397113757f58078deb76768384bab3554 100644 (file)
@@ -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;
 }
index af97ea135047513a9b9c58263992e05ccc80a862..0acda7425fe8840218775297af20a4ea96535e2a 100644 (file)
@@ -83,7 +83,7 @@ public abstract class SharedJobSystem : EntitySystem
 
     public bool MindHasJobWithId(EntityUid? mindId, string prototypeId)
     {
-        return CompOrNull<JobComponent>(mindId)?.PrototypeId == prototypeId;
+        return CompOrNull<JobComponent>(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);
     }
 
     /// <summary>
index ebd6730bbe47e27bc8b92c602581dad943bc7f67..9ba625305cfa9cc03650700e974c631c6ec49658 100644 (file)
@@ -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;