Main Page Modules Namespaces C++ Classes Compound List File List Index
TNL: TNLTest::Building Class Reference

# TNLTest::Building Class Reference

`#include <testGame.h>`

Inheritance diagram for TNLTest::Building:

## Detailed Description

The Building class is an example of a NetObject that is ScopeAlways.

ScopeAlways objects are transmitted to all clients that are currently ghosting, regardless of whether or not the scope object calls GhostConnection::objectInScope for them or not. The "buildings" are represented by red rectangles on the playing field, and are constructed with random position and extents.

## Public Types

enum | MaskBits { InitialMask = (1 << 0) }
| Mask bits used to determine what states are out of date for this object and what then represent. More...

## Public Member Functions

| Building ()
| The Building constructor creates a random position and extent for the building, and marks it as scopeAlways.
| ~Building ()
| The Building destructor removes the Building from the game, if it is associated with a game object.
bool | onGhostAdd (TNL::GhostConnection *theConnection)
| Called on the client when this Building object has been ghosted to the client and its first unpackUpdate has been called.
void | addToGame (TestGame *game)
| addToGame is a helper function called by onGhostAdd and on the server to add the building to the specified game.
TNL::U32 | packUpdate (TNL::GhostConnection *connection, TNL::U32 updateMask, TNL::BitStream *stream)
| packUpdate is called on the server Building object to update any out-of-date network state information to the client.
void | unpackUpdate (TNL::GhostConnection *connection, TNL::BitStream *stream)
| Reads the update information about the building from the specified packet BitStream.
| TNL_DECLARE_CLASS (Building)
| This macro declares Building to be a part of the TNL network class management system.

## Data Fields

TestGame * | game
| The game object this building is associated with.
Position | upperLeft
| Upper left corner of the building rectangle on the screen.
Position | lowerRight
| Lower right corner of the building rectangle on the screen.

## Private Types

typedef TNL::NetObject | Parent

## Member Typedef Documentation

typedef TNL::NetObject TNLTest::Building::Parent`[private]`

Reimplemented from TNL::NetObject.

## Member Enumeration Documentation

enum TNLTest::Building::MaskBits

Mask bits used to determine what states are out of date for this object and what then represent.

Enumerator:

  InitialMask | Building's only mask bit is the initial mask, as no other states are ever set.

## Constructor & Destructor Documentation

TNLTest::Building::Building | ( |  | ) |

The Building constructor creates a random position and extent for the building, and marks it as scopeAlways.

TNLTest::Building::~Building | ( |  | ) |

The Building destructor removes the Building from the game, if it is associated with a game object.

## Member Function Documentation

bool TNLTest::Building::onGhostAdd | ( | TNL::GhostConnection * | theConnection | ) | `[virtual]`

Called on the client when this Building object has been ghosted to the client and its first unpackUpdate has been called.

onGhostAdd adds the building to the client game.

Reimplemented from TNL::NetObject.

void TNLTest::Building::addToGame | ( | TestGame * | game | ) |

addToGame is a helper function called by onGhostAdd and on the server to add the building to the specified game.

TNL::U32 TNLTest::Building::packUpdate | ( | TNL::GhostConnection * | connection,
|  | TNL::U32 | updateMask,
|  | TNL::BitStream * | stream |
| ) |  |  | `[virtual]`

packUpdate is called on the server Building object to update any out-of-date network state information to the client.

Since the Building object only declares an initial mask bit state and never calls setMaskBits, this method will only be invoked when the ghost is being created on the client.

Reimplemented from TNL::NetObject.

void TNLTest::Building::unpackUpdate | ( | TNL::GhostConnection * | connection,
|  | TNL::BitStream * | stream |
| ) |  |  | `[virtual]`

Reads the update information about the building from the specified packet BitStream.

Reimplemented from TNL::NetObject.

TNLTest::Building::TNL_DECLARE_CLASS | ( | Building |  | ) |

This macro declares Building to be a part of the TNL network class management system.

## Field Documentation

TestGame* TNLTest::Building::game

The game object this building is associated with.

Position TNLTest::Building::upperLeft

Upper left corner of the building rectangle on the screen.

Position TNLTest::Building::lowerRight

Lower right corner of the building rectangle on the screen.