Prop build fixes

This commit is contained in:
Nick J. Connors 2022-02-02 17:12:15 -05:00
parent 5ac5391771
commit 028ee62987
3 changed files with 18 additions and 20 deletions

View File

@ -14,30 +14,27 @@ namespace NewHorizons.Builder.Props
{ {
public static class DetailBuilder public static class DetailBuilder
{ {
public static void Make(GameObject go, Sector sector, IPlanetConfig config, IModAssets assets, string uniqueModName) public static void Make(GameObject go, Sector sector, IPlanetConfig config, IModAssets assets, string uniqueModName, PropModule.DetailInfo detail)
{ {
foreach (var detail in config.Props.Details) if (detail.assetBundle != null)
{ {
if (detail.assetBundle != null) var prefab = PropBuildManager.LoadPrefab(detail.assetBundle, detail.path, uniqueModName, assets);
MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal, detail.generateColliders);
}
else if (detail.objFilePath != null)
{
try
{ {
var prefab = PropBuildManager.LoadPrefab(detail.assetBundle, detail.path, uniqueModName, assets); var prefab = assets.Get3DObject(detail.objFilePath, detail.mtlFilePath);
prefab.SetActive(false);
MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal, detail.generateColliders); MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal, detail.generateColliders);
} }
else if (detail.objFilePath != null) catch (Exception e)
{ {
try Logger.LogError($"Could not load 3d object {detail.objFilePath} with texture {detail.mtlFilePath} : {e.Message}");
{
var prefab = assets.Get3DObject(detail.objFilePath, detail.mtlFilePath);
prefab.SetActive(false);
MakeDetail(go, sector, prefab, detail.position, detail.rotation, detail.scale, detail.alignToNormal, detail.generateColliders);
}
catch (Exception e)
{
Logger.LogError($"Could not load 3d object {detail.objFilePath} with texture {detail.mtlFilePath} : {e.Message}");
}
} }
else MakeDetail(go, sector, detail.path, detail.position, detail.rotation, detail.scale, detail.alignToNormal, detail.generateColliders);
} }
else MakeDetail(go, sector, detail.path, detail.position, detail.rotation, detail.scale, detail.alignToNormal, detail.generateColliders);
} }
public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal, bool generateColliders) public static GameObject MakeDetail(GameObject go, Sector sector, string propToClone, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal, bool generateColliders)

View File

@ -28,13 +28,11 @@ namespace NewHorizons.Builder.Props
var dialogueTree = conversationZone.AddComponent<CharacterDialogueTree>(); var dialogueTree = conversationZone.AddComponent<CharacterDialogueTree>();
// XML STUFF GOES HERE
var xml = System.IO.File.ReadAllText(Main.Instance.ModHelper.Manifest.ModFolderPath + info.xmlFile); var xml = System.IO.File.ReadAllText(Main.Instance.ModHelper.Manifest.ModFolderPath + info.xmlFile);
var text = new TextAsset(xml); var text = new TextAsset(xml);
dialogueTree.SetTextXml(text); dialogueTree.SetTextXml(text);
addTranslations(xml); AddTranslation(xml);
conversationZone.transform.parent = sector.transform; conversationZone.transform.parent = sector.transform;

View File

@ -23,7 +23,10 @@ namespace NewHorizons.Builder.Props
} }
if(config.Props.Details != null) if(config.Props.Details != null)
{ {
DetailBuilder.Make(go, sector, config, assets, uniqueModName); foreach (var detail in config.Props.Details)
{
DetailBuilder.Make(go, sector, config, assets, uniqueModName, detail);
}
} }
if(config.Props.Geysers != null) if(config.Props.Geysers != null)
{ {