Added curiousities to api

This commit is contained in:
Nick 2023-07-21 11:54:52 -04:00
parent 74b10f4e53
commit ba30f13076
3 changed files with 39 additions and 11 deletions

View File

@ -14,6 +14,14 @@ namespace NewHorizons.External.SerializableData
this.a = a; this.a = a;
} }
public MColor(Color color)
{
r = (int)(color.r * 255);
g = (int)(color.g * 255);
b = (int)(color.b * 255);
a = (int)(color.a * 255);
}
/// <summary> /// <summary>
/// The red component of this colour from 0-255, higher values will make the colour glow if applicable. /// The red component of this colour from 0-255, higher values will make the colour glow if applicable.
/// </summary> /// </summary>

View File

@ -18,12 +18,13 @@ namespace NewHorizons
/// <summary> /// <summary>
/// Directly add ship logs from XML. Call this method right before ShipLogManager awake. /// Directly add ship logs from XML. Call this method right before ShipLogManager awake.
/// </summary> /// </summary>
/// <param name="mod"></param> /// <param name="mod">The mod this method is being called from. This is required for loading files.</param>
/// <param name="manager"></param> /// <param name="xml">The ship log xml contents</param>
/// <param name="xml"></param> /// <param name="planetName">The planet that these ship logs correspond to in the map mode</param>
/// <param name="planetName"></param> /// <param name="imageFolder">The relative path from your mod manifest.json where the ship log images are located. The filename must be the same as the fact id. Optional.</param>
/// <param name="entryPositions"></param> /// <param name="entryPositions">A dictionary of each fact id to its 2D position in the ship log. Optional.</param>
void AddShipLogXML(IModBehaviour mod, ShipLogManager manager, XElement xml, string planetName, Dictionary<string, Vector2> entryPositions); /// <param name="curiousityColours">A dictionary of each curiousity ID to its colour and highlight colour in the ship log. Optional.</param>
void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, string imageFolder = null, Dictionary<string, Vector2> entryPositions = null, Dictionary<string, (Color colour, Color highlight)> curiousityColours = null);
/// <summary> /// <summary>
/// Will load all configs in the regular folders (planets, systems, translations, etc) for this mod. /// Will load all configs in the regular folders (planets, systems, translations, etc) for this mod.

View File

@ -7,6 +7,7 @@ using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props; using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules.Props.Audio; using NewHorizons.External.Modules.Props.Audio;
using NewHorizons.External.Modules.Props.Dialogue; using NewHorizons.External.Modules.Props.Dialogue;
using NewHorizons.External.SerializableData;
using NewHorizons.Utility; using NewHorizons.Utility;
using NewHorizons.Utility.OWML; using NewHorizons.Utility.OWML;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -66,9 +67,17 @@ namespace NewHorizons
} }
} }
public void AddShipLogXML(IModBehaviour mod, ShipLogManager manager, XElement xml, string planetName, Dictionary<string, Vector2> entryPositions) public void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, string imageFolder, Dictionary<string, Vector2> entryPositions, Dictionary<string, (Color colour, Color highlight)> curiousityColours)
{ {
var body = new NewHorizonsBody(new PlanetConfig() { name = planetName, starSystem = Main.Instance.CurrentStarSystem }, mod); var body = new NewHorizonsBody(new PlanetConfig()
{
name = planetName,
starSystem = Main.Instance.CurrentStarSystem,
ShipLog = new ShipLogModule()
{
spriteFolder = imageFolder
}
}, mod);
if (!Main.BodyDict.ContainsKey(Main.Instance.CurrentStarSystem)) if (!Main.BodyDict.ContainsKey(Main.Instance.CurrentStarSystem))
{ {
@ -77,7 +86,8 @@ namespace NewHorizons
} }
else else
{ {
var existingBody = Main.BodyDict[Main.Instance.CurrentStarSystem].FirstOrDefault(x => x.Config.name == planetName); var existingBody = Main.BodyDict[Main.Instance.CurrentStarSystem]
.FirstOrDefault(x => x.Config.name == planetName && x.Mod.ModHelper.Manifest.UniqueName == mod.ModHelper.Manifest.UniqueName);
if (existingBody != null) if (existingBody != null)
{ {
body = existingBody; body = existingBody;
@ -88,10 +98,19 @@ namespace NewHorizons
} }
} }
var system = new StarSystemConfig() { entryPositions = entryPositions.Select((pair) => new EntryPositionInfo() { id = pair.Key, position = pair.Value }).ToArray() }; var system = new StarSystemConfig()
{
entryPositions = entryPositions
.Select((pair) => new EntryPositionInfo() { id = pair.Key, position = pair.Value })
.ToArray(),
curiosities = curiousityColours
.Select((pair) => new CuriosityColorInfo() { id = pair.Key, color = new MColor(pair.Value.colour), highlightColor = new MColor(pair.Value.highlight) })
.ToArray()
};
Main.Instance.LoadStarSystemConfig(system, null, mod); Main.Instance.LoadStarSystemConfig(system, null, mod);
RumorModeBuilder.AddShipLogXML(manager, xml, body); RumorModeBuilder.AddShipLogXML(GameObject.FindObjectOfType<ShipLogManager>(), xml, body);
} }
public void LoadConfigs(IModBehaviour mod) public void LoadConfigs(IModBehaviour mod)