From 58a49ff9fd4d4373168677a12ed78628904d2eb4 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 19 Jul 2023 21:28:43 -0400 Subject: [PATCH 1/2] If detail path is null create an empty game object --- NewHorizons/Builder/Props/DetailBuilder.cs | 9 ++++++++- NewHorizons/External/Modules/Props/DetailInfo.cs | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index d17da642..1c2f667d 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -20,6 +20,7 @@ namespace NewHorizons.Builder.Props { private static readonly Dictionary _detailInfoToCorrespondingSpawnedGameObject = new(); private static readonly Dictionary<(Sector, string), (GameObject prefab, bool isItem)> _fixedPrefabCache = new(); + private static GameObject _emptyPrefab; static DetailBuilder() { @@ -69,14 +70,20 @@ namespace NewHorizons.Builder.Props /// public static GameObject Make(GameObject planetGO, Sector sector, DetailInfo info) { - var prefab = SearchUtilities.Find(info.path); + _emptyPrefab ??= new GameObject("Empty"); + + // Allow for empty game objects so you can set up conditional activation on them and parent other props to them + var prefab = string.IsNullOrEmpty(info.path) ? _emptyPrefab : SearchUtilities.Find(info.path); + if (prefab == null) { NHLogger.LogError($"Couldn't find detail {info.path}"); return null; } else + { return Make(planetGO, sector, prefab, info); + } } /// diff --git a/NewHorizons/External/Modules/Props/DetailInfo.cs b/NewHorizons/External/Modules/Props/DetailInfo.cs index 6c8e1cf3..a6cb6592 100644 --- a/NewHorizons/External/Modules/Props/DetailInfo.cs +++ b/NewHorizons/External/Modules/Props/DetailInfo.cs @@ -21,7 +21,8 @@ namespace NewHorizons.External.Modules.Props public string assetBundle; /// - /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle + /// Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle. + /// If empty, will make an empty game object. This can be useful for adding other props to it as its children. /// public string path; From e479ec2ad98106eb2466328176e75159c65eb620 Mon Sep 17 00:00:00 2001 From: Ben C Date: Thu, 20 Jul 2023 01:56:33 +0000 Subject: [PATCH 2/2] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index b8c835e9..e56043fd 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1278,7 +1278,7 @@ }, "path": { "type": "string", - "description": "Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle" + "description": "Either the path in the scene hierarchy of the item to copy or the path to the object in the supplied asset bundle. \nIf empty, will make an empty game object. This can be useful for adding other props to it as its children." }, "removeChildren": { "type": "array",