r2mods/ilspy_dump/ror2_csproj/RoR2.Achievements/LoopOnceAchievement.cs

35 lines
1.0 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using System;
namespace RoR2.Achievements;
[RegisterAchievement("LoopOnce", "Items.BounceNearby", null, 3u, null)]
public class LoopOnceAchievement : BaseAchievement
{
public override void OnInstall()
{
base.OnInstall();
UserProfile obj = base.userProfile;
obj.onStatsReceived = (Action)Delegate.Combine(obj.onStatsReceived, new Action(Check));
Check();
}
public override void OnUninstall()
{
UserProfile obj = base.userProfile;
obj.onStatsReceived = (Action)Delegate.Remove(obj.onStatsReceived, new Action(Check));
base.OnUninstall();
}
private void Check()
{
if ((bool)Run.instance && Run.instance.GetType() == typeof(Run) && Run.instance.loopClearCount > 0)
{
SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
if ((bool)sceneDefForCurrentScene && (sceneDefForCurrentScene.sceneType == SceneType.Stage || sceneDefForCurrentScene.sceneType == SceneType.UntimedStage) && !sceneDefForCurrentScene.isFinalStage && sceneDefForCurrentScene.stageOrder == 1)
{
Grant();
}
}
}
}