The Orbit_object class implements the logic for objects that orbit around other other objects. More...
#include <capability_orbit.h>
Public Member Functions | |
| Capability_orbit (ObjectId id) | |
| virtual void | tick (double delta_time_s, double total_time_s) |
Public Member Functions inherited from Capability | |
| Capability (ObjectId id, const std::string &type) | |
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. | |
| DataItem & | addDataItem (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. | |
| DataItem & | accessDataItem (const std::string &dataItem) |
| get a reference to the dataItem | |
| const DataItem & | accessDataItem (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< GameObject > | getParent () 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< GameObject > | getSibling (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< GameObject > | getChild (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 | |
Static Public Member Functions | |
| static Capability * | createFromTemplate (std::shared_ptr< GameObject > future_parent, const nlohmann::json &template_data) |
| static Capability * | createFromDump (ObjectId id) |
Static Public Member Functions inherited from Capability | |
| static std::shared_ptr< Capability > | createFromTemplate (std::shared_ptr< GameObject > owner, const std::string &capability, const nlohmann::json &template_data) |
| static std::shared_ptr< GameObject > | createFromDump (ObjectId id, const std::string &type) |
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 | capabilityName [] = "orbit" |
Static Public Attributes inherited from Capability | |
| static constexpr char | capabilityCategory [] = "capability" |
Static Public Attributes inherited from GameObject | |
| static DataItem | invalidDataItem = DataItem() |
Additional Inherited Members | |
Public Types inherited from Capability | |
| using | undumpFactory = Capability*(*)(ObjectId id) |
| using | createFactory = Capability*(*)(std::shared_ptr<GameObject> future_parent, const nlohmann::json& template_data) |
| using | deleteFactory = void(*)( Capability* ptr ) |
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. | |
| virtual void | _finalizeUndump () |
| Gives the object an opportunity to perform some cleanup/inizialization after the entire object has been deserialized from disk. | |
| GameObject (const std::string &category, ObjectId id, const std::string &type) | |
| Create a GameObject object. | |
The Orbit_object class implements the logic for objects that orbit around other other objects.
The object will be moved in a circular orbit around a center object. The orbiting object will follow the center object if it moves around.
An Orbit_object must have:
The revolutiuon time is used to calculate the orbit angular speed.
An Orbit_object can be created by specifing an initial angle and radius from the center, or by specifiyng an initial position (StarCoord) that will be used to calculate angle and radius from the center.
JSON to define an Orbit_object by initial position: { "orbit_revolution_time": 24, "orbit_direction": 1 "orbit_center_id": xx "position": { x: 1000, y: 1000 } }
JSON to define an Orbit_object by initial angle&radius: { "orbit_revolution_time": 24, "orbit_direction": 1 "orbit_center_id": xx "orbit_radius": 15000.0, "orbit_angle": 0.1 }
|
virtual |
Reimplemented from GameObject.