#include <object.h>
Public Member Functions | |
Type | getType () const |
byte | getSubType () const |
uint16 | getIndex () const |
Common::String | getIndexAsString () const |
Common::String | getName () const |
virtual void | readData (Formats::XRCReadStream *stream) |
virtual void | saveLoad (ResourceSerializer *serializer) |
virtual void | saveLoadCurrent (ResourceSerializer *serializer) |
virtual void | onPostRead () |
virtual void | onAllLoaded () |
virtual void | onEnterLocation () |
virtual void | onGameLoop () |
virtual void | onEnginePause (bool pause) |
virtual void | onExitLocation () |
virtual void | onPreDestroy () |
template<class T > | |
T * | findParent () |
Object * | findChildWithIndex (Type type, uint16 index, int subType=-1) const |
Object * | findChildWithOrder (Type type, uint16 order, int subType=-1) const |
Object * | findChildWithName (Type type, const Common::String &name, int subType=-1) const |
template<class T > | |
T * | findChild (bool mustBeUnique=true) const |
template<class T > | |
T * | findChildWithSubtype (int subType, bool mustBeUnique=true) const |
template<class T > | |
T * | findChildWithIndex (uint16 index, int subType=-1) const |
template<class T > | |
T * | findChildWithOrder (uint16 order, int subType=-1) const |
template<class T > | |
T * | findChildWithName (const Common::String &name, int subType=-1) const |
template<class T > | |
Common::Array< T * > | listChildren (int subType=-1) const |
template<class T > | |
Common::Array< T * > | listChildrenRecursive (int subType=-1) |
void | addChild (Object *child) |
virtual void | print (uint depth=0) |
template<> | |
Object * | cast (Object *resource) |
template<> | |
Object * | findParent () |
template<> | |
Common::Array< Object * > | listChildren (int subType) const |
Static Public Member Functions | |
template<class T > | |
static T * | cast (Object *resource) |
Protected Member Functions | |
Object (Object *parent, byte subType, uint16 index, const Common::String &name) | |
void | printWithDepth (uint depth, const Common::String &string) const |
void | printDescription (uint depth) const |
virtual void | printData () |
Protected Attributes | |
Type | _type |
byte | _subType |
uint16 | _index |
Common::String | _name |
Object * | _parent |
Common::Array< Object * > | _children |
Game resource base object
The in-game objects are represented using subclasses of this class.
The game world is made of a tree of resources, with each level further down the tree adding further details. An instance of this class is a node in that tree.
The first few tree levels are as follow:
The actual world tree is cut off in several sub-trees. There is one sub-tree per xarc archive. For resource management reasons the sub-trees are not merged in memory, the sub-trees are loaded and unloaded as needed, according to the current level / location.
The xarc archives contain each an xrc file, which is a serialized version of the initial state of a resource sub-tree. The readData method is called for each resource by the archive loader when a resource tree is loaded to set up its initial state.
As the game plays, modifications are made to the resources to reflect the game's state. When the resource sub-trees are loaded or unloaded their state is restored or persisted by the state provider. The saveLoad method is called to perform the serialization / deserialization of a resource. The saveLoadCurrent method is additionally called when loading or saving a sub-tree corresponding to the current level / location. This allows to persist additional data needed when restoring an active location.
The OnEnterLocation and OnExitLocation methods are called by the resource provider when entering or leaving a level / location.
The OnGameLoop method is called during the game loop.
|
inline |
Get the resource type
|
inline |
Get the resource sub type
|
inline |
Get the resource index
|
inline |
Get the resource index as a string
|
inline |
Get the name of the resource
|
virtual |
Deserialize the resource static data and initial state.
Reimplemented in Stark::Resources::ImageItem, Stark::Resources::ModelItem, Stark::Resources::FloorPositionedImageItem, Stark::Resources::LevelItemTemplate, Stark::Resources::UnimplementedResource, Stark::Resources::AnimSkeleton, Stark::Resources::AnimVideo, Stark::Resources::AnimProp, Stark::Resources::Command, Stark::Resources::Floor, Stark::Resources::AnimImages, Stark::Resources::ItemVisual, Stark::Resources::Dialog, Stark::Resources::Path3D, Stark::Resources::Layer3D, Stark::Resources::ImageText, Stark::Resources::FloorFace, Stark::Resources::Layer2D, Stark::Resources::Path2D, Stark::Resources::AnimScriptItem, Stark::Resources::ImageStill, Stark::Resources::Anim, Stark::Resources::Script, Stark::Resources::Item, Stark::Resources::Sound, Stark::Resources::Camera, Stark::Resources::Image, Stark::Resources::Layer, Stark::Resources::Path, Stark::Resources::TextureSet, Stark::Resources::AnimHierarchy, Stark::Resources::PATTable, Stark::Resources::Knowledge, Stark::Resources::AnimSoundTrigger, Stark::Resources::Speech, Stark::Resources::Light, Stark::Resources::LipSync, Stark::Resources::FloorField, Stark::Resources::Bookmark, Stark::Resources::BonesMesh, Stark::Resources::FMV, Stark::Resources::Scroll, and Stark::Resources::Direction.
|
virtual |
Persist / restore the resource state
Reimplemented in Stark::Resources::FloorPositionedItem, Stark::Resources::AnimImages, Stark::Resources::ItemVisual, Stark::Resources::Dialog, Stark::Resources::Floor, Stark::Resources::Script, Stark::Resources::Item, Stark::Resources::Layer, Stark::Resources::PATTable, Stark::Resources::AnimScript, Stark::Resources::KnowledgeSet, Stark::Resources::Knowledge, and Stark::Resources::Light.
|
virtual |
Persist / restore the resource state
Called only for active locations
Reimplemented in Stark::Resources::ModelItem, Stark::Resources::AnimVideo, Stark::Resources::ItemTemplate, Stark::Resources::ItemVisual, Stark::Resources::Script, Stark::Resources::Item, Stark::Resources::Sound, Stark::Resources::Layer, Stark::Resources::Location, Stark::Resources::Speech, Stark::Resources::LipSync, and Stark::Resources::Scroll.
|
virtual |
Called when the node's initialization is complete.
Allows to load additional data from file.
Reimplemented in Stark::Resources::AnimSkeleton, Stark::Resources::AnimProp, Stark::Resources::ImageStill, Stark::Resources::TextureSet, Stark::Resources::Light, and Stark::Resources::BonesMesh.
|
virtual |
Called when the resource sub-tree is entirely loaded.
Allows to load data from other nodes.
Reimplemented in Stark::Resources::ModelItem, Stark::Resources::LevelItemTemplate, Stark::Resources::AnimSkeleton, Stark::Resources::AnimVideo, Stark::Resources::ItemTemplate, Stark::Resources::AnimImages, Stark::Resources::ItemVisual, Stark::Resources::Floor, Stark::Resources::Layer3D, Stark::Resources::Script, Stark::Resources::AnimHierarchy, Stark::Resources::PATTable, Stark::Resources::Location, Stark::Resources::AnimSoundTrigger, Stark::Resources::AnimScript, Stark::Resources::Camera, and Stark::Resources::FloorFace.
|
virtual |
Called when entering a location
Reimplemented in Stark::Resources::ModelItem, Stark::Resources::ItemTemplate, Stark::Resources::Layer3D, Stark::Resources::Layer2D, Stark::Resources::PATTable, Stark::Resources::Location, and Stark::Resources::Camera.
|
virtual |
Called once per game loop
Reimplemented in Stark::Resources::AnimSkeleton, Stark::Resources::AnimVideo, Stark::Resources::Script, Stark::Resources::Item, Stark::Resources::Sound, Stark::Resources::Location, Stark::Resources::AnimSoundTrigger, Stark::Resources::AnimScript, Stark::Resources::Speech, Stark::Resources::LipSync, and Stark::Resources::Scroll.
|
virtual |
Called when ScummVM pauses or resumes the engine
Reimplemented in Stark::Resources::AnimVideo, and Stark::Resources::Sound.
|
virtual |
Called when exiting a location
Reimplemented in Stark::Resources::ModelItem, Stark::Resources::Layer2D, and Stark::Resources::Speech.
|
virtual |
Called before a resource sub-tree is unloaded.
Reimplemented in Stark::Resources::AnimSkeleton, Stark::Resources::Sound, and Stark::Resources::Speech.
|
static |
Cast a resource, performing a type check
T * Stark::Resources::Object::findParent | ( | ) |
Find the first parent resource with the specified type
Object* Stark::Resources::Object::findChildWithIndex | ( | Type | type, |
uint16 | index, | ||
int | subType = -1 |
||
) | const |
Find a child resource matching the specified type, index and subtype
Object* Stark::Resources::Object::findChildWithOrder | ( | Type | type, |
uint16 | order, | ||
int | subType = -1 |
||
) | const |
Find a child resource matching the specified type, order in the children list and subtype
Object* Stark::Resources::Object::findChildWithName | ( | Type | type, |
const Common::String & | name, | ||
int | subType = -1 |
||
) | const |
Find a child resource matching the specified type, name and subtype
T * Stark::Resources::Object::findChild | ( | bool | mustBeUnique = true | ) | const |
Find a child matching the template parameter type
T * Stark::Resources::Object::findChildWithSubtype | ( | int | subType, |
bool | mustBeUnique = true |
||
) | const |
Find a child matching the template parameter type and the specified subtype
T * Stark::Resources::Object::findChildWithIndex | ( | uint16 | index, |
int | subType = -1 |
||
) | const |
Find a child matching the template parameter type and the specified index
T * Stark::Resources::Object::findChildWithOrder | ( | uint16 | order, |
int | subType = -1 |
||
) | const |
Find a child matching the template parameter type, order in the children list and subtype
T * Stark::Resources::Object::findChildWithName | ( | const Common::String & | name, |
int | subType = -1 |
||
) | const |
Find a child matching the template parameter type, name and subtype
Common::Array< T * > Stark::Resources::Object::listChildren | ( | int | subType = -1 | ) | const |
List children matching the template parameter type and the specified subtype
Common::Array< T * > Stark::Resources::Object::listChildrenRecursive | ( | int | subType = -1 | ) |
List children recursively matching the template parameter type and the specified subtype
void Stark::Resources::Object::addChild | ( | Object * | child | ) |
Add a resource to the children list
|
virtual |
Print debug information for the resource
Reimplemented in Stark::Resources::Script.