Files
zeling_v2/Assets/_Game/Scripts/Progression/Achievement/NoHealRunCondition.cs
2026-05-20 15:10:35 +08:00

30 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using UnityEngine;
using BaseGames.Core.Save;
namespace BaseGames.Progression
{
/// <summary>
/// 无治疗通关成就条件。
/// 依赖 EventChains.WorldFlags 中的标志位AchievementManager 在玩家治疗时写入 noHeal_failed=true。
/// 满足条件Boss 已击败 且 无治疗标志未被置入失败状态。
/// </summary>
[CreateAssetMenu(menuName = "BaseGames/Achievement/Condition/NoHealRun", fileName = "COND_NoHealRun_")]
public class NoHealRunCondition : AchievementCondition
{
[Tooltip("追踪的 Boss ID击败此 Boss 时检查是否治疗过)")]
public string targetBossId;
[Tooltip("WorldFlags 中记录「已治疗」失败状态的 Key由 AchievementManager 设置)")]
public string healFailFlagKey;
public override bool IsMet(SaveData save)
{
if (save?.World == null) return false;
// Boss 已击败 且 未触发治疗失败标志
bool bossDefeated = save.World.DefeatedBossIds.Contains(targetBossId);
bool didHeal = save.EventChains?.WorldFlags?.TryGetValue(healFailFlagKey, out bool val) == true && val;
return bossDefeated && !didHeal;
}
}
}