GSServer-CBT/soggy_resources/lua/Actor/Gadget/GadgetFactory.lua
Akbar Yahya e0d4d8040c melon
2022-11-21 16:30:31 +08:00

52 lines
1.3 KiB
Lua
Raw 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.

----------------------
-- 这是Lua端GadgetFactory包含了创建特殊GadgetActor的方法
-- @module GadgetFactory
actorMgr = actorMgr or require('Actor/ActorManager')
local GadgetFactory = {}
GadgetFactory.PATH_QUEST_AREA = "Actor/Gadget/QuestArea"
GadgetFactory.PostProcessCreateActor = function(alias, actor)
local preAlias = actor:PreGetAlias()
actor:OnPreInit()
if alias == nil or alias == '' then
if preAlias ~= nil then
alias = preAlias
else
alias = actor.defaultAlias
end
end
actor.alias = alias
actorMgr.ActorDic[alias] = actor
actor:OnInit(alias)
actor:OnPostInit()
end
--- 创建任务区域
GadgetFactory.CreateQuestArea = function(alias, configID, bornPos, areaRadius, delayTime, OnAreaIn, OnAreaOut, OnAreaDelayOut)
local actor = actorMgr:GetActor(alias)
if actor == nil then
local metaActor = require(GadgetFactory.PATH_QUEST_AREA)
actor = metaActor:new()
actor.configID = configID
actor.bornPos = bornPos
actor.areaRadius = areaRadius
actor.targetTime = delayTime
actor.questAreaInHandler = OnAreaIn
actor.questAreaOutHandler = OnAreaOut
actor.questAreaDelayOutHandler = OnAreaDelayOut
actor.isAutoStart = true
GadgetFactory.PostProcessCreateActor(alias, actor)
else
if actor.SetPos ~= nil then
actor:SetPos(bornPos)
end
end
return actor
end
return GadgetFactory