89 lines
3.4 KiB
Lua
89 lines
3.4 KiB
Lua
--[[
|
||
说明文档:
|
||
1、将BuffSystem文件夹加入Script.Global文件夹中
|
||
2、require此文件
|
||
3、GameState的BeginPlay中调用BuffManager.InitRegister(InGameState)
|
||
4、GameState的UGCGameState:GetReplicatedProperties()函数末尾加入 BuffManager.GetReplicatedProperties()
|
||
|
||
]]
|
||
|
||
require('Script.Global.BuffSystem.BuffManager')
|
||
|
||
BuffSystemAPI = BuffSystemAPI or {}
|
||
|
||
---获取给予拥有者该Buff的控制器
|
||
---生效范围:Server
|
||
---@return AController*
|
||
---@param InBuffID uint
|
||
function BuffSystemAPI.GetBuffCauser(InBuffID)
|
||
if BuffManager.BuffInstList[InBuffID] then
|
||
return BuffManager.BuffInstList[InBuffID].BuffCauser
|
||
end
|
||
end
|
||
|
||
|
||
---获取给予拥有者该Buff的Actor 如燃烧子弹、燃烧瓶等
|
||
---生效范围:Server
|
||
---@return AActor*
|
||
---@param InBuffID uint
|
||
function BuffSystemAPI.GetCauserActor(InBuffID)
|
||
if BuffManager.BuffInstList[InBuffID] then
|
||
return BuffManager.BuffInstList[InBuffID].CauserActor
|
||
end
|
||
end
|
||
|
||
---为玩家添加Buff
|
||
---生效范围:Server
|
||
---@return BuffID int @Buff唯一ID
|
||
---@param PlayerPawn PlayerPawn* @玩家角色。所有的接口里的PlayerPawn都可以扩展成任意的Actor,只要这个Actor有一个名字叫BuffSystemComponent的Buff组件即可。
|
||
---@param InBuffAssetType EBuffAssetType @Buff资产类型
|
||
---@param BuffCauser AController* @施加Buff的玩家或AI。可以是nil
|
||
---@param CauserActor AActor* @施加Buff的Actor,比如说PlayerPawn、燃烧瓶Actor等等 可以是nil
|
||
function BuffSystemAPI.PlayerAddBuff(PlayerPawn, InBuffAssetType, BuffCauser, CauserActor)
|
||
return BuffManager.PlayerAddBuff(PlayerPawn, InBuffAssetType, BuffCauser, CauserActor)
|
||
end
|
||
|
||
|
||
---为玩家移除Buff
|
||
---生效范围:Server
|
||
---@param PlayerPawn PlayerPawn* @玩家角色
|
||
---@param BuffName String @Buff名
|
||
---@param LayerCount int @层数
|
||
function BuffSystemAPI.PlayerRemoveBuffFromBuffAssetType(PlayerPawn, InBuffAssetType, LayerCount)
|
||
return BuffManager.PlayerRemoveBuffFromBuffAssetType(PlayerPawn, InBuffAssetType, LayerCount)
|
||
end
|
||
|
||
---移除Buff
|
||
---生效范围:Server
|
||
---@param InBuffID uint
|
||
function BuffSystemAPI.RemoveBuffFromBuffID(InBuffID)
|
||
return BuffManager.RemoveBuffFromBuffID(InBuffID)
|
||
end
|
||
|
||
---是否存在该Buff
|
||
---生效范围:Server
|
||
---@return HasBuff bool @是否存在Buff
|
||
---@param PlayerPawn PlayerPawn* @玩家角色
|
||
---@param InBuffAssetType EBuffAssetType @Buff资产类型
|
||
function BuffManager.PlayerHasBuff(InPawn, InBuffAssetType)
|
||
return BuffManager.PlayerHasBuff(InPawn, InBuffAssetType)
|
||
end
|
||
|
||
---获取Buff当前层数
|
||
---生效范围:服务器&客户端
|
||
---@return Layer int @层数
|
||
---@param PlayerPawn PlayerPawn* @玩家角色
|
||
---@param InBuffAssetType EBuffAssetType @Buff资产类型
|
||
function BuffSystemAPI.GetCurLayer(PlayerPawn, InBuffAssetType)
|
||
-- 玩家拥有这个Buff的所有的BuffID
|
||
local OwnedThisBuffIDs = BuffManager.GetPlayerOwnedBuffIDFromBuffAssetType(PlayerPawn, InBuffAssetType)
|
||
return #OwnedThisBuffIDs
|
||
end
|
||
|
||
---@param InPlayerKey "nil则是广播或客户端发送服务器,table则发送对应客户端,int则为对应玩家"
|
||
---@param BuffID "nil则调单个实例,int则为对应Buff实例中的Action,客户端可能存在同步不及时的情况,建议使用单个实例"
|
||
---@param BuffActionType EBuffActionType
|
||
---@param FuncName string
|
||
function BuffSystemAPI.RPCAction(InPlayerKey, BuffID, BuffActionType, FuncName, ...)
|
||
BuffManager.RPCActionFunc(InPlayerKey, BuffID, BuffActionType, FuncName, ...)
|
||
end |