Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warp pads #546

Merged
merged 15 commits into from
Mar 23, 2023
3 changes: 1 addition & 2 deletions NewHorizons/Builder/Body/BrambleDimensionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject
default: geometryPrefab = _hubGeometry; break;
}

var detailInfo = new PropModule.DetailInfo();
var geometry = DetailBuilder.Make(go, sector, geometryPrefab, detailInfo);
var geometry = DetailBuilder.Make(go, sector, geometryPrefab, new PropModule.DetailInfo());

var exitWarps = _exitWarps.InstantiateInactive();
var repelVolume = _repelVolume.InstantiateInactive();
Expand Down
5 changes: 0 additions & 5 deletions NewHorizons/Builder/Props/GeneralPropBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.OWUtilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using Logger = NewHorizons.Utility.Logger;

Expand Down
18 changes: 2 additions & 16 deletions NewHorizons/Builder/Props/NomaiTextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom
}
case PropModule.NomaiTextType.PreCrashComputer:
{
var detailInfo = new PropModule.DetailInfo()
{
position = info.position,
parentPath = info.parentPath,
isRelativeToParent = info.isRelativeToParent,
rename = info.rename
};
var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, detailInfo);
var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, new PropModule.DetailInfo(info));
computerObject.SetActive(false);

var up = computerObject.transform.position - planetGO.transform.position;
Expand Down Expand Up @@ -487,14 +480,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Nom
case PropModule.NomaiTextType.Recorder:
{
var prefab = (info.type == PropModule.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab);
var detailInfo = new PropModule.DetailInfo {
parentPath = info.parentPath,
rotation = info.rotation,
position = info.position,
isRelativeToParent = info.isRelativeToParent,
rename = info.rename
};
var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, detailInfo);
var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, new PropModule.DetailInfo(info));
recorderObject.SetActive(false);

if (info.rotation == null)
Expand Down
21 changes: 2 additions & 19 deletions NewHorizons/Builder/Props/ProjectionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,7 @@ public static GameObject MakeMindSlidesTarget(GameObject planetGO, Sector sector
if (_visionTorchDetectorPrefab == null) return null;

// spawn a trigger for the vision torch
var detailInfo = new PropModule.DetailInfo()
{
position = info.position,
rotation = info.rotation,
parentPath = info.parentPath,
isRelativeToParent = info.isRelativeToParent,
rename = !string.IsNullOrEmpty(info.rename) ? info.rename : "VisionStaffDetector",
scale = 2
};
var g = DetailBuilder.Make(planetGO, sector, _visionTorchDetectorPrefab, detailInfo);
var g = DetailBuilder.Make(planetGO, sector, _visionTorchDetectorPrefab, new DetailInfo(info) { scale = 2, rename = !string.IsNullOrEmpty(info.rename) ? info.rename : "VisionStaffDetector" });

if (g == null)
{
Expand Down Expand Up @@ -248,15 +239,7 @@ public static GameObject MakeStandingVisionTorch(GameObject planetGO, Sector sec
if (_standingVisionTorchPrefab == null) return null;

// Spawn the torch itself
var detailInfo = new PropModule.DetailInfo()
{
position = info.position,
rotation = info.rotation,
parentPath = info.parentPath,
isRelativeToParent = info.isRelativeToParent,
rename = info.rename
};
var standingTorch = DetailBuilder.Make(planetGO, sector, _standingVisionTorchPrefab, detailInfo);
var standingTorch = DetailBuilder.Make(planetGO, sector, _standingVisionTorchPrefab, new DetailInfo(info));

if (standingTorch == null)
{
Expand Down
29 changes: 29 additions & 0 deletions NewHorizons/Builder/Props/PropBuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using static NewHorizons.External.Modules.PropModule;
using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.Props
{
Expand Down Expand Up @@ -236,6 +237,34 @@ public static void Make(GameObject go, Sector sector, OWRigidbody planetBody, Ne
}
}
}
if (config.Props.warpReceivers != null)
{
foreach (var warpReceiver in config.Props.warpReceivers)
{
try
{
WarpPadBuilder.Make(go, sector, warpReceiver);
}
catch (Exception ex)
{
Logger.LogError($"Couldn't make warp receiver [{warpReceiver.frequency}] for [{go.name}]:\n{ex}");
}
}
}
if (config.Props.warpTransmitters != null)
{
foreach (var warpTransmitter in config.Props.warpTransmitters)
{
try
{
WarpPadBuilder.Make(go, sector, warpTransmitter);
}
catch (Exception ex)
{
Logger.LogError($"Couldn't make warp transmitter [{warpTransmitter.frequency}] for [{go.name}]:\n{ex}");
}
}
}
}
}
}
25 changes: 5 additions & 20 deletions NewHorizons/Builder/Props/RemoteBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using System.Linq;
using UnityEngine;
using static NewHorizons.External.Modules.PropModule;
using Logger = NewHorizons.Utility.Logger;

namespace NewHorizons.Builder.Props
Expand Down Expand Up @@ -171,15 +172,7 @@ public static void Make(GameObject go, Sector sector, PropModule.RemoteInfo info

public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.WhiteboardInfo info, NewHorizonsBody nhBody)
{
var detailInfo = new PropModule.DetailInfo()
{
position = info.position,
rotation = info.rotation,
parentPath = info.parentPath,
isRelativeToParent = info.isRelativeToParent,
rename = info.rename
};
var whiteboard = DetailBuilder.Make(go, sector, _whiteboardPrefab, detailInfo);
var whiteboard = DetailBuilder.Make(go, sector, _whiteboardPrefab, new DetailInfo(info));
whiteboard.SetActive(false);

var decalMat = new Material(_decalMaterial);
Expand All @@ -196,7 +189,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer
{
var textInfo = info.nomaiText[i];
component._remoteIDs[i] = RemoteHandler.GetPlatformID(textInfo.id);
var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new PropModule.TranslatorTextInfo
var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new TranslatorTextInfo
{
arcInfo = textInfo.arcInfo,
location = textInfo.location,
Expand All @@ -205,7 +198,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer
rename = textInfo.rename,
rotation = Vector3.zero,
seed = textInfo.seed,
type = PropModule.NomaiTextType.Wall,
type = NomaiTextType.Wall,
xmlFile = textInfo.xmlFile
}, nhBody).GetComponent<NomaiWallText>();
wallText._showTextOnStart = false;
Expand All @@ -219,15 +212,7 @@ public static void MakeWhiteboard(GameObject go, Sector sector, NomaiRemoteCamer

public static void MakePlatform(GameObject go, Sector sector, NomaiRemoteCameraPlatform.ID id, Texture2D decal, PropModule.RemoteInfo.PlatformInfo info, IModBehaviour mod)
{
var detailInfo = new PropModule.DetailInfo()
{
position = info.position,
rotation = info.rotation,
parentPath = info.parentPath,
isRelativeToParent = info.isRelativeToParent,
rename = info.rename
};
var platform = DetailBuilder.Make(go, sector, _remoteCameraPlatformPrefab, detailInfo);
var platform = DetailBuilder.Make(go, sector, _remoteCameraPlatformPrefab, new DetailInfo(info));
platform.SetActive(false);

var decalMat = new Material(_decalMaterial);
Expand Down
29 changes: 6 additions & 23 deletions NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class TranslatorTextBuilder
private static Material _adultArcMaterial;
private static Material _childArcMaterial;
private static GameObject _scrollPrefab;
private static GameObject _computerPrefab;
public static GameObject ComputerPrefab { get; private set; }
private static GameObject _preCrashComputerPrefab;
private static GameObject _cairnPrefab;
private static GameObject _cairnVariantPrefab;
Expand Down Expand Up @@ -80,9 +80,9 @@ internal static void InitPrefabs()
_scrollPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Scroll").InstantiateInactive().Rename("Prefab_NOM_Scroll").DontDestroyOnLoad();
}

if (_computerPrefab == null)
if (ComputerPrefab == null)
{
_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)
Expand Down Expand Up @@ -208,7 +208,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra
}
case PropModule.NomaiTextType.Computer:
{
var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info);
var computerObject = GeneralPropBuilder.MakeFromPrefab(ComputerPrefab, ComputerPrefab.name, planetGO, sector, info);

var computer = computerObject.GetComponent<NomaiComputer>();
computer.SetSector(sector);
Expand All @@ -229,16 +229,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra
}
case PropModule.NomaiTextType.PreCrashComputer:
{
var detailInfo = new PropModule.DetailInfo()
{
position = info.position,
rotation = info.rotation,
parentPath = info.parentPath,
isRelativeToParent = info.isRelativeToParent,
alignRadial = info.alignRadial,
rename = info.rename
};
var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, detailInfo);
var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, new PropModule.DetailInfo(info));
computerObject.SetActive(false);

var computer = computerObject.GetComponent<NomaiVesselComputer>();
Expand Down Expand Up @@ -314,15 +305,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, PropModule.Tra
case PropModule.NomaiTextType.Recorder:
{
var prefab = (info.type == PropModule.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab);
var detailInfo = new PropModule.DetailInfo {
parentPath = info.parentPath,
rotation = info.rotation,
position = info.position,
isRelativeToParent = info.isRelativeToParent,
rename = info.rename,
alignRadial = info.alignRadial,
};
var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, detailInfo);
var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, new PropModule.DetailInfo(info));
recorderObject.SetActive(false);

var nomaiText = recorderObject.GetComponentInChildren<NomaiText>();
Expand Down
Loading