0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-12 17:10: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.paraMaterial = instance.boxSync.Parachute.GetComponentInChildren<Renderer>().material;
instance.fallSpeed = crateFallSpeed;
return instance;
}
@ -64,6 +65,7 @@ namespace Aki.Custom.Airdrops
var crate = Instantiate(easyAssets.GetAsset<GameObject>(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;

View File

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

View File

@ -18,9 +18,12 @@ namespace Aki.Custom.Airdrops
public async void Start()
{
var gameWorld = Singleton<GameWorld>.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);
}
}