mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
integrated auto spirals with NomaiTextBuilder
This commit is contained in:
parent
0860e93efb
commit
e705c9bdc6
@ -16,14 +16,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
public float maxY = 5f;
|
public float maxY = 5f;
|
||||||
public float minY = -1f;
|
public float minY = -1f;
|
||||||
|
|
||||||
public static SpiralManipulator Place(GameObject spiralMeshHolder = null) {
|
public static SpiralManipulator Place(NomaiTextArcBuilder.SpiralProfile profile, GameObject spiralMeshHolder) {
|
||||||
if (spiralMeshHolder == null)
|
var rootArc = NomaiTextArcBuilder.BuildSpiralGameObject(profile);
|
||||||
{
|
|
||||||
spiralMeshHolder = new GameObject("spiral holder");
|
|
||||||
spiralMeshHolder.AddComponent<NomaiTextArcArranger>();
|
|
||||||
}
|
|
||||||
|
|
||||||
var rootArc = NomaiTextArcBuilder.BuildSpiralGameObject(NomaiTextArcBuilder.adultSpiralProfile);
|
|
||||||
rootArc.transform.parent = spiralMeshHolder.transform;
|
rootArc.transform.parent = spiralMeshHolder.transform;
|
||||||
rootArc.transform.localEulerAngles = new Vector3(0, 0, Random.Range(-60, 60));
|
rootArc.transform.localEulerAngles = new Vector3(0, 0, Random.Range(-60, 60));
|
||||||
|
|
||||||
@ -218,8 +212,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
get { return new Vector2(this.transform.position.x, this.transform.position.y); }
|
get { return new Vector2(this.transform.position.x, this.transform.position.y); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpiralManipulator AddChild() {
|
public SpiralManipulator AddChild(NomaiTextArcBuilder.SpiralProfile profile) {
|
||||||
return AddChild(NomaiTextArcArranger.Place(this.transform.parent.gameObject).gameObject);
|
return AddChild(NomaiTextArcArranger.Place(profile, this.transform.parent.gameObject).gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpiralManipulator AddChild(GameObject prebuiltChild) {
|
public SpiralManipulator AddChild(GameObject prebuiltChild) {
|
||||||
|
|||||||
@ -16,8 +16,6 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
public static class NomaiTextBuilder
|
public static class NomaiTextBuilder
|
||||||
{
|
{
|
||||||
private static List<GameObject> _arcPrefabs;
|
|
||||||
private static List<GameObject> _childArcPrefabs;
|
|
||||||
private static List<GameObject> _ghostArcPrefabs;
|
private static List<GameObject> _ghostArcPrefabs;
|
||||||
private static GameObject _scrollPrefab;
|
private static GameObject _scrollPrefab;
|
||||||
private static GameObject _computerPrefab;
|
private static GameObject _computerPrefab;
|
||||||
@ -44,8 +42,6 @@ namespace NewHorizons.Builder.Props
|
|||||||
return conversationInfoToCorrespondingSpawnedGameObject[convo];
|
return conversationInfoToCorrespondingSpawnedGameObject[convo];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<GameObject> GetArcPrefabs() { return _arcPrefabs; }
|
|
||||||
public static List<GameObject> GetChildArcPrefabs() { return _childArcPrefabs; }
|
|
||||||
public static List<GameObject> GetGhostArcPrefabs() { return _ghostArcPrefabs; }
|
public static List<GameObject> GetGhostArcPrefabs() { return _ghostArcPrefabs; }
|
||||||
|
|
||||||
private static bool _isInit;
|
private static bool _isInit;
|
||||||
@ -56,29 +52,6 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
_isInit = true;
|
_isInit = true;
|
||||||
|
|
||||||
if (_arcPrefabs == null || _childArcPrefabs == null)
|
|
||||||
{
|
|
||||||
// Just take every scroll and get the first arc
|
|
||||||
var existingArcs = GameObject.FindObjectsOfType<ScrollItem>()
|
|
||||||
.Select(x => x?._nomaiWallText?.gameObject?.transform?.Find("Arc 1")?.gameObject)
|
|
||||||
.Where(x => x != null)
|
|
||||||
.OrderBy(x => x.transform.GetPath()) // order by path so game updates dont break things
|
|
||||||
.ToArray();
|
|
||||||
_arcPrefabs = new List<GameObject>();
|
|
||||||
_childArcPrefabs = new List<GameObject>();
|
|
||||||
foreach (var existingArc in existingArcs)
|
|
||||||
{
|
|
||||||
if (existingArc.GetComponent<MeshRenderer>().material.name.Contains("Child"))
|
|
||||||
{
|
|
||||||
_childArcPrefabs.Add(existingArc.InstantiateInactive().Rename("Arc (Child)").DontDestroyOnLoad());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_arcPrefabs.Add(existingArc.InstantiateInactive().Rename("Arc").DontDestroyOnLoad());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_ghostArcPrefabs == null)
|
if (_ghostArcPrefabs == null)
|
||||||
{
|
{
|
||||||
var existingGhostArcs = GameObject.FindObjectsOfType<GhostWallText>()
|
var existingGhostArcs = GameObject.FindObjectsOfType<GhostWallText>()
|
||||||
@ -644,6 +617,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var arranger = nomaiWallText.gameObject.AddComponent<NomaiTextArcArranger>();
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
foreach (var textData in dict.Values)
|
foreach (var textData in dict.Values)
|
||||||
{
|
{
|
||||||
@ -660,65 +635,76 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (var k = 0; k < i*2; k++)
|
||||||
|
{
|
||||||
|
var overlap = arranger.Overlap();
|
||||||
|
if (overlap.x < 0) return;
|
||||||
|
|
||||||
|
arranger.AttemptOverlapResolution(overlap);
|
||||||
|
for(var a = 0; a < 10; a++) arranger.Step();
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.LogError("Overlap resolution failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static GameObject MakeArc(PropModule.NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID)
|
internal static GameObject MakeArc(PropModule.NomaiTextArcInfo arcInfo, GameObject conversationZone, GameObject parent, int textEntryID)
|
||||||
{
|
{
|
||||||
GameObject arc;
|
GameObject arc;
|
||||||
var type = arcInfo != null ? arcInfo.type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult;
|
var type = arcInfo != null ? arcInfo.type : PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult;
|
||||||
var variation = arcInfo != null ? arcInfo.variation : -1;
|
NomaiTextArcBuilder.SpiralProfile profile = new();
|
||||||
|
Material mat = null;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child:
|
case PropModule.NomaiTextArcInfo.NomaiTextArcType.Child:
|
||||||
variation = variation < 0
|
profile = NomaiTextArcBuilder.childSpiralProfile;
|
||||||
? Random.Range(0, _childArcPrefabs.Count())
|
// TODO: set mat
|
||||||
: (variation % _childArcPrefabs.Count());
|
|
||||||
arc = _childArcPrefabs[variation].InstantiateInactive();
|
|
||||||
break;
|
break;
|
||||||
case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any():
|
case PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger when _ghostArcPrefabs.Any():
|
||||||
variation = variation < 0
|
profile = NomaiTextArcBuilder.strangerSpiralProfile;
|
||||||
? Random.Range(0, _ghostArcPrefabs.Count())
|
// TODO: set mat
|
||||||
: (variation % _ghostArcPrefabs.Count());
|
|
||||||
arc = _ghostArcPrefabs[variation].InstantiateInactive();
|
|
||||||
break;
|
break;
|
||||||
case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult:
|
case PropModule.NomaiTextArcInfo.NomaiTextArcType.Adult:
|
||||||
default:
|
default:
|
||||||
variation = variation < 0
|
profile = NomaiTextArcBuilder.adultSpiralProfile;
|
||||||
? Random.Range(0, _arcPrefabs.Count())
|
// TODO: set mat
|
||||||
: (variation % _arcPrefabs.Count());
|
|
||||||
arc = _arcPrefabs[variation].InstantiateInactive();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (parent != null) arc = parent.GetComponent<SpiralManipulator>().AddChild(profile).gameObject;
|
||||||
|
else arc = NomaiTextArcArranger.Place(profile, conversationZone).gameObject;
|
||||||
|
|
||||||
|
if (mat != null) arc.GetComponent<MeshRenderer>().sharedMaterial = mat;
|
||||||
|
|
||||||
arc.transform.parent = conversationZone.transform;
|
arc.transform.parent = conversationZone.transform;
|
||||||
arc.GetComponent<NomaiTextLine>()._prebuilt = false;
|
arc.GetComponent<NomaiTextLine>()._prebuilt = false;
|
||||||
|
|
||||||
if (arcInfo != null)
|
//if (arcInfo != null)
|
||||||
{
|
//{
|
||||||
arcInfo.variation = variation;
|
// arcInfo.variation = variation;
|
||||||
if (arcInfo.position == null) arc.transform.localPosition = Vector3.zero;
|
// if (arcInfo.position == null) arc.transform.localPosition = Vector3.zero;
|
||||||
else arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0);
|
// else arc.transform.localPosition = new Vector3(arcInfo.position.x, arcInfo.position.y, 0);
|
||||||
|
|
||||||
arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation);
|
// arc.transform.localRotation = Quaternion.Euler(0, 0, arcInfo.zRotation);
|
||||||
|
|
||||||
if (arcInfo.mirror) arc.transform.localScale = new Vector3(-1, 1, 1);
|
// if (arcInfo.mirror) arc.transform.localScale = new Vector3(-1, 1, 1);
|
||||||
}
|
//}
|
||||||
// Try auto I guess
|
//// Try auto I guess
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
if (parent == null)
|
// if (parent == null)
|
||||||
{
|
// {
|
||||||
arc.transform.localPosition = Vector3.zero;
|
// arc.transform.localPosition = Vector3.zero;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
var points = parent.GetComponent<NomaiTextLine>().GetPoints();
|
// var points = parent.GetComponent<NomaiTextLine>().GetPoints();
|
||||||
var point = points[points.Count() / 2];
|
// var point = points[points.Count() / 2];
|
||||||
|
|
||||||
arc.transform.localPosition = point;
|
// arc.transform.localPosition = point;
|
||||||
arc.transform.localRotation = Quaternion.Euler(0, 0, Random.Range(0, 360));
|
// arc.transform.localRotation = Quaternion.Euler(0, 0, Random.Range(0, 360));
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
arc.GetComponent<NomaiTextLine>().SetEntryID(textEntryID);
|
arc.GetComponent<NomaiTextLine>().SetEntryID(textEntryID);
|
||||||
arc.GetComponent<MeshRenderer>().enabled = false;
|
arc.GetComponent<MeshRenderer>().enabled = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user