OpenAstra
 
Loading...
Searching...
No Matches
Player Class Reference
Inheritance diagram for Player:
GameObject

Public Member Functions

 Player (const std::string &name, const std::string &race, const nlohmann::json &player_dataitems)
 
 Player (ObjectId id)
 
void addShip (ObjectId ship_id)
 
void setHomestead (ObjectId homestead_id)
 
virtual void _finalizeUndump () final
 Gives the object an opportunity to perform some cleanup/inizialization after the entire object has been deserialized from disk.
 
- Public Member Functions inherited from GameObject
nlohmann::json toJson ()
 serialize the current object to JSON object
 
bool writeToJsonFile ()
 Write to the storage folder a file (see _create_filename() below) containing the object in JSON format.
 
DataItemaddDataItem (const std::string &dataItem)
 Add a dataItem, and return a reference to it.
 
bool hasDataItem (const std::string &dataItem) const
 Check if a specific data item exist.
 
DataItemaccessDataItem (const std::string &dataItem)
 get a reference to the dataItem
 
const DataItemaccessDataItem (const std::string &dataItem) const
 get a const reference to the dataItem
 
void dataItemsFromTemplate (const nlohmann::json &template_data)
 Initialize a list of dataitems from a JSON template.
 
const std::string & category () const
 return the object category (starsystemobject, module, command...)
 
const std::string & type () const
 return the type (ship_xxx, station_xxx, planet_xxx...)
 
ObjectId id () const
 return the object unique ID
 
void reparent (std::shared_ptr< GameObject > new_parent)
 reparent from the current parent, to a new one
 
void lock ()
 
void unlock ()
 
std::shared_ptr< GameObjectgetParent () const
 return pointer to this object parent
 
template<typename T>
std::shared_ptr< T > getParent () const
 return pointer to this object parent
 
std::shared_ptr< GameObjectgetSibling (ObjectId id)
 get sibling with given ID
 
template<typename T>
std::shared_ptr< T > getSibling (ObjectId id)
 get sibling with given ID
 
std::shared_ptr< GameObjectgetChild (ObjectId id)
 return the child to match the id
 
template<typename T>
std::shared_ptr< T > getChild (ObjectId id)
 return the child to match the id
 
bool hasChild (ObjectId id)
 check if current object has a child with this id
 
std::map< ObjectId, std::shared_ptr< GameObject > > & childrenMap ()
 get a direct reference to the children map
 
virtual void tick (double, double)
 

Static Public Member Functions

static std::shared_ptr< GameObjectcreateFromDump (ObjectId id, const std::string &type)
 
static std::shared_ptr< PlayercreateFromTemplate (const std::string &name, const std::string &race)
 
- Static Public Member Functions inherited from GameObject
static bool initialize (const std::string &storage_path)
 initialize the disk serialization process
 
static void registerSubtype (const std::string &category, undumpFactory undumpCb)
 Static function that needs to be called for each derived class to create types autmatically while undumping from JSON.
 
template<typename T>
static std::shared_ptr< T > createFromJsonFile (const std::string &category, ObjectId id)
 create a GameObject object from a JSON file
 

Static Public Attributes

static constexpr char playerCategory [] = "player"
 
static constexpr char objectType [] = "player"
 
- Static Public Attributes inherited from GameObject
static DataItem invalidDataItem = DataItem()
 

Additional Inherited Members

- Public Types inherited from GameObject
using undumpFactory = std::function<std::shared_ptr<GameObject>(ObjectId, const std::string &)>
 
- Protected Member Functions inherited from GameObject
virtual void _finalizeDump ()
 Gives the object an opportunity to perform some additional stuff after the object had been serialized to disk.
 
virtual void _finalizeUndump (std::shared_ptr< GameObject >)
 Gives the object an opportunity to perform some cleanup/inizialization after the specific child has been deserialized from disk.
 
 GameObject (const std::string &category, ObjectId id, const std::string &type)
 Create a GameObject object.
 

Member Function Documentation

◆ _finalizeUndump()

void Player::_finalizeUndump ( )
finalvirtual

Gives the object an opportunity to perform some cleanup/inizialization after the entire object has been deserialized from disk.

Reimplemented from GameObject.


The documentation for this class was generated from the following files: