|
mkRPG
|
The GameObject class is the base class for every part of games. More...
#include <gameobject.h>
Public Member Functions | |
| virtual | ~GameObject () |
| GameObject int | ident () const |
| virtual bool | isEditable () const |
| const QDateTime & | lastInternalEdition () const |
| const QDateTime & | lastChildrenEdition () const |
| const QDateTime & | lastEdition () const |
| void | touch () |
| void | addReference () |
| void | removeReference () |
| void | setParent (GameObject *p) |
| GameObject * | parent () const |
| virtual void | setName (const QString &n) |
| const QString & | name () const |
| virtual GameObject * | child (const int &id) const |
| virtual QList< GameObject * > | children () const |
| virtual int | getParamMin (const QString ¶m) const |
| virtual int | getParamMax (const QString ¶m) const |
| virtual void | setParamMin (const QString ¶m, int min) |
| virtual void | setParamMax (const QString ¶m, int max) |
| virtual void | setParamDomain (const QString ¶m, int min, int max) |
| virtual int | getParam (const QString ¶m) const |
| virtual void | setParam (const QString ¶m, int value) |
| virtual bool | hasParam (const QString ¶m) const |
| virtual QList< QString > | params () const |
| virtual void | renameParam (const QString ¶m, const QString &newParam) |
| virtual void | addParam (const QString ¶m, int value=0, int min=0, int max=100) |
| virtual void | removeParam (const QString ¶m) |
| virtual bool | getFlag (const QString &flag) const |
| virtual void | setFlag (const QString &flag, bool enable) |
| virtual bool | hasFlag (const QString &flag) const |
| virtual QList< QString > | flags () const |
| virtual void | renameFlag (const QString &flag, const QString &newFlag) |
| virtual void | addFlag (const QString &flag, bool enable=true) |
| virtual void | removeFlag (const QString &flag) |
| virtual bool | hasEvent (const QString &event) const |
| virtual Event & | getEvent (const QString &event) const |
| virtual Event & | addEvent (const QString &event) |
| virtual void | removeEvent (const QString &event) |
| virtual QList< QString > | events () const |
| virtual void | renameEvent (const QString &order, const QString &newOrder) |
| virtual bool | hasOrder (const QString &order) const |
| virtual Order & | getOrder (const QString &order) const |
| virtual Order & | addOrder (const QString &order) |
| virtual void | removeOrder (const QString &order) |
| virtual QList< QString > | orders () const |
| virtual void | renameOrder (const QString &order, const QString &newOrder) |
| void | addEmittedAction (Action *action) |
| void | removeEmittedAction (Action *action) |
| void | addReceivedAction (Action *action) |
| void | removeReceivedAction (Action *action) |
| Game * | getGame () |
Protected Member Functions | |
| GameObject (GameObject &parent) | |
| GameObject (Game *g=nullptr, GameObject *parent=nullptr) | |
| void | init (Game *g, GameObject *parent) |
| virtual bool | isValid () const |
| void | copy (GameObject &obj) |
| virtual void | addChild (GameObject *c) |
| virtual void | removeChild (GameObject *c) |
| void | childrenTouched (const QDateTime &d) |
| QList< QString > | filter (QList< QString > l) const |
Protected Attributes | |
| GameObject * | aParent |
| QMap< int, GameObject * > | aChildren |
| Game * | game |
| int | nbRef |
| QMap< QString, Parameter > | aParams |
| QMap< QString, bool > | aFlags |
| QMap< QString, Event * > | aEvents |
| QMap< QString, Order * > | aOrders |
| QString | aName |
| QString | fileName |
| QDateTime | lastEdit |
| QDateTime | lastChildEdit |
| QSet< QString > | reserved |
| QList< Action * > | aEmittedActions |
| QList< Action * > | aReceivedActions |
The GameObject class is the base class for every part of games.
Each instance is identified by a game-wide unique identifier.
## Object edition notification mechanism
To make the edition easier, each GameObject contains two QDateTime values :
## References count
| GameObject::GameObject | ( | GameObject & | parent | ) | [protected] |
Constructs a new GameObject with parent parent.
| GameObject::GameObject | ( | Game * | g = nullptr, |
| GameObject * | parent = nullptr |
||
| ) | [protected] |
Constructs a new GameObject with parent parent and the reference to the game g.
| GameObject::~GameObject | ( | ) | [virtual] |
The default destructor destroy every children of the instance
| void GameObject::addChild | ( | GameObject * | c | ) | [protected, virtual] |
Registers a new child.
| void GameObject::addEmittedAction | ( | Action * | action | ) |
Register the GameObject as the emitter of the action action.
This is usefull to avoid dangling references.
| Event & GameObject::addEvent | ( | const QString & | event | ) | [virtual] |
Create a new event named event.
event already exists, it will be discarded.| void GameObject::addFlag | ( | const QString & | flag, |
| bool | enable = true |
||
| ) | [virtual] |
Inserts a new falg flag.
| Order & GameObject::addOrder | ( | const QString & | order | ) | [virtual] |
Create a new order named order.
order already exists, it will be discarded.| void GameObject::addParam | ( | const QString & | param, |
| int | value = 0, |
||
| int | min = 0, |
||
| int | max = 100 |
||
| ) | [virtual] |
Inserts a new param parameter.
| void GameObject::addReceivedAction | ( | Action * | action | ) |
Register the GameObject as one of the receivers of the action action.
This is usefull to avoid dangling references.
| void GameObject::addReference | ( | ) |
Increases the references counter
| virtual GameObject* GameObject::child | ( | const int & | id | ) | const [inline, virtual] |
Returns the child with identifier i if any.
| virtual QList<GameObject*> GameObject::children | ( | ) | const [inline, virtual] |
| void GameObject::childrenTouched | ( | const QDateTime & | d | ) | [protected] |
Registers a change in one of the child of the object.
| void GameObject::copy | ( | GameObject & | obj | ) | [protected] |
Loads the content of obj in the current instance.
| QList< QString > GameObject::events | ( | ) | const [virtual] |
Returns the list of event's names of the object.
Reimplemented in InheritableObject.
| QList< QString > GameObject::filter | ( | QList< QString > | l | ) | const [protected] |
Removes the protected parameters/flags for the user visible lists.
| QList< QString > GameObject::flags | ( | ) | const [virtual] |
Returns the list of the registered flags
Reimplemented in InheritableObject.
| Event & GameObject::getEvent | ( | const QString & | event | ) | const [virtual] |
Returns the event named event.
Reimplemented in InheritableObject.
| bool GameObject::getFlag | ( | const QString & | flag | ) | const [virtual] |
Returns the value of the flag flag.
false value is returned, and the flags map stay unchangedReimplemented in InheritableObject.
| Game* GameObject::getGame | ( | ) | [inline] |
Returns the Game from which the GameObject is part.
| Order & GameObject::getOrder | ( | const QString & | order | ) | const [virtual] |
Returns the order named order.
Reimplemented in InheritableObject.
| int GameObject::getParam | ( | const QString & | param | ) | const [virtual] |
Returns the value of the param parameter.
Reimplemented in InheritableObject.
| int GameObject::getParamMax | ( | const QString & | param | ) | const [virtual] |
Returns the upper bound of the param parameter.
Reimplemented in InheritableObject.
| int GameObject::getParamMin | ( | const QString & | param | ) | const [virtual] |
Returns the lower bound of the param parameter.
Reimplemented in InheritableObject.
| bool GameObject::hasEvent | ( | const QString & | event | ) | const [virtual] |
Return true if the GameObject has a event named event.
Reimplemented in InheritableObject.
| bool GameObject::hasFlag | ( | const QString & | flag | ) | const [virtual] |
Returns true if the falg flag is register in the object's flags.
Reimplemented in InheritableObject.
| bool GameObject::hasOrder | ( | const QString & | order | ) | const [virtual] |
Return true if the GameObject has a order named order.
Reimplemented in InheritableObject.
| bool GameObject::hasParam | ( | const QString & | param | ) | const [virtual] |
Returns true if the parameter param is register in the object's parameters.
Reimplemented in InheritableObject.
| GameObject int GameObject::ident | ( | ) | const [inline] |
Returns the name wide unique identifier of the object.
| void GameObject::init | ( | Game * | g, |
| GameObject * | parent | ||
| ) | [protected] |
Initialises the object in case it had been construct with a NULL pointer (array of objects)
| virtual bool GameObject::isEditable | ( | ) | const [inline, virtual] |
Returns true if the GameObject is editable by the user.
Reimplemented in GameObjectInventory, GameObjectList< Type >, and DefaultTypes.
| virtual bool GameObject::isValid | ( | ) | const [inline, protected, virtual] |
| const QDateTime& GameObject::lastChildrenEdition | ( | ) | const [inline] |
Returns the last time one of the object's children has been modified.
| const QDateTime& GameObject::lastEdition | ( | ) | const [inline] |
Returns the last time a modification was made on the object or one of its children.
| const QDateTime& GameObject::lastInternalEdition | ( | ) | const [inline] |
Returns the last edition time.
| const QString& GameObject::name | ( | ) | const [inline] |
Returns the name of the object.
| QList< QString > GameObject::orders | ( | ) | const [virtual] |
Returns the list of order's names of the object.
Reimplemented in InheritableObject.
| QList< QString > GameObject::params | ( | ) | const [virtual] |
Returns the list of the registered paramters
Reimplemented in InheritableObject.
| GameObject* GameObject::parent | ( | ) | const [inline] |
Returns the parent of the object.
| void GameObject::removeChild | ( | GameObject * | c | ) | [protected, virtual] |
| void GameObject::removeEmittedAction | ( | Action * | action | ) |
Free the GameObject from the action action as its emitter.
This is usefull to avoid dangling references.
| void GameObject::removeEvent | ( | const QString & | event | ) | [virtual] |
Delete the event named event, if exists.
| void GameObject::removeFlag | ( | const QString & | flag | ) | [virtual] |
Erases the flag flag.
| void GameObject::removeOrder | ( | const QString & | order | ) | [virtual] |
Delete the order named order, if exists.
| void GameObject::removeParam | ( | const QString & | param | ) | [virtual] |
Erases the param parameter.
| void GameObject::removeReceivedAction | ( | Action * | action | ) |
Free the GameObject from the action action as one of its receivers.
This is usefull to avoid dangling references.
| void GameObject::removeReference | ( | ) |
Decreases the references counter
| void GameObject::renameEvent | ( | const QString & | order, |
| const QString & | newOrder | ||
| ) | [virtual] |
Changes the name of the event event to newEvent.
| void GameObject::renameFlag | ( | const QString & | flag, |
| const QString & | newFlag | ||
| ) | [virtual] |
Changes the name of the flag flag to newFlag.
| void GameObject::renameOrder | ( | const QString & | order, |
| const QString & | newOrder | ||
| ) | [virtual] |
Changes the name of the order order to newOrder.
| void GameObject::renameParam | ( | const QString & | param, |
| const QString & | newParam | ||
| ) | [virtual] |
Changes the name of the param parameter to newParam.
| void GameObject::setFlag | ( | const QString & | flag, |
| bool | enable | ||
| ) | [virtual] |
| void GameObject::setName | ( | const QString & | n | ) | [virtual] |
Defines the name of the object.
| void GameObject::setParam | ( | const QString & | param, |
| int | value | ||
| ) | [virtual] |
Set the value of the param parameter.
Reimplemented in InheritableObject.
| void GameObject::setParamDomain | ( | const QString & | param, |
| int | min, | ||
| int | max | ||
| ) | [virtual] |
Sets the lower and upper bound of the param parameter.
| void GameObject::setParamMax | ( | const QString & | param, |
| int | max | ||
| ) | [virtual] |
Sets the upper bound of the param parameter.
| void GameObject::setParamMin | ( | const QString & | param, |
| int | min | ||
| ) | [virtual] |
Sets the lower bound of the param parameter.
| void GameObject::setParent | ( | GameObject * | p | ) |
Defines the parent of the object.
| void GameObject::touch | ( | ) |
Notify the object and its parent that it has been modified.
1.7.6.1