ScummVM API documentation
Stark::Resources::Object Class Reference

#include <object.h>

Inheritance diagram for Stark::Resources::Object:
Stark::Resources::Anim Stark::Resources::AnimHierarchy Stark::Resources::AnimScript Stark::Resources::AnimScriptItem Stark::Resources::AnimSoundTrigger Stark::Resources::BonesMesh Stark::Resources::Bookmark Stark::Resources::Camera Stark::Resources::Command Stark::Resources::Container Stark::Resources::Dialog Stark::Resources::Direction Stark::Resources::Floor Stark::Resources::FloorFace Stark::Resources::FloorField Stark::Resources::FMV Stark::Resources::Image Stark::Resources::Item Stark::Resources::Knowledge Stark::Resources::KnowledgeSet Stark::Resources::Layer Stark::Resources::Level Stark::Resources::Light Stark::Resources::LipSync Stark::Resources::Location Stark::Resources::Path Stark::Resources::PATTable Stark::Resources::Root Stark::Resources::Script Stark::Resources::Scroll Stark::Resources::Sound Stark::Resources::Speech Stark::Resources::String Stark::Resources::TextureSet Stark::Resources::UnimplementedResource

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 ()
 
ObjectfindChildWithIndex (Type type, uint16 index, int subType=-1) const
 
ObjectfindChildWithOrder (Type type, uint16 order, int subType=-1) const
 
ObjectfindChildWithName (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<>
Objectcast (Object *resource)
 
template<>
ObjectfindParent ()
 
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
 

Detailed Description

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.

Member Function Documentation

◆ getType()

Type Stark::Resources::Object::getType ( ) const
inline

Get the resource type

◆ getSubType()

byte Stark::Resources::Object::getSubType ( ) const
inline

Get the resource sub type

◆ getIndex()

uint16 Stark::Resources::Object::getIndex ( ) const
inline

Get the resource index

◆ getIndexAsString()

Common::String Stark::Resources::Object::getIndexAsString ( ) const
inline

Get the resource index as a string

◆ getName()

Common::String Stark::Resources::Object::getName ( ) const
inline

Get the name of the resource

◆ readData()

◆ saveLoad()

◆ saveLoadCurrent()

◆ onPostRead()

virtual void Stark::Resources::Object::onPostRead ( )
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.

◆ onAllLoaded()

◆ onEnterLocation()

virtual void Stark::Resources::Object::onEnterLocation ( )
virtual

◆ onGameLoop()

◆ onEnginePause()

virtual void Stark::Resources::Object::onEnginePause ( bool  pause)
virtual

Called when ScummVM pauses or resumes the engine

Reimplemented in Stark::Resources::AnimVideo, and Stark::Resources::Sound.

◆ onExitLocation()

virtual void Stark::Resources::Object::onExitLocation ( )
virtual

Called when exiting a location

Reimplemented in Stark::Resources::ModelItem, Stark::Resources::Layer2D, and Stark::Resources::Speech.

◆ onPreDestroy()

virtual void Stark::Resources::Object::onPreDestroy ( )
virtual

Called before a resource sub-tree is unloaded.

Reimplemented in Stark::Resources::AnimSkeleton, Stark::Resources::Sound, and Stark::Resources::Speech.

◆ cast()

template<class T >
T * Stark::Resources::Object::cast ( Object resource)
static

Cast a resource, performing a type check

◆ findParent()

template<class T >
T * Stark::Resources::Object::findParent ( )

Find the first parent resource with the specified type

◆ findChildWithIndex() [1/2]

Object* Stark::Resources::Object::findChildWithIndex ( Type  type,
uint16  index,
int  subType = -1 
) const

Find a child resource matching the specified type, index and subtype

◆ findChildWithOrder() [1/2]

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

◆ findChildWithName() [1/2]

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

◆ findChild()

template<class T >
T * Stark::Resources::Object::findChild ( bool  mustBeUnique = true) const

Find a child matching the template parameter type

◆ findChildWithSubtype()

template<class T >
T * Stark::Resources::Object::findChildWithSubtype ( int  subType,
bool  mustBeUnique = true 
) const

Find a child matching the template parameter type and the specified subtype

◆ findChildWithIndex() [2/2]

template<class T >
T * Stark::Resources::Object::findChildWithIndex ( uint16  index,
int  subType = -1 
) const

Find a child matching the template parameter type and the specified index

◆ findChildWithOrder() [2/2]

template<class T >
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

◆ findChildWithName() [2/2]

template<class T >
T * Stark::Resources::Object::findChildWithName ( const Common::String name,
int  subType = -1 
) const

Find a child matching the template parameter type, name and subtype

◆ listChildren()

template<class T >
Common::Array< T * > Stark::Resources::Object::listChildren ( int  subType = -1) const

List children matching the template parameter type and the specified subtype

◆ listChildrenRecursive()

template<class T >
Common::Array< T * > Stark::Resources::Object::listChildrenRecursive ( int  subType = -1)

List children recursively matching the template parameter type and the specified subtype

◆ addChild()

void Stark::Resources::Object::addChild ( Object child)

Add a resource to the children list

◆ print()

virtual void Stark::Resources::Object::print ( uint  depth = 0)
virtual

Print debug information for the resource

Reimplemented in Stark::Resources::Script.


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