2021-12-24 21:11:44 +08:00
|
|
|
|
#include "EventObject.h"
|
2020-10-18 00:27:23 +08:00
|
|
|
|
#include "../model/UserData.h"
|
|
|
|
|
#include "../armature/Armature.h"
|
|
|
|
|
|
|
|
|
|
DRAGONBONES_NAMESPACE_BEGIN
|
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
const char* EventObject::START = "start";
|
|
|
|
|
const char* EventObject::LOOP_COMPLETE = "loopComplete";
|
|
|
|
|
const char* EventObject::COMPLETE = "complete";
|
|
|
|
|
const char* EventObject::FADE_IN = "fadeIn";
|
|
|
|
|
const char* EventObject::FADE_IN_COMPLETE = "fadeInComplete";
|
|
|
|
|
const char* EventObject::FADE_OUT = "fadeOut";
|
2020-10-18 00:27:23 +08:00
|
|
|
|
const char* EventObject::FADE_OUT_COMPLETE = "fadeOutComplete";
|
2021-12-25 10:04:45 +08:00
|
|
|
|
const char* EventObject::FRAME_EVENT = "frameEvent";
|
|
|
|
|
const char* EventObject::SOUND_EVENT = "soundEvent";
|
2020-10-18 00:27:23 +08:00
|
|
|
|
|
|
|
|
|
void EventObject::actionDataToInstance(const ActionData* data, EventObject* instance, Armature* armature)
|
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
|
if (data->type == ActionType::Play)
|
2020-10-18 00:27:23 +08:00
|
|
|
|
{
|
|
|
|
|
instance->type = EventObject::FRAME_EVENT;
|
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
else
|
2020-10-18 00:27:23 +08:00
|
|
|
|
{
|
|
|
|
|
instance->type = data->type == ActionType::Frame ? EventObject::FRAME_EVENT : EventObject::SOUND_EVENT;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
instance->name = data->name;
|
|
|
|
|
instance->armature = armature;
|
2020-10-18 00:27:23 +08:00
|
|
|
|
instance->actionData = data;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
instance->data = data->data;
|
2020-10-18 00:27:23 +08:00
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
if (data->bone != nullptr)
|
2020-10-18 00:27:23 +08:00
|
|
|
|
{
|
|
|
|
|
instance->bone = armature->getBone(data->bone->name);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
if (data->slot != nullptr)
|
2020-10-18 00:27:23 +08:00
|
|
|
|
{
|
|
|
|
|
instance->slot = armature->getSlot(data->slot->name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EventObject::_onClear()
|
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
|
time = 0.0f;
|
|
|
|
|
type = "";
|
|
|
|
|
name = "";
|
|
|
|
|
armature = nullptr;
|
|
|
|
|
bone = nullptr;
|
|
|
|
|
slot = nullptr;
|
2020-10-18 00:27:23 +08:00
|
|
|
|
animationState = nullptr;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
actionData = nullptr;
|
|
|
|
|
data = nullptr;
|
2020-10-18 00:27:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DRAGONBONES_NAMESPACE_END
|