JD2022-TU1/data/EngineData/Helpers/BossSequence_helpers.ilu

156 lines
5.7 KiB
Text

__bossAnim3DList = {}
__bossInput3DList = {}
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- clear animation list
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function clearAnimation3DList()
__bossAnim3DList = {}
__bossInput3DList = {}
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- animations to be auto registered
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function __autoRegisterAnimation3D(_name, _loop)
__bossAnim3DList[_name] = { loop = _loop }
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- inputs to be auto registered
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function __autoRegisterInput3D(_name)
__bossInput3DList[_name] = true
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- declare all animations
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function declareAllAnimations()
local animList = {}
for name, data in pairs(__bossAnim3DList) do
table.insert(animList, __declareAnimation3D(name, data.loop))
end
return animList
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- declare all inputs
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function declareAllInputs()
local inputList = {}
for name, _ in pairs(__bossInput3DList) do
table.insert(inputList, __declareInput3D(name))
end
return inputList
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- add animations, with optionnal friendly name
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function __declareAnimation3D(_name, _loop, _friendly)
if _friendly == nil then
_friendly = _name
end
local animation =
{
Animation3DInfo_Template =
{
friendlyName = _friendly,
name = gpeRoot() .. 'animation/' .. _name .. '.a3d',
}
}
if _loop ~= nil then
animation.Animation3DInfo_Template.loop = _loop
end
return animation
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- add an input
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function __declareInput3D(_name)
return
{
{
InputDesc =
{
name = _name,
varType = AnimInputTypes.uint
}
}
}
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- insert a sequence, with optionnal loop number and node name
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function sequence3D(_data, _loop, _label)
local sequence = { leafs = _data }
if _loop ~= nil then
sequence.loopCount = _loop
end
if _label ~= nil then
sequence.nodeName = _label
end
return { NAME = "Animation3DTreeNodeSequence_Template", Animation3DTreeNodeSequence_Template = sequence }
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- define inputs for a sequence
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function steps3D(_data, _inputName, _label)
local branch = { leafs = _data, leafsCriterias = {} }
local i
if _label ~= nil then
branch.nodeName = _label
end
for i = 1, #_data, 1 do
table.insert(branch.leafsCriterias,
{
BlendLeaf =
{
criterias =
{
{
CriteriaDesc =
{
name = _inputName,
eval = "==",
value = i - 1,
}
}
}
}
})
end
return branch
end
---------------------------------------------------------------------------------------------------------------------------------------------------------------
-- insert an animation, with optionnal node name
---------------------------------------------------------------------------------------------------------------------------------------------------------------
function animation3D(_name, _label, _loop)
local animation = { animationName = _name }
if _label ~= nil then
animation.nodeName = _label
end
-- if _loop ~= nil then
-- animation.loop = 1
-- end
__autoRegisterAnimation3D(_name, _loop)
return { NAME = "Animation3DTreeNodePlayAnim_Template", Animation3DTreeNodePlayAnim_Template = animation }
end