From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 28 Feb 2023 05:32:05 +0000 (+1100) Subject: Fix ContentTileDefinition prototype reloads (#14080) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=25f51379bf0783d48675aa372c115c16f4ddc521;p=space-station-14.git Fix ContentTileDefinition prototype reloads (#14080) --- 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); + } + } } }