From c79ff48966afc9c767e414009a0aacb1e2035932 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 17 Jul 2023 01:48:17 -0400 Subject: [PATCH 1/4] 10 frames --- NewHorizons/Handlers/PlayerSpawnHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Handlers/PlayerSpawnHandler.cs b/NewHorizons/Handlers/PlayerSpawnHandler.cs index 8d70907b..1dcf23ea 100644 --- a/NewHorizons/Handlers/PlayerSpawnHandler.cs +++ b/NewHorizons/Handlers/PlayerSpawnHandler.cs @@ -40,7 +40,7 @@ namespace NewHorizons.Handlers var matchInitialMotion = SearchUtilities.Find("Player_Body").GetComponent(); if (matchInitialMotion != null) UnityEngine.Object.Destroy(matchInitialMotion); - Main.Instance.StartCoroutine(SpawnCoroutine(2)); + Main.Instance.StartCoroutine(SpawnCoroutine(10)); } } From 114af7ef269ea178b1a26b2291cac588ae9b0538 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 17 Jul 2023 10:26:44 -0400 Subject: [PATCH 2/4] Allow setting spawn offset --- .../Builder/General/SpawnPointBuilder.cs | 10 ++++++---- NewHorizons/External/Modules/SpawnModule.cs | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 4ae1084b..591defb4 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -21,7 +21,6 @@ namespace NewHorizons.Builder.General if (module.playerSpawn != null) { GameObject spawnGO = GeneralPropBuilder.MakeNew("PlayerSpawnPoint", planetGO, null, module.playerSpawn); - spawnGO.SetActive(false); spawnGO.layer = Layer.PlayerSafetyCollider; playerSpawn = spawnGO.AddComponent(); @@ -31,8 +30,7 @@ namespace NewHorizons.Builder.General playerSpawn._triggerVolumes = new OWTriggerVolume[0]; // This was a stupid hack to stop players getting stuck in the ground and now we have to keep it forever - spawnGO.transform.position += 4f * spawnGO.transform.up; - spawnGO.SetActive(true); + spawnGO.transform.position += spawnGO.transform.TransformDirection(module.playerSpawn.offset ?? Vector3.up * 4f); } if (module.shipSpawn != null) @@ -57,7 +55,11 @@ namespace NewHorizons.Builder.General ship.transform.rotation = spawnGO.transform.rotation; // Move it up a bit more when aligning to surface - if (module.shipSpawn.alignRadial.GetValueOrDefault()) + if (module.shipSpawn.offset != null) + { + ship.transform.position += spawnGO.transform.TransformDirection(module.shipSpawn.offset); + } + else if (module.shipSpawn.alignRadial.GetValueOrDefault()) { ship.transform.position += ship.transform.up * 4f; } diff --git a/NewHorizons/External/Modules/SpawnModule.cs b/NewHorizons/External/Modules/SpawnModule.cs index 9a613bc7..5899b658 100644 --- a/NewHorizons/External/Modules/SpawnModule.cs +++ b/NewHorizons/External/Modules/SpawnModule.cs @@ -24,7 +24,17 @@ namespace NewHorizons.External.Modules [Obsolete("startWithSuit is deprecated. Use playerSpawn.startWithSuit instead")] public bool startWithSuit; [JsonObject] - public class PlayerSpawnPoint : GeneralPropInfo { + public class SpawnPoint : GeneralPropInfo + { + /// + /// Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0). + /// + public MVector3? offset; + } + + [JsonObject] + public class PlayerSpawnPoint : SpawnPoint + { /// /// If you spawn on a planet with no oxygen, you probably want to set this to true ;;) /// @@ -33,10 +43,13 @@ namespace NewHorizons.External.Modules /// Whether this planet's spawn point is the one the player will initially spawn at, if multiple spawn points exist. /// public bool isDefault; + + } [JsonObject] - public class ShipSpawnPoint : GeneralPropInfo { + public class ShipSpawnPoint : SpawnPoint + { } } From b1857a8b9938778e7e3fadd94a793bd4ec845c43 Mon Sep 17 00:00:00 2001 From: Ben C Date: Mon, 17 Jul 2023 14:29:47 +0000 Subject: [PATCH 3/4] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index ec905995..a63a3c5e 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -3041,6 +3041,17 @@ "type": "object", "additionalProperties": false, "properties": { + "offset": { + "description": "Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).", + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/MVector3" + } + ] + }, "rotation": { "description": "Rotation of the object", "$ref": "#/definitions/MVector3" @@ -3082,6 +3093,17 @@ "type": "object", "additionalProperties": false, "properties": { + "offset": { + "description": "Offsets the player/ship by this local vector when spawning. Used to prevent spawning in the floor. Optional: defaults to (0, 4, 0).", + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/MVector3" + } + ] + }, "rotation": { "description": "Rotation of the object", "$ref": "#/definitions/MVector3" From fbbdbe1b221a6df8aab32d26a49da8eb6628eabb Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 17 Jul 2023 10:54:33 -0400 Subject: [PATCH 4/4] Comment --- NewHorizons/Handlers/PlayerSpawnHandler.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/NewHorizons/Handlers/PlayerSpawnHandler.cs b/NewHorizons/Handlers/PlayerSpawnHandler.cs index 1dcf23ea..09e88c79 100644 --- a/NewHorizons/Handlers/PlayerSpawnHandler.cs +++ b/NewHorizons/Handlers/PlayerSpawnHandler.cs @@ -40,6 +40,7 @@ namespace NewHorizons.Handlers var matchInitialMotion = SearchUtilities.Find("Player_Body").GetComponent(); if (matchInitialMotion != null) UnityEngine.Object.Destroy(matchInitialMotion); + // Arbitrary number, depending on the machine some people die, some people fall through the floor, its very inconsistent Main.Instance.StartCoroutine(SpawnCoroutine(10)); } }