mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Make item/socket colliders triggers by default, and allow it to be overriden via config
This commit is contained in:
parent
4de39c7284
commit
5d663ef76a
@ -1,6 +1,7 @@
|
|||||||
using NewHorizons.Components.Props;
|
using NewHorizons.Components.Props;
|
||||||
using NewHorizons.External.Modules.Props.Item;
|
using NewHorizons.External.Modules.Props.Item;
|
||||||
using NewHorizons.Handlers;
|
using NewHorizons.Handlers;
|
||||||
|
using NewHorizons.Utility.OuterWilds;
|
||||||
using NewHorizons.Utility.OWML;
|
using NewHorizons.Utility.OWML;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using OWML.Utils;
|
using OWML.Utils;
|
||||||
@ -27,6 +28,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static NHItem MakeItem(GameObject go, GameObject planetGO, Sector sector, ItemInfo info, IModBehaviour mod)
|
public static NHItem MakeItem(GameObject go, GameObject planetGO, Sector sector, ItemInfo info, IModBehaviour mod)
|
||||||
{
|
{
|
||||||
|
go.layer = Layer.Interactible;
|
||||||
|
|
||||||
var itemName = info.name;
|
var itemName = info.name;
|
||||||
if (string.IsNullOrEmpty(itemName))
|
if (string.IsNullOrEmpty(itemName))
|
||||||
{
|
{
|
||||||
@ -93,10 +96,13 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
if (info.colliderRadius > 0f)
|
if (info.colliderRadius > 0f)
|
||||||
{
|
{
|
||||||
go.AddComponent<SphereCollider>().radius = info.colliderRadius;
|
var col = go.AddComponent<SphereCollider>();
|
||||||
|
col.radius = info.colliderRadius;
|
||||||
|
col.isTrigger = info.colliderIsTrigger;
|
||||||
go.GetAddComponent<OWCollider>();
|
go.GetAddComponent<OWCollider>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait until next frame when all objects are built before trying to socket the item if it has an initial socket
|
||||||
Delay.FireOnNextUpdate(() =>
|
Delay.FireOnNextUpdate(() =>
|
||||||
{
|
{
|
||||||
if (item != null && !string.IsNullOrEmpty(info.pathToInitialSocket))
|
if (item != null && !string.IsNullOrEmpty(info.pathToInitialSocket))
|
||||||
@ -133,6 +139,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
public static NHItemSocket MakeSocket(GameObject go, GameObject planetGO, Sector sector, ItemSocketInfo info)
|
public static NHItemSocket MakeSocket(GameObject go, GameObject planetGO, Sector sector, ItemSocketInfo info)
|
||||||
{
|
{
|
||||||
|
go.layer = Layer.Interactible;
|
||||||
|
|
||||||
var itemType = EnumUtils.TryParse(info.itemType, true, out ItemType result) ? result : ItemType.Invalid;
|
var itemType = EnumUtils.TryParse(info.itemType, true, out ItemType result) ? result : ItemType.Invalid;
|
||||||
if (itemType == ItemType.Invalid && !string.IsNullOrEmpty(info.itemType))
|
if (itemType == ItemType.Invalid && !string.IsNullOrEmpty(info.itemType))
|
||||||
{
|
{
|
||||||
@ -151,15 +159,18 @@ namespace NewHorizons.Builder.Props
|
|||||||
if (socket._socketTransform == null)
|
if (socket._socketTransform == null)
|
||||||
{
|
{
|
||||||
var socketGO = GeneralPropBuilder.MakeNew("Socket", planetGO, sector, info, defaultParent: go.transform);
|
var socketGO = GeneralPropBuilder.MakeNew("Socket", planetGO, sector, info, defaultParent: go.transform);
|
||||||
if (info.colliderRadius > 0f)
|
|
||||||
{
|
|
||||||
go.AddComponent<SphereCollider>().radius = info.colliderRadius;
|
|
||||||
go.GetAddComponent<OWCollider>();
|
|
||||||
}
|
|
||||||
socketGO.SetActive(true);
|
socketGO.SetActive(true);
|
||||||
socket._socketTransform = socketGO.transform;
|
socket._socketTransform = socketGO.transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info.colliderRadius > 0f)
|
||||||
|
{
|
||||||
|
var col = go.AddComponent<SphereCollider>();
|
||||||
|
col.radius = info.colliderRadius;
|
||||||
|
col.isTrigger = info.colliderIsTrigger;
|
||||||
|
go.GetAddComponent<OWCollider>();
|
||||||
|
}
|
||||||
|
|
||||||
socket.ItemType = itemType;
|
socket.ItemType = itemType;
|
||||||
socket.UseGiveTakePrompts = info.useGiveTakePrompts;
|
socket.UseGiveTakePrompts = info.useGiveTakePrompts;
|
||||||
socket.InsertCondition = info.insertCondition;
|
socket.InsertCondition = info.insertCondition;
|
||||||
@ -169,6 +180,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
socket.ClearRemovalConditionOnInsert = info.clearRemovalConditionOnInsert;
|
socket.ClearRemovalConditionOnInsert = info.clearRemovalConditionOnInsert;
|
||||||
socket.RemovalFact = info.removalFact;
|
socket.RemovalFact = info.removalFact;
|
||||||
|
|
||||||
|
// Wait until initial item socketing is done before considering the socket empty
|
||||||
Delay.FireInNUpdates(() =>
|
Delay.FireInNUpdates(() =>
|
||||||
{
|
{
|
||||||
if (socket != null && !socket._socketedItem)
|
if (socket != null && !socket._socketedItem)
|
||||||
|
|||||||
@ -32,6 +32,10 @@ namespace NewHorizons.External.Modules.Props.Item
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(0.5f)] public float colliderRadius = 0.5f;
|
[DefaultValue(0.5f)] public float colliderRadius = 0.5f;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Whether the added sphere collider will be a trigger (interactible but does not collide). Defaults to true.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(true)] public bool colliderIsTrigger = true;
|
||||||
|
/// <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;
|
||||||
|
|||||||
@ -19,6 +19,15 @@ namespace NewHorizons.External.Modules.Props.Item
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(2f)] public float interactRange = 2f;
|
[DefaultValue(2f)] public float interactRange = 2f;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Default collider radius when interacting with the socket
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(0f)]
|
||||||
|
public float colliderRadius = 0f;
|
||||||
|
/// <summary>
|
||||||
|
/// Whether the added sphere collider will be a trigger (interactible but does not collide). Defaults to true.
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(true)] public bool colliderIsTrigger = true;
|
||||||
|
/// <summary>
|
||||||
/// Whether to use "Give Item" / "Take Item" prompts instead of "Insert Item" / "Remove Item".
|
/// Whether to use "Give Item" / "Take Item" prompts instead of "Insert Item" / "Remove Item".
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool useGiveTakePrompts;
|
public bool useGiveTakePrompts;
|
||||||
@ -46,10 +55,5 @@ namespace NewHorizons.External.Modules.Props.Item
|
|||||||
/// A ship log fact to reveal when removing an item from this socket, or when the socket is empty.
|
/// A ship log fact to reveal when removing an item from this socket, or when the socket is empty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string removalFact;
|
public string removalFact;
|
||||||
/// <summary>
|
|
||||||
/// Default collider radius when interacting with the socket
|
|
||||||
/// </summary>
|
|
||||||
[DefaultValue(0f)]
|
|
||||||
public float colliderRadius = 0f;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user