r2mods/ilspy_dump/ror2_csproj/EntityStates.Engi.EngiWeapon/FireConcussionBlast.cs

138 lines
3.2 KiB
C#

using RoR2;
using UnityEngine;
namespace EntityStates.Engi.EngiWeapon;
public class FireConcussionBlast : BaseState
{
public static GameObject effectPrefab;
public static GameObject hitEffectPrefab;
public static int grenadeCountMax = 3;
public static float damageCoefficient;
public static float fireDuration = 1f;
public static float baseDuration = 2f;
public static float minSpread = 0f;
public static float maxSpread = 5f;
public static float recoilAmplitude = 1f;
public static string attackSoundString;
public static float force;
public static float maxDistance;
public static float radius;
public static GameObject tracerEffectPrefab;
private Ray aimRay;
private Transform modelTransform;
private float duration;
private float fireTimer;
private int grenadeCount;
private void FireGrenade(string targetMuzzle)
{
Util.PlaySound(attackSoundString, base.gameObject);
aimRay = GetAimRay();
if ((bool)modelTransform)
{
ChildLocator component = modelTransform.GetComponent<ChildLocator>();
if ((bool)component)
{
Transform transform = component.FindChild(targetMuzzle);
if ((bool)transform)
{
aimRay.origin = transform.position;
}
}
}
AddRecoil(-1f * recoilAmplitude, -2f * recoilAmplitude, -1f * recoilAmplitude, 1f * recoilAmplitude);
if ((bool)effectPrefab)
{
EffectManager.SimpleMuzzleFlash(effectPrefab, base.gameObject, targetMuzzle, transmit: false);
}
if (base.isAuthority)
{
BulletAttack bulletAttack = new BulletAttack();
bulletAttack.owner = base.gameObject;
bulletAttack.weapon = base.gameObject;
bulletAttack.origin = aimRay.origin;
bulletAttack.aimVector = aimRay.direction;
bulletAttack.minSpread = minSpread;
bulletAttack.maxSpread = maxSpread;
bulletAttack.damage = damageCoefficient * damageStat;
bulletAttack.force = force;
bulletAttack.tracerEffectPrefab = tracerEffectPrefab;
bulletAttack.muzzleName = targetMuzzle;
bulletAttack.hitEffectPrefab = hitEffectPrefab;
bulletAttack.isCrit = Util.CheckRoll(critStat, base.characterBody.master);
bulletAttack.maxDistance = maxDistance;
bulletAttack.radius = radius;
bulletAttack.stopperMask = 0;
bulletAttack.Fire();
}
}
public override void OnEnter()
{
base.OnEnter();
duration = baseDuration / attackSpeedStat;
modelTransform = GetModelTransform();
aimRay = GetAimRay();
StartAimMode(aimRay);
}
public override void OnExit()
{
base.OnExit();
}
public override void FixedUpdate()
{
base.FixedUpdate();
if (!base.isAuthority)
{
return;
}
fireTimer -= GetDeltaTime();
float num = fireDuration / attackSpeedStat / (float)grenadeCountMax;
if (fireTimer <= 0f && grenadeCount < grenadeCountMax)
{
fireTimer += num;
if (grenadeCount % 2 == 0)
{
FireGrenade("MuzzleLeft");
PlayCrossfade("Gesture, Left Cannon", "FireGrenadeLeft", 0.1f);
}
else
{
FireGrenade("MuzzleRight");
PlayCrossfade("Gesture, Right Cannon", "FireGrenadeRight", 0.1f);
}
grenadeCount++;
}
if (base.fixedAge >= duration)
{
outer.SetNextStateToMain();
}
}
public override InterruptPriority GetMinimumInterruptPriority()
{
return InterruptPriority.Skill;
}
}