Fix update from dev

This commit is contained in:
Nick 2023-07-22 12:04:02 -04:00
parent 3bfabadda8
commit ed66cb0665
13 changed files with 141 additions and 76 deletions

View File

@ -1,11 +1,11 @@
using NewHorizons.Components; using NewHorizons.Builder.Props.TranslatorText;
using NewHorizons.Components.Volumes; using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules; using NewHorizons.External.Modules.Props.Shuttle;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using OWML.Common; using OWML.Common;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Props namespace NewHorizons.Builder.Props
{ {
@ -32,20 +32,13 @@ namespace NewHorizons.Builder.Props
} }
} }
public static GameObject Make(GameObject planetGO, Sector sector, PropModule.GravityCannonInfo info, IModBehaviour mod) public static GameObject Make(GameObject planetGO, Sector sector, GravityCannonInfo info, IModBehaviour mod)
{ {
InitPrefab(); InitPrefab();
if (_prefab == null || planetGO == null || sector == null) return null; if (_prefab == null || planetGO == null || sector == null) return null;
var detailInfo = new PropModule.DetailInfo() var detailInfo = new DetailInfo(info);
{
position = info.position,
rotation = info.rotation,
parentPath = info.parentPath,
isRelativeToParent = info.isRelativeToParent,
rename = info.rename
};
var gravityCannonObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo); var gravityCannonObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo);
gravityCannonObject.SetActive(false); gravityCannonObject.SetActive(false);
@ -55,38 +48,40 @@ namespace NewHorizons.Builder.Props
gravityCannonController._shuttleID = ShuttleHandler.GetShuttleID(info.shuttleID); gravityCannonController._shuttleID = ShuttleHandler.GetShuttleID(info.shuttleID);
gravityCannonController._retrieveShipLogFact = info.retrieveReveal; gravityCannonController._retrieveShipLogFact = info.retrieveReveal;
gravityCannonController._launchShipLogFact = info.launchReveal; gravityCannonController._launchShipLogFact = info.launchReveal;
if (info.computer != null) if (info.computer != null)
{ {
gravityCannonController._nomaiComputer = NomaiTextBuilder.Make(planetGO, sector, new PropModule.NomaiTextInfo gravityCannonController._nomaiComputer = CreateComputer(planetGO, sector, info.computer);
{
type = PropModule.NomaiTextInfo.NomaiTextType.Computer,
position = info.computer.position,
rotation = info.computer.rotation,
normal = info.computer.normal,
isRelativeToParent = info.computer.isRelativeToParent,
rename = info.computer.rename,
location = info.computer.location,
xmlFile = info.computer.xmlFile,
parentPath = info.computer.parentPath
}, mod).GetComponent<NomaiComputer>();
} }
else else
{ {
gravityCannonController._nomaiComputer = NomaiTextBuilder.Make(planetGO, sector, new PropModule.NomaiTextInfo gravityCannonController._nomaiComputer = null;
{
type = PropModule.NomaiTextInfo.NomaiTextType.Computer,
position = new MVector3(-2.556838f, -0.8018004f, 10.01348f),
rotation = new MVector3(8.293f, 2.403f, 0.9f),
isRelativeToParent = true,
rename = "Computer",
xmlFile = "Assets/GravityCannonComputer.xml",
parentPath = gravityCannonObject.transform.GetPath().Remove(0, planetGO.name.Length + 1)
}, Main.Instance).GetComponent<NomaiComputer>();
} }
gravityCannonObject.SetActive(true); gravityCannonObject.SetActive(true);
return gravityCannonObject; return gravityCannonObject;
} }
private static NomaiComputer CreateComputer(GameObject planetGO, Sector sector, NomaiComputerInfo computerInfo)
{
var prefab = computerInfo.type switch
{
NomaiComputerType.NORMAL => TranslatorTextBuilder.ComputerPrefab,
NomaiComputerType.PRECRASH => TranslatorTextBuilder.PreCrashComputerPrefab,
_ => throw new System.NotImplementedException()
};
var computerObject = DetailBuilder.Make(planetGO, sector, prefab, new DetailInfo(computerInfo));
var computer = computerObject.GetComponentInChildren<NomaiComputer>();
computer.SetSector(sector);
Delay.FireOnNextUpdate(computer.ClearAllEntries);
computerObject.SetActive(true);
return computer;
}
} }
} }

View File

@ -747,7 +747,7 @@ namespace NewHorizons.Builder.Props
if (rootNode == null) if (rootNode == null)
{ {
Logger.LogError($"Couldn't find NomaiObject in [{xmlPath}]"); NHLogger.LogError($"Couldn't find NomaiObject in [{xmlPath}]");
return dict; return dict;
} }

View File

@ -29,7 +29,7 @@ namespace NewHorizons.Builder.Props
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogError($"Couldn't make gravity cannon [{gravityCannonInfo.shuttleID}] for [{go.name}]:\n{ex}"); NHLogger.LogError($"Couldn't make gravity cannon [{gravityCannonInfo.shuttleID}] for [{go.name}]:\n{ex}");
} }
} }
} }
@ -43,7 +43,7 @@ namespace NewHorizons.Builder.Props
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogError($"Couldn't make shuttle [{shuttleInfo.id}] for [{go.name}]:\n{ex}"); NHLogger.LogError($"Couldn't make shuttle [{shuttleInfo.id}] for [{go.name}]:\n{ex}");
} }
} }
} }

View File

@ -1,10 +1,9 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Components.Volumes; using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules; using NewHorizons.External.Modules.Props.Shuttle;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Props namespace NewHorizons.Builder.Props
{ {
@ -66,20 +65,13 @@ namespace NewHorizons.Builder.Props
} }
} }
public static GameObject Make(GameObject planetGO, Sector sector, PropModule.ShuttleInfo info) public static GameObject Make(GameObject planetGO, Sector sector, ShuttleInfo info)
{ {
InitPrefab(); InitPrefab();
if (_prefab == null || planetGO == null || sector == null) return null; if (_prefab == null || planetGO == null || sector == null) return null;
var detailInfo = new PropModule.DetailInfo() var detailInfo = new DetailInfo(info);
{
position = info.position,
rotation = info.rotation,
parentPath = info.parentPath,
isRelativeToParent = info.isRelativeToParent,
rename = info.rename
};
var shuttleObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo); var shuttleObject = DetailBuilder.Make(planetGO, sector, _prefab, detailInfo);
shuttleObject.SetActive(false); shuttleObject.SetActive(false);

View File

@ -26,7 +26,7 @@ namespace NewHorizons.Builder.Props.TranslatorText
private static Material _childArcMaterial; private static Material _childArcMaterial;
private static GameObject _scrollPrefab; private static GameObject _scrollPrefab;
public static GameObject ComputerPrefab { get; private set; } public static GameObject ComputerPrefab { get; private set; }
private static GameObject _preCrashComputerPrefab; public static GameObject PreCrashComputerPrefab { get; private set; }
private static GameObject _cairnBHPrefab; private static GameObject _cairnBHPrefab;
private static GameObject _cairnTHPrefab; private static GameObject _cairnTHPrefab;
private static GameObject _cairnCTPrefab; private static GameObject _cairnCTPrefab;
@ -89,9 +89,9 @@ namespace NewHorizons.Builder.Props.TranslatorText
ComputerPrefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive().Rename("Prefab_NOM_Computer").DontDestroyOnLoad(); ComputerPrefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive().Rename("Prefab_NOM_Computer").DontDestroyOnLoad();
} }
if (_preCrashComputerPrefab == null) if (PreCrashComputerPrefab == null)
{ {
_preCrashComputerPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_EscapePodCrashSite/Sector_CrashFragment/EscapePod_Socket/Interactibles_EscapePod/Prefab_NOM_Vessel_Computer").InstantiateInactive().Rename("Prefab_NOM_Vessel_Computer").DontDestroyOnLoad(); PreCrashComputerPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_EscapePodCrashSite/Sector_CrashFragment/EscapePod_Socket/Interactibles_EscapePod/Prefab_NOM_Vessel_Computer").InstantiateInactive().Rename("Prefab_NOM_Vessel_Computer").DontDestroyOnLoad();
} }
if (_cairnBHPrefab == null) if (_cairnBHPrefab == null)
@ -238,7 +238,7 @@ namespace NewHorizons.Builder.Props.TranslatorText
} }
case NomaiTextType.PreCrashComputer: case NomaiTextType.PreCrashComputer:
{ {
var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, new DetailInfo(info)); var computerObject = DetailBuilder.Make(planetGO, sector, PreCrashComputerPrefab, new DetailInfo(info));
computerObject.SetActive(false); computerObject.SetActive(false);
var computer = computerObject.GetComponent<NomaiVesselComputer>(); var computer = computerObject.GetComponent<NomaiVesselComputer>();

View File

@ -144,9 +144,16 @@ namespace NewHorizons.Builder.Props
transmitterObject.SetActive(true); transmitterObject.SetActive(true);
} }
private static void CreateComputer(GameObject planetGO, Sector sector, NomaiWarpComputerLoggerInfo computerInfo, NomaiWarpReceiver receiver) private static void CreateComputer(GameObject planetGO, Sector sector, NomaiComputerInfo computerInfo, NomaiWarpReceiver receiver)
{ {
var computerObject = DetailBuilder.Make(planetGO, sector, TranslatorTextBuilder.ComputerPrefab, new DetailInfo(computerInfo)); var prefab = computerInfo.type switch
{
NomaiComputerType.NORMAL => TranslatorTextBuilder.ComputerPrefab,
NomaiComputerType.PRECRASH => TranslatorTextBuilder.PreCrashComputerPrefab,
_ => throw new System.NotImplementedException()
};
var computerObject = DetailBuilder.Make(planetGO, sector, prefab, new DetailInfo(computerInfo));
var computer = computerObject.GetComponentInChildren<NomaiComputer>(); var computer = computerObject.GetComponentInChildren<NomaiComputer>();
computer.SetSector(sector); computer.SetSector(sector);

View File

@ -4,6 +4,7 @@ using NewHorizons.External.Modules.Props.Dialogue;
using NewHorizons.External.Modules.Props.EchoesOfTheEye; using NewHorizons.External.Modules.Props.EchoesOfTheEye;
using NewHorizons.External.Modules.Props.Quantum; using NewHorizons.External.Modules.Props.Quantum;
using NewHorizons.External.Modules.Props.Remote; using NewHorizons.External.Modules.Props.Remote;
using NewHorizons.External.Modules.Props.Shuttle;
using NewHorizons.External.Modules.TranslatorText; using NewHorizons.External.Modules.TranslatorText;
using NewHorizons.External.Modules.VariableSize; using NewHorizons.External.Modules.VariableSize;
using NewHorizons.External.Modules.Volumes.VolumeInfos; using NewHorizons.External.Modules.Volumes.VolumeInfos;
@ -112,6 +113,16 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
public AudioSourceInfo[] audioSources; public AudioSourceInfo[] audioSources;
/// <summary>
/// Add a gravity cannon to this planet. Must be paired to a new shuttle, which can be placed on this planet or elsewhere.
/// </summary>
public GravityCannonInfo[] gravityCannons;
/// <summary>
/// Add a Nomai shuttle to this planet. Can be paired to a gravity cannon on this planet or elsewhere.
/// </summary>
public ShuttleInfo[] shuttles;
[Obsolete("reveal is deprecated. Use Volumes->revealVolumes instead.")] public RevealVolumeInfo[] reveal; [Obsolete("reveal is deprecated. Use Volumes->revealVolumes instead.")] public RevealVolumeInfo[] reveal;
[Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public AudioVolumeInfo[] audioVolumes; [Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public AudioVolumeInfo[] audioVolumes;

View File

@ -0,0 +1,23 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.ComponentModel;
using System.Runtime.Serialization;
namespace NewHorizons.External.Modules.Props
{
[JsonObject]
public class NomaiComputerInfo : GeneralPropInfo
{
/// <summary>
/// What design the computer will use.
/// </summary>
[DefaultValue(NomaiComputerType.NORMAL)] public NomaiComputerType type = NomaiComputerType.NORMAL;
}
[JsonConverter(typeof(StringEnumConverter))]
public enum NomaiComputerType
{
[EnumMember(Value = @"normal")] NORMAL = 0,
[EnumMember(Value = @"precrash")] PRECRASH = 1
}
}

View File

@ -0,0 +1,33 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Props.Shuttle
{
[JsonObject]
public class GravityCannonInfo : GeneralPropInfo
{
/// <summary>
/// Unique ID for the shuttle that pairs with this gravity cannon
/// </summary>
public string shuttleID;
/// <summary>
/// Ship log fact revealed when retrieving the shuttle to this pad. Optional.
/// </summary>
public string retrieveReveal;
/// <summary>
/// Ship log fact revealed when launching from this pad. Optional.
/// </summary>
public string launchReveal;
/// <summary>
/// Will create a modern Nomai computer linked to this gravity cannon.
/// </summary>
public NomaiComputerInfo computer;
}
}

View File

@ -0,0 +1,18 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Props.Shuttle
{
[JsonObject]
public class ShuttleInfo : GeneralPropInfo
{
/// <summary>
/// Unique ID for this shuttle
/// </summary>
public string id;
}
}

View File

@ -1,9 +0,0 @@
using Newtonsoft.Json;
namespace NewHorizons.External.Modules.WarpPad
{
[JsonObject]
public class NomaiWarpComputerLoggerInfo : GeneralPropInfo
{
}
}

View File

@ -1,3 +1,4 @@
using NewHorizons.External.Modules.Props;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace NewHorizons.External.Modules.WarpPad namespace NewHorizons.External.Modules.WarpPad
@ -14,7 +15,7 @@ namespace NewHorizons.External.Modules.WarpPad
/// <summary> /// <summary>
/// Will create a modern Nomai computer linked to this receiver. /// Will create a modern Nomai computer linked to this receiver.
/// </summary> /// </summary>
public NomaiWarpComputerLoggerInfo computer; public NomaiComputerInfo computer;
/// <summary> /// <summary>
/// Set to true if you want to include Nomai ruin details around the warp pad. /// Set to true if you want to include Nomai ruin details around the warp pad.

View File

@ -1,11 +1,6 @@
using NewHorizons.Utility; using NewHorizons.Utility.OWML;
using OWML.Common;
using OWML.Utils; using OWML.Utils;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Handlers namespace NewHorizons.Handlers
{ {
@ -15,8 +10,7 @@ namespace NewHorizons.Handlers
{ {
try try
{ {
NomaiShuttleController.ShuttleID shuttleID; if (EnumUtils.TryParse(id, out NomaiShuttleController.ShuttleID shuttleID))
if (EnumUtils.TryParse<NomaiShuttleController.ShuttleID>(id, out shuttleID))
{ {
return shuttleID; return shuttleID;
} }
@ -27,14 +21,14 @@ namespace NewHorizons.Handlers
} }
catch (Exception e) catch (Exception e)
{ {
Logger.LogError($"Couldn't load shuttle id [{id}]:\n{e}"); NHLogger.LogError($"Couldn't load shuttle id [{id}]:\n{e}");
return EnumUtils.FromObject<NomaiShuttleController.ShuttleID>(-1); return EnumUtils.FromObject<NomaiShuttleController.ShuttleID>(-1);
} }
} }
public static NomaiShuttleController.ShuttleID AddCustomShuttleID(string id) public static NomaiShuttleController.ShuttleID AddCustomShuttleID(string id)
{ {
Logger.LogVerbose($"Registering new shuttle id [{id}]"); NHLogger.LogVerbose($"Registering new shuttle id [{id}]");
return EnumUtilities.Create<NomaiShuttleController.ShuttleID>(id); return EnumUtilities.Create<NomaiShuttleController.ShuttleID>(id);
} }