using RoR2; using UnityEngine; namespace EntityStates.VoidRaidCrab.Weapon; public class ChargeMissiles : BaseState { [SerializeField] public float baseDuration; [SerializeField] public GameObject chargeEffectPrefab; [SerializeField] public string muzzleName; [SerializeField] public string enterSoundString; [SerializeField] public bool isSoundScaledByAttackSpeed; [SerializeField] public string animationLayerName; [SerializeField] public string animationStateName; [SerializeField] public string animationPlaybackRateParam; private float duration; private GameObject chargeEffectInstance; public override void OnEnter() { base.OnEnter(); duration = baseDuration / attackSpeedStat; PlayAnimation(animationLayerName, animationStateName, animationPlaybackRateParam, duration); ChildLocator modelChildLocator = GetModelChildLocator(); if ((bool)modelChildLocator && (bool)chargeEffectPrefab) { Transform transform = modelChildLocator.FindChild(muzzleName) ?? base.characterBody.coreTransform; if ((bool)transform) { chargeEffectInstance = Object.Instantiate(chargeEffectPrefab, transform.position, transform.rotation); chargeEffectInstance.transform.parent = transform; } } if (!string.IsNullOrEmpty(enterSoundString)) { if (isSoundScaledByAttackSpeed) { Util.PlayAttackSpeedSound(enterSoundString, base.gameObject, attackSpeedStat); } else { Util.PlaySound(enterSoundString, base.gameObject); } } } public override void OnExit() { EntityState.Destroy(chargeEffectInstance); base.OnExit(); } public override void FixedUpdate() { base.FixedUpdate(); if (base.isAuthority && base.fixedAge >= duration) { outer.SetNextState(new FireMissiles()); } } public override InterruptPriority GetMinimumInterruptPriority() { return InterruptPriority.PrioritySkill; } }