mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
commit
094f304d39
@ -15,82 +15,51 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
{
|
{
|
||||||
public static class MapModeBuilder
|
public static class MapModeBuilder
|
||||||
{
|
{
|
||||||
private class MapModeObject
|
#region General
|
||||||
|
public static ShipLogAstroObject[][] ConstructMapMode(string systemName, GameObject transformParent, ShipLogAstroObject[][] currentNav, int layer)
|
||||||
{
|
{
|
||||||
public int x;
|
Material greyScaleMaterial = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/Sprite").GetComponent<Image>().material;
|
||||||
public int y;
|
List<NewHorizonsBody> bodies = Main.BodyDict[systemName].Where(b => (b.Config.ShipLog?.mapMode?.remove ?? false) == false).ToList();
|
||||||
public int branch_width;
|
bool flagManualPositionUsed = systemName == "SolarSystem";
|
||||||
public int branch_height;
|
bool flagAutoPositionUsed = false;
|
||||||
public int level;
|
foreach (NewHorizonsBody body in bodies.Where(b => ShipLogHandler.IsVanillaBody(b) == false))
|
||||||
public NewHorizonsBody mainBody;
|
|
||||||
public ShipLogAstroObject astroObject;
|
|
||||||
public List<MapModeObject> children;
|
|
||||||
public MapModeObject parent;
|
|
||||||
public MapModeObject lastSibling;
|
|
||||||
public void Increment_width()
|
|
||||||
{
|
{
|
||||||
branch_width++;
|
if (body.Config.ShipLog?.mapMode?.manualPosition == null)
|
||||||
parent?.Increment_width();
|
{
|
||||||
|
flagAutoPositionUsed = true;
|
||||||
}
|
}
|
||||||
public void Increment_height()
|
else
|
||||||
{
|
{
|
||||||
branch_height++;
|
flagManualPositionUsed = true;
|
||||||
parent?.Increment_height();
|
if (body.Config.ShipLog?.mapMode?.manualNavigationPosition == null)
|
||||||
|
{
|
||||||
|
Logger.LogError("Navigation position is missing for: " + body.Config.Name);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flagAutoPositionUsed && flagManualPositionUsed)
|
||||||
|
{
|
||||||
|
Logger.LogError("Can't mix manual and automatic layout of ship log map mode, skipping generation");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else if (flagAutoPositionUsed)
|
||||||
|
{
|
||||||
|
return ConstructMapModeAuto(bodies, transformParent, greyScaleMaterial, layer);
|
||||||
|
}
|
||||||
|
else if (flagManualPositionUsed)
|
||||||
|
{
|
||||||
|
return ConstructMapModeManual(bodies, transformParent, greyScaleMaterial, currentNav, layer);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetAstroBodyShipLogName(string id)
|
public static string GetAstroBodyShipLogName(string id)
|
||||||
{
|
{
|
||||||
return ShipLogHandler.GetConfigFromID(id)?.Config?.Name ?? id;
|
return ShipLogHandler.GetConfigFromID(id)?.Config?.Name ?? id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ShipLogAstroObject[][] ConstructMapMode(string systemName, GameObject transformParent, int layer)
|
|
||||||
{
|
|
||||||
MapModeObject rootObject = ConstructPrimaryNode(systemName);
|
|
||||||
if (rootObject.mainBody != null)
|
|
||||||
{
|
|
||||||
MakeAllNodes(ref rootObject, transformParent, layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
int maxAmount = Main.BodyDict[Main.Instance.CurrentStarSystem].Count;
|
|
||||||
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 MakeAllNodes(ref MapModeObject parentNode, GameObject parent, int layer)
|
|
||||||
{
|
|
||||||
MakeNode(ref parentNode, parent, layer);
|
|
||||||
for (var i = 0; i < parentNode.children.Count; i++)
|
|
||||||
{
|
|
||||||
MapModeObject child = parentNode.children[i];
|
|
||||||
MakeAllNodes(ref child, parent, layer);
|
|
||||||
parentNode.children[i] = child;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static GameObject CreateImage(GameObject nodeGO, IModAssets assets, string imagePath, string name, int layer)
|
private static GameObject CreateImage(GameObject nodeGO, IModAssets assets, string imagePath, string name, int layer)
|
||||||
{
|
{
|
||||||
GameObject newImageGO = new GameObject(name);
|
GameObject newImageGO = new GameObject(name);
|
||||||
@ -117,33 +86,314 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
return newImageGO;
|
return newImageGO;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CreateShipLogAstroObject(GameObject nodeGO, ref MapModeObject node, GameObject referenceUnviewedSprite, int layer)
|
private static GameObject CreateMapModeGameObject(NewHorizonsBody body, GameObject parent, int layer, Vector2 position)
|
||||||
|
{
|
||||||
|
GameObject newGameObject = new GameObject(body.Config.Name + "_ShipLog");
|
||||||
|
newGameObject.layer = layer;
|
||||||
|
newGameObject.transform.SetParent(parent.transform);
|
||||||
|
|
||||||
|
RectTransform transform = newGameObject.AddComponent<RectTransform>();
|
||||||
|
float scale = body.Config.ShipLog?.mapMode?.scale ?? 1f;
|
||||||
|
transform.localPosition = position;
|
||||||
|
transform.localRotation = Quaternion.identity;
|
||||||
|
transform.localScale = Vector3.one * scale;
|
||||||
|
transform.SetAsFirstSibling();
|
||||||
|
return newGameObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ShipLogAstroObject AddShipLogAstroObject(GameObject gameObject, NewHorizonsBody body, Material greyScaleMaterial, int layer)
|
||||||
{
|
{
|
||||||
const float unviewedIconOffset = 15;
|
const float unviewedIconOffset = 15;
|
||||||
ShipLogAstroObject astroObject = nodeGO.AddComponent<ShipLogAstroObject>();
|
|
||||||
astroObject._id = ShipLogHandler.GetAstroObjectId(node.mainBody);
|
|
||||||
|
|
||||||
string imagePath = node.mainBody.Config.ShipLog?.mapMode?.revealedSprite ?? "DEFAULT";
|
GameObject unviewedReference = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/UnviewedIcon");
|
||||||
string outlinePath = node.mainBody.Config.ShipLog?.mapMode?.outlineSprite ?? imagePath;
|
|
||||||
astroObject._imageObj = CreateImage(nodeGO, node.mainBody.Mod.Assets, imagePath, node.mainBody.Config.Name + " Revealed", layer);
|
|
||||||
astroObject._outlineObj = CreateImage(nodeGO, node.mainBody.Mod.Assets, outlinePath, node.mainBody.Config.Name + " Outline", layer);
|
|
||||||
|
|
||||||
astroObject._unviewedObj = Object.Instantiate(referenceUnviewedSprite, nodeGO.transform, false);
|
ShipLogAstroObject astroObject = gameObject.AddComponent<ShipLogAstroObject>();
|
||||||
if (node.mainBody.Config.FocalPoint != null)
|
astroObject._id = ShipLogHandler.GetAstroObjectId(body);
|
||||||
|
|
||||||
|
string imagePath = body.Config.ShipLog?.mapMode?.revealedSprite ?? "DEFAULT";
|
||||||
|
string outlinePath = body.Config.ShipLog?.mapMode?.outlineSprite ?? imagePath;
|
||||||
|
astroObject._imageObj = CreateImage(gameObject, body.Mod.Assets, imagePath, body.Config.Name + " Revealed", layer);
|
||||||
|
if (ShipLogHandler.BodyHasEntries(body))
|
||||||
{
|
{
|
||||||
astroObject._imageObj.GetComponent<Image>().enabled = false;
|
Image revealedImage = astroObject._imageObj.GetComponent<Image>();
|
||||||
astroObject._outlineObj.GetComponent<Image>().enabled = false;
|
astroObject._greyscaleMaterial = greyScaleMaterial;
|
||||||
astroObject._unviewedObj.GetComponent<Image>().enabled = false;
|
revealedImage.material = greyScaleMaterial;
|
||||||
astroObject.transform.localScale = node.lastSibling.astroObject.transform.localScale;
|
revealedImage.color = Color.white;
|
||||||
|
astroObject._image = revealedImage;
|
||||||
}
|
}
|
||||||
astroObject._invisibleWhenHidden = node.mainBody.Config.ShipLog?.mapMode?.invisibleWhenHidden ?? false;
|
astroObject._outlineObj = CreateImage(gameObject, body.Mod.Assets, outlinePath, body.Config.Name + " Outline", layer);
|
||||||
|
|
||||||
|
astroObject._unviewedObj = Object.Instantiate(unviewedReference, gameObject.transform, false);
|
||||||
|
astroObject._invisibleWhenHidden = body.Config.ShipLog?.mapMode?.invisibleWhenHidden ?? false;
|
||||||
|
|
||||||
Rect imageRect = astroObject._imageObj.GetComponent<RectTransform>().rect;
|
Rect imageRect = astroObject._imageObj.GetComponent<RectTransform>().rect;
|
||||||
astroObject._unviewedObj.transform.localPosition = new Vector3(imageRect.width / 2 + unviewedIconOffset, imageRect.height / 2 + unviewedIconOffset, 0);
|
astroObject._unviewedObj.transform.localPosition = new Vector3(imageRect.width / 2 + unviewedIconOffset, imageRect.height / 2 + unviewedIconOffset, 0);
|
||||||
node.astroObject = astroObject;
|
return astroObject;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
# region Details
|
||||||
|
private static void MakeDetail(ShipLogModule.ShipLogDetailInfo info, Transform parent, IModAssets assets, Material greyScaleMaterial)
|
||||||
|
{
|
||||||
|
GameObject detailGameObject = new GameObject("Detail");
|
||||||
|
detailGameObject.transform.SetParent(parent);
|
||||||
|
detailGameObject.SetActive(false);
|
||||||
|
|
||||||
|
RectTransform detailTransform = detailGameObject.AddComponent<RectTransform>();
|
||||||
|
detailTransform.localPosition = (Vector2)(info.position ?? new MVector2(0, 0));
|
||||||
|
detailTransform.localRotation = Quaternion.Euler(0f, 0f, info.rotation);
|
||||||
|
detailTransform.localScale = (Vector2)(info.scale ?? new MVector2(0, 0));
|
||||||
|
|
||||||
|
string revealedPath = info.revealedSprite ?? "DEFAULT";
|
||||||
|
string outlinePath = info.outlineSprite ?? revealedPath;
|
||||||
|
|
||||||
|
Image revealedImage = CreateImage(detailGameObject, assets, revealedPath, "Detail Revealed", parent.gameObject.layer).GetComponent<Image>();
|
||||||
|
Image outlineImage = CreateImage(detailGameObject, assets, outlinePath, "Detail Outline", parent.gameObject.layer).GetComponent<Image>();
|
||||||
|
|
||||||
|
ShipLogDetail detail = detailGameObject.AddComponent<ShipLogDetail>();
|
||||||
|
detail.Init(info, revealedImage, outlineImage, greyScaleMaterial);
|
||||||
|
detailGameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConnectNodeToLastSibling(MapModeObject node)
|
private static void MakeDetails(NewHorizonsBody body, Transform parent, Material greyScaleMaterial)
|
||||||
|
{
|
||||||
|
if (body.Config.ShipLog?.mapMode?.details?.Length > 0)
|
||||||
|
{
|
||||||
|
GameObject detailsParent = new GameObject("Details");
|
||||||
|
detailsParent.transform.SetParent(parent);
|
||||||
|
detailsParent.SetActive(false);
|
||||||
|
|
||||||
|
RectTransform detailsTransform = detailsParent.AddComponent<RectTransform>();
|
||||||
|
detailsTransform.localPosition = Vector3.zero;
|
||||||
|
detailsTransform.localRotation = Quaternion.identity;
|
||||||
|
detailsTransform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
foreach (ShipLogModule.ShipLogDetailInfo detailInfo in body.Config.ShipLog.mapMode.details)
|
||||||
|
{
|
||||||
|
MakeDetail(detailInfo, detailsTransform, body.Mod.Assets, greyScaleMaterial);
|
||||||
|
}
|
||||||
|
detailsParent.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Manual Map Mode
|
||||||
|
private static ShipLogAstroObject[][] ConstructMapModeManual(List<NewHorizonsBody> bodies, GameObject transformParent, Material greyScaleMaterial, ShipLogAstroObject[][] currentNav, int layer)
|
||||||
|
{
|
||||||
|
int maxAmount = bodies.Count + 20;
|
||||||
|
ShipLogAstroObject[][] navMatrix = new ShipLogAstroObject[maxAmount][];
|
||||||
|
for (int i = 0; i < maxAmount; i++)
|
||||||
|
{
|
||||||
|
navMatrix[i] = new ShipLogAstroObject[maxAmount];
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, int[]> astroIdToNavIndex = new Dictionary<string, int[]>();
|
||||||
|
|
||||||
|
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int y = 0; y < currentNav.Length; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < currentNav[y].Length; x++)
|
||||||
|
{
|
||||||
|
navMatrix[y][x] = currentNav[y][x];
|
||||||
|
astroIdToNavIndex.Add(currentNav[y][x].GetID(), new [] {y, x});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (NewHorizonsBody body in bodies.Where(b => ShipLogHandler.IsVanillaBody(b) == false))
|
||||||
|
{
|
||||||
|
GameObject newMapModeGO = CreateMapModeGameObject(body, transformParent, layer, body.Config.ShipLog?.mapMode?.manualPosition);
|
||||||
|
ShipLogAstroObject newAstroObject = AddShipLogAstroObject(newMapModeGO, body, greyScaleMaterial, layer);
|
||||||
|
MakeDetails(body, newMapModeGO.transform, greyScaleMaterial);
|
||||||
|
Vector2 navigationPosition = body.Config.ShipLog?.mapMode?.manualNavigationPosition;
|
||||||
|
navMatrix[(int) navigationPosition.y][(int) navigationPosition.x] = newAstroObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
||||||
|
{
|
||||||
|
foreach (NewHorizonsBody body in Main.BodyDict["SolarSystem"].Where(ShipLogHandler.IsVanillaBody))
|
||||||
|
{
|
||||||
|
GameObject gameObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + body.Config.Name.Replace(" ", ""));
|
||||||
|
if (body.Config.Destroy || (body.Config.ShipLog?.mapMode?.remove ?? false))
|
||||||
|
{
|
||||||
|
ShipLogAstroObject astroObject = gameObject.GetComponent<ShipLogAstroObject>();
|
||||||
|
if (astroObject != null)
|
||||||
|
{
|
||||||
|
int[] navIndex = astroIdToNavIndex[astroObject.GetID()];
|
||||||
|
navMatrix[navIndex[0]][navIndex[1]] = null;
|
||||||
|
if (astroObject.GetID() == "CAVE_TWIN" || astroObject.GetID() == "TOWER_TWIN")
|
||||||
|
{
|
||||||
|
Object.Destroy(GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Object.Destroy(gameObject);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (body.Config.ShipLog?.mapMode?.manualPosition != null)
|
||||||
|
{
|
||||||
|
gameObject.transform.localPosition = (Vector2)body.Config.ShipLog.mapMode.manualPosition;
|
||||||
|
}
|
||||||
|
if (body.Config.ShipLog?.mapMode?.manualNavigationPosition != null)
|
||||||
|
{
|
||||||
|
Vector2 navigationPosition = body.Config.ShipLog?.mapMode?.manualNavigationPosition;
|
||||||
|
navMatrix[(int) navigationPosition.y][(int) navigationPosition.x] = gameObject.GetComponent<ShipLogAstroObject>();
|
||||||
|
}
|
||||||
|
if (body.Config.ShipLog?.mapMode?.scale != null)
|
||||||
|
{
|
||||||
|
gameObject.transform.localScale = Vector3.one * body.Config.ShipLog.mapMode.scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
navMatrix = navMatrix.Where(a => a.Count(c => c != null && c.gameObject != null) > 0).Prepend(new ShipLogAstroObject[1]).ToArray();
|
||||||
|
for (var index = 0; index < navMatrix.Length; index++)
|
||||||
|
{
|
||||||
|
navMatrix[index] = navMatrix[index].Where(a => a != null && a.gameObject != null).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
return navMatrix;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Automatic Map Mode
|
||||||
|
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 MapModeObject lastSibling;
|
||||||
|
public void Increment_width()
|
||||||
|
{
|
||||||
|
branch_width++;
|
||||||
|
parent?.Increment_width();
|
||||||
|
}
|
||||||
|
public void Increment_height()
|
||||||
|
{
|
||||||
|
branch_height++;
|
||||||
|
parent?.Increment_height();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ShipLogAstroObject[][] ConstructMapModeAuto(List<NewHorizonsBody> bodies, GameObject transformParent, Material greyScaleMaterial, int layer)
|
||||||
|
{
|
||||||
|
MapModeObject rootObject = ConstructPrimaryNode(bodies);
|
||||||
|
if (rootObject.mainBody != null)
|
||||||
|
{
|
||||||
|
MakeAllNodes(ref rootObject, transformParent, greyScaleMaterial, layer);
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxAmount = bodies.Count;
|
||||||
|
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 MakeAllNodes(ref MapModeObject parentNode, GameObject parent, Material greyScaleMaterial, int layer)
|
||||||
|
{
|
||||||
|
MakeNode(ref parentNode, parent, greyScaleMaterial, layer);
|
||||||
|
for (var i = 0; i < parentNode.children.Count; i++)
|
||||||
|
{
|
||||||
|
MapModeObject child = parentNode.children[i];
|
||||||
|
MakeAllNodes(ref child, parent, greyScaleMaterial, layer);
|
||||||
|
parentNode.children[i] = child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MapModeObject ConstructPrimaryNode(List<NewHorizonsBody> bodies)
|
||||||
|
{
|
||||||
|
foreach (NewHorizonsBody body in bodies.Where(b => b.Config.Base.CenterOfSolarSystem))
|
||||||
|
{
|
||||||
|
bodies.Sort((b, o) => b.Config.Orbit.SemiMajorAxis.CompareTo(o.Config.Orbit.SemiMajorAxis));
|
||||||
|
MapModeObject newNode = new MapModeObject
|
||||||
|
{
|
||||||
|
mainBody = body,
|
||||||
|
level = 0,
|
||||||
|
x = 0,
|
||||||
|
y = 0
|
||||||
|
};
|
||||||
|
newNode.children = ConstructChildrenNodes(newNode, bodies);
|
||||||
|
return newNode;
|
||||||
|
}
|
||||||
|
Logger.LogError("Couldn't find center of system!");
|
||||||
|
return new MapModeObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<MapModeObject> ConstructChildrenNodes(MapModeObject parent, List<NewHorizonsBody> searchList)
|
||||||
|
{
|
||||||
|
List<MapModeObject> children = new List<MapModeObject>();
|
||||||
|
int newX = parent.x;
|
||||||
|
int newY = parent.y;
|
||||||
|
int newLevel = parent.level + 1;
|
||||||
|
MapModeObject lastSibling = parent;
|
||||||
|
foreach (NewHorizonsBody body in searchList.Where(b => b.Config.Orbit.PrimaryBody == parent.mainBody.Config.Name))
|
||||||
|
{
|
||||||
|
if (body.Config.Orbit.PrimaryBody == parent.mainBody.Config.Name)
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
lastSibling = lastSibling
|
||||||
|
};
|
||||||
|
newNode.children = ConstructChildrenNodes(newNode, searchList);
|
||||||
|
if (even)
|
||||||
|
{
|
||||||
|
newY += newNode.branch_height;
|
||||||
|
parent.Increment_height();
|
||||||
|
newY += 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newX += newNode.branch_width;
|
||||||
|
parent.Increment_width();
|
||||||
|
newX += 1;
|
||||||
|
}
|
||||||
|
lastSibling = newNode;
|
||||||
|
children.Add(newNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConnectNodeToLastSibling(MapModeObject node, Material greyScaleMaterial)
|
||||||
{
|
{
|
||||||
Vector2 fromPosition = node.astroObject.transform.localPosition;
|
Vector2 fromPosition = node.astroObject.transform.localPosition;
|
||||||
Vector2 toPosition = node.lastSibling.astroObject.transform.localPosition;
|
Vector2 toPosition = node.lastSibling.astroObject.transform.localPosition;
|
||||||
@ -167,66 +417,16 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
};
|
};
|
||||||
|
|
||||||
ShipLogDetail linkDetail = newLink.AddComponent<ShipLogDetail>();
|
ShipLogDetail linkDetail = newLink.AddComponent<ShipLogDetail>();
|
||||||
linkDetail.Init(linkDetailInfo, linkImage, linkImage);
|
linkDetail.Init(linkDetailInfo, linkImage, linkImage, greyScaleMaterial);
|
||||||
|
|
||||||
transform.SetParent(node.astroObject.transform);
|
transform.SetParent(node.astroObject.transform);
|
||||||
transform.SetAsFirstSibling();
|
transform.SetAsFirstSibling();
|
||||||
newLink.SetActive(true);
|
newLink.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MakeDetail(ShipLogModule.ShipLogDetailInfo info, Transform parent, IModAssets assets)
|
private static void MakeNode(ref MapModeObject node, GameObject parent, Material greyScaleMaterial, int layer)
|
||||||
{
|
|
||||||
GameObject detailGameObject = new GameObject("Detail");
|
|
||||||
detailGameObject.transform.SetParent(parent);
|
|
||||||
detailGameObject.SetActive(false);
|
|
||||||
|
|
||||||
RectTransform detailTransform = detailGameObject.AddComponent<RectTransform>();
|
|
||||||
detailTransform.localPosition = (Vector2)(info.position ?? new MVector2(0, 0));
|
|
||||||
detailTransform.localRotation = Quaternion.Euler(0f, 0f, info.rotation);
|
|
||||||
detailTransform.localScale = (Vector2)(info.scale ?? new MVector2(0, 0));
|
|
||||||
|
|
||||||
string revealedPath = info.revealedSprite ?? "DEFAULT";
|
|
||||||
string outlinePath = info.outlineSprite ?? revealedPath;
|
|
||||||
|
|
||||||
Image revealedImage = CreateImage(detailGameObject, assets, revealedPath, "Detail Revealed", parent.gameObject.layer).GetComponent<Image>();
|
|
||||||
Image outlineImage = CreateImage(detailGameObject, assets, outlinePath, "Detail Outline", parent.gameObject.layer).GetComponent<Image>();
|
|
||||||
|
|
||||||
ShipLogDetail detail = detailGameObject.AddComponent<ShipLogDetail>();
|
|
||||||
detail.Init(info, revealedImage, outlineImage);
|
|
||||||
detailGameObject.SetActive(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void MakeDetails(MapModeObject node)
|
|
||||||
{
|
|
||||||
if (node.mainBody.Config.ShipLog?.mapMode?.details?.Length > 0)
|
|
||||||
{
|
|
||||||
GameObject detailsParent = new GameObject("Details");
|
|
||||||
detailsParent.transform.SetParent(node.astroObject.transform);
|
|
||||||
detailsParent.SetActive(false);
|
|
||||||
|
|
||||||
RectTransform detailsTransform = detailsParent.AddComponent<RectTransform>();
|
|
||||||
detailsTransform.localPosition = Vector3.zero;
|
|
||||||
detailsTransform.localRotation = Quaternion.identity;
|
|
||||||
detailsTransform.localScale = Vector3.one;
|
|
||||||
|
|
||||||
foreach (ShipLogModule.ShipLogDetailInfo detailInfo in node.mainBody.Config.ShipLog.mapMode.details)
|
|
||||||
{
|
|
||||||
MakeDetail(detailInfo, detailsTransform, node.mainBody.Mod.Assets);
|
|
||||||
}
|
|
||||||
detailsParent.SetActive(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void MakeNode(ref MapModeObject node, GameObject parent, int layer)
|
|
||||||
{
|
{
|
||||||
const float padding = 250f;
|
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;
|
|
||||||
Vector2 position = Vector2.zero;
|
Vector2 position = Vector2.zero;
|
||||||
if (node.lastSibling != null)
|
if (node.lastSibling != null)
|
||||||
{
|
{
|
||||||
@ -243,77 +443,19 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
position.x += padding * (node.x - node.lastSibling.x) + extraDistance;
|
position.x += padding * (node.x - node.lastSibling.x) + extraDistance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transform.localPosition = new Vector3(position.x, position.y, 0);
|
GameObject newNodeGO = CreateMapModeGameObject(node.mainBody, parent, layer, position);
|
||||||
transform.localRotation = Quaternion.identity;
|
ShipLogAstroObject astroObject = AddShipLogAstroObject(newNodeGO, node.mainBody, greyScaleMaterial, layer);
|
||||||
transform.localScale = Vector3.one * scale;
|
if (node.mainBody.Config.FocalPoint != null)
|
||||||
CreateShipLogAstroObject(newNodeGO, ref node, GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/MapMode/ScaleRoot/PanRoot/TimberHearth/UnviewedIcon"), layer);
|
|
||||||
if (node.lastSibling != null) ConnectNodeToLastSibling(node);
|
|
||||||
MakeDetails(node);
|
|
||||||
transform.SetAsFirstSibling();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MapModeObject ConstructPrimaryNode(string systemName)
|
|
||||||
{
|
{
|
||||||
foreach (NewHorizonsBody body in Main.BodyDict[systemName].Where(b => b.Config.Base.CenterOfSolarSystem))
|
astroObject._imageObj.GetComponent<Image>().enabled = false;
|
||||||
{
|
astroObject._outlineObj.GetComponent<Image>().enabled = false;
|
||||||
List<NewHorizonsBody> searchList = Main.BodyDict[systemName].Where(b => (b.Config.ShipLog?.mapMode?.remove ?? false) == false).ToList();
|
astroObject._unviewedObj.GetComponent<Image>().enabled = false;
|
||||||
searchList.Sort((b, o) => b.Config.Orbit.SemiMajorAxis.CompareTo(o.Config.Orbit.SemiMajorAxis));
|
astroObject.transform.localScale = node.lastSibling.astroObject.transform.localScale;
|
||||||
MapModeObject newNode = new MapModeObject
|
|
||||||
{
|
|
||||||
mainBody = body,
|
|
||||||
level = 0,
|
|
||||||
x = 0,
|
|
||||||
y = 0
|
|
||||||
};
|
|
||||||
newNode.children = ConstructChildrenNodes(systemName, newNode, searchList);
|
|
||||||
return newNode;
|
|
||||||
}
|
}
|
||||||
Logger.LogError("Couldn't find center of system!");
|
node.astroObject = astroObject;
|
||||||
return new MapModeObject();
|
if (node.lastSibling != null) ConnectNodeToLastSibling(node, greyScaleMaterial);
|
||||||
|
MakeDetails(node.mainBody, newNodeGO.transform, greyScaleMaterial);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
private static List<MapModeObject> ConstructChildrenNodes(string systemName, MapModeObject parent, List<NewHorizonsBody> searchList)
|
|
||||||
{
|
|
||||||
List<MapModeObject> children = new List<MapModeObject>();
|
|
||||||
int newX = parent.x;
|
|
||||||
int newY = parent.y;
|
|
||||||
int newLevel = parent.level + 1;
|
|
||||||
MapModeObject lastSibling = parent;
|
|
||||||
foreach (NewHorizonsBody body in searchList.Where(b => b.Config.Orbit.PrimaryBody == parent.mainBody.Config.Name))
|
|
||||||
{
|
|
||||||
if (body.Config.Orbit.PrimaryBody == parent.mainBody.Config.Name)
|
|
||||||
{
|
|
||||||
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,
|
|
||||||
lastSibling = lastSibling
|
|
||||||
};
|
|
||||||
newNode.children = ConstructChildrenNodes(systemName, newNode, searchList);
|
|
||||||
if (even)
|
|
||||||
{
|
|
||||||
newY += newNode.branch_height;
|
|
||||||
parent.Increment_height();
|
|
||||||
newY += 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
newX += newNode.branch_width;
|
|
||||||
parent.Increment_width();
|
|
||||||
newX += 1;
|
|
||||||
}
|
|
||||||
lastSibling = newNode;
|
|
||||||
children.Add(newNode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using NewHorizons.Components;
|
using System;
|
||||||
|
using NewHorizons.Components;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -66,6 +67,23 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
{
|
{
|
||||||
_entryIdToRawName.Add(id.Value, curiosityName.Value);
|
_entryIdToRawName.Add(id.Value, curiosityName.Value);
|
||||||
}
|
}
|
||||||
|
foreach (XElement childEntryElement in entryElement.Elements("Entry"))
|
||||||
|
{
|
||||||
|
XElement childCuriosityName = childEntryElement.Element("Curiosity");
|
||||||
|
XElement childId = childEntryElement.Element("ID");
|
||||||
|
if (childId != null && _entryIdToRawName.ContainsKey(childId.Value))
|
||||||
|
{
|
||||||
|
if (childCuriosityName == null && curiosityName != null)
|
||||||
|
{
|
||||||
|
_entryIdToRawName.Add(childId.Value, curiosityName.Value);
|
||||||
|
}
|
||||||
|
else if (childCuriosityName != null)
|
||||||
|
{
|
||||||
|
_entryIdToRawName.Add(childId.Value, childCuriosityName.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AddTranslation(childEntryElement);
|
||||||
|
}
|
||||||
AddTranslation(entryElement);
|
AddTranslation(entryElement);
|
||||||
}
|
}
|
||||||
TextAsset newAsset = new TextAsset(astroBodyFile.ToString());
|
TextAsset newAsset = new TextAsset(astroBodyFile.ToString());
|
||||||
@ -99,7 +117,8 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
{
|
{
|
||||||
id = entry._id,
|
id = entry._id,
|
||||||
cardPosition = entryPosition,
|
cardPosition = entryPosition,
|
||||||
sprite = body.Config.ShipLog.spriteFolder == null ? null : GetEntrySprite(entry._id, body)
|
sprite = body.Config.ShipLog.spriteFolder == null ? null : GetEntrySprite(entry._id, body),
|
||||||
|
altSprite = body.Config.ShipLog.spriteFolder == null ? null : GetEntrySprite(entry._id + "_ALT", body)
|
||||||
};
|
};
|
||||||
entry.SetSprite(newData.sprite == null ? manager._shipLogLibrary.defaultEntrySprite : newData.sprite);
|
entry.SetSprite(newData.sprite == null ? manager._shipLogLibrary.defaultEntrySprite : newData.sprite);
|
||||||
manager._entryDataDict.Add(entry._id, newData);
|
manager._entryDataDict.Add(entry._id, newData);
|
||||||
@ -127,26 +146,33 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
table[name] = name;
|
table[name] = name;
|
||||||
foreach (XElement rumorFact in entry.Elements("RumorFact"))
|
foreach (XElement rumorFact in entry.Elements("RumorFact"))
|
||||||
{
|
{
|
||||||
XElement rumorName = rumorFact.Element("RumorName");
|
AddTranslationForElement(rumorFact, "RumorName", string.Empty, table);
|
||||||
if (rumorName != null)
|
AddTranslationForElement(rumorFact, "Text", name, table);
|
||||||
{
|
AddTranslationForAltText(rumorFact, name, table);
|
||||||
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"))
|
foreach (XElement exploreFact in entry.Elements("ExploreFact"))
|
||||||
{
|
{
|
||||||
XElement exploreText = exploreFact.Element("Text");
|
AddTranslationForElement(exploreFact, "Text", name, table);
|
||||||
if (exploreText != null)
|
AddTranslationForAltText(exploreFact, name, table);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AddTranslationForElement(XElement parent, string elementName, string keyName, Dictionary<string, string> table)
|
||||||
{
|
{
|
||||||
table[name + exploreText.Value] = exploreText.Value;
|
XElement element = parent.Element(elementName);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
table[keyName + element.Value] = element.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void AddTranslationForAltText(XElement fact, string keyName, Dictionary<string, string> table)
|
||||||
|
{
|
||||||
|
XElement altText = fact.Element("AltText");
|
||||||
|
if (altText != null)
|
||||||
|
{
|
||||||
|
AddTranslationForElement(altText, "Text", keyName, table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,8 +203,8 @@ namespace NewHorizons.Builder.ShipLog
|
|||||||
|
|
||||||
private static Vector2? GetManualEntryPosition(string entryId, ShipLogModule config)
|
private static Vector2? GetManualEntryPosition(string entryId, ShipLogModule config)
|
||||||
{
|
{
|
||||||
if (config.positions == null) return null;
|
if (config.entryPositions == null) return null;
|
||||||
foreach (ShipLogModule.EntryPositionInfo position in config.positions)
|
foreach (ShipLogModule.EntryPositionInfo position in config.entryPositions)
|
||||||
{
|
{
|
||||||
if (position.id == entryId)
|
if (position.id == entryId)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using NewHorizons.External;
|
using System;
|
||||||
|
using NewHorizons.External;
|
||||||
using OWML.Common;
|
using OWML.Common;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@ -8,17 +9,19 @@ namespace NewHorizons.Components
|
|||||||
{
|
{
|
||||||
public class ShipLogDetail : MonoBehaviour
|
public class ShipLogDetail : MonoBehaviour
|
||||||
{
|
{
|
||||||
private Image revealedImage;
|
private Image _revealedImage;
|
||||||
private Image outlineImage;
|
private Image _outlineImage;
|
||||||
private ShipLogModule.ShipLogDetailInfo detailInfo;
|
private Material _greyScaleMaterial;
|
||||||
|
private ShipLogModule.ShipLogDetailInfo _detailInfo;
|
||||||
|
|
||||||
public void Init(ShipLogModule.ShipLogDetailInfo info, Image revealed, Image outline)
|
public void Init(ShipLogModule.ShipLogDetailInfo info, Image revealed, Image outline, Material greyScale)
|
||||||
{
|
{
|
||||||
detailInfo = info;
|
_detailInfo = info;
|
||||||
revealedImage = revealed;
|
_revealedImage = revealed;
|
||||||
outlineImage = outline;
|
_outlineImage = outline;
|
||||||
revealedImage.enabled = false;
|
_greyScaleMaterial = greyScale;
|
||||||
outlineImage.enabled = false;
|
_revealedImage.enabled = false;
|
||||||
|
_outlineImage.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateState(ShipLogEntry.State parentState)
|
public void UpdateState(ShipLogEntry.State parentState)
|
||||||
@ -26,22 +29,32 @@ namespace NewHorizons.Components
|
|||||||
switch (parentState)
|
switch (parentState)
|
||||||
{
|
{
|
||||||
case ShipLogEntry.State.Explored:
|
case ShipLogEntry.State.Explored:
|
||||||
outlineImage.enabled = false;
|
_outlineImage.enabled = false;
|
||||||
revealedImage.enabled = true;
|
_revealedImage.enabled = true;
|
||||||
|
SetGreyScale(false);
|
||||||
break;
|
break;
|
||||||
case ShipLogEntry.State.Rumored:
|
case ShipLogEntry.State.Rumored:
|
||||||
revealedImage.enabled = false;
|
_outlineImage.enabled = false;
|
||||||
outlineImage.enabled = true;
|
_revealedImage.enabled = true;
|
||||||
|
SetGreyScale(true);
|
||||||
break;
|
break;
|
||||||
case ShipLogEntry.State.Hidden:
|
case ShipLogEntry.State.Hidden:
|
||||||
revealedImage.enabled = false;
|
_revealedImage.enabled = false;
|
||||||
outlineImage.enabled = !detailInfo.invisibleWhenHidden;
|
_outlineImage.enabled = !_detailInfo.invisibleWhenHidden;
|
||||||
break;
|
break;
|
||||||
case ShipLogEntry.State.None:
|
case ShipLogEntry.State.None:
|
||||||
revealedImage.enabled = false;
|
_revealedImage.enabled = false;
|
||||||
outlineImage.enabled = false;
|
_outlineImage.enabled = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Logger.LogError("Invalid ShipLogEntryState for " + _revealedImage.transform.parent.parent.gameObject.name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetGreyScale(bool greyScale)
|
||||||
|
{
|
||||||
|
_revealedImage.material = (greyScale ? _greyScaleMaterial : null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
4
NewHorizons/External/ShipLogModule.cs
vendored
4
NewHorizons/External/ShipLogModule.cs
vendored
@ -9,7 +9,7 @@ namespace NewHorizons.External
|
|||||||
public string[] initialReveal;
|
public string[] initialReveal;
|
||||||
public MapModeInfo mapMode;
|
public MapModeInfo mapMode;
|
||||||
public CuriosityColorInfo[] curiosities;
|
public CuriosityColorInfo[] curiosities;
|
||||||
public EntryPositionInfo[] positions;
|
public EntryPositionInfo[] entryPositions;
|
||||||
|
|
||||||
public class MapModeInfo
|
public class MapModeInfo
|
||||||
{
|
{
|
||||||
@ -18,6 +18,8 @@ namespace NewHorizons.External
|
|||||||
public float scale = 1f;
|
public float scale = 1f;
|
||||||
public bool invisibleWhenHidden;
|
public bool invisibleWhenHidden;
|
||||||
public float offset = 0f;
|
public float offset = 0f;
|
||||||
|
public MVector2 manualPosition;
|
||||||
|
public MVector2 manualNavigationPosition;
|
||||||
public bool remove = false;
|
public bool remove = false;
|
||||||
public ShipLogDetailInfo[] details;
|
public ShipLogDetailInfo[] details;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,25 @@ namespace NewHorizons.Builder.Handlers
|
|||||||
public static readonly string PAN_ROOT_PATH = "Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/MapMode/ScaleRoot/PanRoot";
|
public static readonly string PAN_ROOT_PATH = "Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/MapMode/ScaleRoot/PanRoot";
|
||||||
|
|
||||||
private static Dictionary<string, NewHorizonsBody> _astroIdToBody = new Dictionary<string, NewHorizonsBody>();
|
private static Dictionary<string, NewHorizonsBody> _astroIdToBody = new Dictionary<string, NewHorizonsBody>();
|
||||||
|
private static string[] vanillaBodies;
|
||||||
|
private static string[] vanillaIDs;
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
List<GameObject> gameObjects = SearchUtilities.GetAllChildren(GameObject.Find(PAN_ROOT_PATH));
|
||||||
|
vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray();
|
||||||
|
vanillaIDs = gameObjects.ConvertAll(g => g.GetComponent<ShipLogAstroObject>()?.GetID()).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsVanillaAstroID(string astroId)
|
||||||
|
{
|
||||||
|
return vanillaIDs.Contains(astroId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsVanillaBody(NewHorizonsBody body)
|
||||||
|
{
|
||||||
|
return vanillaBodies.Contains(body.Config.Name.Replace(" ", ""));
|
||||||
|
}
|
||||||
|
|
||||||
public static NewHorizonsBody GetConfigFromID(string id)
|
public static NewHorizonsBody GetConfigFromID(string id)
|
||||||
{
|
{
|
||||||
@ -33,7 +52,7 @@ namespace NewHorizons.Builder.Handlers
|
|||||||
|
|
||||||
public static string GetAstroObjectId(NewHorizonsBody body)
|
public static string GetAstroObjectId(NewHorizonsBody body)
|
||||||
{
|
{
|
||||||
if (_astroIdToBody.ContainsValue(body))
|
if (BodyHasEntries(body))
|
||||||
{
|
{
|
||||||
return CollectionUtilities.KeyByValue(_astroIdToBody, body);
|
return CollectionUtilities.KeyByValue(_astroIdToBody, body);
|
||||||
}
|
}
|
||||||
@ -42,5 +61,10 @@ namespace NewHorizons.Builder.Handlers
|
|||||||
return body.Config.Name;
|
return body.Config.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool BodyHasEntries(NewHorizonsBody body)
|
||||||
|
{
|
||||||
|
return _astroIdToBody.ContainsValue(body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@ namespace NewHorizons.Tools
|
|||||||
|
|
||||||
public static void OnShipLogManagerAwake(ShipLogManager __instance)
|
public static void OnShipLogManagerAwake(ShipLogManager __instance)
|
||||||
{
|
{
|
||||||
|
ShipLogHandler.Init();
|
||||||
Logger.Log("Beginning Ship Log Generation For: " + Main.Instance.CurrentStarSystem, Logger.LogType.Log);
|
Logger.Log("Beginning Ship Log Generation For: " + Main.Instance.CurrentStarSystem, Logger.LogType.Log);
|
||||||
if (Main.Instance.CurrentStarSystem != "SolarSystem")
|
if (Main.Instance.CurrentStarSystem != "SolarSystem")
|
||||||
{
|
{
|
||||||
@ -42,6 +43,7 @@ namespace NewHorizons.Tools
|
|||||||
logEntryLocation._initialized = true;
|
logEntryLocation._initialized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
||||||
{
|
{
|
||||||
if (body.Config.ShipLog?.curiosities != null)
|
if (body.Config.ShipLog?.curiosities != null)
|
||||||
@ -49,6 +51,7 @@ namespace NewHorizons.Tools
|
|||||||
RumorModeBuilder.AddCuriosityColors(body.Config.ShipLog.curiosities);
|
RumorModeBuilder.AddCuriosityColors(body.Config.ShipLog.curiosities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
||||||
{
|
{
|
||||||
if (body.Config.ShipLog?.xmlFile != null)
|
if (body.Config.ShipLog?.xmlFile != null)
|
||||||
@ -66,6 +69,7 @@ namespace NewHorizons.Tools
|
|||||||
ShipLogEntry logEntry = __instance._entryList[i];
|
ShipLogEntry logEntry = __instance._entryList[i];
|
||||||
RumorModeBuilder.UpdateEntryCuriosity(ref logEntry);
|
RumorModeBuilder.UpdateEntryCuriosity(ref logEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Log("Ship Log Generation Complete For: " + Main.Instance.CurrentStarSystem, Logger.LogType.Log);
|
Logger.Log("Ship Log Generation Complete For: " + Main.Instance.CurrentStarSystem, Logger.LogType.Log);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,21 +85,24 @@ namespace NewHorizons.Tools
|
|||||||
{
|
{
|
||||||
__result = false;
|
__result = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OnShipLogManagerCheckForCompletionAchievement()
|
public static bool OnShipLogManagerCheckForCompletionAchievement(ShipLogManager __instance)
|
||||||
{
|
{
|
||||||
return Main.Instance.CurrentStarSystem == "SolarSystem";
|
foreach (KeyValuePair<string, ShipLogFact> keyValuePair in __instance._factDict)
|
||||||
|
{
|
||||||
|
if (ShipLogHandler.IsVanillaAstroID(__instance.GetEntry(keyValuePair.Value.GetEntryID()).GetAstroObjectID()) && !keyValuePair.Value.IsRumor() && !keyValuePair.Value.IsRevealed() && !keyValuePair.Key.Equals("TH_VILLAGE_X3") && !keyValuePair.Key.Equals("GD_GABBRO_ISLAND_X1") && __instance.GetEntry(keyValuePair.Value.GetEntryID()).GetCuriosityName() != CuriosityName.InvisiblePlanet)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Achievements.Earn(Achievements.Type.STUDIOUS);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OnShipLogManagerStart(ShipLogManager __instance)
|
public static bool OnShipLogManagerStart(ShipLogManager __instance)
|
||||||
{
|
|
||||||
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
||||||
{
|
{
|
||||||
@ -104,6 +111,13 @@ namespace NewHorizons.Tools
|
|||||||
__instance.RevealFact(fact, false, false);
|
__instance.RevealFact(fact, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
EntryLocationBuilder.InitializeLocations();
|
EntryLocationBuilder.InitializeLocations();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -111,7 +125,7 @@ namespace NewHorizons.Tools
|
|||||||
|
|
||||||
public static bool OnUIStyleManagerGetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result)
|
public static bool OnUIStyleManagerGetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result)
|
||||||
{
|
{
|
||||||
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
if ((int) __0 < 7)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -123,35 +137,38 @@ namespace NewHorizons.Tools
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void OnShipLogMapModeInitialize(ShipLogMapMode __instance)
|
public static void OnShipLogMapModeInitialize(ShipLogMapMode __instance)
|
||||||
{
|
|
||||||
if (Main.Instance.CurrentStarSystem != "SolarSystem")
|
|
||||||
{
|
{
|
||||||
GameObject panRoot = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH);
|
GameObject panRoot = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH);
|
||||||
GameObject sunObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun");
|
GameObject sunObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun");
|
||||||
ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, sunObject.layer);
|
ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer);
|
||||||
if (navMatrix.Length <= 1)
|
if (navMatrix == null || navMatrix.Length <= 1)
|
||||||
{
|
{
|
||||||
Logger.LogWarning("No planets suitable for map mode found! Defaulting to vanilla menu (expect weirdness!).");
|
Logger.LogWarning("Skipping Map Mode Generation.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
__instance._astroObjects = navMatrix;
|
__instance._astroObjects = navMatrix;
|
||||||
__instance._startingAstroObjectID = navMatrix[1][0].GetID();
|
__instance._startingAstroObjectID = navMatrix[1][0].GetID();
|
||||||
|
if (Main.Instance.CurrentStarSystem != "SolarSystem")
|
||||||
|
{
|
||||||
List<GameObject> delete = SearchUtilities.GetAllChildren(panRoot).Where(g => g.name.Contains("_ShipLog") == false).ToList();
|
List<GameObject> delete = SearchUtilities.GetAllChildren(panRoot).Where(g => g.name.Contains("_ShipLog") == false).ToList();
|
||||||
foreach (GameObject gameObject in delete)
|
foreach (GameObject gameObject in delete)
|
||||||
{
|
{
|
||||||
Object.Destroy(GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name));
|
Object.Destroy(GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name));
|
||||||
}
|
}
|
||||||
// Just Lie About Having A Sand Funnel
|
if (GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null)
|
||||||
|
{
|
||||||
__instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>();
|
__instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Logger.Log("Map Mode Construction Complete", Logger.LogType.Log);
|
Logger.Log("Map Mode Construction Complete", Logger.LogType.Log);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool OnShipLogAstroObjectGetName(ShipLogAstroObject __instance, ref string __result)
|
public static bool OnShipLogAstroObjectGetName(ShipLogAstroObject __instance, ref string __result)
|
||||||
{
|
{
|
||||||
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
if (ShipLogHandler.IsVanillaAstroID(__instance.GetID()))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -197,4 +214,3 @@ namespace NewHorizons.Tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1266,7 +1266,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"positions": {
|
"entryPositions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"description": "A set of positions to use instead of automatic layout in rumor mode",
|
"description": "A set of positions to use instead of automatic layout in rumor mode",
|
||||||
"items": {
|
"items": {
|
||||||
@ -1303,6 +1303,34 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"description": "The path to the sprite to show when the planet is unexplored in map mode"
|
"description": "The path to the sprite to show when the planet is unexplored in map mode"
|
||||||
},
|
},
|
||||||
|
"manualPosition": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Manually place this planet at the specified position",
|
||||||
|
"properties": {
|
||||||
|
"x": {
|
||||||
|
"type": "number",
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"type": "number",
|
||||||
|
"default": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"manualNavigationPosition": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Specify where this planet is in terms of navigation",
|
||||||
|
"properties": {
|
||||||
|
"x": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"type": "integer",
|
||||||
|
"default": 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"scale": {
|
"scale": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"description": "Scale to apply to the planet in map mode",
|
"description": "Scale to apply to the planet in map mode",
|
||||||
|
|||||||
@ -1,38 +1,65 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<!-- Astro Object Entry Info -->
|
||||||
<xs:element name="AstroObjectEntry">
|
<xs:element name="AstroObjectEntry">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="ID" type="xs:string"/>
|
<xs:element name="ID" type="xs:string"/>
|
||||||
<xs:element name="Entry" maxOccurs="unbounded">
|
<xs:element name="Entry" maxOccurs="unbounded" type="entryInfo">
|
||||||
<xs:complexType>
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
|
||||||
|
<!-- Entry Info -->
|
||||||
|
<xs:complexType name="entryInfo">
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="ID" type="xs:string"/>
|
<xs:element name="ID" type="xs:string"/>
|
||||||
<xs:element name="Name" type="xs:string"/>
|
<xs:element name="Name" type="xs:string"/>
|
||||||
<xs:element name="Curiosity" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
|
<xs:element name="Curiosity" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
<xs:element name="IsCuriosity" minOccurs="0" maxOccurs="unbounded"/>
|
<xs:element name="IsCuriosity" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
<xs:element name="RumorFact" minOccurs="0" maxOccurs="unbounded">
|
<xs:element name="IgnoreMoreToExplore" minOccurs="0"/>
|
||||||
<xs:complexType>
|
<xs:element name="IgnoreMoreToExploreCondition" type="xs:string" minOccurs="0"/>
|
||||||
|
<xs:element name="AltPhotoCondition" type="xs:string" minOccurs="0"/>
|
||||||
|
<xs:element name="RumorFact" type="rumorFactInfo" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
<xs:element name="ExploreFact" type="exploreFactInfo" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
<xs:element name="Entry" type="entryInfo" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<!-- Rumor Fact Info -->
|
||||||
|
<xs:complexType name="rumorFactInfo">
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="ID" type="xs:string"/>
|
<xs:element name="ID" type="xs:string"/>
|
||||||
<xs:element name="SourceID" type="xs:string" minOccurs="0"/>
|
<xs:element name="SourceID" type="xs:string" minOccurs="0"/>
|
||||||
<xs:element name="RumorName" type="xs:string"/>
|
<xs:element name="RumorName" type="xs:string" minOccurs="0"/>
|
||||||
<xs:element name="Text" type="xs:string"/>
|
<xs:element name="RumorNamePriority" type="xs:int" minOccurs="0"/>
|
||||||
|
<xs:element name="IgnoreMoreToExplore" minOccurs="0"/>
|
||||||
|
<xs:group ref="textData"/>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
|
||||||
<xs:element name="ExploreFact" minOccurs="0" maxOccurs="unbounded">
|
<!-- Explore Fact Info -->
|
||||||
<xs:complexType>
|
<xs:complexType name="exploreFactInfo">
|
||||||
<xs:all>
|
<xs:sequence>
|
||||||
<xs:element name="ID" type="xs:string"/>
|
<xs:element name="ID" type="xs:string"/>
|
||||||
|
<xs:element name="IgnoreMoreToExplore" minOccurs="0"/>
|
||||||
|
<xs:group ref="textData"/>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<!-- Text Data Group -->
|
||||||
|
<xs:group name="textData">
|
||||||
|
<xs:sequence>
|
||||||
<xs:element name="Text" type="xs:string"/>
|
<xs:element name="Text" type="xs:string"/>
|
||||||
</xs:all>
|
<xs:element name="AltText" minOccurs="0">
|
||||||
</xs:complexType>
|
<xs:complexType>
|
||||||
</xs:element>
|
<xs:sequence>
|
||||||
|
<xs:element name="Text" type="xs:string"/>
|
||||||
|
<xs:element name="Condition" type="xs:string"/>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
</xs:sequence>
|
</xs:sequence>
|
||||||
</xs:complexType>
|
</xs:group>
|
||||||
</xs:element>
|
|
||||||
</xs:schema>
|
</xs:schema>
|
||||||
Loading…
x
Reference in New Issue
Block a user