60 lines
1.8 KiB
C#
60 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
// ============================================================================
|
|
// COST CALCULATION CONTEXT - Holds user stats for cost calculations
|
|
// ============================================================================
|
|
|
|
/// <summary>
|
|
/// Context containing user stats needed for cost calculations
|
|
/// Allows ability cost calculation without direct user reference
|
|
/// </summary>
|
|
public struct CostCalculationContext
|
|
{
|
|
public float maxMana;
|
|
public float maxHealth;
|
|
public float currentMana;
|
|
public float currentHealth;
|
|
public float currentClassResource;
|
|
|
|
public static CostCalculationContext FromUser(Taggable user)
|
|
{
|
|
var context = new CostCalculationContext();
|
|
|
|
var mana = user.GetComponent<Mana>();
|
|
if (mana != null)
|
|
{
|
|
context.maxMana = mana.GetMaxValue();
|
|
context.currentMana = mana.GetCurrentValue();
|
|
}
|
|
|
|
var health = user.GetComponent<Health>();
|
|
if (health != null)
|
|
{
|
|
context.maxHealth = health.GetMaxValue();
|
|
context.currentHealth = health.GetCurrentValue();
|
|
}
|
|
|
|
var classResource = user.GetComponent<ClassResource>();
|
|
if (classResource != null)
|
|
{
|
|
context.currentClassResource = classResource.GetCurrentValue();
|
|
}
|
|
|
|
return context;
|
|
}
|
|
|
|
public static CostCalculationContext CreateMockContext(float maxMana = 100f, float maxHealth = 100f)
|
|
{
|
|
return new CostCalculationContext
|
|
{
|
|
maxMana = maxMana,
|
|
maxHealth = maxHealth,
|
|
currentMana = maxMana,
|
|
currentHealth = maxHealth,
|
|
currentClassResource = 100f
|
|
};
|
|
}
|
|
}
|