using RoR2; using RoR2.Projectile; using UnityEngine; namespace EntityStates.VoidSurvivor.Weapon; public class FireMegaBlasterBase : BaseState { [SerializeField] public GameObject projectilePrefab; [SerializeField] public GameObject muzzleflashEffectPrefab; [SerializeField] public float baseDuration = 2f; [SerializeField] public float damageCoefficient = 1.2f; [SerializeField] public float force = 20f; [SerializeField] public string attackSoundString; [SerializeField] public float recoilAmplitude; [SerializeField] public float bloom; [SerializeField] public string muzzle; [SerializeField] public float spread; [SerializeField] public float yawPerProjectile; [SerializeField] public float selfKnockbackForce; [SerializeField] public string animationLayerName; [SerializeField] public string animationStateName; [SerializeField] public string animationPlaybackRateParam; private float duration; public override void OnEnter() { base.OnEnter(); Ray aimRay = GetAimRay(); duration = baseDuration / attackSpeedStat; StartAimMode(duration + 2f); PlayAnimation(animationLayerName, animationStateName, animationPlaybackRateParam, duration); Util.PlaySound(attackSoundString, base.gameObject); AddRecoil(-1f * recoilAmplitude, -1.5f * recoilAmplitude, -0.25f * recoilAmplitude, 0.25f * recoilAmplitude); base.characterBody.AddSpreadBloom(bloom); if ((bool)muzzleflashEffectPrefab) { EffectManager.SimpleMuzzleFlash(muzzleflashEffectPrefab, base.gameObject, muzzle, transmit: false); } if (base.isAuthority) { FireProjectiles(); } base.characterBody.characterMotor.ApplyForce((0f - selfKnockbackForce) * aimRay.direction); } private void FireProjectiles() { Ray ray = GetAimRay(); TrajectoryAimAssist.ApplyTrajectoryAimAssist(ref ray, projectilePrefab, base.gameObject); ray.direction = Util.ApplySpread(ray.direction, 0f, spread, 1f, 1f); FireProjectileInfo fireProjectileInfo = default(FireProjectileInfo); fireProjectileInfo.projectilePrefab = projectilePrefab; fireProjectileInfo.position = ray.origin; fireProjectileInfo.rotation = Util.QuaternionSafeLookRotation(ray.direction); fireProjectileInfo.owner = base.gameObject; fireProjectileInfo.damage = damageStat * damageCoefficient; fireProjectileInfo.force = force; fireProjectileInfo.crit = Util.CheckRoll(critStat, base.characterBody.master); ProjectileManager.instance.FireProjectile(fireProjectileInfo); } public override void OnExit() { base.OnExit(); } public override void FixedUpdate() { base.FixedUpdate(); if (base.isAuthority && base.fixedAge >= duration) { outer.SetNextStateToMain(); } } public override InterruptPriority GetMinimumInterruptPriority() { return InterruptPriority.Skill; } }