RoundManagerObjectReferenceFix
A mod for Lethal Company that prevents crashes caused by unresolved prefab references in custom moon mods.
模組介紹 作者原文
RoundManagerObjectReferenceFix
ℹ️ Only the host is required to install this mod. Should be fine for multiplayer and could potentially prevent crashes on other custom moons too.
A mod for Lethal Company that prevents crashes caused by unresolved prefab references in custom moon mods.
What it does
ℹ️ I created this mod for my own moon as I assigned blank references to the corresponding fields (to keep the mod size small), but the game could not resolve them and crash.
This mod runs during the spawn process of the RoundManager and tries to detect scrap, outside objects, and map hazards that do not have a prefab ( prefab = null).
It does the following when a prefab = null:
- Scrap items:
- If an item has a null prefab, it is replaced with a random valid item from the moon's item spawn list
- Outside objects:
- If an outside object has a null prefab, it is removed from the spawn pool to prevent a crash
- Map objects:
- If an Indoor hazard has a null prefab, it is removed from the spawn pool to prevent a crash
Logging is included so you can identify which objects are not resolving correctly and fix them in your moon configuration.
Example errors
On spawn outside hazards:
[Error: Unity Log] ArgumentException: The Object you want to instantiate is null.
Stack trace:
UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) (at:IL_0048)
UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) (at:IL_0001)
RoundManager.SpawnOutsideHazards () (at:IL_049F)
DMD<>?434046712.Trampoline?-426100634 (RoundManager ) (at:IL_0025)
Dawn.MapObjectRegistrationHandler.SpawnOutsideMapObjects (On.RoundManager+orig_SpawnOutsideHazards orig, RoundManager self) (at./src/API/MapObjects.MapObjectRegistrationHandler.cs:275)
DMD<>?1224120700.Hook?1737978544 (RoundManager ) (at:IL_000F)
RoundManager.FinishGeneratingLevel () (at:IL_0040)
RoundManager.Generator_OnGenerationStatusChanged (DunGen.DungeonGenerator generator, DunGen.GenerationStatus status) (at:IL_000C)
DunGen.DungeonGenerator.ChangeStatus (DunGen.GenerationStatus status) (at:IL_0036)
DunGen.DungeonGenerator+d__131.MoveNext () (at:IL_049E)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at:IL_0026)
On spawning scrap
[Error: Unity Log] ArgumentException: The Object you want to instantiate is null.
Stack trace:
UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at:IL_0049)
UnityEngine.Object.Instantiate (UnityEngine.Object original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) (at:IL_000C)
UnityEngine.Object.Instantiate[T] (T original, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, UnityEngine.Transform parent) (at:IL_0001)
RoundManager.SpawnScrapInLevel () (at:IL_0540)
DMD<>?2052090776.Trampoline?1603470438 (RoundManager ) (at:IL_0025)
Dawn.ItemRegistrationHandler.UpdateItemWeights (On.RoundManager+orig_SpawnScrapInLevel orig, RoundManager self) (at./src/API/Items.ItemRegistrationHandler.cs:107)
DMD<>?1148133988.Hook?1662684564 (RoundManager ) (at:IL_000F)
RoundManager.GeneratedFloorPostProcessing () (at:IL_0009)
RoundManager+d__167.MoveNext () (at:IL_05C5)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at:IL_0026)
Example of the fix
Outside "hazards" / objects:
[Info:RoundManagerObjectReferenceFix] Checking: SpawnOutsideHazards
[Info:RoundManagerObjectReferenceFix] Outside object 'SnowmanShort' | Prefab: Snowman OK
[Info:RoundManagerObjectReferenceFix] Outside object 'SnowmanTall' | Prefab: SnowmanTall OK
[Warning:RoundManagerObjectReferenceFix] Outside object 'TreeLeafless2Snowy' has null prefab, resolving
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。
下面這些內容需要先安裝,否則該模組不會生效: