From 35bda0719a7f39df7391c2834c78aef8f35050d5 Mon Sep 17 00:00:00 2001 From: Fredrik Lillemoen Eiding Date: Mon, 6 Jan 2025 15:09:44 +0100 Subject: [PATCH] Fix bullet fire trails, fix boombardier explosion initialization --- Assets/Prefabs/GunParts/DynamiteBarrel.prefab | 2 +- .../AugmentImplementations/DynamiteBarrel.cs | 4 ++- .../Augment/AugmentImplementations/Fire.cs | 2 +- .../AugmentImplementations/StickyDynamite.cs | 5 ++++ Assets/Scripts/Augment/BulletController.cs | 3 ++ Assets/Scripts/Augment/GunController.cs | 28 ++++++++++--------- 6 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Assets/Prefabs/GunParts/DynamiteBarrel.prefab b/Assets/Prefabs/GunParts/DynamiteBarrel.prefab index c214e8087..1254eb414 100644 --- a/Assets/Prefabs/GunParts/DynamiteBarrel.prefab +++ b/Assets/Prefabs/GunParts/DynamiteBarrel.prefab @@ -266,7 +266,7 @@ AudioSource: m_GameObject: {fileID: 5146486171313696063} m_Enabled: 1 serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} + OutputAudioMixerGroup: {fileID: 4898656368289658944, guid: 92cf7610df7967a41806df0e74d33c49, type: 2} m_audioClip: {fileID: 0} m_PlayOnAwake: 1 m_Volume: 1 diff --git a/Assets/Scripts/Augment/AugmentImplementations/DynamiteBarrel.cs b/Assets/Scripts/Augment/AugmentImplementations/DynamiteBarrel.cs index bee7e998d..48b715c12 100644 --- a/Assets/Scripts/Augment/AugmentImplementations/DynamiteBarrel.cs +++ b/Assets/Scripts/Augment/AugmentImplementations/DynamiteBarrel.cs @@ -1,8 +1,10 @@ +using JetBrains.Annotations; using Mirror; using System; using System.Collections; using System.Collections.Generic; using System.Linq; +using Unity.VisualScripting; using UnityEngine; using UnityEngine.InputSystem; @@ -135,7 +137,7 @@ private void OnDeath(PlayerManager killer, PlayerManager victim, DamageInfo info private void OnDestroy() { StopAllCoroutines(); - if (!gunController || !gunController.Player) + if (!gunController || !gunController.Player || !gunController.Player.IsAlive) return; activeDynamites.ForEach(dynamite => dynamite.gameObject.SetActive(false)); diff --git a/Assets/Scripts/Augment/AugmentImplementations/Fire.cs b/Assets/Scripts/Augment/AugmentImplementations/Fire.cs index 119315b82..abd68c0b5 100644 --- a/Assets/Scripts/Augment/AugmentImplementations/Fire.cs +++ b/Assets/Scripts/Augment/AugmentImplementations/Fire.cs @@ -208,7 +208,7 @@ private void PlayShotAudio(GunStats stats) private void OnDestroy() { - stuckFirePool.Flush(); + stuckFirePool?.Flush(); positionActiveBuffer?.Dispose(); } diff --git a/Assets/Scripts/Augment/AugmentImplementations/StickyDynamite.cs b/Assets/Scripts/Augment/AugmentImplementations/StickyDynamite.cs index 762e04462..3ba54a510 100644 --- a/Assets/Scripts/Augment/AugmentImplementations/StickyDynamite.cs +++ b/Assets/Scripts/Augment/AugmentImplementations/StickyDynamite.cs @@ -23,6 +23,11 @@ private void OnEnable() ResetDynamite(); } + private void Awake() + { + ResetDynamite(); + } + public void ResetDynamite() { explosion.StopAllCoroutines(); diff --git a/Assets/Scripts/Augment/BulletController.cs b/Assets/Scripts/Augment/BulletController.cs index 9c606d941..339410a14 100644 --- a/Assets/Scripts/Augment/BulletController.cs +++ b/Assets/Scripts/Augment/BulletController.cs @@ -23,6 +23,8 @@ public class BulletController : ProjectileController private const float baseSpeed = 50f; + private const int defaultProjectileCount = 512; + private VFXTextureFormatter trailPositionBuffer; [SerializeField] @@ -78,6 +80,7 @@ private void RpcSeedRandom(int seed) public void SetTrail(VisualEffect newTrail) { + trailPositionBuffer ??= new(defaultProjectileCount); trailPositionBuffer.Buffer?.Release(); trail = newTrail; if (trail && stats) diff --git a/Assets/Scripts/Augment/GunController.cs b/Assets/Scripts/Augment/GunController.cs index 4cd82e23c..926c2a0d1 100644 --- a/Assets/Scripts/Augment/GunController.cs +++ b/Assets/Scripts/Augment/GunController.cs @@ -118,20 +118,22 @@ public void UnsubscribeDelegates() onInitializeBullet = null; onReload = null; - projectile.OnColliderHit = null; - projectile.OnHitboxCollision = null; - projectile.OnNetworkInit = null; - projectile.OnProjectileInit = null; - projectile.OnProjectileTravel = null; - projectile.OnRicochet = null; - - if (!barrelAnimator) - return; - + if (projectile) + { + projectile.OnColliderHit = null; + projectile.OnHitboxCollision = null; + projectile.OnNetworkInit = null; + projectile.OnProjectileInit = null; + projectile.OnProjectileTravel = null; + projectile.OnRicochet = null; + } - barrelAnimator.OnShotFiredAnimation -= PlayRecoil; - barrelAnimator.OnShotFiredAnimation -= ShotFired; - barrelAnimator.OnAnimationEnd -= FireEnd; + if (barrelAnimator) + { + barrelAnimator.OnShotFiredAnimation -= PlayRecoil; + barrelAnimator.OnShotFiredAnimation -= ShotFired; + barrelAnimator.OnAnimationEnd -= FireEnd; + } if (!Player || !Player.inputManager) return;