Files
Continentis/Assets/Scripts/MainGame/Character/CharacterSubmodules/CombatBuffSubmodule.cs
SoulliesOfficial 76157e3cb1 继续
2025-10-24 09:11:22 -04:00

97 lines
3.9 KiB
C#

using System.Collections.Generic;
using System.Linq;
using Continentis.MainGame.Card;
using SLSFramework.General;
using UnityEngine;
namespace Continentis.MainGame.Character
{
public partial class CombatBuffSubmodule : SubmoduleBase<CharacterBase>
{
public List<CharacterCombatBuffBase> buffList;
public CombatBuffSubmodule(CharacterBase character) : base(character)
{
buffList = new List<CharacterCombatBuffBase>();
}
}
public partial class CombatBuffSubmodule
{
public T GetBuff<T>() where T : CharacterCombatBuffBase
{
return (T)buffList.Find(x => x.GetType() == typeof(T));
}
public bool HasBuff<T>() where T : CharacterCombatBuffBase
{
return buffList.Exists(x => x.GetType() == typeof(T));
}
}
public partial class CombatBuffSubmodule
{
public void RoundStart()
{
buffList.For(buff => buff.combatRoundTimeSubmodule?.Update());
buffList.For(buff => buff.eventSubmodule?.onRoundStart?.Invoke());
}
public void RoundEnd()
{
buffList.For(buff => buff.eventSubmodule?.onRoundEnd?.Invoke());
}
public void ActionStart()
{
buffList.For(buff => buff.actionCountSubmodule?.Update());
buffList.For(buff => buff.eventSubmodule?.onActionStart?.Invoke());
}
public void ActionEnd()
{
buffList.For(buff => buff.eventSubmodule?.onActionEnd?.Invoke());
}
}
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);
}
}
}