GameBaseData Struct Reference

#include <gameBase.h>

Inheritance diagram for GameBaseData:

Inheritance graph
[legend]
List of all members.

Detailed Description

Scriptable, demo-able datablock.

This variant of SimDataBlock performs these additional tasks:

  • Linking datablock's namepsaces to the namespace of their C++ class, so that datablocks can expose script functionality.
  • Linking datablocks to a user defined scripting namespace, by setting the 'class' field at datablock definition time.
  • Adds a category field; this is used by the world creator in the editor to classify creatable shapes. Creatable shapes are placed under the Shapes node in the treeview for this; additional levels are created, named after the category fields.
  • Adds support for demo stream recording. This support takes the form of the member variable packed. When a demo is being recorded by a client, data is unpacked, then packed again to the data stream, then, in the case of datablocks, preload() is called to process the data. It is occasionally the case that certain references in the datablock stream cannot be resolved until preload is called, in which case a raw ID field is stored in the variable which will eventually be used to store a pointer to the object. However, if packData() is called before we resolve this ID, trying to call getID() on the objecct ID would be a fatal error. Therefore, in these cases, we test packed; if it is true, then we know we have to write the raw data, instead of trying to resolve an ID.

See also:
SimDataBlock for further details about datablocks.

http://hosted.tribalwar.com/t2faq/datablocks.shtml for an excellent explanation of the basics of datablocks from a scripting perspective.


Public Member Functions

bool onAdd ()
 Called when the object is added to the sim.
 DECLARE_CONOBJECT (GameBaseData)
 GameBaseData ()
bool preload (bool server, String &errorStr)
 Called to prepare the datablock for use, after it has been unpacked.
void unpackData (BitStream *stream)

Static Public Member Functions

static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.

Public Attributes

bool packed
StringTableEntry category

Private Types

typedef SimDataBlock Parent


Member Typedef Documentation


Constructor & Destructor Documentation

GameBaseData::GameBaseData (  ) 


Member Function Documentation

bool GameBaseData::onAdd (  )  [virtual]

GameBaseData::DECLARE_CONOBJECT ( GameBaseData   ) 

bool GameBaseData::preload ( bool  server,
String errorStr 
) [virtual]

Called to prepare the datablock for use, after it has been unpacked.

Parameters:
server Set if we're running on the server (and therefore don't need to load things like textures or sounds).
errorStr If an error occurs in loading, this is set to a short string describing the error.
Returns:
True if all went well; false if something failed.
See also:
preload() and File Downloading

Reimplemented from SimDataBlock.

Reimplemented in PathedInteriorData, DecalData, DebrisData, ExplosionData, LightningData, ParticleEmitterData, ParticleEmitterNodeData, SplashData, PlayerData, ProjectileData, RigidShapeData, ShapeBaseImageData, ShapeBaseData, FlyingVehicleData, HoverVehicleData, VehicleData, and WheeledVehicleData.


Member Data Documentation