r2mods/ilspy_dump/ror2_csproj/EntityStates.Engi.Mine/WaitForTarget.cs

54 lines
1.2 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using RoR2.Projectile;
using UnityEngine.Networking;
namespace EntityStates.Engi.Mine;
public class WaitForTarget : BaseMineState
{
private ProjectileSphereTargetFinder targetFinder;
private ProjectileTargetComponent projectileTargetComponent;
private ProjectileImpactExplosion projectileImpactExplosion;
protected override bool shouldStick => true;
public override void OnEnter()
{
base.OnEnter();
projectileTargetComponent = GetComponent<ProjectileTargetComponent>();
targetFinder = GetComponent<ProjectileSphereTargetFinder>();
if (NetworkServer.active)
{
targetFinder.enabled = true;
base.armingStateMachine.SetNextState(new MineArmingWeak());
}
}
public override void OnExit()
{
if ((bool)targetFinder)
{
targetFinder.enabled = false;
}
base.OnExit();
}
public override void FixedUpdate()
{
base.FixedUpdate();
if (NetworkServer.active && (bool)targetFinder)
{
if ((bool)projectileTargetComponent.target)
{
outer.SetNextState(new PreDetonate());
}
if (base.armingStateMachine?.state is BaseMineArmingState baseMineArmingState)
{
targetFinder.enabled = baseMineArmingState.triggerRadius != 0f;
targetFinder.lookRange = baseMineArmingState.triggerRadius;
}
}
}
}