mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Let systems be revealed by facts
This commit is contained in:
parent
b6e71c0792
commit
ddb6780f8d
@ -8,6 +8,7 @@ using NewHorizons.Utility;
|
|||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
|
using NewHorizons.Handlers;
|
||||||
|
|
||||||
namespace NewHorizons.Components
|
namespace NewHorizons.Components
|
||||||
{
|
{
|
||||||
@ -33,6 +34,8 @@ namespace NewHorizons.Components
|
|||||||
private ShipLogEntryCard _target = null;
|
private ShipLogEntryCard _target = null;
|
||||||
private NotificationData _warpNotificationData = null;
|
private NotificationData _warpNotificationData = null;
|
||||||
|
|
||||||
|
private int _nextCardIndex;
|
||||||
|
|
||||||
public override void Initialize(ScreenPromptList centerPromptList, ScreenPromptList upperRightPromptList, OWAudioSource oneShotSource)
|
public override void Initialize(ScreenPromptList centerPromptList, ScreenPromptList upperRightPromptList, OWAudioSource oneShotSource)
|
||||||
{
|
{
|
||||||
root = base.transform.Find("ScaleRoot/PanRoot");
|
root = base.transform.Find("ScaleRoot/PanRoot");
|
||||||
@ -47,25 +50,34 @@ namespace NewHorizons.Components
|
|||||||
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
GlobalMessenger<ReferenceFrame>.AddListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
||||||
GlobalMessenger<OWRigidbody>.AddListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole));
|
GlobalMessenger<OWRigidbody>.AddListener("EnterFlightConsole", new Callback<OWRigidbody>(OnEnterFlightConsole));
|
||||||
|
|
||||||
var x = 0;
|
_nextCardIndex = 0;
|
||||||
foreach (var starSystem in Main.BodyDict.Keys)
|
foreach (var starSystem in Main.BodyDict.Keys)
|
||||||
{
|
{
|
||||||
// Get rid of the warp option for the current system
|
// Get rid of the warp option for the current system
|
||||||
if (starSystem == Main.Instance.CurrentStarSystem) continue;
|
if (starSystem == Main.Instance.CurrentStarSystem) continue;
|
||||||
|
|
||||||
|
var config = Main.SystemDict[starSystem];
|
||||||
|
|
||||||
// Conditions to allow warping into that system (either no planets (stock system) or has a ship spawn point)
|
// Conditions to allow warping into that system (either no planets (stock system) or has a ship spawn point)
|
||||||
var flag = false;
|
var flag = false;
|
||||||
if (starSystem.Equals("SolarSystem")) flag = true;
|
if (starSystem.Equals("SolarSystem")) flag = true;
|
||||||
else if (Main.SystemDict[starSystem].Spawn?.ShipSpawnPoint != null) flag = true;
|
else if (config.Spawn?.ShipSpawnPoint != null) flag = true;
|
||||||
|
|
||||||
|
if (!StarChartHandler.HasUnlockedSystem(starSystem)) continue;
|
||||||
|
|
||||||
if (flag && Main.SystemDict[starSystem].Config.canEnterViaWarpDrive)
|
if (flag && Main.SystemDict[starSystem].Config.canEnterViaWarpDrive)
|
||||||
{
|
{
|
||||||
var card = CreateCard(starSystem, root.transform, new Vector2(x++ * 200, 0));
|
AddSystemCard(starSystem);
|
||||||
_starSystemCards.Add(card);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddSystemCard(string starSystem)
|
||||||
|
{
|
||||||
|
var card = CreateCard(starSystem, root.transform, new Vector2(_nextCardIndex++ * 200, 0));
|
||||||
|
_starSystemCards.Add(card);
|
||||||
|
}
|
||||||
|
|
||||||
public void OnDestroy()
|
public void OnDestroy()
|
||||||
{
|
{
|
||||||
GlobalMessenger<ReferenceFrame>.RemoveListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
GlobalMessenger<ReferenceFrame>.RemoveListener("TargetReferenceFrame", new Callback<ReferenceFrame>(OnTargetReferenceFrame));
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
using NewHorizons.Components;
|
using NewHorizons.Components;
|
||||||
|
using NewHorizons.External.Configs;
|
||||||
|
using NewHorizons.Utility;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
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 UnityEngine;
|
||||||
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.Handlers
|
namespace NewHorizons.Handlers
|
||||||
{
|
{
|
||||||
@ -12,8 +15,15 @@ namespace NewHorizons.Handlers
|
|||||||
{
|
{
|
||||||
public static ShipLogStarChartMode ShipLogStarChartMode;
|
public static ShipLogStarChartMode ShipLogStarChartMode;
|
||||||
|
|
||||||
public static void Init()
|
private static Dictionary<string, string> _starSystemToFactID;
|
||||||
|
private static Dictionary<string, string> _factIDToStarSystem;
|
||||||
|
|
||||||
|
private static NewHorizonsSystem[] _systems;
|
||||||
|
|
||||||
|
public static void Init(NewHorizonsSystem[] systems)
|
||||||
{
|
{
|
||||||
|
_systems = systems;
|
||||||
|
|
||||||
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");
|
||||||
|
|
||||||
var starChartLog = new GameObject("StarChartMode");
|
var starChartLog = new GameObject("StarChartMode");
|
||||||
@ -43,10 +53,67 @@ namespace NewHorizons.Handlers
|
|||||||
var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.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>();
|
var oneShotSource = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>();
|
||||||
|
|
||||||
|
_starSystemToFactID = new Dictionary<string, string>();
|
||||||
|
_factIDToStarSystem = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
foreach (NewHorizonsSystem system in _systems)
|
||||||
|
{
|
||||||
|
if (system.Config.factRequiredForWarp != default)
|
||||||
|
{
|
||||||
|
RegisterFactForSystem(system.Config.factRequiredForWarp, system.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ShipLogStarChartMode.Initialize(
|
ShipLogStarChartMode.Initialize(
|
||||||
centerPromptList,
|
centerPromptList,
|
||||||
upperRightPromptList,
|
upperRightPromptList,
|
||||||
oneShotSource);
|
oneShotSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CanWarp()
|
||||||
|
{
|
||||||
|
foreach(var system in _systems)
|
||||||
|
{
|
||||||
|
if (system.Config.canEnterViaWarpDrive && system.Spawn?.ShipSpawnPoint != null && HasUnlockedSystem(system.Name))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasUnlockedSystem(string system)
|
||||||
|
{
|
||||||
|
if (_starSystemToFactID == null || _starSystemToFactID.Count == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If we can't get a fact for the system, then its unlocked
|
||||||
|
if (!_starSystemToFactID.TryGetValue(system, out var factID))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// If we got a fact but now can't find it elsewhere, its not unlocked
|
||||||
|
if (!GameObject.FindObjectOfType<ShipLogManager>()._factDict.TryGetValue(factID, out var fact))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// It's unlocked if revealed
|
||||||
|
return fact.IsRevealed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnRevealFact(string factID)
|
||||||
|
{
|
||||||
|
if(_factIDToStarSystem.TryGetValue(factID, out var systemUnlocked))
|
||||||
|
{
|
||||||
|
Logger.Log($"Just learned [{factID}] and unlocked [{systemUnlocked}]");
|
||||||
|
if (!Main.HasWarpDrive) Main.Instance.EnableWarpDrive();
|
||||||
|
ShipLogStarChartMode.AddSystemCard(systemUnlocked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RegisterFactForSystem(string factID, string system)
|
||||||
|
{
|
||||||
|
Logger.Log($"Need to know [{factID}] to unlock [{system}]");
|
||||||
|
_starSystemToFactID.Add(system, factID);
|
||||||
|
_factIDToStarSystem.Add(factID, system);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,10 +99,6 @@ namespace NewHorizons.Handlers
|
|||||||
|
|
||||||
if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, config.UIDictionary[originalKey]);
|
if (!_uiTranslationDictionary[language].ContainsKey(key)) _uiTranslationDictionary[language].Add(key, config.UIDictionary[originalKey]);
|
||||||
else _uiTranslationDictionary[language][key] = config.UIDictionary[originalKey];
|
else _uiTranslationDictionary[language][key] = config.UIDictionary[originalKey];
|
||||||
|
|
||||||
//Also add an upper case version
|
|
||||||
if (!_uiTranslationDictionary[language].ContainsKey(key.ToUpper())) _uiTranslationDictionary[language].Add(key.ToUpper(), config.UIDictionary[originalKey].ToUpper());
|
|
||||||
else _uiTranslationDictionary[language][key] = config.UIDictionary[originalKey].ToUpper();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,6 +139,9 @@ namespace NewHorizons
|
|||||||
|
|
||||||
private void ReloadConfigs()
|
private void ReloadConfigs()
|
||||||
{
|
{
|
||||||
|
BodyDict = new Dictionary<string, List<NewHorizonsBody>>();
|
||||||
|
SystemDict = new Dictionary<string, NewHorizonsSystem>();
|
||||||
|
|
||||||
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
BodyDict["SolarSystem"] = new List<NewHorizonsBody>();
|
||||||
SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), this);
|
SystemDict["SolarSystem"] = new NewHorizonsSystem("SolarSystem", new StarSystemConfig(null), this);
|
||||||
foreach (AssetBundle bundle in AssetBundles.Values)
|
foreach (AssetBundle bundle in AssetBundles.Values)
|
||||||
@ -196,34 +199,15 @@ namespace NewHorizons
|
|||||||
// By default we dont have it
|
// By default we dont have it
|
||||||
HasWarpDrive = false;
|
HasWarpDrive = false;
|
||||||
|
|
||||||
// Lets us warp home if we want
|
// Gotta prepare it anyway
|
||||||
if (_currentStarSystem != "SolarSystem")
|
StarChartHandler.Init(SystemDict.Values.ToArray());
|
||||||
{
|
HasWarpDrive = StarChartHandler.CanWarp();
|
||||||
HasWarpDrive = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Make the warp controller if there are multiple star systems
|
|
||||||
foreach (NewHorizonsSystem system in SystemDict.Values)
|
|
||||||
{
|
|
||||||
Logger.Log($"System {system}, {system.Config.canEnterViaWarpDrive}");
|
|
||||||
if (system.Config.canEnterViaWarpDrive && system.Spawn?.ShipSpawnPoint != null)
|
|
||||||
{
|
|
||||||
HasWarpDrive = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HasWarpDrive == true)
|
_shipWarpController = GameObject.Find("Ship_Body").AddComponent<ShipWarpController>();
|
||||||
{
|
_shipWarpController.Init();
|
||||||
Logger.Log("Setting up warp drive");
|
|
||||||
_shipWarpController = GameObject.Find("Ship_Body").AddComponent<ShipWarpController>();
|
if (HasWarpDrive == true) EnableWarpDrive();
|
||||||
_shipWarpController.Init();
|
|
||||||
StarChartHandler.Init();
|
|
||||||
|
|
||||||
LoadBody(LoadConfig(this, "AssetBundle/WarpDriveConfig.json"));
|
|
||||||
}
|
|
||||||
LoadTranslations(ModHelper.Manifest.ModFolderPath + "AssetBundle/", this);
|
LoadTranslations(ModHelper.Manifest.ModFolderPath + "AssetBundle/", this);
|
||||||
|
|
||||||
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => AstroObjectLocator.GetAstroObject("MapSatellite").gameObject.AddComponent<MapSatelliteOrbitFix>());
|
Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => AstroObjectLocator.GetAstroObject("MapSatellite").gameObject.AddComponent<MapSatelliteOrbitFix>());
|
||||||
@ -330,6 +314,13 @@ namespace NewHorizons
|
|||||||
IsWarping = false;
|
IsWarping = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EnableWarpDrive()
|
||||||
|
{
|
||||||
|
Logger.Log("Setting up warp drive");
|
||||||
|
LoadBody(LoadConfig(this, "AssetBundle/WarpDriveConfig.json"));
|
||||||
|
HasWarpDrive = true;
|
||||||
|
}
|
||||||
|
|
||||||
#region TitleScreen
|
#region TitleScreen
|
||||||
|
|
||||||
public void DisplayBodyOnTitleScreen()
|
public void DisplayBodyOnTitleScreen()
|
||||||
@ -497,7 +488,7 @@ namespace NewHorizons
|
|||||||
var config = mod.ModHelper.Storage.Load<PlanetConfig>(relativeDirectory);
|
var config = mod.ModHelper.Storage.Load<PlanetConfig>(relativeDirectory);
|
||||||
Logger.Log($"Loaded {config.Name}");
|
Logger.Log($"Loaded {config.Name}");
|
||||||
if (config.Base.CenterOfSolarSystem) config.Orbit.IsStatic = true;
|
if (config.Base.CenterOfSolarSystem) config.Orbit.IsStatic = true;
|
||||||
if (!BodyDict.ContainsKey(config.StarSystem))
|
if (!SystemDict.ContainsKey(config.StarSystem))
|
||||||
{
|
{
|
||||||
// See if theres a star system config
|
// See if theres a star system config
|
||||||
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>($"systems/{config.StarSystem}.json");
|
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>($"systems/{config.StarSystem}.json");
|
||||||
|
|||||||
@ -8,6 +8,7 @@ using Logger = NewHorizons.Utility.Logger;
|
|||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
using NewHorizons.Builder.ShipLog;
|
using NewHorizons.Builder.ShipLog;
|
||||||
using NewHorizons.Builder.Handlers;
|
using NewHorizons.Builder.Handlers;
|
||||||
|
using NewHorizons.Handlers;
|
||||||
|
|
||||||
namespace NewHorizons.Tools
|
namespace NewHorizons.Tools
|
||||||
{
|
{
|
||||||
@ -29,6 +30,8 @@ namespace NewHorizons.Tools
|
|||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogMapMode>("Initialize", typeof(ShipLogPatches), nameof(ShipLogPatches.OnShipLogMapModeInitialize));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogMapMode>("Initialize", typeof(ShipLogPatches), nameof(ShipLogPatches.OnShipLogMapModeInitialize));
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogManager>("Awake", typeof(ShipLogPatches), nameof(ShipLogPatches.OnShipLogManagerAwakeComplete));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogManager>("Awake", typeof(ShipLogPatches), nameof(ShipLogPatches.OnShipLogManagerAwakeComplete));
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogAstroObject>("UpdateState", typeof(ShipLogPatches), nameof(ShipLogPatches.OnShipLogAstroObjectUpdateState));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogAstroObject>("UpdateState", typeof(ShipLogPatches), nameof(ShipLogPatches.OnShipLogAstroObjectUpdateState));
|
||||||
|
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogManager>(nameof(ShipLogManager.RevealFact), typeof(ShipLogPatches), nameof(ShipLogPatches.OnShipLogManagerRevealFact));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OnShipLogManagerAwake(ShipLogManager __instance)
|
public static void OnShipLogManagerAwake(ShipLogManager __instance)
|
||||||
@ -211,5 +214,10 @@ namespace NewHorizons.Tools
|
|||||||
ShipLogManager manager = Locator.GetShipLogManager();
|
ShipLogManager manager = Locator.GetShipLogManager();
|
||||||
__result = __result.Where(e => manager.GetFact(e) != null).ToList();
|
__result = __result.Where(e => manager.GetFact(e) != null).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void OnShipLogManagerRevealFact(string __0)
|
||||||
|
{
|
||||||
|
StarChartHandler.OnRevealFact(__0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user