mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Warp drive "works"
This commit is contained in:
parent
97901c9ee7
commit
547d2c2401
BIN
NewHorizons/AssetBundle/hearthian system.png
Normal file
BIN
NewHorizons/AssetBundle/hearthian system.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 390 KiB |
@ -15,46 +15,39 @@ namespace NewHorizons.Builder.General
|
|||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
Logger.Log("Fuck");
|
|
||||||
var shipLogRoot = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas");
|
var shipLogRoot = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas");
|
||||||
Logger.Log("Fuck");
|
|
||||||
var starChartLog = new GameObject("StarChartMode");
|
var starChartLog = new GameObject("StarChartMode");
|
||||||
starChartLog.SetActive(false);
|
starChartLog.SetActive(false);
|
||||||
starChartLog.transform.parent = shipLogRoot.transform;
|
starChartLog.transform.parent = shipLogRoot.transform;
|
||||||
starChartLog.transform.localScale = Vector3.one * 0.5f;
|
starChartLog.transform.localScale = Vector3.one * 1f;
|
||||||
Logger.Log("Fuck");
|
starChartLog.transform.localPosition = Vector3.zero;
|
||||||
|
starChartLog.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
|
||||||
ShipLogStarChartMode = starChartLog.AddComponent<ShipLogStarChartMode>();
|
ShipLogStarChartMode = starChartLog.AddComponent<ShipLogStarChartMode>();
|
||||||
Logger.Log("Fuck");
|
|
||||||
var reticleImage = GameObject.Instantiate(GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ReticleImage (1)/"), starChartLog.transform);
|
var reticleImage = GameObject.Instantiate(GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ReticleImage (1)/"), starChartLog.transform);
|
||||||
Logger.Log("Fuck");
|
|
||||||
var scaleRoot = new GameObject("ScaleRoot");
|
var scaleRoot = new GameObject("ScaleRoot");
|
||||||
scaleRoot.transform.parent = starChartLog.transform;
|
scaleRoot.transform.parent = starChartLog.transform;
|
||||||
scaleRoot.transform.localScale = Vector3.one;
|
scaleRoot.transform.localScale = Vector3.one;
|
||||||
Logger.Log("Fuck");
|
scaleRoot.transform.localPosition = Vector3.zero;
|
||||||
|
scaleRoot.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
|
||||||
var panRoot = new GameObject("PanRoot");
|
var panRoot = new GameObject("PanRoot");
|
||||||
panRoot.transform.parent = scaleRoot.transform;
|
panRoot.transform.parent = scaleRoot.transform;
|
||||||
panRoot.transform.localScale = Vector3.one;
|
panRoot.transform.localScale = Vector3.one;
|
||||||
Logger.Log("Fuck");
|
panRoot.transform.localPosition = Vector3.zero;
|
||||||
CreateCard("Test", panRoot.transform);
|
panRoot.transform.localRotation = Quaternion.Euler(0,0,0);
|
||||||
}
|
|
||||||
|
|
||||||
public static GameObject _cardTemplate = null;
|
var centerPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_Center")?.GetComponent<ScreenPromptList>();
|
||||||
|
var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent<ScreenPromptList>();
|
||||||
|
var oneShotSource = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>();
|
||||||
|
|
||||||
public static void CreateCard(string name, Transform parent)
|
ShipLogStarChartMode.Initialize(
|
||||||
{
|
centerPromptList,
|
||||||
if(_cardTemplate == null)
|
upperRightPromptList,
|
||||||
{
|
oneShotSource);
|
||||||
Logger.Log("Fuck");
|
|
||||||
var panRoot = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot");
|
|
||||||
Logger.Log("Fuck");
|
|
||||||
_cardTemplate = GameObject.Instantiate(panRoot.GetComponentInChildren<ShipLogEntryCard>().gameObject);
|
|
||||||
Logger.Log("Fuck");
|
|
||||||
_cardTemplate.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
var newCard = GameObject.Instantiate(_cardTemplate, parent);
|
|
||||||
Logger.Log("Fuck");
|
|
||||||
newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent<UnityEngine.UI.Text>().text = name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,11 +3,111 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
using NewHorizons.Utility;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using OWML.Common;
|
||||||
|
|
||||||
namespace NewHorizons.Components
|
namespace NewHorizons.Components
|
||||||
{
|
{
|
||||||
public class ShipLogStarChartMode : ShipLogMode
|
public class ShipLogStarChartMode : ShipLogMode
|
||||||
{
|
{
|
||||||
|
private List<GameObject> _starSystemCards = new List<GameObject>();
|
||||||
|
private GameObject _cardTemplate = null;
|
||||||
|
private int _cardIndex = 0;
|
||||||
|
private OWAudioSource _oneShotSource;
|
||||||
|
|
||||||
|
private float _startPanTime;
|
||||||
|
private float _panDuration;
|
||||||
|
private Transform root;
|
||||||
|
private Vector2 _panRootPos = Vector2.zero;
|
||||||
|
private Vector2 _startPanPos;
|
||||||
|
|
||||||
|
private ScreenPromptList _upperRightPromptList;
|
||||||
|
private ScreenPromptList _centerPromptList;
|
||||||
|
|
||||||
|
private ScreenPrompt _detectiveModePrompt;
|
||||||
|
private ScreenPrompt _targetSystemPrompt;
|
||||||
|
|
||||||
|
private ShipLogEntryCard _target = null;
|
||||||
|
private NotificationData _warpNotificationData = null;
|
||||||
|
|
||||||
|
public override void Initialize(ScreenPromptList centerPromptList, ScreenPromptList upperRightPromptList, OWAudioSource oneShotSource)
|
||||||
|
{
|
||||||
|
root = base.transform.Find("ScaleRoot/PanRoot");
|
||||||
|
_oneShotSource = oneShotSource;
|
||||||
|
|
||||||
|
_centerPromptList = centerPromptList;
|
||||||
|
_upperRightPromptList = upperRightPromptList;
|
||||||
|
|
||||||
|
_detectiveModePrompt = new ScreenPrompt(InputLibrary.swapShipLogMode, "Detective Mode", 0, ScreenPrompt.DisplayState.Normal, false);
|
||||||
|
_targetSystemPrompt = new ScreenPrompt(InputLibrary.markEntryOnHUD, "Target", 0, ScreenPrompt.DisplayState.Normal, false);
|
||||||
|
|
||||||
|
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
||||||
|
|
||||||
|
var x = 0;
|
||||||
|
foreach (var starSystem in Main.BodyDict.Keys)
|
||||||
|
{
|
||||||
|
var card = CreateCard(starSystem, root.transform, new Vector2(x++ * 256, 0));
|
||||||
|
_starSystemCards.Add(card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
GlobalMessenger<ReferenceFrame>.RemoveListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameObject CreateCard(string uniqueName, Transform parent, Vector2 position)
|
||||||
|
{
|
||||||
|
if (_cardTemplate == null)
|
||||||
|
{
|
||||||
|
var panRoot = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot");
|
||||||
|
_cardTemplate = GameObject.Instantiate(panRoot.GetComponentInChildren<ShipLogEntryCard>().gameObject);
|
||||||
|
_cardTemplate.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
var newCard = GameObject.Instantiate(_cardTemplate, parent);
|
||||||
|
newCard.transform.Find("EntryCardRoot/NameBackground/Name").GetComponent<UnityEngine.UI.Text>().text = UniqueNameToString(uniqueName);
|
||||||
|
newCard.SetActive(true);
|
||||||
|
newCard.transform.name = uniqueName;
|
||||||
|
newCard.transform.localPosition = new Vector3(position.x, position.y, 0);
|
||||||
|
newCard.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
|
|
||||||
|
var shipLogEntryCard = newCard.GetComponent<ShipLogEntryCard>();
|
||||||
|
|
||||||
|
Texture texture = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (uniqueName.Equals("SolarSystem"))
|
||||||
|
{
|
||||||
|
IModAssets assets = Main.Instance.ModHelper.Assets;
|
||||||
|
texture = assets.GetTexture("AssetBundle/hearthian system.png");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IModAssets assets = Main.BodyDict[uniqueName][0].Assets;
|
||||||
|
var path = $"planets/{uniqueName}.png";
|
||||||
|
Logger.Log($"Trying to load {path}");
|
||||||
|
texture = assets.GetTexture(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
|
||||||
|
if(texture != null)
|
||||||
|
{
|
||||||
|
shipLogEntryCard._photo.sprite = MakeSprite((Texture2D)texture);
|
||||||
|
newCard.transform.Find("EntryCardRoot/EntryCardBackground/PhotoImage").gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
shipLogEntryCard._hudMarkerIcon.gameObject.SetActive(false);
|
||||||
|
shipLogEntryCard._moreToExploreIcon.gameObject.SetActive(false);
|
||||||
|
shipLogEntryCard._unreadIcon.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
return newCard;
|
||||||
|
}
|
||||||
|
|
||||||
public override bool AllowCancelInput()
|
public override bool AllowCancelInput()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -20,12 +120,18 @@ namespace NewHorizons.Components
|
|||||||
|
|
||||||
public override void EnterMode(string entryID = "", List<ShipLogFact> revealQueue = null)
|
public override void EnterMode(string entryID = "", List<ShipLogFact> revealQueue = null)
|
||||||
{
|
{
|
||||||
|
base.gameObject.SetActive(true);
|
||||||
|
|
||||||
|
Locator.GetPromptManager().AddScreenPrompt(_detectiveModePrompt, _upperRightPromptList, TextAnchor.MiddleRight, -1, true);
|
||||||
|
Locator.GetPromptManager().AddScreenPrompt(_targetSystemPrompt, _centerPromptList, TextAnchor.MiddleCenter, -1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ExitMode()
|
public override void ExitMode()
|
||||||
{
|
{
|
||||||
|
base.gameObject.SetActive(false);
|
||||||
|
|
||||||
|
Locator.GetPromptManager().RemoveScreenPrompt(_detectiveModePrompt);
|
||||||
|
Locator.GetPromptManager().RemoveScreenPrompt(_targetSystemPrompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string GetFocusedEntryID()
|
public override string GetFocusedEntryID()
|
||||||
@ -33,11 +139,6 @@ namespace NewHorizons.Components
|
|||||||
return "0";
|
return "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize(ScreenPromptList centerPromptList, ScreenPromptList upperRightPromptList, OWAudioSource oneShotSource)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnEnterComputer()
|
public override void OnEnterComputer()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -50,7 +151,103 @@ namespace NewHorizons.Components
|
|||||||
|
|
||||||
public override void UpdateMode()
|
public override void UpdateMode()
|
||||||
{
|
{
|
||||||
|
UpdateMapCamera();
|
||||||
|
UpdateMapNavigation();
|
||||||
|
UpdatePrompts();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateMapCamera()
|
||||||
|
{
|
||||||
|
Vector2 b = -_starSystemCards[_cardIndex].transform.localPosition;
|
||||||
|
float num = Mathf.InverseLerp(_startPanTime, _startPanTime + _panDuration, Time.unscaledTime);
|
||||||
|
num = 1f - (num - 1f) * (num - 1f);
|
||||||
|
_panRootPos = Vector2.Lerp(_startPanPos, b, num);
|
||||||
|
root.transform.localPosition = new Vector3(_panRootPos.x, _panRootPos.y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateMapNavigation()
|
||||||
|
{
|
||||||
|
var oldIndex = _cardIndex;
|
||||||
|
if (OWInput.IsNewlyPressed(InputLibrary.right, InputMode.All) || OWInput.IsNewlyPressed(InputLibrary.right2, InputMode.All))
|
||||||
|
{
|
||||||
|
_cardIndex = Posmod(_cardIndex + 1, _starSystemCards.Count());
|
||||||
|
}
|
||||||
|
else if (OWInput.IsNewlyPressed(InputLibrary.left, InputMode.All) || OWInput.IsNewlyPressed(InputLibrary.left2, InputMode.All))
|
||||||
|
{
|
||||||
|
_cardIndex = Posmod(_cardIndex - 1, _starSystemCards.Count());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldIndex != _cardIndex)
|
||||||
|
{
|
||||||
|
Logger.Log($"Moving to {_cardIndex}");
|
||||||
|
_oneShotSource.PlayOneShot(global::AudioType.ShipLogMoveBetweenPlanets, 1f);
|
||||||
|
_startPanTime = Time.unscaledTime;
|
||||||
|
_startPanPos = _panRootPos;
|
||||||
|
_panDuration = 0.25f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdatePrompts()
|
||||||
|
{
|
||||||
|
if (OWInput.IsNewlyPressed(InputLibrary.markEntryOnHUD, InputMode.All))
|
||||||
|
{
|
||||||
|
var shipLogEntryCard = _starSystemCards[_cardIndex].GetComponent<ShipLogEntryCard>();
|
||||||
|
|
||||||
|
if (_target == shipLogEntryCard) RemoveWarpTarget();
|
||||||
|
else SetWarpTarget(shipLogEntryCard);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UniqueNameToString(string uniqueName)
|
||||||
|
{
|
||||||
|
if (uniqueName.Equals("SolarSystem")) return "Hearthian System";
|
||||||
|
|
||||||
|
var splitString = uniqueName.Split('.');
|
||||||
|
if (splitString.Length > 1) splitString = splitString.Skip(1).ToArray();
|
||||||
|
var name = string.Join("", splitString).SplitCamelCase();
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int Posmod(int a, int b)
|
||||||
|
{
|
||||||
|
return (a % b + b) % b;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Sprite MakeSprite(Texture2D texture)
|
||||||
|
{
|
||||||
|
var rect = new Rect(0, 0, texture.width, texture.height);
|
||||||
|
var pivot = new Vector2(texture.width / 2, texture.height / 2);
|
||||||
|
return Sprite.Create(texture, rect, pivot);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTargetReferenceFrame(ReferenceFrame referenceFrame)
|
||||||
|
{
|
||||||
|
RemoveWarpTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetWarpTarget(ShipLogEntryCard shipLogEntryCard)
|
||||||
|
{
|
||||||
|
RemoveWarpTarget(false);
|
||||||
|
_oneShotSource.PlayOneShot(global::AudioType.ShipLogUnmarkLocation, 1f);
|
||||||
|
_target = shipLogEntryCard;
|
||||||
|
_target.SetMarkedOnHUD(true);
|
||||||
|
GlobalMessenger.FireEvent("UntargetReferenceFrame");
|
||||||
|
_warpNotificationData = new NotificationData($"AUTOPILOT LOCKED TO:\n{UniqueNameToString(shipLogEntryCard.name).ToUpper()}");
|
||||||
|
NotificationManager.SharedInstance.PostNotification(_warpNotificationData, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveWarpTarget(bool playSound = false)
|
||||||
|
{
|
||||||
|
if(_warpNotificationData != null) NotificationManager.SharedInstance.UnpinNotification(_warpNotificationData);
|
||||||
|
if (_target == null) return;
|
||||||
|
if(playSound) _oneShotSource.PlayOneShot(global::AudioType.ShipLogMarkLocation, 1f);
|
||||||
|
_target.SetMarkedOnHUD(false);
|
||||||
|
_target = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetTargetStarSystem()
|
||||||
|
{
|
||||||
|
return _target.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ using NewHorizons.Utility;
|
|||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using OWML.ModHelper;
|
using OWML.ModHelper;
|
||||||
using OWML.Utils;
|
using OWML.Utils;
|
||||||
|
using PacificEngine.OW_CommonResources.Game.Player;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@ -28,7 +29,7 @@ namespace NewHorizons
|
|||||||
public static AssetBundle ShaderBundle;
|
public static AssetBundle ShaderBundle;
|
||||||
public static Main Instance { get; private set; }
|
public static Main Instance { get; private set; }
|
||||||
|
|
||||||
public static List<NewHorizonsBody> BodyList = new List<NewHorizonsBody>();
|
public static Dictionary<string, List<NewHorizonsBody>> BodyDict = new Dictionary<string, List<NewHorizonsBody>>();
|
||||||
public static List<NewHorizonsBody> NextPassBodies = new List<NewHorizonsBody>();
|
public static List<NewHorizonsBody> NextPassBodies = new List<NewHorizonsBody>();
|
||||||
public static Dictionary<string, AssetBundle> AssetBundles = new Dictionary<string, AssetBundle>();
|
public static Dictionary<string, AssetBundle> AssetBundles = new Dictionary<string, AssetBundle>();
|
||||||
public static float FurthestOrbit { get; set; } = 50000f;
|
public static float FurthestOrbit { get; set; } = 50000f;
|
||||||
@ -36,6 +37,9 @@ namespace NewHorizons
|
|||||||
|
|
||||||
private string _currentStarSystem = "SolarSystem";
|
private string _currentStarSystem = "SolarSystem";
|
||||||
private bool _isChangingStarSystem = false;
|
private bool _isChangingStarSystem = false;
|
||||||
|
private bool _warpIn = false;
|
||||||
|
|
||||||
|
private SingularityController shipSingularity;
|
||||||
|
|
||||||
public override object GetApi()
|
public override object GetApi()
|
||||||
{
|
{
|
||||||
@ -48,6 +52,7 @@ namespace NewHorizons
|
|||||||
Instance = this;
|
Instance = this;
|
||||||
GlobalMessenger<DeathType>.AddListener("PlayerDeath", OnDeath);
|
GlobalMessenger<DeathType>.AddListener("PlayerDeath", OnDeath);
|
||||||
ShaderBundle = Main.Instance.ModHelper.Assets.LoadBundle("AssetBundle/shader");
|
ShaderBundle = Main.Instance.ModHelper.Assets.LoadBundle("AssetBundle/shader");
|
||||||
|
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
||||||
|
|
||||||
Utility.Patches.Apply();
|
Utility.Patches.Apply();
|
||||||
|
|
||||||
@ -73,12 +78,6 @@ namespace NewHorizons
|
|||||||
GlobalMessenger<DeathType>.RemoveListener("PlayerDeath", OnDeath);
|
GlobalMessenger<DeathType>.RemoveListener("PlayerDeath", OnDeath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnDeath(DeathType _)
|
|
||||||
{
|
|
||||||
// We reset the solar system on death (unless we just killed the player)
|
|
||||||
if (!_isChangingStarSystem) _currentStarSystem = "SolarSystem";
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||||
{
|
{
|
||||||
Logger.Log($"Scene Loaded: {scene.name} {mode}");
|
Logger.Log($"Scene Loaded: {scene.name} {mode}");
|
||||||
@ -142,8 +141,7 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Order by stars then planets then moons (not necessary but probably speeds things up, maybe) ALSO only include current star system
|
// Order by stars then planets then moons (not necessary but probably speeds things up, maybe) ALSO only include current star system
|
||||||
var toLoad = BodyList
|
var toLoad = BodyDict[_currentStarSystem]
|
||||||
.Where(b => b.Config.StarSystem.Equals(_currentStarSystem))
|
|
||||||
.OrderBy(b =>
|
.OrderBy(b =>
|
||||||
(b.Config.BuildPriority != -1 ? b.Config.BuildPriority :
|
(b.Config.BuildPriority != -1 ? b.Config.BuildPriority :
|
||||||
(b.Config.FocalPoint != null ? 0 :
|
(b.Config.FocalPoint != null ? 0 :
|
||||||
@ -196,12 +194,22 @@ namespace NewHorizons
|
|||||||
|
|
||||||
var map = GameObject.FindObjectOfType<MapController>();
|
var map = GameObject.FindObjectOfType<MapController>();
|
||||||
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
|
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
|
||||||
|
|
||||||
|
GameObject singularityGO = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/Sector_TowerTwin/Sector_Tower_HGT/Interactables_Tower_HGT/Interactables_Tower_TT/Prefab_NOM_WarpTransmitter (1)/BlackHole/BlackHoleSingularity"), GameObject.Find("Ship_Body").transform);
|
||||||
|
singularityGO.transform.localPosition = new Vector3(0f, 0f, 5f);
|
||||||
|
singularityGO.transform.localScale = Vector3.one * 10f;
|
||||||
|
shipSingularity = singularityGO.GetComponent<SingularityController>();
|
||||||
|
|
||||||
|
if(_warpIn) Instance.ModHelper.Events.Unity.FireInNUpdates(() => WarpInShip(), 3);
|
||||||
|
_warpIn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region TitleScreen
|
||||||
|
|
||||||
public void DisplayBodyOnTitleScreen()
|
public void DisplayBodyOnTitleScreen()
|
||||||
{
|
{
|
||||||
//Try loading one planet why not
|
//Try loading one planet why not
|
||||||
var eligible = BodyList.Where(b => b.Config.HeightMap != null || b.Config.Atmosphere?.Cloud != null).ToArray();
|
var eligible = BodyDict.Values.SelectMany(x => x).ToList().Where(b => b.Config.HeightMap != null || b.Config.Atmosphere?.Cloud != null).ToArray();
|
||||||
var eligibleCount = eligible.Count();
|
var eligibleCount = eligible.Count();
|
||||||
if (eligibleCount == 0) return;
|
if (eligibleCount == 0) return;
|
||||||
|
|
||||||
@ -293,6 +301,29 @@ namespace NewHorizons
|
|||||||
return titleScreenGO;
|
return titleScreenGO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion TitleScreen
|
||||||
|
|
||||||
|
#region Load
|
||||||
|
public void LoadConfigs(IModBehaviour mod)
|
||||||
|
{
|
||||||
|
var folder = mod.ModHelper.Manifest.ModFolderPath;
|
||||||
|
foreach (var file in Directory.GetFiles(folder + @"planets\", "*.json", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var config = mod.ModHelper.Storage.Load<PlanetConfig>(file.Replace(folder, ""));
|
||||||
|
Logger.Log($"Loaded {config.Name}");
|
||||||
|
if (config.Base.CenterOfSolarSystem) config.Orbit.IsStatic = true;
|
||||||
|
if (!BodyDict.ContainsKey(config.StarSystem)) BodyDict.Add(config.StarSystem, new List<NewHorizonsBody>());
|
||||||
|
BodyDict[config.StarSystem].Add(new NewHorizonsBody(config, mod.ModHelper.Assets, mod.ModHelper.Manifest.UniqueName));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.LogError($"Couldn't load {file}: {e.Message}, is your Json formatted correctly?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
private bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
||||||
{
|
{
|
||||||
var stringID = body.Config.Name.ToUpper().Replace(" ", "_").Replace("'", "");
|
var stringID = body.Config.Name.ToUpper().Replace(" ", "_").Replace("'", "");
|
||||||
@ -348,25 +379,6 @@ namespace NewHorizons
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadConfigs(IModBehaviour mod)
|
|
||||||
{
|
|
||||||
var folder = mod.ModHelper.Manifest.ModFolderPath;
|
|
||||||
foreach (var file in Directory.GetFiles(folder + @"planets\", "*.json", SearchOption.AllDirectories))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var config = mod.ModHelper.Storage.Load<PlanetConfig>(file.Replace(folder, ""));
|
|
||||||
Logger.Log($"Loaded {config.Name}");
|
|
||||||
if (config.Base.CenterOfSolarSystem) config.Orbit.IsStatic = true;
|
|
||||||
BodyList.Add(new NewHorizonsBody(config, mod.ModHelper.Assets, mod.ModHelper.Manifest.UniqueName));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Logger.LogError($"Couldn't load {file}: {e.Message}, is your Json formatted correctly?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameObject UpdateBody(NewHorizonsBody body, GameObject go)
|
public GameObject UpdateBody(NewHorizonsBody body, GameObject go)
|
||||||
{
|
{
|
||||||
Logger.Log($"Updating existing Object {go.name}");
|
Logger.Log($"Updating existing Object {go.name}");
|
||||||
@ -378,6 +390,10 @@ namespace NewHorizons
|
|||||||
return SharedGenerateBody(body, go, sector, rb);
|
return SharedGenerateBody(body, go, sector, rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion Load
|
||||||
|
|
||||||
|
#region Body generation
|
||||||
|
|
||||||
public GameObject GenerateBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
public GameObject GenerateBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
||||||
{
|
{
|
||||||
AstroObject primaryBody;
|
AstroObject primaryBody;
|
||||||
@ -527,15 +543,35 @@ namespace NewHorizons
|
|||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeCurrentStarSystem(string newStarSystem)
|
#endregion Body generation
|
||||||
|
|
||||||
|
#region Change star system
|
||||||
|
public void ChangeCurrentStarSystem(string newStarSystem, bool warpIn = false)
|
||||||
{
|
{
|
||||||
|
shipSingularity.Create();
|
||||||
_currentStarSystem = newStarSystem;
|
_currentStarSystem = newStarSystem;
|
||||||
_isChangingStarSystem = true;
|
_isChangingStarSystem = true;
|
||||||
|
_warpIn = warpIn;
|
||||||
Locator.GetDeathManager().KillPlayer(DeathType.Meditation);
|
Locator.GetDeathManager().KillPlayer(DeathType.Meditation);
|
||||||
LoadManager.LoadSceneAsync(OWScene.SolarSystem, true, LoadManager.FadeType.ToBlack, 0.1f, true);
|
LoadManager.LoadSceneAsync(OWScene.SolarSystem, true, LoadManager.FadeType.ToBlack, 0.1f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnDeath(DeathType _)
|
||||||
|
{
|
||||||
|
// We reset the solar system on death (unless we just killed the player)
|
||||||
|
if (!_isChangingStarSystem) _currentStarSystem = "SolarSystem";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WarpInShip()
|
||||||
|
{
|
||||||
|
var ship = GameObject.Find("Ship_Body");
|
||||||
|
Teleportation.teleportPlayerToShip();
|
||||||
|
ship.GetComponent<ShipCockpitController>().OnPressInteract();
|
||||||
|
}
|
||||||
|
#endregion Change star system
|
||||||
|
}
|
||||||
|
|
||||||
|
#region API
|
||||||
public class NewHorizonsApi
|
public class NewHorizonsApi
|
||||||
{
|
{
|
||||||
[Obsolete("Create(Dictionary<string, object> config) is deprecated, please use Create(Dictionary<string, object> config, IModBehaviour mod) instead")]
|
[Obsolete("Create(Dictionary<string, object> config) is deprecated, please use Create(Dictionary<string, object> config, IModBehaviour mod) instead")]
|
||||||
@ -551,7 +587,8 @@ namespace NewHorizons
|
|||||||
|
|
||||||
var body = new NewHorizonsBody(planetConfig, mod != null ? mod.ModHelper.Assets : Main.Instance.ModHelper.Assets, mod.ModHelper.Manifest.UniqueName);
|
var body = new NewHorizonsBody(planetConfig, mod != null ? mod.ModHelper.Assets : Main.Instance.ModHelper.Assets, mod.ModHelper.Manifest.UniqueName);
|
||||||
|
|
||||||
Main.BodyList.Add(body);
|
if (!Main.BodyDict.ContainsKey(body.Config.StarSystem)) Main.BodyDict.Add(body.Config.StarSystem, new List<NewHorizonsBody>());
|
||||||
|
Main.BodyDict[body.Config.StarSystem].Add(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadConfigs(IModBehaviour mod)
|
public void LoadConfigs(IModBehaviour mod)
|
||||||
@ -561,7 +598,8 @@ namespace NewHorizons
|
|||||||
|
|
||||||
public GameObject GetPlanet(string name)
|
public GameObject GetPlanet(string name)
|
||||||
{
|
{
|
||||||
return Main.BodyList.FirstOrDefault(x => x.Config.Name == name).Object;
|
return Main.BodyDict.Values.SelectMany(x => x).ToList().FirstOrDefault(x => x.Config.Name == name).Object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion API
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace NewHorizons.Utility
|
namespace NewHorizons.Utility
|
||||||
@ -97,8 +98,20 @@ namespace NewHorizons.Utility
|
|||||||
{
|
{
|
||||||
Logger.LogWarning($"Couldn't copy property {targetProperty.Name} from {source} to {destination}");
|
Logger.LogWarning($"Couldn't copy property {targetProperty.Name} from {source} to {destination}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string SplitCamelCase(this string str)
|
||||||
|
{
|
||||||
|
return Regex.Replace(
|
||||||
|
Regex.Replace(
|
||||||
|
str,
|
||||||
|
@"(\P{Ll})(\P{Ll}\p{Ll})",
|
||||||
|
"$1 $2"
|
||||||
|
),
|
||||||
|
@"(\p{Ll})(\P{Ll})",
|
||||||
|
"$1 $2"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,8 @@ namespace NewHorizons.Utility
|
|||||||
|
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogController>("Update", typeof(Patches), nameof(Patches.OnShipLogControllerUpdate));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogController>("Update", typeof(Patches), nameof(Patches.OnShipLogControllerUpdate));
|
||||||
|
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipCockpitController>("Update", typeof(Patches), nameof(Patches.OnShipCockpitControllerUpdate));
|
||||||
|
|
||||||
// Postfixes
|
// Postfixes
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<OWCamera>("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<OWCamera>("Awake", typeof(Patches), nameof(Patches.OnOWCameraAwake));
|
||||||
@ -383,5 +385,16 @@ namespace NewHorizons.Utility
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool OnShipCockpitControllerUpdate(ShipCockpitController __instance)
|
||||||
|
{
|
||||||
|
if(__instance._playerAtFlightConsole && OWInput.IsNewlyPressed(InputLibrary.autopilot, InputMode.ShipCockpit))
|
||||||
|
{
|
||||||
|
var targetSystem = ShipLogBuilder.ShipLogStarChartMode.GetTargetStarSystem();
|
||||||
|
if (targetSystem != null)
|
||||||
|
Main.Instance.ChangeCurrentStarSystem(targetSystem, true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user