2016-11-15 20:52:37 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
#include "engine/resource.h"
|
2018-08-22 20:53:54 +02:00
|
|
|
#include "engine/resource_manager.h"
|
2016-11-15 20:52:37 +01:00
|
|
|
#include "state_machine.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Lumix
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
namespace Anim
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2018-08-22 20:53:54 +02:00
|
|
|
class ControllerManager final : public ResourceManager
|
2016-11-15 20:52:37 +01:00
|
|
|
{
|
|
|
|
public:
|
2016-11-23 17:03:29 +01:00
|
|
|
explicit ControllerManager(IAllocator& allocator)
|
2018-08-22 20:53:54 +02:00
|
|
|
: ResourceManager(allocator)
|
2016-11-15 20:52:37 +01:00
|
|
|
, m_allocator(allocator)
|
|
|
|
{}
|
|
|
|
~ControllerManager() {}
|
2017-11-28 19:37:15 +01:00
|
|
|
IAllocator& getAllocator() const { return m_allocator; }
|
2016-11-15 20:52:37 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Resource* createResource(const Path& path) override;
|
|
|
|
void destroyResource(Resource& resource) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
IAllocator& m_allocator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ControllerResource : public Resource
|
|
|
|
{
|
2017-03-23 01:07:16 +01:00
|
|
|
public:
|
|
|
|
enum class Version : int
|
|
|
|
{
|
|
|
|
ANIMATION_SETS,
|
2017-04-07 13:45:00 +02:00
|
|
|
MAX_ROOT_ROTATION_SPEED,
|
2017-05-16 15:58:45 +02:00
|
|
|
INPUT_REFACTOR,
|
2017-09-07 19:24:24 +02:00
|
|
|
ENTER_EXIT_EVENTS,
|
2017-10-20 21:59:46 +02:00
|
|
|
ANIMATION_SPEED_MULTIPLIER,
|
2017-10-29 14:48:13 +01:00
|
|
|
MASKS,
|
|
|
|
END_GUARD,
|
2018-03-25 17:51:59 +02:00
|
|
|
EVENTS_FIX,
|
2017-03-23 01:07:16 +01:00
|
|
|
|
|
|
|
LAST
|
|
|
|
};
|
|
|
|
|
2016-11-15 20:52:37 +01:00
|
|
|
public:
|
2018-08-22 20:53:54 +02:00
|
|
|
ControllerResource(const Path& path, ResourceManager& resource_manager, IAllocator& allocator);
|
2016-11-16 02:01:21 +01:00
|
|
|
~ControllerResource();
|
2016-11-15 20:52:37 +01:00
|
|
|
|
2018-01-11 21:13:59 +01:00
|
|
|
ResourceType getType() const override { return TYPE; }
|
2017-12-08 00:34:11 +01:00
|
|
|
|
2016-11-16 02:01:21 +01:00
|
|
|
void create() { onCreated(State::READY); }
|
2018-01-06 23:34:44 +01:00
|
|
|
void destroy() { doUnload(); }
|
2017-11-28 19:37:15 +01:00
|
|
|
void unload() override;
|
2016-11-15 20:52:37 +01:00
|
|
|
bool load(FS::IFile& file) override;
|
2017-11-28 19:37:15 +01:00
|
|
|
ComponentInstance* createInstance(IAllocator& allocator) const;
|
2016-11-15 20:52:37 +01:00
|
|
|
void serialize(OutputBlob& blob);
|
2017-10-29 14:48:13 +01:00
|
|
|
bool deserialize(InputBlob& blob, int& version);
|
2017-11-28 19:37:15 +01:00
|
|
|
IAllocator& getAllocator() const { return m_allocator; }
|
2017-03-23 01:07:16 +01:00
|
|
|
void addAnimation(int set, u32 hash, Animation* animation);
|
2016-11-15 20:52:37 +01:00
|
|
|
|
2017-03-23 01:07:16 +01:00
|
|
|
struct AnimSetEntry
|
|
|
|
{
|
|
|
|
int set;
|
|
|
|
u32 hash;
|
|
|
|
Animation* animation;
|
|
|
|
};
|
|
|
|
|
|
|
|
Array<AnimSetEntry> m_animation_set;
|
|
|
|
Array<StaticString<32>> m_sets_names;
|
2017-10-29 14:48:13 +01:00
|
|
|
Array<BoneMask> m_masks;
|
2016-11-15 20:52:37 +01:00
|
|
|
InputDecl m_input_decl;
|
|
|
|
Component* m_root;
|
2017-03-23 01:07:16 +01:00
|
|
|
|
2018-01-11 21:13:59 +01:00
|
|
|
static const ResourceType TYPE;
|
|
|
|
|
2017-03-23 01:07:16 +01:00
|
|
|
private:
|
|
|
|
void clearAnimationSets();
|
|
|
|
|
2016-11-15 20:52:37 +01:00
|
|
|
IAllocator& m_allocator;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Anim
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Lumix
|