2021-12-05 17:54:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CDTable.h"
|
2023-03-26 10:09:04 +00:00
|
|
|
#include <list>
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
struct CDAnimation {
|
2024-01-09 07:54:14 +00:00
|
|
|
// uint32_t animationGroupID;
|
2023-03-20 13:10:52 +00:00
|
|
|
// std::string animation_type;
|
|
|
|
// The above two are a pair to represent a primary key in the map.
|
2022-07-28 13:39:57 +00:00
|
|
|
std::string animation_name; //!< The animation name
|
|
|
|
float chance_to_play; //!< The chance to play the animation
|
2024-01-09 07:54:14 +00:00
|
|
|
UNUSED_COLUMN(uint32_t min_loops;) //!< The minimum number of loops
|
|
|
|
UNUSED_COLUMN(uint32_t max_loops;) //!< The maximum number of loops
|
2022-07-28 13:39:57 +00:00
|
|
|
float animation_length; //!< The animation length
|
2023-03-26 10:09:04 +00:00
|
|
|
UNUSED_COLUMN(bool hideEquip;) //!< Whether or not to hide the equip
|
|
|
|
UNUSED_COLUMN(bool ignoreUpperBody;) //!< Whether or not to ignore the upper body
|
|
|
|
UNUSED_COLUMN(bool restartable;) //!< Whether or not the animation is restartable
|
|
|
|
UNUSED_COLUMN(std::string face_animation_name;) //!< The face animation name
|
|
|
|
UNUSED_COLUMN(float priority;) //!< The priority
|
|
|
|
UNUSED_COLUMN(float blendTime;) //!< The blend time
|
2021-12-05 17:54:36 +00:00
|
|
|
};
|
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
typedef LookupResult<CDAnimation> CDAnimationLookupResult;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-03-17 14:36:21 +00:00
|
|
|
class CDAnimationsTable : public CDTable<CDAnimationsTable> {
|
2023-03-20 13:10:52 +00:00
|
|
|
typedef int32_t AnimationGroupID;
|
|
|
|
typedef std::string AnimationID;
|
|
|
|
typedef std::pair<std::string, AnimationGroupID> CDAnimationKey;
|
2021-12-05 17:54:36 +00:00
|
|
|
public:
|
2023-08-11 04:27:40 +00:00
|
|
|
void LoadValuesFromDatabase();
|
2023-03-26 10:09:04 +00:00
|
|
|
/**
|
|
|
|
* Given an animationType and the previousAnimationName played, return the next animationType to play.
|
|
|
|
* If there are more than 1 animationTypes that can be played, one is selected at random but also does not allow
|
|
|
|
* the previousAnimationName to be played twice.
|
|
|
|
*
|
|
|
|
* @param animationType The animationID to lookup
|
|
|
|
* @param previousAnimationName The previously played animation
|
|
|
|
* @param animationGroupID The animationGroupID to lookup
|
|
|
|
* @return CDAnimationLookupResult
|
|
|
|
*/
|
|
|
|
[[nodiscard]] CDAnimationLookupResult GetAnimation(const AnimationID& animationType, const std::string& previousAnimationName, const AnimationGroupID animationGroupID);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cache a full AnimationGroup by its ID.
|
|
|
|
*/
|
2023-03-20 13:10:52 +00:00
|
|
|
void CacheAnimationGroup(AnimationGroupID animationGroupID);
|
|
|
|
private:
|
2023-03-26 10:09:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cache all animations given a premade key
|
|
|
|
*/
|
2023-03-20 13:10:52 +00:00
|
|
|
void CacheAnimations(const CDAnimationKey animationKey);
|
2023-03-26 10:09:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the query responsible for caching the data.
|
|
|
|
* @param queryToCache
|
|
|
|
* @return true
|
|
|
|
* @return false
|
|
|
|
*/
|
|
|
|
bool CacheData(CppSQLite3Statement& queryToCache);
|
|
|
|
|
2023-03-20 13:10:52 +00:00
|
|
|
/**
|
2023-03-26 10:09:04 +00:00
|
|
|
* Each animation is key'd by its animationName and its animationGroupID. Each
|
|
|
|
* animation has a possible list of animations. This is because there can be animations have a percent chance to play so one is selected at random.
|
2023-03-20 13:10:52 +00:00
|
|
|
*/
|
2023-03-26 10:09:04 +00:00
|
|
|
std::map<CDAnimationKey, std::list<CDAnimation>> animations;
|
2021-12-05 17:54:36 +00:00
|
|
|
};
|