2025-10-03 00:02:43 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
using SLSFramework.General;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Continentis.MainGame
|
|
|
|
|
|
{
|
|
|
|
|
|
public enum BuffDispelLevel
|
|
|
|
|
|
{
|
|
|
|
|
|
Basic = 0, //弱驱散
|
|
|
|
|
|
Strong = 10, //强驱散
|
2025-10-25 07:49:39 -04:00
|
|
|
|
DeathOnly = 20, //不可驱散(死亡除外)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
Undispellable = 100 //不可驱散(包括死亡)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum BuffType
|
|
|
|
|
|
{
|
|
|
|
|
|
Positive,
|
|
|
|
|
|
Negative,
|
2025-10-24 09:11:22 -04:00
|
|
|
|
Neutral,
|
|
|
|
|
|
Focusing
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-24 09:11:22 -04:00
|
|
|
|
public abstract partial class BuffBase<T> : IPrioritized
|
2025-10-25 07:49:39 -04:00
|
|
|
|
{
|
|
|
|
|
|
public string identification;
|
2025-10-03 00:02:43 -04:00
|
|
|
|
public BuffType buffType;
|
|
|
|
|
|
public BuffDispelLevel dispelThreshold;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
public ContentSubmodule contentSubmodule;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
public int Priority { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected void Initialize(BuffType buffType, BuffDispelLevel dispelThreshold, int priority = 0)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
|
|
|
|
|
this.buffType = buffType;
|
|
|
|
|
|
this.dispelThreshold = dispelThreshold;
|
2025-10-24 09:11:22 -04:00
|
|
|
|
this.Priority = priority + (buffType == BuffType.Focusing ? 10000 : 0);
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-10-25 07:49:39 -04:00
|
|
|
|
|
|
|
|
|
|
protected void SetIdentification(string id)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.identification = id;
|
|
|
|
|
|
}
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class BuffBase<T>
|
|
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
protected bool FindExistingSameBuff<T1, T2>(out T2 existingBuff, List<T1> buffList) where T1 : BuffBase<T> where T2 : BuffBase<T>
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
|
|
|
|
|
existingBuff = null;
|
2025-10-23 00:49:44 -04:00
|
|
|
|
Debug.Log($"Searching for existing buff of type: {this.GetType()} in buff list of count: {buffList.Count}");
|
|
|
|
|
|
foreach (T1 buff in buffList)
|
2025-10-03 00:02:43 -04:00
|
|
|
|
{
|
2025-10-23 00:49:44 -04:00
|
|
|
|
Debug.Log($"existing buff type: {buff.GetType().AssemblyQualifiedName}, this buff type: {this.GetType().AssemblyQualifiedName}");
|
|
|
|
|
|
if (buff.GetType() == this.GetType())
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("Found existing buff of the same type.");
|
|
|
|
|
|
existingBuff = buff as T2;
|
|
|
|
|
|
Debug.Log(existingBuff == null);
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("Buff types do not match.");
|
|
|
|
|
|
}
|
2025-10-03 00:02:43 -04:00
|
|
|
|
}
|
2025-10-23 00:49:44 -04:00
|
|
|
|
|
2025-10-03 00:02:43 -04:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public abstract void Apply(T attached);
|
|
|
|
|
|
|
|
|
|
|
|
public abstract void Remove();
|
|
|
|
|
|
|
|
|
|
|
|
public abstract void UntriggerRemove();
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void Dispel(BuffDispelLevel dispelLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (CanBeDispelled(dispelLevel))
|
|
|
|
|
|
{
|
|
|
|
|
|
OnBuffDispel();
|
|
|
|
|
|
Remove();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class BuffBase<T>
|
|
|
|
|
|
{
|
|
|
|
|
|
//Buff生命周期函数
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Buff被尝试添加到角色时调用。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual bool OnBuffApply(out BuffBase<T> existingBuff)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new System.NotImplementedException(); //需要在子类中实现
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Buff首次成功添加到角色后调用。在OnBuffApply完成,且返回true之后调用。
|
|
|
|
|
|
/// 如果Buff在被添加时,发现已有同类Buff存在,则不会调用此函数。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void OnAfterFirstApply()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Buff被驱散(移除)时调用,在OnBuffRemove之前调用。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void OnBuffDispel()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2025-10-24 09:11:22 -04:00
|
|
|
|
/// Buff被正常移除(包括驱散)时调用。在Buff生命周期结束时调用。
|
|
|
|
|
|
/// UntriggerRemove不会调用此函数。但是UntriggerRemove通常情况下绝不会被调用。
|
2025-10-03 00:02:43 -04:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void OnBuffRemove()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class BuffBase<T>
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 判断该Buff能否被指定驱散等级的驱散效果驱散。
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected bool CanBeDispelled(BuffDispelLevel dispelLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
return dispelLevel >= dispelThreshold;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|