Files
Cielonos/Assets/Scripts/MainGame/Base/FunctionalAnimation/Payloads/SetBreakthroughResistance.cs
SoulliesOfficial 649b7a5ddc 更新
2026-05-23 08:27:50 -04:00

86 lines
3.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using Cielonos.MainGame.Buffs.Character;
using Cielonos.MainGame.Characters;
using Sirenix.OdinInspector;
using SLSUtilities.FunctionalAnimation;
using UnityEngine;
using UnityEngine.Serialization;
namespace Cielonos.MainGame.FunctionalAnimation
{
[Serializable]
public class SetBreakthroughResistance : FuncAnimPayloadBase
{
[InfoBox("设置角色的突破抗性状态,同时开启或关闭轮廓线效果。\n角色会被突破类型相同或更高的攻击打断不会被低于该突破类型的攻击打断。")]
[FormerlySerializedAs("outlineSwitch")]
[Tooltip("是否开启")]
public bool isEnabling = true;
[Tooltip("是否从行为树参数获取突破类型")]
public bool getFromBehaviorTree = true;
[Tooltip("突破类型")]
[HideIf("getFromBehaviorTree")]
public Breakthrough.Type breakthroughableType = Breakthrough.Type.Heavy;
[Tooltip("是否使用详细设置")]
public bool detailedSettings = false;
[Tooltip("轮廓线宽度")]
[ShowIf("@this.detailedSettings && this.isEnabling")]
public float outlineWidth = 0.05f;
[Tooltip("轮廓线淡入淡出时间")]
[ShowIf("detailedSettings")]
public float outlineFadeDuration = 0.1f;
public override void Invoke()
{
RenderSubcontrollerBase renderSc = character.renderSc;
if (getFromBehaviorTree)
{
BehaviorSubcontroller behaviorSc = (character as Automata)!.behaviorSc;
string typeName = behaviorSc.mainBehaviorTree.GetVariable<string>("BreakthroughableType").Value;
if (string.IsNullOrEmpty(typeName))
{
breakthroughableType = Breakthrough.Type.Heavy;
}
breakthroughableType = Enum.TryParse(typeName, out Breakthrough.Type parsedType) ? parsedType : Breakthrough.Type.Heavy;
}
if (isEnabling)
{
new BreakthroughResistanceModification(breakthroughableType).Apply(character);
//renderSc.OutlineOn(breakthroughableType, outlineWidth, outlineFadeDuration);
//SetResistance(breakthroughableType, true);
}
else
{
character.buffSm.GetBuff<BreakthroughResistanceModification>()?.Remove();
//renderSc.OutlineOff(outlineFadeDuration);
//SetResistance(breakthroughableType, false);
}
}
private void SetResistance(Breakthrough.Type type, bool isResistant)
{
foreach (var lowerType in Breakthrough.GetLowerTypes(type))
{
character.reactionSc.breakthroughResistances[lowerType].Modify(isResistant);
}
character.reactionSc.breakthroughResistances[type].Modify(!isResistant);
foreach (var higherType in Breakthrough.GetHigherTypes(type))
{
character.reactionSc.breakthroughResistances[higherType].Modify(!isResistant);
}
}
}
}