59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
#ifndef CHARACTER_MANAGER_CLASS
|
|
#define CHARACTER_MANAGER_CLASS
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
class Character;
|
|
class Rig;
|
|
class Animation;
|
|
class HitboxSystem;
|
|
struct CharacterTemplate;
|
|
|
|
class CharacterManager {
|
|
public:
|
|
CharacterManager();
|
|
~CharacterManager();
|
|
|
|
Rig* LoadRig(const std::string& name, const std::string& path);
|
|
Animation* LoadAnimation(const std::string& name, const std::string& path,
|
|
const std::string& rigName = "");
|
|
Character* CreateCharacter(const std::string& name,
|
|
const std::string& rigName = "",
|
|
const std::string& animationName = "");
|
|
|
|
// A new kind of fighter to fill in, or the one already called name
|
|
CharacterTemplate* AddTemplate(const std::string& name);
|
|
CharacterTemplate* GetTemplate(const std::string& name) const;
|
|
const std::vector<CharacterTemplate*>& GetTemplates() const { return templateOrder; } // in the order they were added
|
|
|
|
// A character that's the template called templateName, see Character::ApplyTemplate. nullptr if there's no such template.
|
|
Character* CreateCharacterFromTemplate(const std::string& name, const std::string& templateName);
|
|
|
|
Rig* GetRig(const std::string& name) const;
|
|
Animation* GetAnimation(const std::string& name) const;
|
|
Character* GetCharacter(const std::string& name) const;
|
|
|
|
// Every character's mind decides its actions for this frame
|
|
void Think();
|
|
void Step(float dt);
|
|
|
|
|
|
// Puts out the hitbox of every swing that can connect this frame, after Step
|
|
void AddAttackHitboxes(HitboxSystem& hitboxes);
|
|
|
|
const std::vector<Character*>& GetCharacters() const { return characterOrder; }
|
|
|
|
private:
|
|
std::unordered_map<std::string, std::unique_ptr<Rig>> rigs;
|
|
std::unordered_map<std::string, std::unique_ptr<Animation>> animations;
|
|
std::unordered_map<std::string, std::unique_ptr<CharacterTemplate>> templates;
|
|
std::unordered_map<std::string, std::unique_ptr<Character>> characters;
|
|
std::vector<Character*> characterOrder;
|
|
std::vector<CharacterTemplate*> templateOrder;
|
|
};
|
|
|
|
#endif
|