From 9a0dbdf0a7e5f5ff4b07fc905f2f90b43f86acfb Mon Sep 17 00:00:00 2001 From: Joshua Thome Date: Wed, 13 Mar 2024 14:54:54 -0500 Subject: [PATCH] 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;