mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
chore: removed some unused logs, comments, and code
This commit is contained in:
parent
392b459840
commit
2e693b45b9
@ -33,7 +33,6 @@ namespace NewHorizons.Utility
|
||||
private IModBehaviour loadedMod = null;
|
||||
private Dictionary<string, PlanetConfig> loadedConfigFiles = new Dictionary<string, PlanetConfig>();
|
||||
private bool saveButtonUnlocked = false;
|
||||
private bool propsHaveBeenLoaded = false;
|
||||
private Vector2 recentModListScrollPosition = Vector2.zero;
|
||||
|
||||
private void Awake()
|
||||
@ -66,8 +65,6 @@ namespace NewHorizons.Utility
|
||||
|
||||
private void CloseMenu() { menuOpen = false; }
|
||||
|
||||
|
||||
|
||||
private void LoadFavoriteProps()
|
||||
{
|
||||
string favoritePropsPlayerPref = PlayerPrefs.GetString(favoritePropsPlayerPrefKey);
|
||||
@ -81,17 +78,6 @@ namespace NewHorizons.Utility
|
||||
this.favoriteProps.Add(favoriteProp);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!Main.Debug) return;
|
||||
|
||||
/*if (Keyboard.current[Key.Escape].wasPressedThisFrame)
|
||||
{
|
||||
menuOpen = !menuOpen;
|
||||
if (menuOpen) InitMenu();
|
||||
}*/
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
@ -99,9 +85,6 @@ namespace NewHorizons.Utility
|
||||
if (!Main.Debug) return;
|
||||
|
||||
Vector2 menuPosition = new Vector2(10, 40);
|
||||
|
||||
//TODO: add gui for stuff https://github.com/Bwc9876/OW-SaveEditor/blob/master/SaveEditor/SaveEditor.cs
|
||||
// https://docs.unity3d.com/ScriptReference/GUI.TextField.html
|
||||
|
||||
GUILayout.BeginArea(new Rect(menuPosition.x, menuPosition.y, EditorMenuSize.x, EditorMenuSize.y), _editorMenuStyle);
|
||||
|
||||
@ -164,7 +147,6 @@ namespace NewHorizons.Utility
|
||||
loadedMod = mod;
|
||||
_dpp.active = true;
|
||||
|
||||
propsHaveBeenLoaded = true;
|
||||
var folder = loadedMod.ModHelper.Manifest.ModFolderPath;
|
||||
|
||||
List<NewHorizonsBody> bodiesForThisMod = Main.BodyDict.Values.SelectMany(x => x).Where(x => x.Mod == loadedMod).ToList();
|
||||
@ -178,18 +160,6 @@ namespace NewHorizons.Utility
|
||||
loadedConfigFiles[folder + body.RelativePath] = (body.Config as PlanetConfig);
|
||||
_dpp.FindAndRegisterPropsFromConfig(body.Config);
|
||||
}
|
||||
|
||||
//if (System.IO.Directory.Exists(folder + "planets"))
|
||||
//{
|
||||
// foreach (var file in System.IO.Directory.GetFiles(folder + @"planets\", "*.json", System.IO.SearchOption.AllDirectories))
|
||||
// {
|
||||
// Logger.Log("READING FROM CONFIG @ " + file);
|
||||
// var relativeDirectory = file.Replace(folder, "");
|
||||
// var bodyConfig = loadedMod.ModHelper.Storage.Load<PlanetConfig>(relativeDirectory);
|
||||
// loadedConfigFiles[file] = bodyConfig;
|
||||
// _dpp.FindAndRegisterPropsFromConfig(bodyConfig);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,32 +169,11 @@ namespace NewHorizons.Utility
|
||||
{
|
||||
GUILayout.Label(loadedMod.ModHelper.Manifest.UniqueName);
|
||||
}
|
||||
// workingModName = GUILayout.TextField(workingModName);
|
||||
|
||||
|
||||
|
||||
//GUI.enabled = !propsHaveBeenLoaded && loadedMod != null;
|
||||
//if (GUILayout.Button("Load Detail Props from Configs", GUILayout.ExpandWidth(false)))
|
||||
//{
|
||||
// propsHaveBeenLoaded = true;
|
||||
// var folder = loadedMod.ModHelper.Manifest.ModFolderPath;
|
||||
|
||||
// if (System.IO.Directory.Exists(folder + "planets"))
|
||||
// {
|
||||
// foreach (var file in System.IO.Directory.GetFiles(folder + @"planets\", "*.json", System.IO.SearchOption.AllDirectories))
|
||||
// {
|
||||
// Logger.Log("READING FROM CONFIG @ " + file);
|
||||
// var relativeDirectory = file.Replace(folder, "");
|
||||
// var bodyConfig = loadedMod.ModHelper.Storage.Load<PlanetConfig>(relativeDirectory);
|
||||
// loadedConfigFiles[file] = bodyConfig;
|
||||
// _dpp.FindAndRegisterPropsFromConfig(bodyConfig);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//GUI.enabled = true;
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
// save your work
|
||||
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button(saveButtonUnlocked ? " O " : " | ", GUILayout.ExpandWidth(false)))
|
||||
@ -258,23 +207,17 @@ namespace NewHorizons.Utility
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Print your mod's updated configs"))
|
||||
{
|
||||
UpdateLoadedConfigs();
|
||||
//if (GUILayout.Button("Print your mod's updated configs"))
|
||||
//{
|
||||
// UpdateLoadedConfigs();
|
||||
|
||||
foreach (var filePath in loadedConfigFiles.Keys)
|
||||
{
|
||||
Logger.Log("The updated copy of " + filePath);
|
||||
Logger.Log(Newtonsoft.Json.JsonConvert.SerializeObject(loadedConfigFiles[filePath], Newtonsoft.Json.Formatting.Indented));
|
||||
}
|
||||
// _dpp.PrintConfigs();
|
||||
}
|
||||
|
||||
// TODO: field to provide name of mod to load configs from, plus button to load those into the PropPlaecr (make sure not to load more than once, once the button has been pushed, disable it)
|
||||
// TODO: add a warning that the button cannot be pushed more than once
|
||||
|
||||
// TODO: put a text field here to print all the configs in
|
||||
// TODO: put a button here to save configs to file
|
||||
// foreach (var filePath in loadedConfigFiles.Keys)
|
||||
// {
|
||||
// Logger.Log("The updated copy of " + filePath);
|
||||
// Logger.Log(Newtonsoft.Json.JsonConvert.SerializeObject(loadedConfigFiles[filePath], Newtonsoft.Json.Formatting.Indented));
|
||||
// }
|
||||
// // _dpp.PrintConfigs();
|
||||
//}
|
||||
|
||||
GUILayout.EndArea();
|
||||
}
|
||||
@ -282,20 +225,14 @@ namespace NewHorizons.Utility
|
||||
private void UpdateLoadedConfigs()
|
||||
{
|
||||
// for each keyvalue in _dpp.GetPropsConfigByBody()
|
||||
// find the matching entry loadedConfigFiles
|
||||
// entry matches if the value of AstroOBjectLocator.FindBody(key) matches
|
||||
// find the matching entry loadedConfigFiles
|
||||
// entry matches if the value of AstroOBjectLocator.FindBody(key) matches
|
||||
|
||||
var newDetails = _dpp.GetPropsConfigByBody(true);
|
||||
|
||||
|
||||
//var allConfigsForMod = Main.Instance.BodyDict[Main.CurrentStarSystem].Where(x => x.Mod == mod).Select(x => x.Config)
|
||||
|
||||
//var allConfigs = Main.BodyDict.Values.SelectMany(x => x).Where(x => x.Mod == loadedMod).Select(x => x.Config);
|
||||
|
||||
Logger.Log("updating configs");
|
||||
|
||||
Logger.Log("New Details Counts by planet: " + string.Join(", ", newDetails.Keys.Select(x => x + $" ({newDetails[x].Length})")));
|
||||
Logger.Log("All props: " + _dpp.DEBUG_PrintAllPropLocations());
|
||||
|
||||
// TODO: looks like placing the first prop on a given planet in a given session clears out all existing props on that planet
|
||||
Dictionary<string, string> planetToConfigPath = new Dictionary<string, string>();
|
||||
|
||||
@ -19,20 +19,10 @@ namespace NewHorizons.Utility
|
||||
{
|
||||
public string body;
|
||||
public string system;
|
||||
|
||||
//public string propPath;
|
||||
|
||||
public GameObject gameObject;
|
||||
//public Vector3 pos { get { return gameObject.transform.localPosition; } }
|
||||
//public Vector3 rotation { get { return gameObject.transform.localEulerAngles; } }
|
||||
|
||||
//public string assetBundle;
|
||||
//public string[] removeChildren;
|
||||
|
||||
public DetailInfo detailInfo;
|
||||
}
|
||||
|
||||
// DreamWorld_Body/Sector_DreamWorld/Sector_DreamZone_1/Props_DreamZone_1/OtherComponentsGroup/Trees_Z1/DreamHouseIsland/Tree_DW_M_Var
|
||||
public static readonly string DEFAULT_OBJECT = "BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District1/Props_HangingCity_District1/OtherComponentsGroup/Props_HangingCity_Building_10/Prefab_NOM_VaseThin";
|
||||
|
||||
public string currentObject { get; private set; }
|
||||
@ -60,11 +50,6 @@ namespace NewHorizons.Utility
|
||||
{
|
||||
PlaceObject();
|
||||
}
|
||||
|
||||
//if (Keyboard.current[Key.Semicolon].wasReleasedThisFrame)
|
||||
//{
|
||||
// PrintConfigs();
|
||||
//}
|
||||
|
||||
if (Keyboard.current[Key.Minus].wasReleasedThisFrame)
|
||||
{
|
||||
@ -111,8 +96,6 @@ namespace NewHorizons.Utility
|
||||
|
||||
try
|
||||
{
|
||||
// TODO: if currentObject == "" or null, spawn some generic placeholder instead
|
||||
|
||||
if (currentObject == "" || currentObject == null)
|
||||
{
|
||||
SetCurrentObject(DEFAULT_OBJECT);
|
||||
@ -120,16 +103,12 @@ namespace NewHorizons.Utility
|
||||
|
||||
GameObject prop = DetailBuilder.MakeDetail(data.hitObject, data.hitObject.GetComponentInChildren<Sector>(), currentObject, data.pos, data.norm, 1, false);
|
||||
PropPlacementData propData = RegisterProp_WithReturn(data.bodyName, prop);
|
||||
|
||||
// TODO: rotate around vertical axis to face player
|
||||
//var dirTowardsPlayer = playerAbsolutePosition - prop.transform.position;
|
||||
//dirTowardsPlayer.y = 0;
|
||||
|
||||
// align with surface normal
|
||||
Vector3 alignToSurface = (Quaternion.LookRotation(data.norm) * Quaternion.FromToRotation(Vector3.up, Vector3.forward)).eulerAngles;
|
||||
prop.transform.localEulerAngles = alignToSurface;
|
||||
|
||||
// rotate facing dir
|
||||
// rotate facing dir towards player
|
||||
GameObject g = new GameObject();
|
||||
g.transform.parent = prop.transform.parent;
|
||||
g.transform.localPosition = prop.transform.localPosition;
|
||||
@ -156,14 +135,9 @@ namespace NewHorizons.Utility
|
||||
{
|
||||
AstroObject planet = AstroObjectLocator.GetAstroObject(config.Name);
|
||||
|
||||
//if (planet == null || planet.GetRootSector() == null) return;
|
||||
if (planet == null) return;
|
||||
if (config.Props == null || config.Props.Details == null) return;
|
||||
|
||||
//List<Transform> potentialProps = new List<Transform>();
|
||||
//foreach (Transform child in planet.GetRootSector().transform) potentialProps.Add(child);
|
||||
//potentialProps.Where(potentialProp => potentialProp.gameObject.name.EndsWith("(Clone)")).ToList();
|
||||
|
||||
var bodyName = config.Name;
|
||||
var astroObjectName = AstroObjectLocator.GetAstroObject(bodyName).name;
|
||||
if (astroObjectName.EndsWith("_Body")) astroObjectName = astroObjectName.Substring(0, astroObjectName.Length-"_Body".Length);
|
||||
@ -184,41 +158,6 @@ namespace NewHorizons.Utility
|
||||
{
|
||||
RecentlyPlacedProps.Add(data.detailInfo.path);
|
||||
}
|
||||
|
||||
//var propPathElements = detail.path.Split('/');
|
||||
//string propName = propPathElements[propPathElements.Length-1];
|
||||
|
||||
//potentialProps
|
||||
// .Where(potentialProp => potentialProp.gameObject.name == propName+"(Clone)")
|
||||
// .OrderBy(potentialProp => Vector3.Distance(potentialProp.localPosition, detail.position))
|
||||
// .ToList();
|
||||
|
||||
//if (potentialProps.Count <= 0)
|
||||
//{
|
||||
// Logger.LogError($"No candidate found for prop {detail.path} on planet ${config.Name}.");
|
||||
// continue;
|
||||
//}
|
||||
|
||||
|
||||
//TODO: this probably doesn't work
|
||||
//when saving props loaded from a config to a file (aka, load a config, then place a prop, then save)
|
||||
//all positions of loaded props are 0,0,0
|
||||
|
||||
|
||||
//Transform spawnedProp = potentialProps[0];
|
||||
|
||||
//Logger.Log("Found potential prop " + transform.gameObject.name + " @ " + transform.localPosition + " for " + detail.path);
|
||||
|
||||
//var bodyName = config.Name;
|
||||
//var astroObjectName = AstroObjectLocator.GetAstroObject(bodyName).name;
|
||||
//if (astroObjectName.EndsWith("_Body")) astroObjectName = astroObjectName.Substring(0, astroObjectName.Length-"_Body".Length);
|
||||
//PropPlacementData data = RegisterProp_WithReturn(astroObjectName, spawnedProp.gameObject, detail.path, config.StarSystem, detail);
|
||||
//potentialProps.Remove(spawnedProp);
|
||||
|
||||
//if (!RecentlyPlacedProps.Contains(data.detailInfo.path))
|
||||
//{
|
||||
// RecentlyPlacedProps.Add(data.detailInfo.path);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,67 +194,6 @@ namespace NewHorizons.Utility
|
||||
return data;
|
||||
}
|
||||
|
||||
//public void PrintConfigs()
|
||||
//{
|
||||
// foreach(string configFile in GenerateConfigs())
|
||||
// {
|
||||
// Logger.Log(configFile);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public List<String> GenerateConfigs()
|
||||
//{
|
||||
// var groupedProps = props
|
||||
// .GroupBy(p => AstroObjectLocator.GetAstroObject(p.body).name)
|
||||
// .Select(grp => grp.ToList())
|
||||
// .ToList();
|
||||
|
||||
// List<string> configFiles = new List<string>();
|
||||
|
||||
// foreach (List<PropPlacementData> bodyProps in groupedProps)
|
||||
// {
|
||||
// string configFile =
|
||||
// "{" + Environment.NewLine +
|
||||
// " \"$schema\": \"https://raw.githubusercontent.com/xen-42/outer-wilds-new-horizons/master/NewHorizons/schema.json\"," + Environment.NewLine +
|
||||
// $" \"name\" : \"{bodyProps[0].body}\"," + Environment.NewLine +
|
||||
// " \"Props\" :" + Environment.NewLine +
|
||||
// " {" + Environment.NewLine +
|
||||
// " \"details\": [" + Environment.NewLine;
|
||||
|
||||
// for(int i = 0; i < bodyProps.Count; i++)
|
||||
// {
|
||||
// PropPlacementData prop = bodyProps[i];
|
||||
|
||||
// string positionString = $"\"x\":{prop.pos.x},\"y\":{prop.pos.y},\"z\":{prop.pos.z}";
|
||||
// string rotationString = $"\"x\":{prop.rotation.x},\"y\":{prop.rotation.y},\"z\":{prop.rotation.z}";
|
||||
// string endingString = i == bodyProps.Count-1 ? "" : ",";
|
||||
|
||||
// configFile += " {" +
|
||||
// "\"path\" : \"" +prop.propPath+ "\", " +
|
||||
// "\"position\": {"+positionString+"}, " +
|
||||
// "\"rotation\": {"+rotationString+"}, " +
|
||||
// "\"scale\": 1"+
|
||||
// (prop.assetBundle == null ? "" : $", \"assetBundle\": \"{prop.assetBundle}\"") +
|
||||
// (prop.removeChildren == null ? "" : $", \"removeChildren\": \"[{string.Join(",",prop.removeChildren)}]\"") +
|
||||
// "}" + endingString + Environment.NewLine;
|
||||
// }
|
||||
|
||||
// configFile +=
|
||||
// " ]" + Environment.NewLine +
|
||||
// " }" + Environment.NewLine +
|
||||
// "}";
|
||||
|
||||
// configFiles.Add(configFile);
|
||||
// }
|
||||
|
||||
// return configFiles;
|
||||
//}
|
||||
|
||||
public string DEBUG_PrintAllPropLocations()
|
||||
{
|
||||
return string.Join(", ", props.Select(x => x.system + DebugMenu.separatorCharacter + x.body).ToList());
|
||||
}
|
||||
|
||||
public Dictionary<string, DetailInfo[]> GetPropsConfigByBody(bool useAstroObjectName = false)
|
||||
{
|
||||
var groupedProps = props
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user