mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Basic Version
This commit is contained in:
parent
028ee62987
commit
8b0d38aa01
3
.gitignore
vendored
3
.gitignore
vendored
@ -6,4 +6,5 @@ obj
|
|||||||
zip
|
zip
|
||||||
*.zip
|
*.zip
|
||||||
|
|
||||||
*/Build/*
|
*/Build/*
|
||||||
|
.idea/
|
||||||
|
|||||||
@ -1,17 +1,436 @@
|
|||||||
using NewHorizons.Components;
|
using NewHorizons.Components;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Xml.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using NewHorizons.External;
|
||||||
|
using NewHorizons.Utility;
|
||||||
|
using OWML.Common;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
|
||||||
namespace NewHorizons.Builder.General
|
namespace NewHorizons.Builder.General
|
||||||
{
|
{
|
||||||
public static class ShipLogBuilder
|
public static class ShipLogBuilder
|
||||||
{
|
{
|
||||||
|
public static readonly string PAN_ROOT_PATH = "Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/MapMode/ScaleRoot/PanRoot";
|
||||||
|
|
||||||
public static ShipLogStarChartMode ShipLogStarChartMode;
|
public static ShipLogStarChartMode ShipLogStarChartMode;
|
||||||
|
private static Dictionary<CuriosityName, Color> curiosityColors = new Dictionary<CuriosityName, Color>();
|
||||||
|
private static Dictionary<CuriosityName, Color> curiosityHighlightColors = new Dictionary<CuriosityName, Color>();
|
||||||
|
private static Dictionary<string, CuriosityName> rawNameToCuriosityName = new Dictionary<string, CuriosityName>();
|
||||||
|
private static Dictionary<string, string> entryIdToRawName = new Dictionary<string, string>();
|
||||||
|
private static Dictionary<string, NewHorizonsBody> astroIdToBody = new Dictionary<string, NewHorizonsBody>();
|
||||||
|
|
||||||
|
private class MapModeObject
|
||||||
|
{
|
||||||
|
public int x;
|
||||||
|
public int y;
|
||||||
|
public int branch_width;
|
||||||
|
public int branch_height;
|
||||||
|
public int level;
|
||||||
|
public NewHorizonsBody mainBody;
|
||||||
|
public ShipLogAstroObject astroObject;
|
||||||
|
public List<MapModeObject> children;
|
||||||
|
public MapModeObject parent;
|
||||||
|
public void increment_width()
|
||||||
|
{
|
||||||
|
branch_width++;
|
||||||
|
parent?.increment_width();
|
||||||
|
}
|
||||||
|
public void increment_height()
|
||||||
|
{
|
||||||
|
branch_height++;
|
||||||
|
parent?.increment_height();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string GetAstroBodyShipLogName(string id)
|
||||||
|
{
|
||||||
|
return astroIdToBody[id].Config.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShipLogAstroObject[][] ConstructMapMode(string systemName, GameObject transformParent, int layer)
|
||||||
|
{
|
||||||
|
MapModeObject rootObject = MakePrimaryNode(systemName);
|
||||||
|
if (rootObject.mainBody != null)
|
||||||
|
{
|
||||||
|
CreateAllNodes(ref rootObject, transformParent, layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int maxAmount = 20;
|
||||||
|
ShipLogAstroObject[][] navMatrix = new ShipLogAstroObject[maxAmount][];
|
||||||
|
for (int i = 0; i < maxAmount; i++)
|
||||||
|
{
|
||||||
|
navMatrix[i] = new ShipLogAstroObject[maxAmount];
|
||||||
|
}
|
||||||
|
CreateNavigationMatrix(rootObject, ref navMatrix);
|
||||||
|
navMatrix = navMatrix.Where(a => a.Count(c => c != null) > 0).Prepend(new ShipLogAstroObject[1]).ToArray();
|
||||||
|
for (var index = 0; index < navMatrix.Length; index++)
|
||||||
|
{
|
||||||
|
navMatrix[index] = navMatrix[index].Where(a => a != null).ToArray();
|
||||||
|
}
|
||||||
|
return navMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateNavigationMatrix(MapModeObject root, ref ShipLogAstroObject[][] navMatrix)
|
||||||
|
{
|
||||||
|
if (root.astroObject != null)
|
||||||
|
{
|
||||||
|
navMatrix[root.y][root.x] = root.astroObject;
|
||||||
|
}
|
||||||
|
foreach (MapModeObject child in root.children)
|
||||||
|
{
|
||||||
|
CreateNavigationMatrix(child, ref navMatrix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateAllNodes(ref MapModeObject parentNode, GameObject parent, int layer)
|
||||||
|
{
|
||||||
|
CreateNode(ref parentNode, parent, layer);
|
||||||
|
for (var i = 0; i < parentNode.children.Count; i++)
|
||||||
|
{
|
||||||
|
MapModeObject child = parentNode.children[i];
|
||||||
|
CreateAllNodes(ref child, parent, layer);
|
||||||
|
parentNode.children[i] = child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static GameObject CreateImage(GameObject nodeGO, IModAssets assets, string imagePath, string name, int layer)
|
||||||
|
{
|
||||||
|
GameObject newImageGO = new GameObject(name);
|
||||||
|
newImageGO.layer = layer;
|
||||||
|
newImageGO.transform.SetParent(nodeGO.transform);
|
||||||
|
|
||||||
|
RectTransform transform = newImageGO.AddComponent<RectTransform>();
|
||||||
|
transform.localPosition = Vector3.zero;
|
||||||
|
transform.localRotation = Quaternion.identity;
|
||||||
|
transform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
Image newImage = newImageGO.AddComponent<Image>();
|
||||||
|
if (imagePath == "DEFAULT")
|
||||||
|
{
|
||||||
|
newImage.sprite = Locator.GetShipLogManager()._shipLogLibrary.defaultEntrySprite;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Texture2D newTexture = assets.GetTexture(imagePath);
|
||||||
|
Rect rect = new Rect(0, 0, newTexture.width, newTexture.height);
|
||||||
|
Vector2 pivot = new Vector2(newTexture.width / 2, newTexture.height / 2);
|
||||||
|
newImage.sprite = Sprite.Create(newTexture, rect, pivot);
|
||||||
|
}
|
||||||
|
return newImageGO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T KeyByValue<T, W>(this Dictionary<T, W> dict, W val)
|
||||||
|
{
|
||||||
|
T key = default;
|
||||||
|
foreach (KeyValuePair<T, W> pair in dict)
|
||||||
|
{
|
||||||
|
if (EqualityComparer<W>.Default.Equals(pair.Value, val))
|
||||||
|
{
|
||||||
|
key = pair.Key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetAstroObjectId(NewHorizonsBody body)
|
||||||
|
{
|
||||||
|
return KeyByValue(astroIdToBody, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateAstroObject(GameObject nodeGO, ref MapModeObject node, GameObject referenceUnviewedSprite, int layer)
|
||||||
|
{
|
||||||
|
const float unviewedIconOffset = 15;
|
||||||
|
ShipLogAstroObject astroObject = nodeGO.AddComponent<ShipLogAstroObject>();
|
||||||
|
astroObject._id = GetAstroObjectId(node.mainBody);
|
||||||
|
string imagePath = node.mainBody.Config.ShipLog?.mapMode?.revealedSprite ?? "DEFAULT";
|
||||||
|
string outlinePath = node.mainBody.Config.ShipLog?.mapMode?.outlineSprite ?? imagePath;
|
||||||
|
astroObject._imageObj = CreateImage(nodeGO, node.mainBody.Mod.Assets, imagePath, "Image", layer);
|
||||||
|
astroObject._outlineObj = CreateImage(nodeGO, node.mainBody.Mod.Assets, outlinePath, "Outline", layer);
|
||||||
|
astroObject._unviewedObj = GameObject.Instantiate(referenceUnviewedSprite, nodeGO.transform, false);
|
||||||
|
astroObject._invisibleWhenHidden = node.mainBody.Config.ShipLog?.mapMode?.invisibleWhenHidden ?? false;
|
||||||
|
Rect imageRect = astroObject._imageObj.GetComponent<RectTransform>().rect;
|
||||||
|
astroObject._unviewedObj.transform.localPosition = new Vector3(imageRect.width / 2 + unviewedIconOffset, imageRect.height / 2 + unviewedIconOffset, 0);
|
||||||
|
node.astroObject = astroObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateNode(ref MapModeObject node, GameObject parent, int layer)
|
||||||
|
{
|
||||||
|
const float padding = 250f;
|
||||||
|
|
||||||
|
GameObject newNodeGO = new GameObject(node.mainBody.Config.Name + "_ShipLog");
|
||||||
|
newNodeGO.layer = layer;
|
||||||
|
newNodeGO.transform.SetParent(parent.transform);
|
||||||
|
|
||||||
|
RectTransform transform = newNodeGO.AddComponent<RectTransform>();
|
||||||
|
float scale = node.mainBody.Config.ShipLog?.mapMode?.scale?? 1f;
|
||||||
|
scale = scale <= 0 ? 1f : scale;
|
||||||
|
transform.localPosition = new Vector3(node.x * padding, node.y * padding, 0);
|
||||||
|
transform.localRotation = Quaternion.identity;
|
||||||
|
transform.localScale = Vector3.one * scale;
|
||||||
|
|
||||||
|
if (node.mainBody.Config.ShipLog?.xmlFile == null)
|
||||||
|
{
|
||||||
|
Image newImage = newNodeGO.AddComponent<Image>();
|
||||||
|
string imagePath = node.mainBody.Config.ShipLog?.mapMode?.revealedSprite ?? "DEFAULT";
|
||||||
|
if (imagePath == "DEFAULT")
|
||||||
|
{
|
||||||
|
newImage.sprite = Locator.GetShipLogManager()._shipLogLibrary.defaultEntrySprite;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Texture2D newTexture = node.mainBody.Mod.Assets.GetTexture(imagePath);
|
||||||
|
Rect rect = new Rect(0, 0, newTexture.width, newTexture.height);
|
||||||
|
Vector2 pivot = new Vector2(newTexture.width / 2, newTexture.height / 2);
|
||||||
|
newImage.sprite = Sprite.Create(newTexture, rect, pivot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CreateAstroObject(newNodeGO, ref node, GameObject.Find(PAN_ROOT_PATH + "/TimberHearth/UnviewedIcon"), layer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MapModeObject MakePrimaryNode(string systemName)
|
||||||
|
{
|
||||||
|
foreach (NewHorizonsBody body in Main.BodyDict[systemName])
|
||||||
|
{
|
||||||
|
if (!body.Config.Base.CenterOfSolarSystem) continue;
|
||||||
|
MapModeObject newNode = new MapModeObject
|
||||||
|
{
|
||||||
|
mainBody = body,
|
||||||
|
level = 0,
|
||||||
|
x = 0,
|
||||||
|
y = 0
|
||||||
|
};
|
||||||
|
newNode.children = MakeChildrenNodes(systemName, newNode);
|
||||||
|
return newNode;
|
||||||
|
}
|
||||||
|
Logger.LogError("Couldn't find center of system!");
|
||||||
|
return new MapModeObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<MapModeObject> MakeChildrenNodes(string systemName, MapModeObject parent)
|
||||||
|
{
|
||||||
|
List<MapModeObject> children = new List<MapModeObject>();
|
||||||
|
int newX = parent.x;
|
||||||
|
int newY = parent.y;
|
||||||
|
foreach (NewHorizonsBody body in Main.BodyDict[systemName])
|
||||||
|
{
|
||||||
|
if (body.Config.Orbit.PrimaryBody == parent.mainBody.Config.Name)
|
||||||
|
{
|
||||||
|
int newLevel = parent.level + 1;
|
||||||
|
bool even = newLevel % 2 == 0;
|
||||||
|
newX = even ? newX : newX + 1;
|
||||||
|
newY = even ? newY + 1 : newY;
|
||||||
|
MapModeObject newNode = new MapModeObject()
|
||||||
|
{
|
||||||
|
mainBody = body,
|
||||||
|
level = newLevel,
|
||||||
|
x = newX,
|
||||||
|
y = newY,
|
||||||
|
parent=parent
|
||||||
|
};
|
||||||
|
newNode.children = MakeChildrenNodes(systemName, newNode);
|
||||||
|
if (even)
|
||||||
|
{
|
||||||
|
newY += newNode.branch_height;
|
||||||
|
parent.increment_height();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newX += newNode.branch_width;
|
||||||
|
parent.increment_width();
|
||||||
|
}
|
||||||
|
children.Add(newNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddCuriosityColors(ShipLogModule.CuriosityColor[] newColors)
|
||||||
|
{
|
||||||
|
foreach (ShipLogModule.CuriosityColor newColor in newColors)
|
||||||
|
{
|
||||||
|
if (rawNameToCuriosityName.ContainsKey(newColor.id) == false)
|
||||||
|
{
|
||||||
|
CuriosityName newName = (CuriosityName) 8 + rawNameToCuriosityName.Count;
|
||||||
|
rawNameToCuriosityName.Add(newColor.id, newName);
|
||||||
|
curiosityColors.Add(newName, newColor.color.ToColor());
|
||||||
|
curiosityHighlightColors.Add(newName, newColor.highlightColor.ToColor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Color GetCuriosityColor(CuriosityName curiosityName, bool highlighted, Color defaultColor, Color defaultHighlight)
|
||||||
|
{
|
||||||
|
if (curiosityColors.ContainsKey(curiosityName) && curiosityHighlightColors.ContainsKey(curiosityName))
|
||||||
|
{
|
||||||
|
return (highlighted ? curiosityHighlightColors : curiosityColors)[curiosityName];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return highlighted? defaultHighlight : defaultColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AddAstroBodyToShipLog(ShipLogManager manager, NewHorizonsBody body)
|
||||||
|
{
|
||||||
|
string systemName = body.Config.StarSystem;
|
||||||
|
XElement astroBodyFile = XElement.Load(Main.Instance.ModHelper.Manifest.ModFolderPath + body.Config.ShipLog.xmlFile);
|
||||||
|
XElement astroBodyId = astroBodyFile.Element("ID");
|
||||||
|
if (astroBodyId == null)
|
||||||
|
{
|
||||||
|
Logger.LogError("Failed to load ship log for " + systemName + "!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
astroBodyId.SetValue(systemName + "/" + astroBodyId.Value);
|
||||||
|
foreach (XElement entryElement in astroBodyFile.DescendantsAndSelf("Entry"))
|
||||||
|
{
|
||||||
|
XElement curiosityName = entryElement.Element("Curiosity");
|
||||||
|
XElement id = entryElement.Element("ID");
|
||||||
|
if (curiosityName != null && id != null && entryIdToRawName.ContainsKey(id.Value) == false)
|
||||||
|
{
|
||||||
|
entryIdToRawName.Add(id.Value, curiosityName.Value);
|
||||||
|
}
|
||||||
|
AddTranslation(entryElement);
|
||||||
|
}
|
||||||
|
TextAsset newAsset = new TextAsset(astroBodyFile.ToString());
|
||||||
|
List<TextAsset> newBodies = new List<TextAsset>(manager._shipLogXmlAssets) {newAsset};
|
||||||
|
manager._shipLogXmlAssets = newBodies.ToArray();
|
||||||
|
if (astroIdToBody.ContainsKey(astroBodyId.Value) == false)
|
||||||
|
{
|
||||||
|
astroIdToBody.Add(astroBodyId.Value, body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AddTranslation(XElement entry)
|
||||||
|
{
|
||||||
|
Dictionary<string, string> table = TextTranslation.Get().m_table.theShipLogTable;
|
||||||
|
XElement nameElement = entry.Element("Name");
|
||||||
|
if (nameElement != null)
|
||||||
|
{
|
||||||
|
string name = nameElement.Value;
|
||||||
|
table[name] = name;
|
||||||
|
foreach (XElement rumorFact in entry.Elements("RumorFact"))
|
||||||
|
{
|
||||||
|
XElement rumorName = rumorFact.Element("RumorName");
|
||||||
|
if (rumorName != null)
|
||||||
|
{
|
||||||
|
table[rumorName.Value] = rumorName.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
XElement rumorText = rumorFact.Element("Text");
|
||||||
|
if (rumorText != null)
|
||||||
|
{
|
||||||
|
table[name + rumorText.Value] = rumorText.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (XElement exploreFact in entry.Elements("ExploreFact"))
|
||||||
|
{
|
||||||
|
XElement exploreText = exploreFact.Element("Text");
|
||||||
|
if (exploreText != null)
|
||||||
|
{
|
||||||
|
table[name + exploreText.Value] = exploreText.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void UpdateEntryCuriosity(ref ShipLogEntry entry)
|
||||||
|
{
|
||||||
|
if (entryIdToRawName.ContainsKey(entry._id))
|
||||||
|
{
|
||||||
|
entry._curiosity = rawNameToCuriosityName[entryIdToRawName[entry._id]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Sprite GetSprite(string entryId, NewHorizonsBody body)
|
||||||
|
{
|
||||||
|
IModAssets assets = body.Mod.Assets;
|
||||||
|
string path = body.Config.ShipLog.spriteFolder + "/" + entryId + ".png";
|
||||||
|
if (File.Exists(Main.Instance.ModHelper.Manifest.ModFolderPath + path))
|
||||||
|
{
|
||||||
|
Texture2D newTexture = assets.GetTexture(path);
|
||||||
|
Rect rect = new Rect(0, 0, newTexture.width, newTexture.height);
|
||||||
|
Vector2 pivot = new Vector2(newTexture.width / 2, newTexture.height / 2);
|
||||||
|
return Sprite.Create(newTexture, rect, pivot);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Locator.GetShipLogManager()._shipLogLibrary.defaultEntrySprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static NewHorizonsBody GetConfigFromEntry(ShipLogEntry entry)
|
||||||
|
{
|
||||||
|
return astroIdToBody[entry._astroObjectID];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Vector2? FindPosition(string entryId, ShipLogModule config)
|
||||||
|
{
|
||||||
|
if (config.positions == null) return null;
|
||||||
|
foreach (ShipLogModule.EntryPosition position in config.positions)
|
||||||
|
{
|
||||||
|
if (position.id == entryId)
|
||||||
|
{
|
||||||
|
return position.position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void GenerateEntryData(ShipLogManager manager)
|
||||||
|
{
|
||||||
|
const int step = 400;
|
||||||
|
int colAccumulator = 0;
|
||||||
|
int rowAccumulator = 0;
|
||||||
|
foreach(ShipLogEntry entry in manager._entryList)
|
||||||
|
{
|
||||||
|
if (manager._entryDataDict.ContainsKey(entry._id) == false)
|
||||||
|
{
|
||||||
|
NewHorizonsBody body = GetConfigFromEntry(entry);
|
||||||
|
Vector2? manualEntryPosition = FindPosition(entry._id, body.Config.ShipLog);
|
||||||
|
Vector2 entryPosition;
|
||||||
|
if (manualEntryPosition == null)
|
||||||
|
{
|
||||||
|
entryPosition = new Vector2(colAccumulator, rowAccumulator);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entryPosition = (Vector2) manualEntryPosition;
|
||||||
|
}
|
||||||
|
EntryData newData = new EntryData
|
||||||
|
{
|
||||||
|
id = entry._id,
|
||||||
|
cardPosition = entryPosition,
|
||||||
|
sprite = body.Config.ShipLog.spriteFolder == null? null : GetSprite(entry._id, body)
|
||||||
|
};
|
||||||
|
entry.SetSprite(newData.sprite == null? manager._shipLogLibrary.defaultEntrySprite : newData.sprite);
|
||||||
|
manager._entryDataDict.Add(entry._id, newData);
|
||||||
|
int index = manager._entryList.IndexOf(entry);
|
||||||
|
if (index < manager._entryList.Count - 2 && manager._entryList[index + 1]._astroObjectID != entry._astroObjectID)
|
||||||
|
{
|
||||||
|
rowAccumulator += step;
|
||||||
|
colAccumulator = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
colAccumulator += step;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
|||||||
1
NewHorizons/External/IPlanetConfig.cs
vendored
1
NewHorizons/External/IPlanetConfig.cs
vendored
@ -20,6 +20,7 @@ namespace NewHorizons.External
|
|||||||
StarModule Star { get; }
|
StarModule Star { get; }
|
||||||
FocalPointModule FocalPoint { get; }
|
FocalPointModule FocalPoint { get; }
|
||||||
PropModule Props { get; }
|
PropModule Props { get; }
|
||||||
|
ShipLogModule ShipLog { get; }
|
||||||
SpawnModule Spawn { get; }
|
SpawnModule Spawn { get; }
|
||||||
SignalModule Signal { get; }
|
SignalModule Signal { get; }
|
||||||
SingularityModule Singularity { get; }
|
SingularityModule Singularity { get; }
|
||||||
|
|||||||
1
NewHorizons/External/PlanetConfig.cs
vendored
1
NewHorizons/External/PlanetConfig.cs
vendored
@ -23,6 +23,7 @@ namespace NewHorizons.External
|
|||||||
public StarModule Star { get; set; }
|
public StarModule Star { get; set; }
|
||||||
public FocalPointModule FocalPoint { get; set; }
|
public FocalPointModule FocalPoint { get; set; }
|
||||||
public PropModule Props { get; set; }
|
public PropModule Props { get; set; }
|
||||||
|
public ShipLogModule ShipLog { get; set; }
|
||||||
public SpawnModule Spawn { get; set; }
|
public SpawnModule Spawn { get; set; }
|
||||||
public SignalModule Signal { get; set; }
|
public SignalModule Signal { get; set; }
|
||||||
public SingularityModule Singularity { get; set; }
|
public SingularityModule Singularity { get; set; }
|
||||||
|
|||||||
34
NewHorizons/External/ShipLogModule.cs
vendored
Normal file
34
NewHorizons/External/ShipLogModule.cs
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using NewHorizons.Utility;
|
||||||
|
|
||||||
|
namespace NewHorizons.External
|
||||||
|
{
|
||||||
|
public class ShipLogModule : Module
|
||||||
|
{
|
||||||
|
public string xmlFile;
|
||||||
|
public string spriteFolder;
|
||||||
|
public MapMode mapMode;
|
||||||
|
public CuriosityColor[] curiosities;
|
||||||
|
public EntryPosition[] positions;
|
||||||
|
|
||||||
|
public class MapMode
|
||||||
|
{
|
||||||
|
public string revealedSprite;
|
||||||
|
public string outlineSprite;
|
||||||
|
public float scale;
|
||||||
|
public bool invisibleWhenHidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CuriosityColor
|
||||||
|
{
|
||||||
|
public string id;
|
||||||
|
public MColor color;
|
||||||
|
public MColor highlightColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EntryPosition
|
||||||
|
{
|
||||||
|
public string id;
|
||||||
|
public MVector2 position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,12 +12,13 @@ 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;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Epic.OnlineServices;
|
||||||
|
using PacificEngine.OW_CommonResources.Game.Player;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@ -50,6 +51,35 @@ namespace NewHorizons
|
|||||||
return new NewHorizonsApi();
|
return new NewHorizonsApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
GUILayout.BeginArea(new Rect(0, 0, 100, 100));
|
||||||
|
bool learnPress = GUILayout.Button("Learn Thing");
|
||||||
|
if (learnPress)
|
||||||
|
{
|
||||||
|
Locator.GetShipLogManager().RevealFact("COOL_ROCK_R1", false, true);
|
||||||
|
Locator.GetShipLogManager().RevealFact("COOL_ROCK_R2", false, true);
|
||||||
|
Locator.GetShipLogManager().RevealFact("UNCOOL_ROCK_R1", false, true);
|
||||||
|
Locator.GetShipLogManager().RevealFact("UNCOOL_ROCK_R2", false, true);
|
||||||
|
Locator.GetShipLogManager().RevealFact("UNCOOL_ROCK_R3", false, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool iRemem = GUILayout.Button("I Remem");
|
||||||
|
if (iRemem)
|
||||||
|
{
|
||||||
|
Data.knowAllFacts = true;
|
||||||
|
Data.knowAllRumors = true;
|
||||||
|
}
|
||||||
|
bool forgorPress = GUILayout.Button("I Forgor");
|
||||||
|
if (forgorPress)
|
||||||
|
{
|
||||||
|
Data.knowAllFacts = false;
|
||||||
|
Data.knowAllRumors = false;
|
||||||
|
}
|
||||||
|
GUILayout.EndArea();
|
||||||
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectView>ProjectFiles</ProjectView>
|
<ProjectView>ProjectFiles</ProjectView>
|
||||||
<OutputPath>$(AppData)\OuterWildsModManager\OWML\Mods\xen.NewHorizons</OutputPath>
|
<OutputPath>$(AppData)\OuterWildsModManager\OWML\Mods\xen.NewHorizons</OutputPath>
|
||||||
<OuterWildsModsDirectory>$(AppData)\OuterWildsModManager\OWML\Mods</OuterWildsModsDirectory>
|
<OuterWildsModsDirectory>$(AppData)\OuterWildsModManager\OWML\Mods</OuterWildsModsDirectory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@ -5,11 +5,17 @@ using NewHorizons.External;
|
|||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using Harmony;
|
||||||
|
using NewHorizons.Utility;
|
||||||
|
using OWML.Utils;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace NewHorizons.Tools
|
namespace NewHorizons.Tools
|
||||||
{
|
{
|
||||||
@ -41,9 +47,11 @@ namespace NewHorizons.Tools
|
|||||||
var playerDataLearnFrequency = typeof(PlayerData).GetMethod("LearnFrequency");
|
var playerDataLearnFrequency = typeof(PlayerData).GetMethod("LearnFrequency");
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataLearnFrequency, typeof(Patches), nameof(Patches.OnPlayerDataLearnFrequency));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataLearnFrequency, typeof(Patches), nameof(Patches.OnPlayerDataLearnFrequency));
|
||||||
var playerDataKnowsMultipleFrequencies = typeof(PlayerData).GetMethod("KnowsMultipleFrequencies");
|
var playerDataKnowsMultipleFrequencies = typeof(PlayerData).GetMethod("KnowsMultipleFrequencies");
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataKnowsMultipleFrequencies, typeof(Patches), nameof(Patches.OnPlayerDataKnowsMultipleFrequencies));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix(playerDataKnowsMultipleFrequencies, typeof(Patches), nameof(Patches.OnPlayerDataKnowsMultipleFrequencies));
|
||||||
var playerDataResetGame = typeof(PlayerData).GetMethod("ResetGame");
|
var playerDataResetGame = typeof(PlayerData).GetMethod("ResetGame");
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix(playerDataResetGame, typeof(Patches), nameof(Patches.OnPlayerDataResetGame));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix(playerDataResetGame, typeof(Patches), nameof(Patches.OnPlayerDataResetGame));
|
||||||
|
var playerDataGetNewlyRevealedFactIDs = typeof(PlayerData).GetMethod("GetNewlyRevealedFactIDs");
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix(playerDataGetNewlyRevealedFactIDs, typeof(Patches), nameof(Patches.OnPlayerDataGetNewlyRevealedFactIDsComplete));
|
||||||
|
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<BlackHoleVolume>("Start", typeof(Patches), nameof(Patches.OnBlackHoleVolumeStart));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<BlackHoleVolume>("Start", typeof(Patches), nameof(Patches.OnBlackHoleVolumeStart));
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<WhiteHoleVolume>("Awake", typeof(Patches), nameof(Patches.OnWhiteHoleVolumeAwake));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<WhiteHoleVolume>("Awake", typeof(Patches), nameof(Patches.OnWhiteHoleVolumeAwake));
|
||||||
@ -51,12 +59,30 @@ namespace NewHorizons.Tools
|
|||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SurveyorProbe>("IsLaunched", typeof(Patches), nameof(Patches.OnSurveyorProbeIsLaunched));
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<SurveyorProbe>("IsLaunched", typeof(Patches), nameof(Patches.OnSurveyorProbeIsLaunched));
|
||||||
|
|
||||||
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<ShipLogManager>("Awake", typeof(Patches), nameof(Patches.OnShipLogManagerAwake));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogManager>("IsFactRevealed", typeof(Patches), nameof(Patches.OnShipLogManagerIsFactRevealed));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogManager>("CheckForCompletionAchievement", typeof(Patches), nameof(Patches.OnShipLogManagerCheckForCompletionAchievement));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogManager>("RevealFact", typeof(Patches), nameof(Patches.OnShipLogManagerRevealFact));
|
||||||
|
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<UIStyleManager>("GetCuriosityColor", typeof(Patches), nameof(Patches.OnUIStyleManagerGetCuriosityColor));
|
||||||
|
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogMapMode>("Initialize", typeof(Patches), nameof(Patches.OnShipLogMapModeInitialize));
|
||||||
|
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogSandFunnel>("Awake", typeof(Patches), nameof(Patches.DisableShipLogSandFunnel));
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogSandFunnel>("UpdateState", typeof(Patches), nameof(Patches.DisableShipLogSandFunnel));
|
||||||
|
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogAstroObject>("GetName", typeof(Patches), nameof(Patches.OnShipLogAstroObjectGetName));
|
||||||
|
|
||||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipCockpitController>("Update", typeof(Patches), nameof(Patches.OnShipCockpitControllerUpdate));
|
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<ShipLogMapMode>("EnterMode", typeof(Patches), nameof(Patches.OnShipLogMapModeEnterMode));
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogMapMode>("EnterMode", typeof(Patches), nameof(Patches.OnShipLogMapModeEnterMode));
|
||||||
|
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogManager>("Awake", typeof(Patches), nameof(Patches.OnShipLogManagerAwakeComplete));
|
||||||
|
|
||||||
|
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogMapMode>("Initialize", typeof(Patches), nameof(Patches.OnShipLogMapModeInitializeComplete));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool GetHUDDisplayName(ReferenceFrame __instance, ref string __result)
|
public static bool GetHUDDisplayName(ReferenceFrame __instance, ref string __result)
|
||||||
@ -398,6 +424,155 @@ namespace NewHorizons.Tools
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region ShipLog
|
||||||
|
public static void OnShipLogManagerAwake(ShipLogManager __instance)
|
||||||
|
{
|
||||||
|
Logger.Log("Beginning Ship Log Generation For: " + Main.Instance.CurrentStarSystem, Logger.LogType.Log);
|
||||||
|
if (Main.Instance.CurrentStarSystem != "SolarSystem")
|
||||||
|
{
|
||||||
|
__instance._shipLogXmlAssets = new TextAsset[] {};
|
||||||
|
foreach (ShipLogEntryLocation logEntryLocation in GameObject.FindObjectsOfType<ShipLogEntryLocation>())
|
||||||
|
{
|
||||||
|
logEntryLocation._initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
||||||
|
{
|
||||||
|
if (body.Config.ShipLog?.curiosities != null)
|
||||||
|
{
|
||||||
|
ShipLogBuilder.AddCuriosityColors(body.Config.ShipLog.curiosities);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
||||||
|
{
|
||||||
|
if (body.Config.ShipLog?.xmlFile != null)
|
||||||
|
{
|
||||||
|
ShipLogBuilder.AddAstroBodyToShipLog(__instance, body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnShipLogManagerAwakeComplete(ShipLogManager __instance)
|
||||||
|
{
|
||||||
|
ShipLogBuilder.GenerateEntryData(__instance);
|
||||||
|
for (var i = 0; i < __instance._entryList.Count; i++)
|
||||||
|
{
|
||||||
|
ShipLogEntry logEntry = __instance._entryList[i];
|
||||||
|
ShipLogBuilder.UpdateEntryCuriosity(ref logEntry);
|
||||||
|
}
|
||||||
|
Logger.Log("Ship Log Generation Complete For: " + Main.Instance.CurrentStarSystem, Logger.LogType.Log);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnShipLogManagerIsFactRevealed(ShipLogManager __instance, ref bool __result, string __0)
|
||||||
|
{
|
||||||
|
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (__instance._factDict.ContainsKey(__0) == false)
|
||||||
|
{
|
||||||
|
__result = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnShipLogManagerCheckForCompletionAchievement()
|
||||||
|
{
|
||||||
|
return Main.Instance.CurrentStarSystem == "SolarSystem";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnShipLogManagerRevealFact(string __0)
|
||||||
|
{
|
||||||
|
if (Main.Instance.CurrentStarSystem != "SolarSystem" && __0 == "TH_VILLAGE_X1")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnUIStyleManagerGetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result)
|
||||||
|
{
|
||||||
|
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__result = ShipLogBuilder.GetCuriosityColor(__0, __1, __instance._neutralColor, __instance._neutralHighlight);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DeleteDetail(string name)
|
||||||
|
{
|
||||||
|
Object.Destroy(GameObject.Find(ShipLogBuilder.PAN_ROOT_PATH + "/" + name));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnShipLogMapModeInitialize(ShipLogMapMode __instance)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnShipLogMapModeInitializeComplete(ShipLogMapMode __instance)
|
||||||
|
{
|
||||||
|
if (Main.Instance.CurrentStarSystem != "SolarSystem")
|
||||||
|
{
|
||||||
|
GameObject panRoot = GameObject.Find(ShipLogBuilder.PAN_ROOT_PATH);
|
||||||
|
GameObject sunObject = GameObject.Find(ShipLogBuilder.PAN_ROOT_PATH + "/Sun");
|
||||||
|
ShipLogAstroObject[][] navMatrix = ShipLogBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, sunObject.layer);
|
||||||
|
if (navMatrix.Length <= 1)
|
||||||
|
{
|
||||||
|
Logger.LogWarning("No planets suitable for map mode found! Defaulting to vanilla menu (expect weirdness!).");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__instance._astroObjects = navMatrix;
|
||||||
|
__instance._startingAstroObjectID = navMatrix[1][0].GetID();
|
||||||
|
List<GameObject> delete = SearchUtilities.GetAllChildren(panRoot).Where(g => g.name.Contains("_ShipLog") == false).ToList();
|
||||||
|
foreach (GameObject gameObject in delete)
|
||||||
|
{
|
||||||
|
DeleteDetail(gameObject.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Logger.Log("Map Mode Construction Complete", Logger.LogType.Log);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool OnShipLogAstroObjectGetName(ShipLogAstroObject __instance, ref string __result)
|
||||||
|
{
|
||||||
|
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
__result = ShipLogBuilder.GetAstroBodyShipLogName(__instance.GetID());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool DisableShipLogSandFunnel()
|
||||||
|
{
|
||||||
|
return Main.Instance.CurrentStarSystem == "SolarSystem";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void OnPlayerDataGetNewlyRevealedFactIDsComplete(ref List<string> __result)
|
||||||
|
{
|
||||||
|
ShipLogManager manager = Locator.GetShipLogManager();
|
||||||
|
__result = __result.Where(e => manager.GetFact(e) != null).ToList();
|
||||||
|
}
|
||||||
|
# endregion
|
||||||
|
|
||||||
public static void OnShipLogMapModeEnterMode(ShipLogMapMode __instance)
|
public static void OnShipLogMapModeEnterMode(ShipLogMapMode __instance)
|
||||||
{
|
{
|
||||||
|
|||||||
26
NewHorizons/Utility/MVector2.cs
Normal file
26
NewHorizons/Utility/MVector2.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NewHorizons.Utility
|
||||||
|
{
|
||||||
|
public class MVector2
|
||||||
|
{
|
||||||
|
public MVector2(float x, float y)
|
||||||
|
{
|
||||||
|
X = x;
|
||||||
|
Y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float X { get; }
|
||||||
|
public float Y { get; }
|
||||||
|
|
||||||
|
public static implicit operator MVector2(Vector2 vec)
|
||||||
|
{
|
||||||
|
return new MVector2(vec.x, vec.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static implicit operator Vector2(MVector2 vec)
|
||||||
|
{
|
||||||
|
return new Vector2(vec.X, vec.Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -72,5 +72,15 @@ namespace NewHorizons.Utility
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<GameObject> GetAllChildren(GameObject parent)
|
||||||
|
{
|
||||||
|
List<GameObject> children = new List<GameObject>();
|
||||||
|
foreach (Transform child in parent.transform)
|
||||||
|
{
|
||||||
|
children.Add(child.gameObject);
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user