Skip to content

Commit

Permalink
Eye Travel Ordering (#1051)
Browse files Browse the repository at this point in the history
## Minor features

- Add `afterTraveler` to custom Eye Travelers to place them after a base
game traveler in the campfire order (resolves #1037)

## Improvements

- Fix order of travelers at the Eye when both base game guests have been
gathered and custom travelers are used
  • Loading branch information
Hawkbat authored Feb 16, 2025
2 parents cb17ba0 + 3736cb5 commit 52a1b0e
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NewHorizons.External.Modules.Props.Audio;
using NewHorizons.External.Modules.Props.Dialogue;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace NewHorizons.External.Modules.Props.EyeOfTheUniverse
{
Expand Down Expand Up @@ -46,5 +47,23 @@ public class EyeTravelerInfo : DetailInfo
/// The dialogue to use for this traveler. If omitted, the first CharacterDialogueTree in the object will be used.
/// </summary>
public DialogueInfo dialogue;

/// <summary>
/// The name of the base game traveler to position this traveler after at the campfire, starting clockwise from Riebeck. Defaults to the end of the list (right before Riebeck).
/// </summary>
public TravelerName? afterTraveler;


[JsonConverter(typeof(StringEnumConverter))]
public enum TravelerName
{
Riebeck,
Chert,
Esker,
Felspar,
Gabbro,
Solanum,
Prisoner,
}
}
}
62 changes: 49 additions & 13 deletions NewHorizons/Handlers/EyeSceneHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,28 +266,48 @@ public static void UpdateTravelerPositions()

var quantumCampsiteController = Object.FindObjectOfType<QuantumCampsiteController>();

var travelers = new List<Transform>()
{
quantumCampsiteController._travelerControllers[0].transform, // Riebeck
quantumCampsiteController._travelerControllers[2].transform, // Chert
quantumCampsiteController._travelerControllers[6].transform, // Esker
quantumCampsiteController._travelerControllers[1].transform, // Felspar
quantumCampsiteController._travelerControllers[3].transform, // Gabbro
};
var travelers = new List<Transform>();

var hasMetSolanum = quantumCampsiteController._hasMetSolanum;
var hasMetPrisoner = quantumCampsiteController._hasMetPrisoner;

if (quantumCampsiteController._hasMetSolanum)
// The order of the travelers in the base game differs depending on if the player has met both Solanum and the Prisoner or not.
if (hasMetPrisoner && hasMetSolanum)
{
travelers.Add(quantumCampsiteController._travelerControllers[0].transform); // Riebeck
travelers.Add(quantumCampsiteController._travelerControllers[5].transform); // Prisoner
travelers.Add(quantumCampsiteController._travelerControllers[6].transform); // Esker
travelers.Add(quantumCampsiteController._travelerControllers[1].transform); // Felspar
travelers.Add(quantumCampsiteController._travelerControllers[3].transform); // Gabbro
travelers.Add(quantumCampsiteController._travelerControllers[4].transform); // Solanum
travelers.Add(quantumCampsiteController._travelerControllers[2].transform); // Chert
}
if (quantumCampsiteController._hasMetPrisoner)
else
{
travelers.Add(quantumCampsiteController._travelerControllers[5].transform); // Prisoner
travelers.Add(quantumCampsiteController._travelerControllers[0].transform); // Riebeck
travelers.Add(quantumCampsiteController._travelerControllers[2].transform); // Chert
travelers.Add(quantumCampsiteController._travelerControllers[6].transform); // Esker
travelers.Add(quantumCampsiteController._travelerControllers[1].transform); // Felspar
travelers.Add(quantumCampsiteController._travelerControllers[3].transform); // Gabbro
if (hasMetSolanum)
travelers.Add(quantumCampsiteController._travelerControllers[4].transform); // Solanum
if (hasMetPrisoner)
travelers.Add(quantumCampsiteController._travelerControllers[5].transform); // Prisoner
}

// Custom travelers (starting at index 7)
// Custom travelers (starting at index 7, after Esker). We loop through the array instead of the list of custom travelers in case a non-NH mod added their own.
for (int i = 7; i < quantumCampsiteController._travelerControllers.Length; i++)
{
travelers.Add(quantumCampsiteController._travelerControllers[i].transform);
var travelerInfo = GetActiveCustomEyeTravelers().FirstOrDefault(t => t.controller == quantumCampsiteController._travelerControllers[i]);
var travelerName = travelerInfo?.info?.afterTraveler;
if (travelerName.HasValue)
{
InsertTravelerAfter(quantumCampsiteController, travelers, travelerInfo.info.afterTraveler.ToString(), quantumCampsiteController._travelerControllers[i].transform);
}
else
{
travelers.Add(quantumCampsiteController._travelerControllers[i].transform);
}
}

var radius = 2f + 0.2f * travelers.Count;
Expand All @@ -312,6 +332,22 @@ public static void UpdateTravelerPositions()
}
}

private static void InsertTravelerAfter(QuantumCampsiteController campsite, List<Transform> travelers, string travelerName, Transform newTraveler)
{
if (travelerName == "Prisoner")
travelerName = "Prisoner_Campfire";
var existingTraveler = campsite._travelerControllers.FirstOrDefault(c => c.name == travelerName);
if (existingTraveler != null)
{
var index = travelers.IndexOf(existingTraveler.transform);
travelers.Insert(index + 1, newTraveler);
}
else
{
travelers.Add(newTraveler);
}
}

public class EyeTravelerData
{
public string id;
Expand Down
33 changes: 33 additions & 0 deletions NewHorizons/Schemas/body_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,17 @@
"dialogue": {
"description": "The dialogue to use for this traveler. If omitted, the first CharacterDialogueTree in the object will be used.",
"$ref": "#/definitions/DialogueInfo"
},
"afterTraveler": {
"description": "The name of the base game traveler to position this traveler after at the campfire, starting clockwise from Riebeck. Defaults to the end of the list (right before Riebeck).",
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/definitions/TravelerName"
}
]
}
}
},
Expand Down Expand Up @@ -1522,6 +1533,28 @@
"none"
]
},
"TravelerName": {
"type": "string",
"description": "",
"x-enumNames": [
"Riebeck",
"Chert",
"Esker",
"Felspar",
"Gabbro",
"Solanum",
"Prisoner"
],
"enum": [
"Riebeck",
"Chert",
"Esker",
"Felspar",
"Gabbro",
"Solanum",
"Prisoner"
]
},
"InstrumentZoneInfo": {
"type": "object",
"additionalProperties": false,
Expand Down

0 comments on commit 52a1b0e

Please sign in to comment.