PGRData/Script/matrix/xhome/xdorm/xhomechar/XHomeCharFSMFactory.lua

36 lines
No EOL
819 B
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.

--状态
XHomeCharFSMType = {
EMPTY = "EMPTY", --空状态
IDLE = "IDLE", --游荡状态
MOOD = "MOOD", --心情状态
INTERACT = "INTERACT", --交互状态
CONTROL = "CONTROL", --控制状态
}
--状态工厂
XHomeCharFSMFactory = {}
--注册表
local Registry = {}
--注册状态机
function XHomeCharFSMFactory.RegisterFSM(name, state)
local machine = XClass(XHomeCharFSM, name)
Registry[state] = machine
machine.name = state
return machine
end
--新建状态
function XHomeCharFSMFactory.New(state, agent)
if not Registry[state] then
XLog.Error("状态机未注册StateMachine :" .. tostring(state))
return nil
end
return Registry[state].New(agent)
end
--清空注册表
function XHomeCharFSMFactory.ClearRegistry()
Registry = {}
end