This commit is contained in:
metalgearsloth
2023-09-11 18:10:07 +10:00
committed by GitHub
parent e1a91466f1
commit 66c4dfaa8e
2 changed files with 20 additions and 8 deletions

View File

@@ -21,7 +21,19 @@ public sealed class StationJobsTest
[TestPrototypes] [TestPrototypes]
private const string Prototypes = @" private const string Prototypes = @"
- type: playTimeTracker - type: playTimeTracker
id: PlayTimeDummy id: PlayTimeDummyAssistant
- type: playTimeTracker
id: PlayTimeDummyMime
- type: playTimeTracker
id: PlayTimeDummyClown
- type: playTimeTracker
id: PlayTimeDummyCaptain
- type: playTimeTracker
id: PlayTimeDummyChaplain
- type: gameMap - type: gameMap
id: FooStation id: FooStation
@@ -44,26 +56,26 @@ public sealed class StationJobsTest
- type: job - type: job
id: TAssistant id: TAssistant
playTimeTracker: PlayTimeDummy playTimeTracker: PlayTimeDummyAssistant
- type: job - type: job
id: TMime id: TMime
weight: 20 weight: 20
playTimeTracker: PlayTimeDummy playTimeTracker: PlayTimeDummyMime
- type: job - type: job
id: TClown id: TClown
weight: -10 weight: -10
playTimeTracker: PlayTimeDummy playTimeTracker: PlayTimeDummyClown
- type: job - type: job
id: TCaptain id: TCaptain
weight: 10 weight: 10
playTimeTracker: PlayTimeDummy playTimeTracker: PlayTimeDummyCaptain
- type: job - type: job
id: TChaplain id: TChaplain
playTimeTracker: PlayTimeDummy playTimeTracker: PlayTimeDummyChaplain
"; ";
private const int StationCount = 100; private const int StationCount = 100;

View File

@@ -30,17 +30,17 @@ public abstract class SharedJobSystem : EntitySystem
{ {
base.Shutdown(); base.Shutdown();
_protoManager.PrototypesReloaded -= OnProtoReload; _protoManager.PrototypesReloaded -= OnProtoReload;
_inverseTrackerLookup.Clear();
} }
private void OnProtoReload(PrototypesReloadedEventArgs obj) private void OnProtoReload(PrototypesReloadedEventArgs obj)
{ {
_inverseTrackerLookup.Clear();
SetupTrackerLookup(); SetupTrackerLookup();
} }
private void SetupTrackerLookup() private void SetupTrackerLookup()
{ {
_inverseTrackerLookup.Clear();
// This breaks if you have N trackers to 1 JobId but future concern. // This breaks if you have N trackers to 1 JobId but future concern.
foreach (var job in _protoManager.EnumeratePrototypes<JobPrototype>()) foreach (var job in _protoManager.EnumeratePrototypes<JobPrototype>())
{ {