OpenAstra
 
Loading...
Searching...
No Matches
command.h
1#ifndef COMMAND_H
2#define COMMAND_H
3
4#include "gameobject.h"
5
6#include "../utils/dynamicloader.hpp"
7#include "../utils/json.hpp"
8
21class Command
22 : public GameObject
23{
24public:
25 using undumpFactory = Command*(*)(ObjectId);
26 using networkFactory = Command*(*)(const nlohmann::json&);
27 using deleteFactory = void(*)( Command* ptr );
28
29 static constexpr char commandCategory[] = "command";
30 static std::shared_ptr<Command> createFromDump( ObjectId id, const std::string& type );
31 static std::shared_ptr<Command> createFromNetwork(ObjectId player_id,
32 const nlohmann::json& command_json );
33
34 virtual ~Command();
35
36 virtual bool performCommand() = 0;
37
38 ObjectId starsystem_id;
39 ObjectId object_id;
40 ObjectId module_id;
41 ObjectId player_id;
42
43protected:
44 Command(ObjectId dumped_id, const std::string& type );
45
46private:
47 virtual void _finalizeUndump();
48
49 std::shared_ptr<DynamicLoader> _plugin_handle;
50
51};
52
53#endif // COMMAND_H
GameObject(const std::string &category, ObjectId id, const std::string &type)
Create a GameObject object.
Definition gameobject.cpp:38
const std::string & type() const
return the type (ship_xxx, station_xxx, planet_xxx...)
Definition gameobject.h:213
Definition gameid.hpp:9