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

41 lines
1011 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
namespace RoR2.Achievements;
[RegisterAchievement("KillEliteMonster", "Items.Medkit", null, 1u, typeof(KillEliteMonsterServerAchievement))]
public class KillEliteMonsterAchievement : BaseAchievement
{
private class KillEliteMonsterServerAchievement : BaseServerAchievement
{
public override void OnInstall()
{
base.OnInstall();
GlobalEventManager.onCharacterDeathGlobal += OnCharacterDeath;
}
public override void OnUninstall()
{
GlobalEventManager.onCharacterDeathGlobal -= OnCharacterDeath;
base.OnUninstall();
}
private void OnCharacterDeath(DamageReport damageReport)
{
if (damageReport.victimIsElite && (bool)damageReport.attackerMaster && damageReport.attackerMaster.gameObject == serverAchievementTracker.networkUser.masterObject)
{
Grant();
}
}
}
public override void OnInstall()
{
base.OnInstall();
SetServerTracked(shouldTrack: true);
}
public override void OnUninstall()
{
SetServerTracked(shouldTrack: false);
base.OnUninstall();
}
}