Files
SoulliesOfficial ac98ec3aef 更新
2026-04-17 12:01:50 -04:00

56 lines
1.9 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 SLSUtilities.UModAssistance;
using UnityEngine;
namespace Continentis.MainGame.Character
{
public abstract partial class CharacterBuffBase : BuffBase<CharacterBase>
{
public CharacterBase attachedCharacter;
public CharacterBase sourceCharacter;
public IconSubmodule iconSubmodule;
public EventSubmodule eventSubmodule;
}
public partial class CharacterBuffBase
{
public override void Apply(CharacterBase attached)
{
this.Apply(attached, null);
}
public abstract void Apply(CharacterBase attachedCharacter, CharacterBase sourceCharacter = null);
}
public partial class CharacterBuffBase
{
/// <summary>
/// 创建一个角色战斗Buff实例
/// 注意此函数依赖ModManager的类型注册功能请确保在Mod加载时已注册对应Buff类型
/// 此函数中的T并不是原型参数而是获取Mod中注册的类型用的
/// </summary>
public T CreateCharacterBuff<T>(params object[] parameters) where T :CharacterCombatBuffBase
{
string buffTypeID = ModManager.GetTypeID(typeof(T));
if (string.IsNullOrEmpty(buffTypeID))
{
Debug.LogError($"Failed to get buff name for type {typeof(T).FullName}");
return null;
}
return ModManager.CreateInstance<T>(buffTypeID, parameters);
}
public T CreateCharacterBuff<T>(string buffTypeID, params object[] parameters) where T :CharacterCombatBuffBase
{
if (string.IsNullOrEmpty(buffTypeID))
{
Debug.LogError($"Failed to get buff name for type {typeof(T).FullName}");
return null;
}
return ModManager.CreateInstance<T>(buffTypeID, parameters);
}
}
}