Tidying up some awkward patterns

This commit is contained in:
Joshua Thome 2025-08-11 19:09:51 -05:00
parent bb390c5715
commit edde8eecb2
3 changed files with 31 additions and 22 deletions

View File

@ -345,30 +345,38 @@ namespace NewHorizons.Builder.Props
{ {
if (info.attentionPoint != null) if (info.attentionPoint != null)
{ {
var pointSector = sector; MakeAttentionPoint(go, sector, dialogue, info.attentionPoint);
var ptGo = GeneralPropBuilder.MakeNew("AttentionPoint", go, ref pointSector, info.attentionPoint, defaultParent: dialogue.transform);
dialogue._attentionPoint = ptGo.transform;
dialogue._attentionPointOffset = info.attentionPoint.offset ?? Vector3.zero;
ptGo.SetActive(true);
} }
if (info.swappedAttentionPoints != null && info.swappedAttentionPoints.Length > 0) if (info.swappedAttentionPoints != null && info.swappedAttentionPoints.Length > 0)
{ {
foreach (var pointInfo in info.swappedAttentionPoints) foreach (var pointInfo in info.swappedAttentionPoints)
{ {
var pointSector = sector; MakeSwappedAttentionPoint(go, sector, dialogue, pointInfo);
var ptGo = GeneralPropBuilder.MakeNew($"AttentionPoint_{pointInfo.dialogueNode}_{pointInfo.dialoguePage}", go, ref pointSector, pointInfo, defaultParent: dialogue.transform);
var swapper = ptGo.AddComponent<DialogueAttentionPointSwapper>();
swapper._dialogueTree = dialogue;
swapper._attentionPoint = ptGo.transform;
swapper._attentionPointOffset = pointInfo.offset ?? Vector3.zero;
swapper._nodeName = pointInfo.dialogueNode;
swapper._dialoguePage = pointInfo.dialoguePage;
swapper._lookEasing = pointInfo.lookEasing;
ptGo.SetActive(true);
} }
} }
} }
private static void MakeAttentionPoint(GameObject go, Sector sector, CharacterDialogueTree dialogue, AttentionPointInfo info)
{
var ptGo = GeneralPropBuilder.MakeNew("AttentionPoint", go, ref sector, info, defaultParent: dialogue.transform);
dialogue._attentionPoint = ptGo.transform;
dialogue._attentionPointOffset = info.offset ?? Vector3.zero;
ptGo.SetActive(true);
}
private static void MakeSwappedAttentionPoint(GameObject go, Sector sector, CharacterDialogueTree dialogue, SwappedAttentionPointInfo info)
{
var ptGo = GeneralPropBuilder.MakeNew($"AttentionPoint_{info.dialogueNode}_{info.dialoguePage}", go, ref sector, info, defaultParent: dialogue.transform);
var swapper = ptGo.AddComponent<DialogueAttentionPointSwapper>();
swapper._dialogueTree = dialogue;
swapper._attentionPoint = ptGo.transform;
swapper._attentionPointOffset = info.offset ?? Vector3.zero;
swapper._nodeName = info.dialogueNode;
swapper._dialoguePage = info.dialoguePage;
swapper._lookEasing = info.lookEasing;
ptGo.SetActive(true);
}
private static void MakePlayerTrackingZone(GameObject go, CharacterDialogueTree dialogue, DialogueInfo info) private static void MakePlayerTrackingZone(GameObject go, CharacterDialogueTree dialogue, DialogueInfo info)
{ {
var character = go.transform.Find(info.pathToAnimController); var character = go.transform.Find(info.pathToAnimController);

View File

@ -65,9 +65,10 @@ namespace NewHorizons.Builder.Props
if (_interfacePrefab == null || planetGO == null || sector == null || _detailedPlatformPrefab == null || _platformPrefab == null) return null; if (_interfacePrefab == null || planetGO == null || sector == null || _detailedPlatformPrefab == null || _platformPrefab == null) return null;
var planetSector = sector;
var detailInfo = new DetailInfo(info.controls) { keepLoaded = true }; var detailInfo = new DetailInfo(info.controls) { keepLoaded = true };
var cannonSector = sector; var gravityCannonObject = DetailBuilder.Make(planetGO, ref sector, mod, _interfacePrefab, detailInfo);
var gravityCannonObject = DetailBuilder.Make(planetGO, ref cannonSector, mod, _interfacePrefab, detailInfo);
gravityCannonObject.SetActive(false); gravityCannonObject.SetActive(false);
var gravityCannonController = gravityCannonObject.GetComponent<GravityCannonController>(); var gravityCannonController = gravityCannonObject.GetComponent<GravityCannonController>();
@ -78,14 +79,14 @@ namespace NewHorizons.Builder.Props
gravityCannonController._retrieveShipLogFact = info.retrieveReveal ?? string.Empty; gravityCannonController._retrieveShipLogFact = info.retrieveReveal ?? string.Empty;
gravityCannonController._launchShipLogFact = info.launchReveal ?? string.Empty; gravityCannonController._launchShipLogFact = info.launchReveal ?? string.Empty;
CreatePlatform(planetGO, sector, mod, gravityCannonController, info); CreatePlatform(planetGO, planetSector, mod, gravityCannonController, info);
if (info.computer != null) if (info.computer != null)
{ {
// Do it next update so that the shuttle has been made // Do it next update so that the shuttle has been made
Delay.FireOnNextUpdate(() => Delay.FireOnNextUpdate(() =>
{ {
gravityCannonController._nomaiComputer = CreateComputer(planetGO, sector, info.computer, id); gravityCannonController._nomaiComputer = CreateComputer(planetGO, planetSector, info.computer, id);
}); });
} }
else else

View File

@ -92,9 +92,9 @@ namespace NewHorizons.Builder.Props
public static void Make(GameObject planetGO, Sector sector, IModBehaviour mod, NomaiWarpReceiverInfo info) public static void Make(GameObject planetGO, Sector sector, IModBehaviour mod, NomaiWarpReceiverInfo info)
{ {
var planetSector = sector;
var detailInfo = new DetailInfo(info); var detailInfo = new DetailInfo(info);
var receiverSector = sector; var receiverObject = DetailBuilder.Make(planetGO, ref sector, mod, info.detailed ? _detailedReceiverPrefab : _receiverPrefab, detailInfo);
var receiverObject = DetailBuilder.Make(planetGO, ref receiverSector, mod, info.detailed ? _detailedReceiverPrefab : _receiverPrefab, detailInfo);
NHLogger.Log($"Position is {detailInfo.position} was {info.position}"); NHLogger.Log($"Position is {detailInfo.position} was {info.position}");
@ -127,7 +127,7 @@ namespace NewHorizons.Builder.Props
if (info.computer != null) if (info.computer != null)
{ {
CreateComputer(planetGO, sector, mod, info.computer, receiver); CreateComputer(planetGO, planetSector, mod, info.computer, receiver);
} }
} }