From dc54c40cc86af54511c7ee23f9418dd330c7f13e Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 26 May 2022 16:00:15 -0400 Subject: [PATCH 1/2] Launcher Override --- MeteorLaunching/MeteorLaunching.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/MeteorLaunching/MeteorLaunching.cs b/MeteorLaunching/MeteorLaunching.cs index 3373414..edb672f 100644 --- a/MeteorLaunching/MeteorLaunching.cs +++ b/MeteorLaunching/MeteorLaunching.cs @@ -38,6 +38,8 @@ public class ProjectileLaunchEvent : UnityEvent { } public ProjectileSwitchEvent OnProjectileSwitched; public ProjectileLaunchEvent OnProjectileLaunched; + private Transform launcherOverride = null; + private void Awake() { instance = this; @@ -85,12 +87,13 @@ private IEnumerator LateInitialize() private GameObject LaunchMeteor() { + var currentLauncher = launcherOverride ?? launcher; if (projectiles == null) return null; if (projectiles.Length == 0) return null; if (!lateInitialized) return null; if (p >= projectiles.Length) p = 0; - GameObject newMeteor = Instantiate(projectiles[p], launcher.position + launcher.forward * .5f + launcher.forward * launchSize * projectiles[p].GetComponentInChildren().bounds.size.x * .5f, launcher.rotation); + GameObject newMeteor = Instantiate(projectiles[p], currentLauncher.position + currentLauncher.forward * .5f + currentLauncher.forward * launchSize * projectiles[p].GetComponentInChildren().bounds.size.x * .5f, currentLauncher.rotation); /*GameObject newMeteor = GameObject.CreatePrimitive(PrimitiveType.Cube); newMeteor.transform.position = launcher.position + launcher.forward * launchSize * 2; newMeteor.transform.rotation = launcher.rotation; @@ -102,15 +105,16 @@ private GameObject LaunchMeteor() var fluid = Detector.AddComponent(); owrigid._attachedForceDetector = force; owrigid._attachedFluidDetector = fluid;*/ - newMeteor.GetComponent().velocity = launcher.forward * launchSpeed; + newMeteor.GetComponent().velocity = currentLauncher.forward * launchSpeed; newMeteor.transform.localScale = new Vector3(launchSize, launchSize, launchSize); newMeteor.name = "Projectile"; if (p == 0) OnMeteorLaunched(newMeteor); else if (p == 1) - OnMarshmallowLaunched(newMeteor); + OnMarshmallowLaunched(newMeteor, currentLauncher); OnProjectileLaunched?.Invoke(p, newMeteor); audio.PlayOneShot(AudioType.BH_MeteorLaunch, 0.25f); + launcherOverride = null; return newMeteor; } @@ -134,9 +138,9 @@ private void OnMeteorLaunched(GameObject newMeteor) newMeteorContr._suspendRoot = playerBody.transform; } - private void OnMarshmallowLaunched(GameObject marshmallow) + private void OnMarshmallowLaunched(GameObject marshmallow, Transform currentLauncher) { - marshmallow.GetComponent().velocity = launcher.forward * (launchSpeed / 4); + marshmallow.GetComponent().velocity = currentLauncher.forward * (launchSpeed / 4); Destroy(marshmallow.GetComponent()); marshmallow.GetComponentInChildren().material.color = new Color(1, 1, 1, 0); } @@ -211,7 +215,9 @@ public override void Configure(IModConfig config) public class Api { - public Transform GetLauncher() => Instance.launcher; + public Transform GetLauncher() => Instance.launcherOverride ?? Instance.launcher; + + public void OverrideLauncherForNextLaunch(Transform launcher) => Instance.launcherOverride = launcher; public float GetLaunchSpeed() => Instance.launchSpeed; From 6c3ae647addec287857f95e14473bad16365c595 Mon Sep 17 00:00:00 2001 From: Noah Pilarski Date: Thu, 26 May 2022 16:01:01 -0400 Subject: [PATCH 2/2] 0.2.2 --- MeteorLaunching/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MeteorLaunching/manifest.json b/MeteorLaunching/manifest.json index abebb84..411fd09 100644 --- a/MeteorLaunching/manifest.json +++ b/MeteorLaunching/manifest.json @@ -3,6 +3,6 @@ "author": "12090113", "name": "Meteor Launching", "uniqueName": "12090113.MeteorLaunching", - "version": "0.2.1", + "version": "0.2.2", "owmlVersion": "2.0.0" }