2024-02-25 14:46:47 +00:00
|
|
|
#pragma once
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
#include "StarAiTypes.hpp"
|
|
|
|
#include "StarUuid.hpp"
|
|
|
|
#include "StarDrawable.hpp"
|
|
|
|
#include "StarLuaComponents.hpp"
|
|
|
|
#include "StarWorld.hpp"
|
|
|
|
|
|
|
|
namespace Star {
|
|
|
|
|
|
|
|
STAR_CLASS(Companion);
|
|
|
|
STAR_CLASS(PlayerCompanions);
|
|
|
|
|
|
|
|
class Companion {
|
|
|
|
public:
|
|
|
|
Companion(Json const& json);
|
|
|
|
Json toJson() const;
|
|
|
|
|
|
|
|
Uuid podUuid() const;
|
|
|
|
Maybe<String> name() const;
|
|
|
|
Maybe<String> description() const;
|
|
|
|
|
|
|
|
List<Drawable> portrait() const;
|
|
|
|
|
|
|
|
Maybe<float> resource(String const& resourceName) const;
|
|
|
|
Maybe<float> resourceMax(String const& resourceName) const;
|
|
|
|
|
|
|
|
Maybe<float> stat(String const& statName) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Json m_json;
|
|
|
|
List<Drawable> m_portrait;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PlayerCompanions {
|
|
|
|
public:
|
|
|
|
PlayerCompanions(Json const& config);
|
|
|
|
|
|
|
|
void diskLoad(Json const& diskStore);
|
|
|
|
Json diskStore() const;
|
|
|
|
|
|
|
|
List<CompanionPtr> getCompanions(String const& category) const;
|
|
|
|
|
|
|
|
void init(Entity* player, World* world);
|
|
|
|
void uninit();
|
|
|
|
|
|
|
|
void dismissCompanion(String const& category, Uuid const& podUuid);
|
|
|
|
|
|
|
|
Maybe<Json> receiveMessage(String const& message, bool localMessage, JsonArray const& args = {});
|
2023-07-20 14:58:49 +00:00
|
|
|
void update(float dt);
|
2023-06-20 04:33:09 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
LuaCallbacks makeCompanionsCallbacks();
|
|
|
|
|
|
|
|
World* m_world;
|
|
|
|
Json m_config;
|
|
|
|
StringMap<List<CompanionPtr>> m_companions;
|
|
|
|
|
|
|
|
LuaMessageHandlingComponent<LuaStorableComponent<LuaUpdatableComponent<LuaWorldComponent<LuaBaseComponent>>>>
|
|
|
|
m_scriptComponent;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|