diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 9e50184c..82ac960e 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -1,3 +1,4 @@ +using Epic.OnlineServices.Presence; using NewHorizons.Builder.Props; using NewHorizons.External.Modules; using NewHorizons.Utility; @@ -18,8 +19,7 @@ namespace NewHorizons.Builder.General if (!Main.Instance.IsWarpingFromVessel && !Main.Instance.IsWarpingFromShip && module.playerSpawn != null) { - bool alignToBody = module.playerSpawn.rotation == null; - GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO, null, module.playerSpawn, alignToBody: alignToBody); + GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO, null, module.playerSpawn); spawnGO.layer = LayerUtilities.PlayerSafetyCollider; playerSpawn = spawnGO.AddComponent(); @@ -29,8 +29,7 @@ namespace NewHorizons.Builder.General } if (module.shipSpawn != null) { - bool alignToBody = module.shipSpawn.rotation == null; - GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO, null, module.shipSpawn, alignToBody: alignToBody); + GameObject spawnGO = GeneralPropBuilder.MakeNew("ShipSpawnPoint", planetGO, null, module.shipSpawn); spawnGO.layer = LayerUtilities.PlayerSafetyCollider; var spawnPoint = spawnGO.AddComponent(); @@ -44,7 +43,7 @@ namespace NewHorizons.Builder.General ship.transform.rotation = spawnGO.transform.rotation; // Move it up a bit more when aligning to surface - if (alignToBody) + if (module.shipSpawn.alignRadial.GetValueOrDefault()) { ship.transform.position += ship.transform.up * 4f; } diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index da732970..e4e59795 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -90,12 +90,12 @@ namespace NewHorizons.Builder.Props // We save copies with all their components fixed, good if the user is placing the same detail more than once if (detail?.path != null && _fixedPrefabCache.TryGetValue((sector, detail.path), out var storedPrefab)) { - prop = GeneralPropBuilder.MakeFromPrefab(storedPrefab.prefab, prefab.name, go, sector, detail, alignToBody: detail.alignToNormal); + prop = GeneralPropBuilder.MakeFromPrefab(storedPrefab.prefab, prefab.name, go, sector, detail); isItem = storedPrefab.isItem; } else { - prop = GeneralPropBuilder.MakeFromPrefab(prefab, prefab.name, go, sector, detail, alignToBody: detail.alignToNormal); + prop = GeneralPropBuilder.MakeFromPrefab(prefab, prefab.name, go, sector, detail); StreamingHandler.SetUpStreaming(prop, sector); diff --git a/NewHorizons/Builder/Props/GeneralPropBuilder.cs b/NewHorizons/Builder/Props/GeneralPropBuilder.cs index 28f1c13e..eae23d74 100644 --- a/NewHorizons/Builder/Props/GeneralPropBuilder.cs +++ b/NewHorizons/Builder/Props/GeneralPropBuilder.cs @@ -15,7 +15,6 @@ namespace NewHorizons.Builder.Props { public static GameObject MakeFromExisting(GameObject go, GameObject planetGO, Sector sector, GeneralPointPropInfo info, - bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform parentOverride = null) { if (info == null) return go; @@ -61,9 +60,11 @@ namespace NewHorizons.Builder.Props var pos = (Vector3)(info.position ?? defaultPosition ?? Vector3.zero); var rot = Quaternion.identity; + var alignRadial = false; if (info is GeneralPropInfo rotInfo) { rot = rotInfo.rotation != null ? Quaternion.Euler(rotInfo.rotation) : Quaternion.identity; + alignRadial = rotInfo.alignRadial.HasValue && rotInfo.alignRadial.Value; } if (info.isRelativeToParent) { @@ -80,43 +81,30 @@ namespace NewHorizons.Builder.Props go.transform.position = pos; go.transform.rotation = rot; } - if (alignToBody) + if (alignRadial) { var up = (go.transform.position - planetGO.transform.position).normalized; - if (normal != null) - { - if (info.isRelativeToParent) - { - up = go.transform.parent.TransformDirection(normal); - } - else - { - up = planetGO.transform.TransformDirection(normal); - } - } - go.transform.rotation = Quaternion.FromToRotation(go.transform.up, up) * rot; + go.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * rot; } return go; } public static GameObject MakeNew(string defaultName, - GameObject planetGO, Sector sector, GeneralPointPropInfo info, - bool alignToBody = false, MVector3 normal = null, + GameObject planetGO, Sector sector, GeneralPointPropInfo info, MVector3 defaultPosition = null, string defaultParentPath = null, Transform parentOverride = null) { var go = new GameObject(defaultName); go.SetActive(false); - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, parentOverride); + return MakeFromExisting(go, planetGO, sector, info, defaultPosition, defaultParentPath, parentOverride); } public static GameObject MakeFromPrefab(GameObject prefab, string defaultName, GameObject planetGO, Sector sector, GeneralPointPropInfo info, - bool alignToBody = false, MVector3 normal = null, MVector3 defaultPosition = null, string defaultParentPath = null, Transform parentOverride = null) { var go = prefab.InstantiateInactive(); go.name = defaultName; - return MakeFromExisting(go, planetGO, sector, info, alignToBody, normal, defaultPosition, defaultParentPath, parentOverride); + return MakeFromExisting(go, planetGO, sector, info, defaultPosition, defaultParentPath, parentOverride); } } } diff --git a/NewHorizons/Builder/Props/GeyserBuilder.cs b/NewHorizons/Builder/Props/GeyserBuilder.cs index e8b1f723..cdd9c714 100644 --- a/NewHorizons/Builder/Props/GeyserBuilder.cs +++ b/NewHorizons/Builder/Props/GeyserBuilder.cs @@ -20,22 +20,11 @@ namespace NewHorizons.Builder.Props InitPrefab(); var geyserGO = GeneralPropBuilder.MakeFromPrefab(_geyserPrefab, "Geyser", planetGO, sector, info); - - var pos = planetGO.transform.InverseTransformPoint(geyserGO.transform.position); - // Offset height, default -97.5 pushes it underground so the spout is at the surface - var length = pos.magnitude + info.offset; - - // About 130 high, bubbles start at 10, shaft starts at 67, spout starts at 97.5 - geyserGO.transform.position = planetGO.transform.TransformPoint(pos.normalized * length); + geyserGO.transform.position += geyserGO.transform.up * info.offset; geyserGO.transform.localScale = Vector3.one; - // Geyser alignment is technically incorrect due to inheriting the prefab's rotation but we need backwards compat so explicitly applying it here - geyserGO.transform.rotation = _geyserPrefab.transform.rotation; - var up = planetGO.transform.TransformPoint(pos) - planetGO.transform.position; - geyserGO.transform.rotation = Quaternion.FromToRotation(geyserGO.transform.up, up) * _geyserPrefab.transform.rotation; - var bubbles = geyserGO.FindChild("GeyserParticles/GeyserBubbles"); var shaft = geyserGO.FindChild("GeyserParticles/GeyserShaft"); var spout = geyserGO.FindChild("GeyserParticles/GeyserSpout"); diff --git a/NewHorizons/Builder/Props/NomaiTextBuilder.cs b/NewHorizons/Builder/Props/NomaiTextBuilder.cs index c0910bfa..400170b6 100644 --- a/NewHorizons/Builder/Props/NomaiTextBuilder.cs +++ b/NewHorizons/Builder/Props/NomaiTextBuilder.cs @@ -151,7 +151,7 @@ namespace NewHorizons.Builder.Props switch (info.type) { - case PropModule.NomaiTextInfo.NomaiTextType.Wall: + case PropModule.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath).gameObject; @@ -216,7 +216,7 @@ namespace NewHorizons.Builder.Props return nomaiWallTextObj; } - case PropModule.NomaiTextInfo.NomaiTextType.Scroll: + case PropModule.NomaiTextType.Scroll: { var customScroll = _scrollPrefab.InstantiateInactive(); @@ -305,7 +305,7 @@ namespace NewHorizons.Builder.Props return customScroll; } - case PropModule.NomaiTextInfo.NomaiTextType.Computer: + case PropModule.NomaiTextType.Computer: { var computerObject = _computerPrefab.InstantiateInactive(); @@ -358,7 +358,7 @@ namespace NewHorizons.Builder.Props return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashComputer: + case PropModule.NomaiTextType.PreCrashComputer: { var detailInfo = new PropModule.DetailInfo() { @@ -408,10 +408,10 @@ namespace NewHorizons.Builder.Props return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Cairn: - case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: + case PropModule.NomaiTextType.Cairn: + case PropModule.NomaiTextType.CairnVariant: { - var cairnObject = (info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive(); + var cairnObject = (info.type == PropModule.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab).InstantiateInactive(); if (!string.IsNullOrEmpty(info.rename)) { @@ -483,10 +483,10 @@ namespace NewHorizons.Builder.Props return cairnObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: - case PropModule.NomaiTextInfo.NomaiTextType.Recorder: + case PropModule.NomaiTextType.PreCrashRecorder: + case PropModule.NomaiTextType.Recorder: { - var prefab = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); + var prefab = (info.type == PropModule.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); var detailInfo = new PropModule.DetailInfo { parentPath = info.parentPath, rotation = info.rotation, @@ -518,7 +518,7 @@ namespace NewHorizons.Builder.Props conversationInfoToCorrespondingSpawnedGameObject[info] = recorderObject; return recorderObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: + case PropModule.NomaiTextType.Trailmarker: { var trailmarkerObject = _trailmarkerPrefab.InstantiateInactive(); diff --git a/NewHorizons/Builder/Props/RemoteBuilder.cs b/NewHorizons/Builder/Props/RemoteBuilder.cs index 2bee70b9..b62e1f75 100644 --- a/NewHorizons/Builder/Props/RemoteBuilder.cs +++ b/NewHorizons/Builder/Props/RemoteBuilder.cs @@ -195,7 +195,7 @@ namespace NewHorizons.Builder.Props { var textInfo = info.nomaiText[i]; component._remoteIDs[i] = RemoteHandler.GetPlatformID(textInfo.id); - var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new PropModule.NomaiTextInfo + var wallText = TranslatorTextBuilder.Make(whiteboard, sector, new PropModule.TranslatorTextInfo { arcInfo = textInfo.arcInfo, location = textInfo.location, @@ -204,7 +204,7 @@ namespace NewHorizons.Builder.Props rename = textInfo.rename, rotation = Vector3.zero, seed = textInfo.seed, - type = PropModule.NomaiTextInfo.NomaiTextType.Wall, + type = PropModule.NomaiTextType.Wall, xmlFile = textInfo.xmlFile }, nhBody).GetComponent(); wallText._showTextOnStart = false; diff --git a/NewHorizons/Builder/Props/TornadoBuilder.cs b/NewHorizons/Builder/Props/TornadoBuilder.cs index 17cebf59..2341211f 100644 --- a/NewHorizons/Builder/Props/TornadoBuilder.cs +++ b/NewHorizons/Builder/Props/TornadoBuilder.cs @@ -100,7 +100,7 @@ namespace NewHorizons.Builder.Props private static void MakeTornado(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, Vector3 position, bool downwards) { var prefab = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive(); - var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, true, defaultPosition: position); + var tornadoGO = GeneralPropBuilder.MakeFromPrefab(prefab, downwards ? "Tornado_Down" : "Tornado_Up", planetGO, sector, info, defaultPosition: position); // Add the sound thing before changing the scale var soundGO = _soundPrefab.InstantiateInactive(); diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 9361fd22..6dc4bc90 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -37,9 +37,9 @@ namespace NewHorizons.Builder.Props return arcInfoToCorrespondingSpawnedGameObject[arc]; } - private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); + private static Dictionary conversationInfoToCorrespondingSpawnedGameObject = new Dictionary(); - public static GameObject GetSpawnedGameObjectByNomaiTextInfo(PropModule.NomaiTextInfo convo) + public static GameObject GetSpawnedGameObjectByTranslatorTextInfo(PropModule.TranslatorTextInfo convo) { Logger.LogVerbose("Retrieving wall text obj for " + convo); if (!conversationInfoToCorrespondingSpawnedGameObject.ContainsKey(convo)) return null; @@ -120,7 +120,7 @@ namespace NewHorizons.Builder.Props } } - public static GameObject Make(GameObject planetGO, Sector sector, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody) + public static GameObject Make(GameObject planetGO, Sector sector, PropModule.TranslatorTextInfo info, NewHorizonsBody nhBody) { InitPrefabs(); @@ -128,30 +128,21 @@ namespace NewHorizons.Builder.Props switch (info.type) { - case PropModule.NomaiTextInfo.NomaiTextType.Wall: + case PropModule.NomaiTextType.Wall: { var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath, nhBody).gameObject; nomaiWallTextObj = GeneralPropBuilder.MakeFromExisting(nomaiWallTextObj, planetGO, sector, info); - - // using GeneralPropBuilder normal here does not work so have to do it manually + if (info.normal != null) { - // In global coordinates (normal was in local coordinates) var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized; var forward = planetGO.transform.TransformDirection(info.normal).normalized; - if (info.isRelativeToParent) - { - nomaiWallTextObj.transform.up = up; - nomaiWallTextObj.transform.forward = forward; - } else - { - nomaiWallTextObj.transform.forward = forward; + nomaiWallTextObj.transform.forward = forward; - var desiredUp = Vector3.ProjectOnPlane(up, forward); - var zRotation = Vector3.SignedAngle(nomaiWallTextObj.transform.up, desiredUp, forward); - nomaiWallTextObj.transform.RotateAround(nomaiWallTextObj.transform.position, forward, zRotation); - } + var desiredUp = Vector3.ProjectOnPlane(up, forward); + var zRotation = Vector3.SignedAngle(nomaiWallTextObj.transform.up, desiredUp, forward); + nomaiWallTextObj.transform.RotateAround(nomaiWallTextObj.transform.position, forward, zRotation); } // nomaiWallTextObj.GetComponent().DrawBoundsWithDebugSpheres(); @@ -161,9 +152,9 @@ namespace NewHorizons.Builder.Props return nomaiWallTextObj; } - case PropModule.NomaiTextInfo.NomaiTextType.Scroll: + case PropModule.NomaiTextType.Scroll: { - var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info, alignToBody: info.rotation == null); + var customScroll = GeneralPropBuilder.MakeFromPrefab(_scrollPrefab, _scrollPrefab.name, planetGO, sector, info); var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath, nhBody); nomaiWallText.transform.parent = customScroll.transform; @@ -213,9 +204,9 @@ namespace NewHorizons.Builder.Props return customScroll; } - case PropModule.NomaiTextInfo.NomaiTextType.Computer: + case PropModule.NomaiTextType.Computer: { - var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info, alignToBody: true, normal: info.normal); + var computerObject = GeneralPropBuilder.MakeFromPrefab(_computerPrefab, _computerPrefab.name, planetGO, sector, info); var computer = computerObject.GetComponent(); computer.SetSector(sector); @@ -234,22 +225,20 @@ namespace NewHorizons.Builder.Props return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashComputer: + case PropModule.NomaiTextType.PreCrashComputer: { var detailInfo = new PropModule.DetailInfo() { position = info.position, + rotation = info.rotation, parentPath = info.parentPath, isRelativeToParent = info.isRelativeToParent, + alignRadial = info.alignRadial, rename = info.rename }; var computerObject = DetailBuilder.Make(planetGO, sector, _preCrashComputerPrefab, detailInfo); computerObject.SetActive(false); - var up = computerObject.transform.position - planetGO.transform.position; - if (info.normal != null) up = planetGO.transform.TransformDirection(info.normal); - computerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * computerObject.transform.rotation; - var computer = computerObject.GetComponent(); computer.SetSector(sector); @@ -284,11 +273,11 @@ namespace NewHorizons.Builder.Props return computerObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Cairn: - case PropModule.NomaiTextInfo.NomaiTextType.CairnVariant: + case PropModule.NomaiTextType.Cairn: + case PropModule.NomaiTextType.CairnVariant: { - var cairnPrefab = info.type == PropModule.NomaiTextInfo.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; - var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, planetGO, sector, info, alignToBody: info.rotation == null); + var cairnPrefab = info.type == PropModule.NomaiTextType.CairnVariant ? _cairnVariantPrefab : _cairnPrefab; + var cairnObject = GeneralPropBuilder.MakeFromPrefab(cairnPrefab, _cairnPrefab.name, planetGO, sector, info); // Idk do we have to set it active before finding things? cairnObject.SetActive(true); @@ -319,17 +308,17 @@ namespace NewHorizons.Builder.Props return cairnObject; } - case PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder: - case PropModule.NomaiTextInfo.NomaiTextType.Recorder: + case PropModule.NomaiTextType.PreCrashRecorder: + case PropModule.NomaiTextType.Recorder: { - var prefab = (info.type == PropModule.NomaiTextInfo.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); + var prefab = (info.type == PropModule.NomaiTextType.PreCrashRecorder ? _preCrashRecorderPrefab : _recorderPrefab); var detailInfo = new PropModule.DetailInfo { parentPath = info.parentPath, rotation = info.rotation, position = info.position, isRelativeToParent = info.isRelativeToParent, rename = info.rename, - alignToNormal = info.rotation == null, + alignRadial = info.alignRadial, }; var recorderObject = DetailBuilder.Make(planetGO, sector, prefab, detailInfo); recorderObject.SetActive(false); @@ -349,9 +338,9 @@ namespace NewHorizons.Builder.Props conversationInfoToCorrespondingSpawnedGameObject[info] = recorderObject; return recorderObject; } - case PropModule.NomaiTextInfo.NomaiTextType.Trailmarker: + case PropModule.NomaiTextType.Trailmarker: { - var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, planetGO, sector, info, alignToBody: info.rotation == null); + var trailmarkerObject = GeneralPropBuilder.MakeFromPrefab(_trailmarkerPrefab, _trailmarkerPrefab.name, planetGO, sector, info); // shrink because that is what mobius does on all trailmarkers or else they are the size of the player trailmarkerObject.transform.localScale = Vector3.one * 0.75f; @@ -380,7 +369,7 @@ namespace NewHorizons.Builder.Props } } - private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.NomaiTextInfo info, string xmlPath, NewHorizonsBody nhBody) + private static NomaiWallText MakeWallText(GameObject go, Sector sector, PropModule.TranslatorTextInfo info, string xmlPath, NewHorizonsBody nhBody) { GameObject nomaiWallTextObj = new GameObject("NomaiWallText"); nomaiWallTextObj.SetActive(false); @@ -417,7 +406,7 @@ namespace NewHorizons.Builder.Props return nomaiWallText; } - internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody) + internal static void BuildArcs(string xml, NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.TranslatorTextInfo info, NewHorizonsBody nhBody) { var dict = MakeNomaiTextDict(xml); @@ -437,7 +426,7 @@ namespace NewHorizons.Builder.Props public bool mirrored; } - internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.NomaiTextInfo info, NewHorizonsBody nhBody, string cacheKey) + internal static void RefreshArcs(NomaiWallText nomaiWallText, GameObject conversationZone, PropModule.TranslatorTextInfo info, NewHorizonsBody nhBody, string cacheKey) { var dict = nomaiWallText._dictNomaiTextData; Random.InitState(info.seed == 0 ? info.xmlFile.GetHashCode() : info.seed); @@ -451,8 +440,8 @@ namespace NewHorizons.Builder.Props } ArcCacheData[] cachedData = null; - if (nhBody.Cache?.ContainsKey(cacheKey) ?? false) - cachedData = nhBody.Cache.Get(cacheKey); + //if (nhBody.Cache?.ContainsKey(cacheKey) ?? false) + // cachedData = nhBody.Cache.Get(cacheKey); var arranger = nomaiWallText.gameObject.AddComponent(); diff --git a/NewHorizons/Builder/Props/VolcanoBuilder.cs b/NewHorizons/Builder/Props/VolcanoBuilder.cs index aaf541cf..6d39a591 100644 --- a/NewHorizons/Builder/Props/VolcanoBuilder.cs +++ b/NewHorizons/Builder/Props/VolcanoBuilder.cs @@ -46,7 +46,7 @@ namespace NewHorizons.Builder.Props { InitPrefab(); - var launcherGO = GeneralPropBuilder.MakeFromPrefab(_meteorLauncherPrefab, "MeteorLauncher", planetGO, sector, info, alignToBody: true); + var launcherGO = GeneralPropBuilder.MakeFromPrefab(_meteorLauncherPrefab, "MeteorLauncher", planetGO, sector, info); var meteorLauncher = launcherGO.GetComponent(); meteorLauncher._audioSector = sector; diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index abc1f522..20eed396 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -487,7 +487,7 @@ namespace NewHorizons.External.Configs } // Remote dialogue trigger reorganized to use GeneralPointPropInfo - if (Props != null && Props.dialogue != null) + if (Props?.dialogue != null) { foreach (var dialogue in Props.dialogue) { @@ -502,6 +502,66 @@ namespace NewHorizons.External.Configs } } } + + // alignRadial added to all props with rotation; default behavior varies + if (Spawn?.playerSpawn != null && Spawn.playerSpawn.rotation == null && !Spawn.playerSpawn.alignRadial.HasValue) + { + Spawn.playerSpawn.alignRadial = true; + } + if (Spawn?.shipSpawn != null && Spawn.shipSpawn.rotation == null && !Spawn.shipSpawn.alignRadial.HasValue) + { + Spawn.playerSpawn.alignRadial = true; + } + if (Props?.details != null) + { + foreach (var detail in Props.details) + { + if (!detail.alignRadial.HasValue) + { + detail.alignRadial = detail.alignToNormal; + } + } + } + if (Props?.proxyDetails != null) + { + foreach (var detail in Props.proxyDetails) + { + if (!detail.alignRadial.HasValue) + { + detail.alignRadial = detail.alignToNormal; + } + } + } + if (Props?.geysers != null) + { + foreach (var geyser in Props.geysers) + { + if (!geyser.alignRadial.HasValue && geyser.rotation == null) + { + geyser.alignRadial = true; + } + } + } + if (Props?.tornados != null) + { + foreach (var tornado in Props.tornados) + { + if (!tornado.alignRadial.HasValue && tornado.rotation == null) + { + tornado.alignRadial = true; + } + } + } + if (Props?.volcanoes != null) + { + foreach (var volcano in Props.volcanoes) + { + if (!volcano.alignRadial.HasValue && volcano.rotation == null) + { + volcano.alignRadial = true; + } + } + } } } } \ No newline at end of file diff --git a/NewHorizons/External/Modules/GeneralPropInfo.cs b/NewHorizons/External/Modules/GeneralPropInfo.cs index c9ead346..8ab528a1 100644 --- a/NewHorizons/External/Modules/GeneralPropInfo.cs +++ b/NewHorizons/External/Modules/GeneralPropInfo.cs @@ -35,6 +35,12 @@ namespace NewHorizons.External.Modules /// Rotation of the object /// public MVector3 rotation; + + /// + /// Do we try to automatically align this object to stand upright relative to the body's center? Stacks with rotation. + /// Defaults to true for geysers, tornados, and volcanoes, and false for everything else. + /// + public bool? alignRadial; } [JsonObject] diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index 1f4169ce..5772cd26 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -42,7 +42,7 @@ namespace NewHorizons.External.Modules /// /// Add translatable text to this planet /// - public NomaiTextInfo[] translatorText; + public TranslatorTextInfo[] translatorText; /// /// Details which will be shown from 50km away. Meant to be lower resolution. @@ -165,12 +165,6 @@ namespace NewHorizons.External.Modules [JsonObject] public class DetailInfo : GeneralPropInfo { - - /// - /// Do we override rotation and try to automatically align this object to stand upright on the body's surface? - /// - public bool alignToNormal; - /// /// Relative filepath to an asset-bundle to load the prefab defined in `path` from /// @@ -229,10 +223,12 @@ namespace NewHorizons.External.Modules /// If there's already good colliders on the detail, you can make this 0. /// [DefaultValue(1f)] public float physicsRadius = 1f; + + [Obsolete("alignToNormal is deprecated. Use alignRadial instead")] public bool alignToNormal; } [JsonObject] - public class RaftInfo : GeneralPointPropInfo + public class RaftInfo : GeneralPropInfo { /// /// Acceleration of the raft. Default acceleration is 5. @@ -241,7 +237,7 @@ namespace NewHorizons.External.Modules } [JsonObject] - public class GeyserInfo : GeneralPointPropInfo + public class GeyserInfo : GeneralPropInfo { /// /// Vertical offset of the geyser. From 0, the bubbles start at a height of 10, the shaft at 67, and the spout at 97.5. @@ -280,7 +276,7 @@ namespace NewHorizons.External.Modules } [JsonObject] - public class TornadoInfo : GeneralPointPropInfo + public class TornadoInfo : GeneralPropInfo { [JsonConverter(typeof(StringEnumConverter))] public enum TornadoType @@ -342,7 +338,7 @@ namespace NewHorizons.External.Modules } [JsonObject] - public class VolcanoInfo : GeneralPointPropInfo + public class VolcanoInfo : GeneralPropInfo { /// /// The colour of the meteor's lava. @@ -473,40 +469,75 @@ namespace NewHorizons.External.Modules public string id; } + [JsonObject] + public class TranslatorTextInfo : GeneralPropInfo + { + /// + /// Additional information about each arc in the text + /// + public NomaiTextArcInfo[] arcInfo; + + /// + /// The random seed used to pick what the text arcs will look like. + /// + public int seed; + + /// + /// Only for wall text. Aligns wall text to face towards the given direction, with 'up' oriented relative to its current rotation or alignment. + /// + public MVector3 normal; + + /// + /// The type of object this is. + /// + [DefaultValue("wall")] public NomaiTextType type = NomaiTextType.Wall; + + /// + /// The location of this object. Arcs will be blue if their locations match the wall, else orange. + /// + [DefaultValue("unspecified")] public NomaiTextLocation location = NomaiTextLocation.UNSPECIFIED; + + /// + /// The relative path to the xml file for this object. + /// + public string xmlFile; + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextType + { + [EnumMember(Value = @"wall")] Wall = 0, + + [EnumMember(Value = @"scroll")] Scroll = 1, + + [EnumMember(Value = @"computer")] Computer = 2, + + [EnumMember(Value = @"cairn")] Cairn = 3, + + [EnumMember(Value = @"recorder")] Recorder = 4, + + [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5, + + [EnumMember(Value = @"preCrashComputer")] PreCrashComputer = 6, + + [EnumMember(Value = @"trailmarker")] Trailmarker = 7, + + [EnumMember(Value = @"cairnVariant")] CairnVariant = 8, + } + + [JsonConverter(typeof(StringEnumConverter))] + public enum NomaiTextLocation + { + [EnumMember(Value = @"unspecified")] UNSPECIFIED = 0, + + [EnumMember(Value = @"a")] A = 1, + + [EnumMember(Value = @"b")] B = 2 + } + [JsonObject] public class NomaiTextInfo : GeneralPointPropInfo { - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextType - { - [EnumMember(Value = @"wall")] Wall = 0, - - [EnumMember(Value = @"scroll")] Scroll = 1, - - [EnumMember(Value = @"computer")] Computer = 2, - - [EnumMember(Value = @"cairn")] Cairn = 3, - - [EnumMember(Value = @"recorder")] Recorder = 4, - - [EnumMember(Value = @"preCrashRecorder")] PreCrashRecorder = 5, - - [EnumMember(Value = @"preCrashComputer")] PreCrashComputer = 6, - - [EnumMember(Value = @"trailmarker")] Trailmarker = 7, - - [EnumMember(Value = @"cairnVariant")] CairnVariant = 8, - } - - [JsonConverter(typeof(StringEnumConverter))] - public enum NomaiTextLocation - { - [EnumMember(Value = @"unspecified")] UNSPECIFIED = 0, - - [EnumMember(Value = @"a")] A = 1, - - [EnumMember(Value = @"b")] B = 2 - } /// /// Additional information about each arc in the text @@ -827,7 +858,7 @@ namespace NewHorizons.External.Modules /// /// The location of this object. Arcs will be blue if their locations match the wall, else orange. /// - [DefaultValue("unspecified")] public NomaiTextInfo.NomaiTextLocation location = NomaiTextInfo.NomaiTextLocation.UNSPECIFIED; + [DefaultValue("unspecified")] public NomaiTextLocation location = NomaiTextLocation.UNSPECIFIED; /// /// The relative path to the xml file for this object. diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index ce358343..7c0bdc71 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -155,14 +155,14 @@ namespace NewHorizons } public GameObject SpawnObject(GameObject planet, Sector sector, string propToCopyPath, Vector3 position, Vector3 eulerAngles, - float scale, bool alignWithNormal) + float scale, bool alignRadial) { var prefab = SearchUtilities.Find(propToCopyPath); var detailInfo = new PropModule.DetailInfo() { position = position, rotation = eulerAngles, scale = scale, - alignToNormal = alignWithNormal + alignRadial = alignRadial }; return DetailBuilder.Make(planet, sector, prefab, detailInfo); } diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index e9632c3b..da3ceeef 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -273,7 +273,7 @@ namespace NewHorizons.Utility.DebugUtilities // So we can't use local position/rotation here, we have to inverse transform the global position/rotation relative to root object prop.detailInfo.position = rootTransform.InverseTransformPoint(prop.gameObject.transform.position); prop.detailInfo.scale = prop.gameObject.transform.localScale.x; - if (!prop.detailInfo.alignToNormal) prop.detailInfo.rotation = rootTransform.InverseTransformRotation(prop.gameObject.transform.rotation).eulerAngles; + if (!prop.detailInfo.alignRadial.GetValueOrDefault()) prop.detailInfo.rotation = rootTransform.InverseTransformRotation(prop.gameObject.transform.rotation).eulerAngles; infoArray[i] = prop.detailInfo; }