From 9a0dbdf0a7e5f5ff4b07fc905f2f90b43f86acfb Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Wed, 13 Mar 2024 14:54:54 -0500 Subject: [PATCH 1/3] Add sphere collider to custom items --- NewHorizons/Builder/Props/DetailBuilder.cs | 5 +++++ NewHorizons/Builder/Props/ItemBuilder.cs | 6 ++++++ NewHorizons/External/Modules/Props/Item/ItemInfo.cs | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 054f53d3..7ee56bad 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -171,6 +171,11 @@ namespace NewHorizons.Builder.Props if (detail.item != null) { ItemBuilder.MakeItem(prop, go, sector, detail.item, mod); + isItem = true; + if (detail.hasPhysics) + { + NHLogger.LogWarning($"An item with the path {detail.path} has both '{nameof(DetailInfo.hasPhysics)}' and '{nameof(DetailInfo.item)}' set. This will usually result in undesirable behavior."); + } } if (detail.itemSocket != null) diff --git a/NewHorizons/Builder/Props/ItemBuilder.cs b/NewHorizons/Builder/Props/ItemBuilder.cs index 825eafce..78a866be 100644 --- a/NewHorizons/Builder/Props/ItemBuilder.cs +++ b/NewHorizons/Builder/Props/ItemBuilder.cs @@ -79,6 +79,12 @@ namespace NewHorizons.Builder.Props item.ClearPickupConditionOnDrop = info.clearPickupConditionOnDrop; item.PickupFact = info.pickupFact; + if (info.colliderRadius > 0f) + { + go.AddComponent().radius = info.colliderRadius; + go.GetAddComponent(); + } + Delay.FireOnNextUpdate(() => { if (item != null && !string.IsNullOrEmpty(info.pathToInitialSocket)) diff --git a/NewHorizons/External/Modules/Props/Item/ItemInfo.cs b/NewHorizons/External/Modules/Props/Item/ItemInfo.cs index 6876bd4c..6307db11 100644 --- a/NewHorizons/External/Modules/Props/Item/ItemInfo.cs +++ b/NewHorizons/External/Modules/Props/Item/ItemInfo.cs @@ -19,7 +19,7 @@ namespace NewHorizons.External.Modules.Props.Item /// public string name; /// - /// The type of the item, which determines its orientation when held and what sockets it fits into. This can be a custom string, or a vanilla ItemType (Scroll, WarpCode, SharedStone, ConversationStone, Lantern, SlideReel, DreamLantern, or VisionTorch). Defaults to the item name. + /// The type of the item, which determines its orientation when held and what sockets it fits into. This can be a custom string, or a vanilla ItemType (Scroll, WarpCore, SharedStone, ConversationStone, Lantern, SlideReel, DreamLantern, or VisionTorch). Defaults to the item name. /// public string itemType; /// @@ -27,6 +27,11 @@ namespace NewHorizons.External.Modules.Props.Item /// [DefaultValue(2f)] public float interactRange = 2f; /// + /// The radius that the added sphere collider will use for collision and hover detection. + /// If there's already a collider on the detail, you can make this 0. + /// + [DefaultValue(0.5f)] public float colliderRadius = 0.5f; + /// /// Whether the item can be dropped. Defaults to true. /// [DefaultValue(true)] public bool droppable = true; From 4314f510c912e1b43d08c610308e2d0e86ba7156 Mon Sep 17 00:00:00 2001 From: Ben C Date: Wed, 13 Mar 2024 20:00:47 +0000 Subject: [PATCH 2/3] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 833b1a89..b5eb711c 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -1402,7 +1402,7 @@ }, "itemType": { "type": "string", - "description": "The type of the item, which determines its orientation when held and what sockets it fits into. This can be a custom string, or a vanilla ItemType (Scroll, WarpCode, SharedStone, ConversationStone, Lantern, SlideReel, DreamLantern, or VisionTorch). Defaults to the item name." + "description": "The type of the item, which determines its orientation when held and what sockets it fits into. This can be a custom string, or a vanilla ItemType (Scroll, WarpCore, SharedStone, ConversationStone, Lantern, SlideReel, DreamLantern, or VisionTorch). Defaults to the item name." }, "interactRange": { "type": "number", @@ -1410,6 +1410,12 @@ "format": "float", "default": 2.0 }, + "colliderRadius": { + "type": "number", + "description": "The radius that the added sphere collider will use for collision and hover detection.\nIf there's already a collider on the detail, you can make this 0.", + "format": "float", + "default": 0.5 + }, "droppable": { "type": "boolean", "description": "Whether the item can be dropped. Defaults to true.", From bb39c98411b5100820f16f0939a34cd60bfaf25c Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 15 Mar 2024 14:14:23 -0400 Subject: [PATCH 3/3] Fix translations with cdata in keys breaking --- NewHorizons/Handlers/TranslationHandler.cs | 4 ++-- NewHorizons/Utility/NewHorizonExtensions.cs | 2 +- NewHorizons/manifest.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Handlers/TranslationHandler.cs b/NewHorizons/Handlers/TranslationHandler.cs index f2e75075..d8130aa8 100644 --- a/NewHorizons/Handlers/TranslationHandler.cs +++ b/NewHorizons/Handlers/TranslationHandler.cs @@ -57,7 +57,7 @@ namespace NewHorizons.Handlers return translatedText; } // Try without whitespace if its missing - else if (table.TryGetValue(text.TruncateWhitespace(), out translatedText)) + else if (table.TryGetValue(text.TruncateWhitespaceAndToLower(), out translatedText)) { return translatedText; } @@ -99,7 +99,7 @@ namespace NewHorizons.Handlers // Fix new lines in dialogue translations, remove whitespace from keys else if the dialogue has weird whitespace and line breaks it gets really annoying // to write translation keys for (can't just copy paste out of xml, have to start adding \\n and \\r and stuff // If any of these issues become relevant to other dictionaries we can bring this code over, but for now why fix what isnt broke - var key = originalKey.Replace("\\n", "\n").TruncateWhitespace().Replace("<", "<").Replace(">", ">").Replace("", ""); + var key = originalKey.Replace("\\n", "\n").Replace("<", "<").Replace(">", ">").Replace("", "").TruncateWhitespaceAndToLower(); var value = config.DialogueDictionary[originalKey].Replace("\\n", "\n").Replace("<", "<").Replace(">", ">").Replace("", ""); if (!_dialogueTranslationDictionary[language].ContainsKey(key)) _dialogueTranslationDictionary[language].Add(key, value); diff --git a/NewHorizons/Utility/NewHorizonExtensions.cs b/NewHorizons/Utility/NewHorizonExtensions.cs index 1815ed87..9ded956b 100644 --- a/NewHorizons/Utility/NewHorizonExtensions.cs +++ b/NewHorizons/Utility/NewHorizonExtensions.cs @@ -351,7 +351,7 @@ namespace NewHorizons.Utility return parentNode.ChildNodes.Cast().First(node => node.LocalName == tagName); } - public static string TruncateWhitespace(this string text) + public static string TruncateWhitespaceAndToLower(this string text) { // return Regex.Replace(text.Trim(), @"[^\S\r\n]+", "GUH"); return Regex.Replace(text.Trim(), @"\s+", " ").ToLowerInvariant(); diff --git a/NewHorizons/manifest.json b/NewHorizons/manifest.json index fa5ca048..4f8d2554 100644 --- a/NewHorizons/manifest.json +++ b/NewHorizons/manifest.json @@ -4,7 +4,7 @@ "author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends", "name": "New Horizons", "uniqueName": "xen.NewHorizons", - "version": "1.19.0", + "version": "1.19.1", "owmlVersion": "2.9.8", "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ],