Files
Continentis/Assets/Scripts/MainGame/Character/CharacterSubmodules/CombatBuffSubmodule.cs
SoulliesOfficial 9b1b5ca93f initial
2025-10-03 00:02:43 -04:00

96 lines
3.8 KiB
C#

using System.Collections.Generic;
using System.Linq;
using SoulliesFramework.General;
using UnityEngine;
namespace Continentis.MainGame.Character
{
public partial class CombatBuffSubmodule : SubmoduleBase<CharacterBase>
{
public List<CombatBuffBase> buffList;
public CombatBuffSubmodule(CharacterBase character) : base(character)
{
buffList = new List<CombatBuffBase>();
}
}
public partial class CombatBuffSubmodule
{
public T GetBuff<T>() where T : CombatBuffBase
{
return (T)buffList.Find(x => x.GetType() == typeof(T));
}
public bool HasBuff<T>() where T : CombatBuffBase
{
return buffList.Exists(x => x.GetType() == typeof(T));
}
}
public partial class CombatBuffSubmodule
{
public void RoundStart()
{
buffList.For(buff => buff.combatRoundTimeSubmodule?.UpdateModule());
buffList.For(buff => buff.OnRoundStart());
}
public void RoundEnd()
{
buffList.For(buff => buff.OnRoundEnd());
}
public void ActionStart()
{
buffList.For(buff => buff.combatActionTimeSubmodule?.UpdateModule());
buffList.For(buff => buff.OnActionStart());
}
public void ActionEnd()
{
buffList.For(buff => buff.OnActionEnd());
}
}
public partial class CombatBuffSubmodule
{
public void GetCoreAttributeChange(string attributeName, out float numericChange,
out float percentageChangeOfAccumulation, out float percentChangeOfMultiplication)
{
numericChange = buffList.Where(buff => buff.coreAttributeSubmodule != null)
.SelectMany(buff => buff.coreAttributeSubmodule.numericChange)
.Where(change => change.Key == attributeName)
.Sum(change => change.Value);
percentageChangeOfAccumulation = buffList.Where(buff => buff.coreAttributeSubmodule != null)
.SelectMany(buff => buff.coreAttributeSubmodule.percentageChangeOfAccumulation)
.Where(change => change.Key == attributeName)
.Sum(change => change.Value);
percentChangeOfMultiplication = buffList.Where(buff => buff.coreAttributeSubmodule != null)
.SelectMany(buff => buff.coreAttributeSubmodule.percentageChangeOfMultiplication)
.Where(change => change.Key == attributeName)
.Aggregate<KeyValuePair<string, float>, float>(1, (current, change) => current * change.Value);
}
public void GetGeneralAttributeChange(string attributeName, out float numericChange,
out float percentageChangeOfAccumulation, out float percentChangeOfMultiplication)
{
numericChange = buffList.Where(buff => buff.generalAttributeSubmodule != null)
.SelectMany(buff => buff.generalAttributeSubmodule.numericChange)
.Where(change => change.Key == attributeName)
.Sum(change => change.Value);
percentageChangeOfAccumulation = buffList.Where(buff => buff.generalAttributeSubmodule != null)
.SelectMany(buff => buff.generalAttributeSubmodule.percentageChangeOfAccumulation)
.Where(change => change.Key == attributeName)
.Sum(change => change.Value);
percentChangeOfMultiplication = buffList.Where(buff => buff.generalAttributeSubmodule != null)
.SelectMany(buff => buff.generalAttributeSubmodule.percentageChangeOfMultiplication)
.Where(change => change.Key == attributeName)
.Aggregate<KeyValuePair<string, float>, float>(1, (current, change) => current * change.Value);
}
}
}