r2mods/ilspy_dump/ror2_csproj/RoR2.Achievements/CaptainBuyMegaDroneAchievem...

52 lines
1.4 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using UnityEngine;
namespace RoR2.Achievements;
[RegisterAchievement("CaptainBuyMegaDrone", "Skills.Captain.CaptainSupplyDropHacking", "CompleteMainEnding", 3u, typeof(CaptainBuyMegaDroneServerAchievement))]
public class CaptainBuyMegaDroneAchievement : BaseAchievement
{
private class CaptainBuyMegaDroneServerAchievement : BaseServerAchievement
{
private GameObject megaDroneMasterPrefab;
public override void OnInstall()
{
base.OnInstall();
megaDroneMasterPrefab = MasterCatalog.FindMasterPrefab("MegaDroneMaster");
GlobalEventManager.OnInteractionsGlobal += OnInteractionsGlobal;
}
public override void OnUninstall()
{
GlobalEventManager.OnInteractionsGlobal -= OnInteractionsGlobal;
megaDroneMasterPrefab = null;
base.OnUninstall();
}
private void OnInteractionsGlobal(Interactor interactor, IInteractable interactable, GameObject interactableObject)
{
if (IsCurrentBody(interactor.gameObject) && interactableObject.GetComponent<SummonMasterBehavior>()?.masterPrefab == megaDroneMasterPrefab)
{
Grant();
}
}
}
protected override BodyIndex LookUpRequiredBodyIndex()
{
return BodyCatalog.FindBodyIndex("CaptainBody");
}
protected override void OnBodyRequirementMet()
{
base.OnBodyRequirementMet();
SetServerTracked(shouldTrack: true);
}
protected override void OnBodyRequirementBroken()
{
SetServerTracked(shouldTrack: false);
base.OnBodyRequirementBroken();
}
}