Fix removeComponents deleting NH item components

This commit is contained in:
Joshua Thome 2025-02-16 23:26:03 -06:00
parent 8b49f94bd4
commit dcbc834e93

View File

@ -209,24 +209,6 @@ 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)
{
ItemBuilder.MakeSocket(prop, go, sector, detail.itemSocket);
}
// Items should always be kept loaded else they will vanish in your hand as you leave the sector
if (isItem) detail.keepLoaded = true;
prop.transform.localScale = detail.stretch ?? (detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale); prop.transform.localScale = detail.stretch ?? (detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale);
if (detail.removeChildren != null) if (detail.removeChildren != null)
@ -271,11 +253,29 @@ namespace NewHorizons.Builder.Props
prop = newDetailGO; prop = newDetailGO;
} }
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)
{
ItemBuilder.MakeSocket(prop, go, sector, detail.itemSocket);
}
if (isItem) if (isItem)
{ {
// Else when you put them down you can't pick them back up // Else when you put them down you can't pick them back up
var col = prop.GetComponent<OWCollider>(); var col = prop.GetComponent<OWCollider>();
if (col != null) col._physicsRemoved = false; if (col != null) col._physicsRemoved = false;
// Items should always be kept loaded else they will vanish in your hand as you leave the sector
detail.keepLoaded = true;
} }
if (!detail.keepLoaded) GroupsBuilder.Make(prop, sector); if (!detail.keepLoaded) GroupsBuilder.Make(prop, sector);