From c2e05e986e6f8b27911689ce545098d8282d0cf5 Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 26 May 2023 21:18:30 +0100 Subject: [PATCH] Improve airdrop code formatting --- project/Aki.Custom/Airdrops/AirdropBox.cs | 16 +++++++--- project/Aki.Custom/Airdrops/AirdropPlane.cs | 1 - .../Aki.Custom/Airdrops/AirdropsManager.cs | 29 ++++++++++++------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/project/Aki.Custom/Airdrops/AirdropBox.cs b/project/Aki.Custom/Airdrops/AirdropBox.cs index 306c611..8ebf39b 100644 --- a/project/Aki.Custom/Airdrops/AirdropBox.cs +++ b/project/Aki.Custom/Airdrops/AirdropBox.cs @@ -54,6 +54,7 @@ namespace Aki.Custom.Airdrops instance.paraAnimator = instance.boxSync.Parachute.GetComponent(); instance.paraMaterial = instance.boxSync.Parachute.GetComponentInChildren().material; instance.fallSpeed = crateFallSpeed; + return instance; } @@ -64,6 +65,7 @@ namespace Aki.Custom.Airdrops var crate = Instantiate(easyAssets.GetAsset(CRATE_PATH)); crate.SetActive(false); + return crate; } @@ -193,8 +195,11 @@ namespace Aki.Custom.Airdrops AudioSource.SetRolloff(clip.Falloff); AudioSource.source1.volume = volume; - if (AudioSource.source1.isPlaying) return; - + if (AudioSource.source1.isPlaying) + { + return; + } + AudioSource.source1.clip = clip.Clip; AudioSource.source1.loop = looped; AudioSource.source1.Play(); @@ -231,8 +236,11 @@ namespace Aki.Custom.Airdrops private void ReleaseAudioSource() { - if (audioSource == null) return; - + if (audioSource == null) + { + return; + } + audioSource.transform.parent = null; audioSource.Release(); audioSource = null; diff --git a/project/Aki.Custom/Airdrops/AirdropPlane.cs b/project/Aki.Custom/Airdrops/AirdropPlane.cs index a4d7c8b..a22a92b 100644 --- a/project/Aki.Custom/Airdrops/AirdropPlane.cs +++ b/project/Aki.Custom/Airdrops/AirdropPlane.cs @@ -2,7 +2,6 @@ using System.Threading.Tasks; using Comfort.Common; using EFT; -using EFT.Airdrop; using EFT.SynchronizableObjects; using UnityEngine; diff --git a/project/Aki.Custom/Airdrops/AirdropsManager.cs b/project/Aki.Custom/Airdrops/AirdropsManager.cs index d28226c..9c72961 100644 --- a/project/Aki.Custom/Airdrops/AirdropsManager.cs +++ b/project/Aki.Custom/Airdrops/AirdropsManager.cs @@ -18,9 +18,12 @@ namespace Aki.Custom.Airdrops public async void Start() { var gameWorld = Singleton.Instance; - - if (gameWorld == null) Destroy(this); - + + if (gameWorld == null) + { + Destroy(this); + } + airdropParameters = AirdropUtil.InitAirdropParams(gameWorld, isFlareDrop); if (!airdropParameters.AirdropAvailable) @@ -31,14 +34,17 @@ namespace Aki.Custom.Airdrops try { - airdropPlane = await AirdropPlane.Init(airdropParameters.RandomAirdropPoint, - airdropParameters.DropHeight, airdropParameters.Config.PlaneVolume, airdropParameters.Config.PlaneSpeed); + airdropPlane = await AirdropPlane.Init( + airdropParameters.RandomAirdropPoint, + airdropParameters.DropHeight, + airdropParameters.Config.PlaneVolume, + airdropParameters.Config.PlaneSpeed); airdropBox = await AirdropBox.Init(airdropParameters.Config.CrateFallSpeed); factory = new ItemFactoryUtil(); } catch { - Debug.LogError($"[AKI-AIRDROPS]: Unable to create plane or crate, airdrop won't occur"); + Debug.LogError("[AKI-AIRDROPS]: Unable to create plane or crate, airdrop won't occur"); Destroy(this); throw; } @@ -55,14 +61,17 @@ namespace Aki.Custom.Airdrops StartPlane(); } - if (!airdropParameters.PlaneSpawned) return; - + if (!airdropParameters.PlaneSpawned) + { + return; + } + if (airdropParameters.DistanceTraveled >= airdropParameters.DistanceToDrop && !airdropParameters.BoxSpawned) { StartBox(); BuildLootContainer(); } - + if (airdropParameters.DistanceTraveled < airdropParameters.DistanceToTravel) { airdropParameters.DistanceTraveled += Time.deltaTime * airdropParameters.Config.PlaneSpeed; @@ -100,7 +109,7 @@ namespace Aki.Custom.Airdrops private void SetDistanceToDrop() { airdropParameters.DistanceToDrop = Vector3.Distance( - new Vector3(airdropParameters.RandomAirdropPoint.x, airdropParameters.DropHeight, airdropParameters.RandomAirdropPoint.z), + new Vector3(airdropParameters.RandomAirdropPoint.x, airdropParameters.DropHeight, airdropParameters.RandomAirdropPoint.z), airdropPlane.transform.position); } }