chore: fixed merge conflict with main

This commit is contained in:
FreezeDriedMangoes 2022-05-21 22:26:13 -04:00
parent f80ae73d20
commit 0dfe9bf769
6 changed files with 586 additions and 546 deletions

View File

@ -1,5 +1,6 @@
using NewHorizons.External; using NewHorizons.External;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using OWML.Common; using OWML.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -11,6 +12,13 @@ using UnityEngine.InputSystem;
namespace NewHorizons.Utility namespace NewHorizons.Utility
{ {
//
//
// TODO: split this into two separate classes "DebugMenu" and "DebugPropPlacerMenu"
//
//
[RequireComponent(typeof(DebugRaycaster))] [RequireComponent(typeof(DebugRaycaster))]
[RequireComponent(typeof(DebugPropPlacer))] [RequireComponent(typeof(DebugPropPlacer))]
class DebugMenu : MonoBehaviour class DebugMenu : MonoBehaviour
@ -18,8 +26,8 @@ namespace NewHorizons.Utility
GUIStyle _editorMenuStyle; GUIStyle _editorMenuStyle;
Vector2 EditorMenuSize = new Vector2(600, 900); Vector2 EditorMenuSize = new Vector2(600, 900);
bool menuOpen = false; bool menuOpen = false;
static bool openMenuOnPause = false; static bool openMenuOnPause;
static bool staticInitialized = false; static bool staticInitialized;
DebugPropPlacer _dpp; DebugPropPlacer _dpp;
DebugRaycaster _drc; DebugRaycaster _drc;
@ -36,12 +44,19 @@ namespace NewHorizons.Utility
private bool saveButtonUnlocked = false; private bool saveButtonUnlocked = false;
private Vector2 recentModListScrollPosition = Vector2.zero; private Vector2 recentModListScrollPosition = Vector2.zero;
private double debugcountA = 0;
private double debugcountB = 0;
private double debugcountC = 0;
private double debugcountD = 0;
private void Awake() private void Awake()
{ {
_dpp = this.GetRequiredComponent<DebugPropPlacer>(); _dpp = this.GetRequiredComponent<DebugPropPlacer>();
_drc = this.GetRequiredComponent<DebugRaycaster>(); _drc = this.GetRequiredComponent<DebugRaycaster>();
LoadFavoriteProps(); LoadFavoriteProps();
} }
private void Start() private void Start()
{ {
@ -60,6 +75,10 @@ namespace NewHorizons.Utility
Main.Instance.OnChangeStarSystem.AddListener((string s) => SaveLoadedConfigsForRecentSystem()); Main.Instance.OnChangeStarSystem.AddListener((string s) => SaveLoadedConfigsForRecentSystem());
} }
else
{
InitMenu();
}
if (loadedMod != null) if (loadedMod != null)
{ {
@ -70,12 +89,13 @@ namespace NewHorizons.Utility
private void PauseMenuInitHook() private void PauseMenuInitHook()
{ {
Logger.Log("PAUSE MENU INIT HOOK");
InitMenu(); InitMenu();
var editorButton = Main.Instance.ModHelper.Menus.PauseMenu.OptionsButton.Duplicate("Toggle Prop Placer Menu".ToUpper()); var editorButton = Main.Instance.ModHelper.Menus.PauseMenu.OptionsButton.Duplicate("Toggle Prop Placer Menu".ToUpper());
editorButton.OnClick += ToggleMenu; editorButton.OnClick += ToggleMenu;
} }
private void RestoreMenuOpennessState() { menuOpen = openMenuOnPause; } private void RestoreMenuOpennessState() { Logger.Log("RESTORING MENU OPENNESS STATE: " + openMenuOnPause); menuOpen = openMenuOnPause; }
private void ToggleMenu() { menuOpen = !menuOpen; openMenuOnPause = !openMenuOnPause; } private void ToggleMenu() { Logger.Log($"oMY MENU BUTTON WAS CLICKED! debug counts: {debugcountA}, {debugcountB}, {debugcountC}, {debugcountD}"); menuOpen = !menuOpen; openMenuOnPause = !openMenuOnPause; }
private void CloseMenu() { menuOpen = false; } private void CloseMenu() { menuOpen = false; }
@ -95,13 +115,19 @@ namespace NewHorizons.Utility
private void OnGUI() private void OnGUI()
{ {
debugcountA ++;
if (!menuOpen) return; if (!menuOpen) return;
if (!Main.Debug) return; if (!Main.Debug) return;
debugcountB ++;
Vector2 menuPosition = new Vector2(10, 40); Vector2 menuPosition = new Vector2(10, 40);
GUILayout.BeginArea(new Rect(menuPosition.x, menuPosition.y, EditorMenuSize.x, EditorMenuSize.y), _editorMenuStyle); GUILayout.BeginArea(new Rect(menuPosition.x, menuPosition.y, EditorMenuSize.x, EditorMenuSize.y), _editorMenuStyle);
debugcountC++;
// //
// DebugPropPlacer // DebugPropPlacer
// //
@ -190,6 +216,8 @@ namespace NewHorizons.Utility
} }
GUILayout.EndArea(); GUILayout.EndArea();
debugcountD++;
} }
private void LoadMod(IModBehaviour mod) private void LoadMod(IModBehaviour mod)
@ -269,7 +297,7 @@ namespace NewHorizons.Utility
if (!newDetails.ContainsKey(astroObjectName)) continue; if (!newDetails.ContainsKey(astroObjectName)) continue;
if (loadedConfigFiles[filePath].Props == null) loadedConfigFiles[filePath].Props = new External.PropModule(); if (loadedConfigFiles[filePath].Props == null) loadedConfigFiles[filePath].Props = new External.Modules.PropModule();
loadedConfigFiles[filePath].Props.Details = newDetails[astroObjectName]; loadedConfigFiles[filePath].Props.Details = newDetails[astroObjectName];
Logger.Log("successfully updated copy of config file for " + astroObjectName); Logger.Log("successfully updated copy of config file for " + astroObjectName);
@ -282,7 +310,7 @@ namespace NewHorizons.Utility
Logger.Log("Fabricating new config file for " + astroObjectName); Logger.Log("Fabricating new config file for " + astroObjectName);
var filepath = "planets/" + Main.Instance.CurrentStarSystem + "/" + astroObjectName + ".json"; var filepath = "planets/" + Main.Instance.CurrentStarSystem + "/" + astroObjectName + ".json";
PlanetConfig c = new PlanetConfig(null); PlanetConfig c = new PlanetConfig();
c.StarSystem = Main.Instance.CurrentStarSystem; c.StarSystem = Main.Instance.CurrentStarSystem;
c.Name = astroObjectName; c.Name = astroObjectName;
c.Props = new PropModule(); c.Props = new PropModule();
@ -294,8 +322,12 @@ namespace NewHorizons.Utility
private void InitMenu() private void InitMenu()
{ {
Logger.Log("Maybe Initing menu");
if (_editorMenuStyle != null) return; if (_editorMenuStyle != null) return;
Logger.Log("Initing menu");
_dpp = this.GetRequiredComponent<DebugPropPlacer>(); _dpp = this.GetRequiredComponent<DebugPropPlacer>();
_drc = this.GetRequiredComponent<DebugRaycaster>(); _drc = this.GetRequiredComponent<DebugRaycaster>();

View File

@ -7,7 +7,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using static NewHorizons.External.PropModule; using static NewHorizons.External.Modules.PropModule;
namespace NewHorizons.Utility namespace NewHorizons.Utility
{ {
@ -46,7 +46,7 @@ namespace NewHorizons.Utility
if (!Main.Debug) return; if (!Main.Debug) return;
if (!active) return; if (!active) return;
if (Keyboard.current[Key.X].wasReleasedThisFrame) if (Keyboard.current[Key.G].wasReleasedThisFrame)
{ {
PlaceObject(); PlaceObject();
} }
@ -143,7 +143,7 @@ namespace NewHorizons.Utility
return astroObjectName; return astroObjectName;
} }
public void FindAndRegisterPropsFromConfig(IPlanetConfig config) public void FindAndRegisterPropsFromConfig(PlanetConfig config)
{ {
if (config.StarSystem != Main.Instance.CurrentStarSystem) return; if (config.StarSystem != Main.Instance.CurrentStarSystem) return;

View File

@ -27,6 +27,8 @@ namespace NewHorizons.Utility
} }
} }
internal void PrintRaycast() internal void PrintRaycast()
{ {
DebugRaycastData data = Raycast(); DebugRaycastData data = Raycast();
@ -37,10 +39,16 @@ namespace NewHorizons.Utility
if(_normalSphere1 != null) GameObject.Destroy(_normalSphere1); if(_normalSphere1 != null) GameObject.Destroy(_normalSphere1);
if(_normalSphere2 != null) GameObject.Destroy(_normalSphere2); if(_normalSphere2 != null) GameObject.Destroy(_normalSphere2);
_surfaceSphere = AddDebugShape.AddSphere(hitInfo.transform.gameObject, 0.1f, Color.green); _surfaceSphere = AddDebugShape.AddSphere(data.hitObject, 0.1f, Color.green);
_normalSphere1 = AddDebugShape.AddSphere(hitInfo.transform.gameObject, 0.01f, Color.red); _normalSphere1 = AddDebugShape.AddSphere(data.hitObject, 0.01f, Color.red);
_normalSphere2 = AddDebugShape.AddSphere(hitInfo.transform.gameObject, 0.01f, Color.red); _normalSphere2 = AddDebugShape.AddSphere(data.hitObject, 0.01f, Color.red);
_surfaceSphere.transform.localPosition = data.pos;
_normalSphere1.transform.localPosition = data.pos + data.norm * 0.5f;
_normalSphere2.transform.localPosition = data.pos + data.norm;
Logger.Log($"Raycast hit \"position\": {posText}, \"normal\": {normText} on [{data.bodyName}] at [{data.bodyPath}]");
}
internal DebugRaycastData Raycast() internal DebugRaycastData Raycast()
{ {
DebugRaycastData data = new DebugRaycastData(); DebugRaycastData data = new DebugRaycastData();