Files
Cielonos/Assets/Scripts/MainGame/Items/Consumables/AutomaticShield.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2026-02-13 09:22:11 -05:00
using SLSUtilities.General;
2026-01-03 18:19:39 -05:00
using UnityEngine;
2026-05-23 08:27:50 -04:00
namespace Cielonos.MainGame.Inventory.Collections
2026-01-03 18:19:39 -05:00
{
public class AutomaticShield : ConsumableBase
{
public override void OnObtained()
{
base.OnObtained();
2026-05-23 08:27:50 -04:00
player.eventSm.onBeforeGetAttacked.Add("AutomaticShield", new PrioritizedAction<AttackAreaBase, Attack.Context>(CheckAndEffect));
2026-01-03 18:19:39 -05:00
}
public override void OnDiscarded()
{
base.OnDiscarded();
player.eventSm.onBeforeGetAttacked.Remove("AutomaticShield");
}
2026-05-23 08:27:50 -04:00
void CheckAndEffect(AttackAreaBase attackArea, Attack.Context attackContext)
2026-01-03 18:19:39 -05:00
{
2026-05-23 08:27:50 -04:00
if (attackContext.value.damage > 1f)
2026-01-03 18:19:39 -05:00
{
if (Use(1))
{
2026-05-23 08:27:50 -04:00
// 使用 Context 的前置否决标记使其伤害彻底作废:
2026-06-02 12:55:39 -04:00
attackContext.isDenied = true;
2026-05-23 08:27:50 -04:00
attackContext.value.damageMultiplier = 0f;
2026-03-20 12:07:44 -04:00
2026-01-03 18:19:39 -05:00
CameraEffectManager.Instance.vignetteEffects["Shield"].mainEffect.Play();
}
}
}
}
}