From 25f51379bf0783d48675aa372c115c16f4ddc521 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 28 Feb 2023 16:32:05 +1100 Subject: [PATCH] Fix ContentTileDefinition prototype reloads (#14080) --- Content.Shared/Entry/EntryPoint.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Content.Shared/Entry/EntryPoint.cs b/Content.Shared/Entry/EntryPoint.cs index b561e732cd..ecf76cc6d6 100644 --- a/Content.Shared/Entry/EntryPoint.cs +++ b/Content.Shared/Entry/EntryPoint.cs @@ -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.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()) + { + def.AssignTileId(_tileDefinitionManager[def.ID].TileId); + } + } } } -- 2.52.0