Files
Continentis/Assets/Scripts/MainGame/Card/CardSubmodules/CombatBuffSubmodule.cs

83 lines
2.8 KiB
C#
Raw Normal View History

2025-10-03 00:02:43 -04:00
using System.Collections.Generic;
using System.Linq;
2026-04-17 12:01:50 -04:00
using SLSUtilities.General;
2025-10-03 00:02:43 -04:00
using UnityEngine;
namespace Continentis.MainGame.Card
{
2025-11-15 12:17:34 -05:00
public partial class CombatBuffSubmodule : SubmoduleBase<CardInstance>
2025-10-03 00:02:43 -04:00
{
2025-10-24 09:11:22 -04:00
public List<CardCombatBuffBase> buffList;
2025-10-03 00:02:43 -04:00
2025-11-15 12:17:34 -05:00
public CombatBuffSubmodule(CardInstance owner) : base(owner)
2025-10-03 00:02:43 -04:00
{
2025-10-24 09:11:22 -04:00
buffList = new List<CardCombatBuffBase>();
2025-10-03 00:02:43 -04:00
}
}
public partial class CombatBuffSubmodule
{
2025-10-24 09:11:22 -04:00
public T GetBuff<T>() where T : CardCombatBuffBase
2025-10-03 00:02:43 -04:00
{
return (T)buffList.Find(x => x.GetType() == typeof(T));
}
2025-10-24 09:11:22 -04:00
public bool HasBuff<T>() where T : CardCombatBuffBase
2025-10-03 00:02:43 -04:00
{
return buffList.Exists(x => x.GetType() == typeof(T));
}
}
public partial class CombatBuffSubmodule
{
public void Use()
{
buffList.For(buff => buff.usageSubmodule?.UpdateModule());
buffList.For(buff => buff.OnUsage());
}
public void RoundStart()
{
2025-10-23 00:49:44 -04:00
buffList.For(buff => buff.combatRoundTimeSubmodule?.Update());
2025-10-03 00:02:43 -04:00
buffList.For(buff => buff.OnRoundStart());
}
public void RoundEnd()
{
buffList.For(buff => buff.OnRoundEnd());
}
public void ActionStart()
{
2025-10-23 00:49:44 -04:00
buffList.For(buff => buff.combatActionTimeSubmodule?.Update());
2025-10-03 00:02:43 -04:00
buffList.For(buff => buff.OnActionStart());
}
public void ActionEnd()
{
buffList.For(buff => buff.OnActionEnd());
}
}
public partial class CombatBuffSubmodule
{
public void GetAttributeChange(string attributeName, out float numericChange,
out float percentageChangeOfAccumulation, out float percentChangeOfMultiplication)
{
numericChange = buffList.Where(buff => buff.attributeSubmodule != null)
.SelectMany(buff => buff.attributeSubmodule.numericChange)
.Where(change => change.Key == attributeName)
.Sum(change => change.Value);
percentageChangeOfAccumulation = buffList.Where(buff => buff.attributeSubmodule != null)
.SelectMany(buff => buff.attributeSubmodule.percentageChangeOfAccumulation)
.Where(change => change.Key == attributeName)
.Sum(change => change.Value);
percentChangeOfMultiplication = buffList.Where(buff => buff.attributeSubmodule != null)
.SelectMany(buff => buff.attributeSubmodule.percentageChangeOfMultiplication)
.Where(change => change.Key == attributeName)
.Aggregate<KeyValuePair<string, float>, float>(1, (current, change) => current * change.Value);
}
}
}