r2mods/ilspy_dump/ror2_csproj/RoR2.Projectile/LunarSunProjectileControlle...

50 lines
1.1 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using UnityEngine;
using UnityEngine.Networking;
namespace RoR2.Projectile;
[DisallowMultipleComponent]
[RequireComponent(typeof(ProjectileController))]
[RequireComponent(typeof(ProjectileImpactExplosion))]
[RequireComponent(typeof(ProjectileOwnerOrbiter))]
public class LunarSunProjectileController : MonoBehaviour
{
private ProjectileImpactExplosion explosion;
public void OnEnable()
{
explosion = GetComponent<ProjectileImpactExplosion>();
if (NetworkServer.active)
{
ProjectileController component = GetComponent<ProjectileController>();
if ((bool)component.owner)
{
AcquireOwner(component);
}
else
{
component.onInitialized += AcquireOwner;
}
}
}
private void AcquireOwner(ProjectileController controller)
{
controller.onInitialized -= AcquireOwner;
CharacterBody component = controller.owner.GetComponent<CharacterBody>();
if ((bool)component)
{
ProjectileOwnerOrbiter component2 = GetComponent<ProjectileOwnerOrbiter>();
component.GetComponent<LunarSunBehavior>().InitializeOrbiter(component2, this);
}
}
public void Detonate()
{
if ((bool)explosion)
{
explosion.Detonate();
}
}
}