Files
linuxdistro-roguelite/Assets/Scripts/Core/CombatInsightEvents.cs
T

47 lines
1.9 KiB
C#

using System;
using KernelPanic.Combat;
namespace KernelPanic.Core
{
public sealed class ObservedBackgroundAction : IDisposable
{
private readonly CardInstance _card;
private readonly string _stage, _label;
public ObservedBackgroundAction(CardInstance card, string stage, string label)
{
_card = card; _stage = stage; _label = label;
GameEvents.RaiseBackgroundAction(new BackgroundActionEvent(card, stage, label, true));
}
public void Dispose() => GameEvents.RaiseBackgroundAction(new BackgroundActionEvent(_card, _stage, _label, false));
}
public static partial class GameEvents
{
// Observation only. These never replay card-play/equipment hooks.
public static event Action<CardContributionEvent> CardContribution;
public static event Action<BackgroundActionEvent> BackgroundAction;
public static void RaiseCardContribution(CardContributionEvent value) => CardContribution?.Invoke(value);
public static void RaiseBackgroundAction(BackgroundActionEvent value) => BackgroundAction?.Invoke(value);
}
public readonly struct CardContributionEvent
{
public CardContributionEvent(CardInstance card, int uptimeDamage = 0, int shieldDamage = 0, int shieldGranted = 0)
{ Card = card; UptimeDamage = uptimeDamage; ShieldDamage = shieldDamage; ShieldGranted = shieldGranted; }
public CardInstance Card { get; }
public int UptimeDamage { get; }
public int ShieldDamage { get; }
public int ShieldGranted { get; }
}
public readonly struct BackgroundActionEvent
{
public BackgroundActionEvent(CardInstance card, string stage, string label, bool started)
{ Card = card; Stage = stage; Label = label; Started = started; }
public CardInstance Card { get; }
public string Stage { get; }
public string Label { get; }
public bool Started { get; }
}
}