]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix ContentTileDefinition prototype reloads (#14080)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Tue, 28 Feb 2023 05:32:05 +0000 (16:32 +1100)
committerGitHub <noreply@github.com>
Tue, 28 Feb 2023 05:32:05 +0000 (21:32 -0800)
Content.Shared/Entry/EntryPoint.cs

index b561e732cdb92b8def075151c72f6d1922a1e470..ecf76cc6d630f9020325290d2287341b76c7e95f 100644 (file)
@@ -23,6 +23,11 @@ namespace Content.Shared.Entry
             SharedContentIoC.Register();
         }
 
+        public override void Shutdown()
+        {
+            _prototypeManager.PrototypesReloaded -= PrototypeReload;
+        }
+
         public override void Init()
         {
         }
@@ -48,6 +53,8 @@ namespace Content.Shared.Entry
 
         private void InitTileDefinitions()
         {
+            _prototypeManager.PrototypesReloaded += PrototypeReload;
+
             // Register space first because I'm a hard coding hack.
             var spaceDef = _prototypeManager.Index<ContentTileDefinition>(ContentTileDefinition.SpaceID);
 
@@ -75,5 +82,14 @@ namespace Content.Shared.Entry
 
             _tileDefinitionManager.Initialize();
         }
+
+        private void PrototypeReload(PrototypesReloadedEventArgs obj)
+        {
+            // Need to re-allocate tiledefs due to how prototype reloads work
+            foreach (var def in _prototypeManager.EnumeratePrototypes<ContentTileDefinition>())
+            {
+                def.AssignTileId(_tileDefinitionManager[def.ID].TileId);
+            }
+        }
     }
 }