diff --git a/1.4/Assemblies/AdaptiveStorageFramework.dll b/1.4/Assemblies/AdaptiveStorageFramework.dll index 744bf10..2a9f614 100644 Binary files a/1.4/Assemblies/AdaptiveStorageFramework.dll and b/1.4/Assemblies/AdaptiveStorageFramework.dll differ diff --git a/1.4/Assemblies/AdaptiveStorageFramework.pdb b/1.4/Assemblies/AdaptiveStorageFramework.pdb index a3fc4c6..550a0ce 100644 Binary files a/1.4/Assemblies/AdaptiveStorageFramework.pdb and b/1.4/Assemblies/AdaptiveStorageFramework.pdb differ diff --git a/1.5/Assemblies/AdaptiveStorageFramework.dll b/1.5/Assemblies/AdaptiveStorageFramework.dll index 7bee6f8..b51600a 100644 Binary files a/1.5/Assemblies/AdaptiveStorageFramework.dll and b/1.5/Assemblies/AdaptiveStorageFramework.dll differ diff --git a/1.5/Assemblies/AdaptiveStorageFramework.pdb b/1.5/Assemblies/AdaptiveStorageFramework.pdb index 32d388e..1bbbb0b 100644 Binary files a/1.5/Assemblies/AdaptiveStorageFramework.pdb and b/1.5/Assemblies/AdaptiveStorageFramework.pdb differ diff --git a/Source/Directory.Build.Props b/Source/Directory.Build.Props index 66d2516..f98c927 100644 --- a/Source/Directory.Build.Props +++ b/Source/Directory.Build.Props @@ -5,7 +5,7 @@ AdaptiveStorage Bradson Copyright (c) 2023 Bradson - 1.1.1 + 1.1.2 net48 preview enable @@ -43,6 +43,7 @@ + diff --git a/Source/ExtensionMethods.cs b/Source/ExtensionMethods.cs index 03c6d9a..08415bc 100644 --- a/Source/ExtensionMethods.cs +++ b/Source/ExtensionMethods.cs @@ -3,10 +3,8 @@ // If a copy of the license was not distributed with this file, // You can obtain one at https://opensource.org/licenses/MIT/. -using AdaptiveStorage.Pools; -#if V1_4 using System.Runtime.CompilerServices; -#endif +using AdaptiveStorage.Pools; namespace AdaptiveStorage; @@ -166,6 +164,15 @@ public static void SetPosition(this ref Matrix4x4 matrix, in Vector3 position) public static Vector3 GetPosition(this in Matrix4x4 matrix) => default(Vector3) with { x = matrix.m03, y = matrix.m13, z = matrix.m23 }; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Map? TryGetMap(this Thing thing) + { + var maps = Current.Game.Maps; + var mapIndex = (uint)thing.mapIndexOrState; + + return mapIndex < (uint)maps.Count ? maps[(int)mapIndex] : null; + } public static TextureAtlasGroup GetAtlasGroup(this Thing thing) => thing.def.category.ToAtlasGroup(); diff --git a/Source/StorageRenderer.cs b/Source/StorageRenderer.cs index d093650..e92cee1 100644 --- a/Source/StorageRenderer.cs +++ b/Source/StorageRenderer.cs @@ -575,10 +575,14 @@ public void FreeThingGraphic(Thing newItem, SectionLayer? layer, bool updateOthe public void TryDirtyParentMapMesh() { - if (!Parent.Spawned || Time.frameCount == _lastMapMeshDirtyFrame) + if (Parent.TryGetMap() is not { } map + || Time.frameCount == _lastMapMeshDirtyFrame + || map.mapDrawer is not { sections: not null}) + { return; + } - Parent.DirtyMapMesh(Parent.Map); + Parent.DirtyMapMesh(map); _lastMapMeshDirtyFrame = Time.frameCount; }