0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 02:30:44 -05:00

Improve airdrop code formatting

This commit is contained in:
Dev 2023-05-26 21:18:30 +01:00
parent b050f6230e
commit c2e05e986e
3 changed files with 31 additions and 15 deletions

View File

@ -54,6 +54,7 @@ namespace Aki.Custom.Airdrops
instance.paraAnimator = instance.boxSync.Parachute.GetComponent<Animator>(); instance.paraAnimator = instance.boxSync.Parachute.GetComponent<Animator>();
instance.paraMaterial = instance.boxSync.Parachute.GetComponentInChildren<Renderer>().material; instance.paraMaterial = instance.boxSync.Parachute.GetComponentInChildren<Renderer>().material;
instance.fallSpeed = crateFallSpeed; instance.fallSpeed = crateFallSpeed;
return instance; return instance;
} }
@ -64,6 +65,7 @@ namespace Aki.Custom.Airdrops
var crate = Instantiate(easyAssets.GetAsset<GameObject>(CRATE_PATH)); var crate = Instantiate(easyAssets.GetAsset<GameObject>(CRATE_PATH));
crate.SetActive(false); crate.SetActive(false);
return crate; return crate;
} }
@ -193,7 +195,10 @@ namespace Aki.Custom.Airdrops
AudioSource.SetRolloff(clip.Falloff); AudioSource.SetRolloff(clip.Falloff);
AudioSource.source1.volume = volume; AudioSource.source1.volume = volume;
if (AudioSource.source1.isPlaying) return; if (AudioSource.source1.isPlaying)
{
return;
}
AudioSource.source1.clip = clip.Clip; AudioSource.source1.clip = clip.Clip;
AudioSource.source1.loop = looped; AudioSource.source1.loop = looped;
@ -231,7 +236,10 @@ namespace Aki.Custom.Airdrops
private void ReleaseAudioSource() private void ReleaseAudioSource()
{ {
if (audioSource == null) return; if (audioSource == null)
{
return;
}
audioSource.transform.parent = null; audioSource.transform.parent = null;
audioSource.Release(); audioSource.Release();

View File

@ -2,7 +2,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Comfort.Common; using Comfort.Common;
using EFT; using EFT;
using EFT.Airdrop;
using EFT.SynchronizableObjects; using EFT.SynchronizableObjects;
using UnityEngine; using UnityEngine;

View File

@ -19,7 +19,10 @@ namespace Aki.Custom.Airdrops
{ {
var gameWorld = Singleton<GameWorld>.Instance; var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null) Destroy(this); if (gameWorld == null)
{
Destroy(this);
}
airdropParameters = AirdropUtil.InitAirdropParams(gameWorld, isFlareDrop); airdropParameters = AirdropUtil.InitAirdropParams(gameWorld, isFlareDrop);
@ -31,14 +34,17 @@ namespace Aki.Custom.Airdrops
try try
{ {
airdropPlane = await AirdropPlane.Init(airdropParameters.RandomAirdropPoint, airdropPlane = await AirdropPlane.Init(
airdropParameters.DropHeight, airdropParameters.Config.PlaneVolume, airdropParameters.Config.PlaneSpeed); airdropParameters.RandomAirdropPoint,
airdropParameters.DropHeight,
airdropParameters.Config.PlaneVolume,
airdropParameters.Config.PlaneSpeed);
airdropBox = await AirdropBox.Init(airdropParameters.Config.CrateFallSpeed); airdropBox = await AirdropBox.Init(airdropParameters.Config.CrateFallSpeed);
factory = new ItemFactoryUtil(); factory = new ItemFactoryUtil();
} }
catch 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); Destroy(this);
throw; throw;
} }
@ -55,7 +61,10 @@ namespace Aki.Custom.Airdrops
StartPlane(); StartPlane();
} }
if (!airdropParameters.PlaneSpawned) return; if (!airdropParameters.PlaneSpawned)
{
return;
}
if (airdropParameters.DistanceTraveled >= airdropParameters.DistanceToDrop && !airdropParameters.BoxSpawned) if (airdropParameters.DistanceTraveled >= airdropParameters.DistanceToDrop && !airdropParameters.BoxSpawned)
{ {