Add sphere collider to custom items

This commit is contained in:
Joshua Thome 2024-03-13 14:54:54 -05:00
parent b0e9437b42
commit 9a0dbdf0a7
3 changed files with 17 additions and 1 deletions

View File

@ -171,6 +171,11 @@ namespace NewHorizons.Builder.Props
if (detail.item != null) if (detail.item != null)
{ {
ItemBuilder.MakeItem(prop, go, sector, detail.item, mod); 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) if (detail.itemSocket != null)

View File

@ -79,6 +79,12 @@ namespace NewHorizons.Builder.Props
item.ClearPickupConditionOnDrop = info.clearPickupConditionOnDrop; item.ClearPickupConditionOnDrop = info.clearPickupConditionOnDrop;
item.PickupFact = info.pickupFact; item.PickupFact = info.pickupFact;
if (info.colliderRadius > 0f)
{
go.AddComponent<SphereCollider>().radius = info.colliderRadius;
go.GetAddComponent<OWCollider>();
}
Delay.FireOnNextUpdate(() => Delay.FireOnNextUpdate(() =>
{ {
if (item != null && !string.IsNullOrEmpty(info.pathToInitialSocket)) if (item != null && !string.IsNullOrEmpty(info.pathToInitialSocket))

View File

@ -19,7 +19,7 @@ namespace NewHorizons.External.Modules.Props.Item
/// </summary> /// </summary>
public string name; public string name;
/// <summary> /// <summary>
/// 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.
/// </summary> /// </summary>
public string itemType; public string itemType;
/// <summary> /// <summary>
@ -27,6 +27,11 @@ namespace NewHorizons.External.Modules.Props.Item
/// </summary> /// </summary>
[DefaultValue(2f)] public float interactRange = 2f; [DefaultValue(2f)] public float interactRange = 2f;
/// <summary> /// <summary>
/// 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.
/// </summary>
[DefaultValue(0.5f)] public float colliderRadius = 0.5f;
/// <summary>
/// Whether the item can be dropped. Defaults to true. /// Whether the item can be dropped. Defaults to true.
/// </summary> /// </summary>
[DefaultValue(true)] public bool droppable = true; [DefaultValue(true)] public bool droppable = true;