mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Added XML Schemas
- Improved Map mode - Added XML Schemas for Dialogue and Ship Log - Added New Properties to JSON Schema - Added Reveal Props
This commit is contained in:
parent
3238749a2d
commit
1673de69ac
@ -21,12 +21,17 @@ namespace NewHorizons.Builder.General
|
||||
public static readonly string PAN_ROOT_PATH = "Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/MapMode/ScaleRoot/PanRoot";
|
||||
|
||||
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 static NewHorizonsBody GetConfigFromEntry(ShipLogEntry entry)
|
||||
{
|
||||
return astroIdToBody[entry._astroObjectID];
|
||||
}
|
||||
|
||||
#region Map Mode
|
||||
|
||||
public class MapModeBuilder
|
||||
{
|
||||
private class MapModeObject
|
||||
{
|
||||
public int x;
|
||||
@ -38,6 +43,7 @@ namespace NewHorizons.Builder.General
|
||||
public ShipLogAstroObject astroObject;
|
||||
public List<MapModeObject> children;
|
||||
public MapModeObject parent;
|
||||
public MapModeObject lastSibling;
|
||||
public void increment_width()
|
||||
{
|
||||
branch_width++;
|
||||
@ -51,9 +57,16 @@ namespace NewHorizons.Builder.General
|
||||
}
|
||||
|
||||
public static string GetAstroBodyShipLogName(string id)
|
||||
{
|
||||
if (astroIdToBody.ContainsKey(id))
|
||||
{
|
||||
return astroIdToBody[id].Config.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
public static ShipLogAstroObject[][] ConstructMapMode(string systemName, GameObject transformParent, int layer)
|
||||
{
|
||||
@ -69,6 +82,7 @@ namespace NewHorizons.Builder.General
|
||||
{
|
||||
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++)
|
||||
@ -127,7 +141,7 @@ namespace NewHorizons.Builder.General
|
||||
return newImageGO;
|
||||
}
|
||||
|
||||
public static T KeyByValue<T, W>(this Dictionary<T, W> dict, W val)
|
||||
public static T KeyByValue<T, W>(Dictionary<T, W> dict, W val)
|
||||
{
|
||||
T key = default;
|
||||
foreach (KeyValuePair<T, W> pair in dict)
|
||||
@ -142,11 +156,18 @@ namespace NewHorizons.Builder.General
|
||||
}
|
||||
|
||||
private static string GetAstroObjectId(NewHorizonsBody body)
|
||||
{
|
||||
if (astroIdToBody.ContainsValue(body))
|
||||
{
|
||||
return KeyByValue(astroIdToBody, body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return body.Config.Name;
|
||||
}
|
||||
}
|
||||
|
||||
private static void CreateAstroObject(GameObject nodeGO, ref MapModeObject node, GameObject referenceUnviewedSprite, int layer)
|
||||
private static void CreateShipLogAstroObject(GameObject nodeGO, ref MapModeObject node, GameObject referenceUnviewedSprite, int layer)
|
||||
{
|
||||
const float unviewedIconOffset = 15;
|
||||
ShipLogAstroObject astroObject = nodeGO.AddComponent<ShipLogAstroObject>();
|
||||
@ -162,6 +183,11 @@ namespace NewHorizons.Builder.General
|
||||
node.astroObject = astroObject;
|
||||
}
|
||||
|
||||
private static void ConnectNodes(MapModeObject from, MapModeObject to)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static void CreateNode(ref MapModeObject node, GameObject parent, int layer)
|
||||
{
|
||||
const float padding = 250f;
|
||||
@ -172,38 +198,32 @@ namespace NewHorizons.Builder.General
|
||||
|
||||
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);
|
||||
Vector2 position = Vector2.zero;
|
||||
if (node.lastSibling != null)
|
||||
{
|
||||
ShipLogAstroObject lastAstroObject = node.lastSibling.astroObject;
|
||||
Vector3 lastPosition = lastAstroObject.transform.localPosition;
|
||||
position = lastPosition;
|
||||
float extraDistance = (node.mainBody.Config.ShipLog?.mapMode?.offset ?? 0f) * 100;
|
||||
if (node.level % 2 == 0)
|
||||
{
|
||||
position.y += padding * (node.y - node.lastSibling.y) + extraDistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
position.x += padding * (node.x - node.lastSibling.x) + extraDistance;
|
||||
}
|
||||
}
|
||||
transform.localPosition = new Vector3(position.x, position.y, 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);
|
||||
}
|
||||
CreateShipLogAstroObject(newNodeGO, ref node, GameObject.Find(PAN_ROOT_PATH + "/TimberHearth/UnviewedIcon"), layer);
|
||||
}
|
||||
|
||||
private static MapModeObject MakePrimaryNode(string systemName)
|
||||
{
|
||||
foreach (NewHorizonsBody body in Main.BodyDict[systemName])
|
||||
foreach (NewHorizonsBody body in Main.BodyDict[systemName].Where(b => b.Config.Base.CenterOfSolarSystem))
|
||||
{
|
||||
if (!body.Config.Base.CenterOfSolarSystem) continue;
|
||||
MapModeObject newNode = new MapModeObject
|
||||
{
|
||||
mainBody = body,
|
||||
@ -223,11 +243,12 @@ namespace NewHorizons.Builder.General
|
||||
List<MapModeObject> children = new List<MapModeObject>();
|
||||
int newX = parent.x;
|
||||
int newY = parent.y;
|
||||
foreach (NewHorizonsBody body in Main.BodyDict[systemName])
|
||||
int newLevel = parent.level + 1;
|
||||
MapModeObject lastSibling = parent;
|
||||
foreach (NewHorizonsBody body in Main.BodyDict[systemName].Where(b => b.Config.ShipLog?.mapMode?.remove == false && b.Config.Orbit.PrimaryBody == parent.mainBody.Config.Name))
|
||||
{
|
||||
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;
|
||||
@ -237,7 +258,8 @@ namespace NewHorizons.Builder.General
|
||||
level = newLevel,
|
||||
x = newX,
|
||||
y = newY,
|
||||
parent=parent
|
||||
parent = parent,
|
||||
lastSibling = lastSibling
|
||||
};
|
||||
newNode.children = MakeChildrenNodes(systemName, newNode);
|
||||
if (even)
|
||||
@ -250,11 +272,22 @@ namespace NewHorizons.Builder.General
|
||||
newX += newNode.branch_width;
|
||||
parent.increment_width();
|
||||
}
|
||||
lastSibling = newNode;
|
||||
children.Add(newNode);
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Rumor Mode
|
||||
public static class RumorModeBuilder
|
||||
{
|
||||
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>();
|
||||
|
||||
public static void AddCuriosityColors(ShipLogModule.CuriosityColor[] newColors)
|
||||
{
|
||||
@ -282,14 +315,14 @@ namespace NewHorizons.Builder.General
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddAstroBodyToShipLog(ShipLogManager manager, NewHorizonsBody body)
|
||||
public static void AddBodyToShipLog(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 + "!");
|
||||
Logger.LogError("Failed to load ship logs for " + systemName + "!");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -314,6 +347,48 @@ namespace NewHorizons.Builder.General
|
||||
}
|
||||
}
|
||||
|
||||
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 = GetManualEntryPosition(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 : GetEntrySprite(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddTranslation(XElement entry)
|
||||
{
|
||||
Dictionary<string, string> table = TextTranslation.Get().m_table.theShipLogTable;
|
||||
@ -355,7 +430,7 @@ namespace NewHorizons.Builder.General
|
||||
}
|
||||
}
|
||||
|
||||
private static Sprite GetSprite(string entryId, NewHorizonsBody body)
|
||||
private static Sprite GetEntrySprite(string entryId, NewHorizonsBody body)
|
||||
{
|
||||
IModAssets assets = body.Mod.Assets;
|
||||
string path = body.Config.ShipLog.spriteFolder + "/" + entryId + ".png";
|
||||
@ -368,16 +443,11 @@ namespace NewHorizons.Builder.General
|
||||
}
|
||||
else
|
||||
{
|
||||
return Locator.GetShipLogManager()._shipLogLibrary.defaultEntrySprite;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static NewHorizonsBody GetConfigFromEntry(ShipLogEntry entry)
|
||||
{
|
||||
return astroIdToBody[entry._astroObjectID];
|
||||
}
|
||||
|
||||
private static Vector2? FindPosition(string entryId, ShipLogModule config)
|
||||
private static Vector2? GetManualEntryPosition(string entryId, ShipLogModule config)
|
||||
{
|
||||
if (config.positions == null) return null;
|
||||
foreach (ShipLogModule.EntryPosition position in config.positions)
|
||||
@ -389,48 +459,110 @@ namespace NewHorizons.Builder.General
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static void GenerateEntryData(ShipLogManager manager)
|
||||
#region Fact Reveals
|
||||
public static class RevealBuilder
|
||||
{
|
||||
const int step = 400;
|
||||
int colAccumulator = 0;
|
||||
int rowAccumulator = 0;
|
||||
foreach(ShipLogEntry entry in manager._entryList)
|
||||
public static void Make(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
||||
{
|
||||
if (manager._entryDataDict.ContainsKey(entry._id) == false)
|
||||
GameObject newRevealGO = MakeGameObject(go, sector, info, mod);
|
||||
switch (info.revealOn.ToLower())
|
||||
{
|
||||
NewHorizonsBody body = GetConfigFromEntry(entry);
|
||||
Vector2? manualEntryPosition = FindPosition(entry._id, body.Config.ShipLog);
|
||||
Vector2 entryPosition;
|
||||
if (manualEntryPosition == null)
|
||||
{
|
||||
entryPosition = new Vector2(colAccumulator, rowAccumulator);
|
||||
case "enter":
|
||||
MakeTrigger(newRevealGO, sector, info, mod);
|
||||
break;
|
||||
case "observe":
|
||||
MakeObservable(newRevealGO, sector, info, mod);
|
||||
break;
|
||||
case "snapshot":
|
||||
MakeSnapshot(newRevealGO, sector, info, mod);
|
||||
break;
|
||||
default:
|
||||
Logger.LogError("Invalid revealOn: " + info.revealOn);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
entryPosition = (Vector2) manualEntryPosition;
|
||||
|
||||
newRevealGO.SetActive(true);
|
||||
}
|
||||
EntryData newData = new EntryData
|
||||
|
||||
private static SphereShape MakeShape(GameObject go, PropModule.RevealInfo info, Shape.CollisionMode collisionMode)
|
||||
{
|
||||
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;
|
||||
SphereShape newShape = go.AddComponent<SphereShape>();
|
||||
newShape.radius = info.radius;
|
||||
newShape.SetCollisionMode(collisionMode);
|
||||
return newShape;
|
||||
}
|
||||
else
|
||||
|
||||
private static GameObject MakeGameObject(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
||||
{
|
||||
colAccumulator += step;
|
||||
GameObject revealTriggerVolume = new GameObject("Reveal Volume (" + info.revealOn + ")");
|
||||
revealTriggerVolume.SetActive(false);
|
||||
revealTriggerVolume.transform.parent = sector?.transform ?? go.transform;
|
||||
revealTriggerVolume.transform.localPosition = info.position;
|
||||
return revealTriggerVolume;
|
||||
}
|
||||
|
||||
private static void MakeTrigger(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
||||
{
|
||||
SphereShape newShape = MakeShape(go, info, Shape.CollisionMode.Volume);
|
||||
OWTriggerVolume newVolume = go.AddComponent<OWTriggerVolume>();
|
||||
newVolume._shape = newShape;
|
||||
ShipLogFactListTriggerVolume volume = go.AddComponent<ShipLogFactListTriggerVolume>();
|
||||
volume._factIDs = info.reveals;
|
||||
}
|
||||
|
||||
private static void MakeObservable(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
||||
{
|
||||
go.layer = LayerMask.NameToLayer("Interactible");
|
||||
SphereCollider newSphere = go.AddComponent<SphereCollider>();
|
||||
newSphere.radius = info.radius;
|
||||
OWCollider newCollider = go.AddComponent<OWCollider>();
|
||||
ShipLogFactObserveTrigger newObserveTrigger = go.AddComponent<ShipLogFactObserveTrigger>();
|
||||
newObserveTrigger._factIDs = info.reveals;
|
||||
newObserveTrigger._maxViewDistance = info.maxDistance == -1f ? 2f : info.maxDistance;
|
||||
newObserveTrigger._maxViewAngle = info.maxAngle;
|
||||
newObserveTrigger._owCollider = newCollider;
|
||||
newObserveTrigger._disableColliderOnRevealFact = true;
|
||||
}
|
||||
|
||||
private static void MakeSnapshot(GameObject go, Sector sector, PropModule.RevealInfo info, IModHelper mod)
|
||||
{
|
||||
SphereShape newShape = MakeShape(go, info, Shape.CollisionMode.Manual);
|
||||
ShapeVisibilityTracker newTracker = go.AddComponent<ShapeVisibilityTracker>();
|
||||
newTracker._shapes = new Shape[] {newShape};
|
||||
ShipLogFactSnapshotTrigger newSnapshotTrigger = go.AddComponent<ShipLogFactSnapshotTrigger>();
|
||||
newSnapshotTrigger._maxDistance = info.maxDistance == -1f ? 200f : info.maxDistance;
|
||||
newSnapshotTrigger._factIDs = info.reveals;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Entry Locations
|
||||
public static class EntryLocationBuilder
|
||||
{
|
||||
private static List<ShipLogEntryLocation> locationsToInitialize = new List<ShipLogEntryLocation>();
|
||||
public static void Make(GameObject go, Sector sector, PropModule.EntryLocationInfo info, IModHelper mod)
|
||||
{
|
||||
GameObject entryLocationGameObject = new GameObject("Entry Location (" + info.id + ")");
|
||||
entryLocationGameObject.SetActive(false);
|
||||
entryLocationGameObject.transform.parent = sector?.transform ?? go.transform;
|
||||
entryLocationGameObject.transform.localPosition = info.position;
|
||||
ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent<ShipLogEntryLocation>();
|
||||
newLocation._entryID = info.id;
|
||||
newLocation._isWithinCloakField = info.cloaked;
|
||||
locationsToInitialize.Add(newLocation);
|
||||
entryLocationGameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public static void InitializeLocations()
|
||||
{
|
||||
locationsToInitialize.ForEach(l => l.InitEntry());
|
||||
locationsToInitialize.Clear();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
|
||||
@ -8,6 +8,7 @@ using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
using System.Reflection;
|
||||
using NewHorizons.Builder.General;
|
||||
using NewHorizons.Utility;
|
||||
using OWML.Common;
|
||||
|
||||
@ -53,6 +54,20 @@ namespace NewHorizons.Builder.Props
|
||||
DialogueBuilder.Make(go, sector, dialogueInfo, mod);
|
||||
}
|
||||
}
|
||||
if (config.Props.Reveal != null)
|
||||
{
|
||||
foreach (var revealInfo in config.Props.Reveal)
|
||||
{
|
||||
ShipLogBuilder.RevealBuilder.Make(go, sector, revealInfo, mod);
|
||||
}
|
||||
}
|
||||
if (config.Props.EntryLocation != null)
|
||||
{
|
||||
foreach (var entryLocationInfo in config.Props.EntryLocation)
|
||||
{
|
||||
ShipLogBuilder.EntryLocationBuilder.Make(go, sector, entryLocationInfo, mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static GameObject LoadPrefab(string assetBundle, string path, string uniqueModName, IModAssets assets)
|
||||
|
||||
@ -145,6 +145,7 @@ namespace NewHorizons.Builder.Props
|
||||
}
|
||||
audioSignal._name = name;
|
||||
audioSignal._sourceRadius = info.SourceRadius;
|
||||
audioSignal._revealFactID = info.Reveals;
|
||||
audioSignal._onlyAudibleToScope = info.OnlyAudibleToScope;
|
||||
audioSignal._identificationDistance = info.IdentificationRadius;
|
||||
audioSignal._canBePickedUpByScope = true;
|
||||
|
||||
19
NewHorizons/External/PropModule.cs
vendored
19
NewHorizons/External/PropModule.cs
vendored
@ -15,6 +15,8 @@ namespace NewHorizons.External
|
||||
public GeyserInfo[] Geysers;
|
||||
public TornadoInfo[] Tornados;
|
||||
public DialogueInfo[] Dialogue;
|
||||
public RevealInfo[] Reveal;
|
||||
public EntryLocationInfo[] EntryLocation;
|
||||
|
||||
public class ScatterInfo
|
||||
{
|
||||
@ -68,5 +70,22 @@ namespace NewHorizons.External
|
||||
public MVector3 remoteTriggerPosition;
|
||||
public string persistentCondition;
|
||||
}
|
||||
|
||||
public class RevealInfo
|
||||
{
|
||||
public string revealOn;
|
||||
public string[] reveals;
|
||||
public MVector3 position;
|
||||
public float radius = 1f;
|
||||
public float maxDistance = -1f; // Snapshot & Observe Only
|
||||
public float maxAngle = 180f; // Observe Only
|
||||
}
|
||||
|
||||
public class EntryLocationInfo
|
||||
{
|
||||
public string id;
|
||||
public bool cloaked;
|
||||
public MVector3 position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
5
NewHorizons/External/ShipLogModule.cs
vendored
5
NewHorizons/External/ShipLogModule.cs
vendored
@ -9,13 +9,16 @@ namespace NewHorizons.External
|
||||
public MapMode mapMode;
|
||||
public CuriosityColor[] curiosities;
|
||||
public EntryPosition[] positions;
|
||||
public string[] initialReveal;
|
||||
|
||||
public class MapMode
|
||||
{
|
||||
public string revealedSprite;
|
||||
public string outlineSprite;
|
||||
public float scale;
|
||||
public float scale = 1f;
|
||||
public bool invisibleWhenHidden;
|
||||
public float offset = 0f;
|
||||
public bool remove = false;
|
||||
}
|
||||
|
||||
public class CuriosityColor
|
||||
|
||||
1
NewHorizons/External/SignalModule.cs
vendored
1
NewHorizons/External/SignalModule.cs
vendored
@ -18,6 +18,7 @@ namespace NewHorizons.External
|
||||
public string Name;
|
||||
public string AudioClip = null;
|
||||
public string AudioFilePath = null;
|
||||
public string Reveals = "";
|
||||
public float SourceRadius = 1f;
|
||||
public float DetectionRadius = 0f;
|
||||
public float IdentificationRadius = 10f;
|
||||
|
||||
@ -60,14 +60,12 @@ namespace NewHorizons.Tools
|
||||
|
||||
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogManager>("Awake", typeof(Patches), nameof(Patches.OnShipLogManagerAwake));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipLogManager>("Start", typeof(Patches), nameof(Patches.OnShipLogManagerStart));
|
||||
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));
|
||||
|
||||
@ -81,7 +79,7 @@ namespace NewHorizons.Tools
|
||||
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogManager>("Awake", typeof(Patches), nameof(Patches.OnShipLogManagerAwakeComplete));
|
||||
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogMapMode>("Initialize", typeof(Patches), nameof(Patches.OnShipLogMapModeInitializeComplete));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<ShipLogMapMode>("Initialize", typeof(Patches), nameof(Patches.OnShipLogMapModeInitialize));
|
||||
}
|
||||
|
||||
public static bool GetHUDDisplayName(ReferenceFrame __instance, ref string __result)
|
||||
@ -408,25 +406,25 @@ namespace NewHorizons.Tools
|
||||
{
|
||||
if (body.Config.ShipLog?.curiosities != null)
|
||||
{
|
||||
ShipLogBuilder.AddCuriosityColors(body.Config.ShipLog.curiosities);
|
||||
ShipLogBuilder.RumorModeBuilder.AddCuriosityColors(body.Config.ShipLog.curiosities);
|
||||
}
|
||||
}
|
||||
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
||||
{
|
||||
if (body.Config.ShipLog?.xmlFile != null)
|
||||
{
|
||||
ShipLogBuilder.AddAstroBodyToShipLog(__instance, body);
|
||||
ShipLogBuilder.RumorModeBuilder.AddBodyToShipLog(__instance, body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void OnShipLogManagerAwakeComplete(ShipLogManager __instance)
|
||||
{
|
||||
ShipLogBuilder.GenerateEntryData(__instance);
|
||||
ShipLogBuilder.RumorModeBuilder.GenerateEntryData(__instance);
|
||||
for (var i = 0; i < __instance._entryList.Count; i++)
|
||||
{
|
||||
ShipLogEntry logEntry = __instance._entryList[i];
|
||||
ShipLogBuilder.UpdateEntryCuriosity(ref logEntry);
|
||||
ShipLogBuilder.RumorModeBuilder.UpdateEntryCuriosity(ref logEntry);
|
||||
}
|
||||
Logger.Log("Ship Log Generation Complete For: " + Main.Instance.CurrentStarSystem, Logger.LogType.Log);
|
||||
}
|
||||
@ -456,14 +454,24 @@ namespace NewHorizons.Tools
|
||||
return Main.Instance.CurrentStarSystem == "SolarSystem";
|
||||
}
|
||||
|
||||
public static bool OnShipLogManagerRevealFact(string __0)
|
||||
public static bool OnShipLogManagerStart(ShipLogManager __instance)
|
||||
{
|
||||
if (Main.Instance.CurrentStarSystem != "SolarSystem" && __0 == "TH_VILLAGE_X1")
|
||||
if (Main.Instance.CurrentStarSystem == "SolarSystem")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (NewHorizonsBody body in Main.BodyDict[Main.Instance.CurrentStarSystem])
|
||||
{
|
||||
foreach (string fact in body.Config.ShipLog?.initialReveal ?? Array.Empty<string>())
|
||||
{
|
||||
__instance.RevealFact(fact, false, false);
|
||||
}
|
||||
}
|
||||
ShipLogBuilder.EntryLocationBuilder.InitializeLocations();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool OnUIStyleManagerGetCuriosityColor(UIStyleManager __instance, CuriosityName __0, bool __1, ref Color __result)
|
||||
@ -474,7 +482,7 @@ namespace NewHorizons.Tools
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = ShipLogBuilder.GetCuriosityColor(__0, __1, __instance._neutralColor, __instance._neutralHighlight);
|
||||
__result = ShipLogBuilder.RumorModeBuilder.GetCuriosityColor(__0, __1, __instance._neutralColor, __instance._neutralHighlight);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -485,17 +493,12 @@ namespace NewHorizons.Tools
|
||||
}
|
||||
|
||||
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);
|
||||
ShipLogAstroObject[][] navMatrix = ShipLogBuilder.MapModeBuilder.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!).");
|
||||
@ -509,7 +512,7 @@ namespace NewHorizons.Tools
|
||||
{
|
||||
DeleteDetail(gameObject.name);
|
||||
}
|
||||
|
||||
// Just Lie About Having A Sand Funnel
|
||||
__instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>();
|
||||
}
|
||||
}
|
||||
@ -524,7 +527,7 @@ namespace NewHorizons.Tools
|
||||
}
|
||||
else
|
||||
{
|
||||
__result = ShipLogBuilder.GetAstroBodyShipLogName(__instance.GetID());
|
||||
__result = ShipLogBuilder.MapModeBuilder.GetAstroBodyShipLogName(__instance.GetID());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
39
NewHorizons/dialogue_schema.xsd
Normal file
39
NewHorizons/dialogue_schema.xsd
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="DialogueTree">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="NameField" type="xs:string"/>
|
||||
<xs:element name="DialogueNode" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Name" type="xs:string"/>
|
||||
<xs:element name="EntryCondition" type="xs:string" minOccurs="0"/>
|
||||
<xs:element name="Dialogue">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Page" type="xs:string" maxOccurs="unbounded"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="DialogueOptionsList" minOccurs="0">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="DialogueOption" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="Text" type="xs:string"/>
|
||||
<xs:element name="DialogueTarget" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@ -791,6 +791,94 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"reveal": {
|
||||
"type": "array",
|
||||
"description": "A set of volumes that reveal ship log fact",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"revealOn": {
|
||||
"type": "string",
|
||||
"description": "'enter', 'observe', or 'snapshot' what needs to be done to the volume to unlock the facts"
|
||||
},
|
||||
"reveals": {
|
||||
"type": "array",
|
||||
"description": "A list of facts to reveal",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"position": {
|
||||
"type": "object",
|
||||
"description": "The position to place the volume at",
|
||||
"properties": {
|
||||
"x": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"y": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"z": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"radius": {
|
||||
"type": "number",
|
||||
"description": "The radius of the volume",
|
||||
"default": 1.0
|
||||
},
|
||||
"maxDistance": {
|
||||
"type": "number",
|
||||
"description": "The max distance the user can be away from the volume to reveal the fact (snapshot and observe only)"
|
||||
},
|
||||
"maxAngle": {
|
||||
"type": "number",
|
||||
"description": "The max view angle the player can see the volume with to unlock the fact",
|
||||
"default": 180.0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"entryLocation": {
|
||||
"type": "array",
|
||||
"description": "A set of locations for ship log entries",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "The ID of the entry this location is for"
|
||||
},
|
||||
"cloaked": {
|
||||
"type": "bool",
|
||||
"description": "Whether this entry location is in a cloaking field",
|
||||
"default": false
|
||||
},
|
||||
"position": {
|
||||
"type": "object",
|
||||
"description": "The position of this entry location",
|
||||
"properties": {
|
||||
"x": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"y": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"z": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -886,6 +974,10 @@
|
||||
"type": "string",
|
||||
"description": "Relative filepath to the .wav file to use as the audio. Mutually exclusive with audioClip"
|
||||
},
|
||||
"reveals": {
|
||||
"type": "string",
|
||||
"description": "A ship log fact to reveal when the signal is identified"
|
||||
},
|
||||
"sourceRadius": {
|
||||
"type": "number",
|
||||
"default": 1,
|
||||
@ -1154,6 +1246,158 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ShipLog": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"xmlFile": {
|
||||
"type": "string",
|
||||
"description": "The xml file to load ship log entries from"
|
||||
},
|
||||
"spriteFolder": {
|
||||
"type": "string",
|
||||
"description": "A path to the folder where entry sprites are stored"
|
||||
},
|
||||
"initialReveal": {
|
||||
"type": "array",
|
||||
"description": "A list of fact IDs to reveal when the game starts",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"positions": {
|
||||
"type": "array",
|
||||
"description": "A set of positions to use instead of automatic layout in rumor mode",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "The name of the entry to apply the position"
|
||||
},
|
||||
"position": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"y": {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"MapMode": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"revealedSprite": {
|
||||
"type": "string",
|
||||
"description": "The path to the sprite to show when the planet is revealed in map mode"
|
||||
},
|
||||
"outlineSprite": {
|
||||
"type": "string",
|
||||
"description": "The path to the sprite to show when the planet is unexplored in map mode"
|
||||
},
|
||||
"scale": {
|
||||
"type": "number",
|
||||
"description": "Scale to apply to the planet in map mode",
|
||||
"default": 1
|
||||
},
|
||||
"invisibleWhenHidden": {
|
||||
"type": "bool",
|
||||
"description": "Hide the planet completely if unexplored instead of showing an outline",
|
||||
"default": false
|
||||
},
|
||||
"offset": {
|
||||
"type": "number",
|
||||
"description": "Extra distance to apply to this object in map mode",
|
||||
"default": 0
|
||||
},
|
||||
"remove": {
|
||||
"type": "boolean",
|
||||
"description": "Completely remove this planet from map mode",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"Curiosities": {
|
||||
"type": "array",
|
||||
"description": "A set of colors to apply to curiosities",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "The ID of the curiosity to apply the color to"
|
||||
},
|
||||
"color": {
|
||||
"type": "object",
|
||||
"description": "The color to apply to entries with this curiosity",
|
||||
"properties": {
|
||||
"R": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"G": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"B": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"A": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
}
|
||||
}
|
||||
},
|
||||
"highlightColor": {
|
||||
"type": "object",
|
||||
"description": "The color to apply to highlighted entries with this curiosity",
|
||||
"properties": {
|
||||
"R": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"G": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"B": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"A": {
|
||||
"type": "integer",
|
||||
"default": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
NewHorizons/shiplog_schema.xsd
Normal file
38
NewHorizons/shiplog_schema.xsd
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="AstroObjectEntry">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ID" type="xs:string"/>
|
||||
<xs:element name="Entry" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ID" type="xs:string"/>
|
||||
<xs:element name="Name" type="xs:string"/>
|
||||
<xs:element name="Curiosity" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="IsCuriosity" minOccurs="0" maxOccurs="unbounded"/>
|
||||
<xs:element name="RumorFact" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="ID" type="xs:string"/>
|
||||
<xs:element name="SourceID" type="xs:string" minOccurs="0"/>
|
||||
<xs:element name="RumorName" type="xs:string"/>
|
||||
<xs:element name="Text" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="ExploreFact" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="ID" type="xs:string"/>
|
||||
<xs:element name="Text" type="xs:string"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
Loading…
x
Reference in New Issue
Block a user