Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
BuildAssistant Class Reference

#include <BuildAssistant.h>

Inherits SubsystemInterface.

Classes

struct  TileBuildInfo
 

Public Types

enum  LocalLegalToBuildOptions {
  TERRAIN_RESTRICTIONS = 0x00000001 , CLEAR_PATH = 0x00000002 , NO_OBJECT_OVERLAP = 0X00000004 , USE_QUICK_PATHFIND = 0x00000008 ,
  SHROUD_REVEALED = 0x00000010 , NO_ENEMY_OBJECT_OVERLAP = 0x00000020 , IGNORE_STEALTHED = 0x00000040 , FAIL_STEALTHED_WITHOUT_FEEDBACK = 0x00000080
}
 

Public Member Functions

 BuildAssistant (void)
 
virtual ~BuildAssistant (void)
 
virtual void init (void)
 for subsytem
 
virtual void reset (void)
 for subsytem
 
virtual void update (void)
 for subsytem
 
void iterateFootprint (const ThingTemplate *build, Real buildOrientation, const Coord3D *worldPos, Real sampleResolution, IterateFootprintFunc func, void *funcUserData)
 iterate the "footprint" area of a structure at the given "sample resolution"
 
virtual ObjectbuildObjectNow (Object *constructorObject, const ThingTemplate *what, const Coord3D *pos, Real angle, Player *owningPlayer)
 create object from a build and put it in the world now
 
virtual void buildObjectLineNow (Object *constructorObject, const ThingTemplate *what, const Coord3D *start, const Coord3D *end, Real angle, Player *owningPlayer)
 using the "line placement" for objects (like walls etc) create that line of objects line
 
virtual LegalBuildCode isLocationLegalToBuild (const Coord3D *worldPos, const ThingTemplate *build, Real angle, UnsignedInt options, Object *builderObject, Player *player)
 query if we can build at this location
 
virtual LegalBuildCode isLocationClearOfObjects (const Coord3D *worldPos, const ThingTemplate *build, Real angle, Object *builderObject, UnsignedInt options, Player *thePlayer)
 query if we can build at this location
 
virtual void addBibs (const Coord3D *worldPos, const ThingTemplate *build)
 Adds bib highlighting for this location.
 
virtual TileBuildInfobuildTiledLocations (const ThingTemplate *thingBeingTiled, Real angle, const Coord3D *start, const Coord3D *end, Real tilingSize, Int maxTiles, Object *builderObject)
 tiling wall object helper function, we can use this to "tile" walls when building
 
virtual Coord3DgetBuildLocations (void)
 return the "scratch pad" array that can be used to create a line of build locations
 
virtual Bool isLineBuildTemplate (const ThingTemplate *tTemplate)
 is the template a line build object, like a wall
 
virtual CanMakeType canMakeUnit (Object *builder, const ThingTemplate *whatToBuild) const
 are all the requirements for making this unit satisfied
 
virtual Bool isPossibleToMakeUnit (Object *builder, const ThingTemplate *whatToBuild) const
 are all the requirements for making this unit (except available cash) are satisfied
 
virtual void sellObject (Object *obj)
 sell an object
 
void xferTheSellList (Xfer *xfer)
 
- Public Member Functions inherited from SubsystemInterface
 SubsystemInterface ()
 
virtual ~SubsystemInterface ()
 
virtual void postProcessLoad ()
 
virtual void draw (void)
 
void UPDATE (void)
 
void DRAW (void)
 
AsciiString getName (void)
 
void setName (AsciiString name)
 

Protected Member Functions

Bool isRemovableForConstruction (Object *obj)
 some objects will be "cleared" automatically when constructing
 
void clearRemovableForConstruction (const ThingTemplate *whatToBuild, const Coord3D *pos, Real angle)
 clear the area of removable objects for construction
 
Bool moveObjectsForConstruction (const ThingTemplate *whatToBuild, const Coord3D *pos, Real angle, Player *playerToBuild)
 

Protected Attributes

Coord3Dm_buildPositions
 array used to create a line of build locations (think walls)
 
Int m_buildPositionSize
 number of elements in the build position array
 
ObjectSellList m_sellList
 list of objects currently going through the "sell process"
 
- Protected Attributes inherited from SubsystemInterface
AsciiString m_name
 

Detailed Description

Definition at line 103 of file BuildAssistant.h.

Member Enumeration Documentation

◆ LocalLegalToBuildOptions

Enumerator
TERRAIN_RESTRICTIONS 

Check for basic terrain restrictions.

CLEAR_PATH 

Must be able to path find to location.

NO_OBJECT_OVERLAP 

Can't overlap enemy objects, or locally controled objects that can't move out of the way.

USE_QUICK_PATHFIND 

Use the quick pathfind method for CLEAR_PATH.

SHROUD_REVEALED 

Check to make sure the shroud is revealed.

NO_ENEMY_OBJECT_OVERLAP 

Can't overlap enemy objects only.

IGNORE_STEALTHED 

Units that we can't see are legal to "build" on. (when moving mouse around)

FAIL_STEALTHED_WITHOUT_FEEDBACK 

USE WITH IGNORE_STEALTHED except it will fail without BIB feedback (when clicking to place).

Definition at line 114 of file BuildAssistant.h.

Constructor & Destructor Documentation

◆ BuildAssistant()

BuildAssistant::BuildAssistant ( void )

Definition at line 113 of file BuildAssistant.cpp.

◆ ~BuildAssistant()

BuildAssistant::~BuildAssistant ( void )
virtual

Definition at line 123 of file BuildAssistant.cpp.

Member Function Documentation

◆ addBibs()

void BuildAssistant::addBibs ( const Coord3D * worldPos,
const ThingTemplate * build )
virtual

Adds bib highlighting for this location.

Adds bibs to structures near to worldPos

Definition at line 1073 of file BuildAssistant.cpp.

◆ buildObjectLineNow()

void BuildAssistant::buildObjectLineNow ( Object * constructorObject,
const ThingTemplate * what,
const Coord3D * start,
const Coord3D * end,
Real angle,
Player * owningPlayer )
virtual

using the "line placement" for objects (like walls etc) create that line of objects line

This method will create a line of objects end to end along the line defined in 3D space from start to end. This is especially useful in building walls

Definition at line 454 of file BuildAssistant.cpp.

◆ buildObjectNow()

Object * BuildAssistant::buildObjectNow ( Object * constructorObject,
const ThingTemplate * what,
const Coord3D * pos,
Real angle,
Player * owningPlayer )
virtual

create object from a build and put it in the world now

Nice little method to wrap up creating an object from a build

Definition at line 333 of file BuildAssistant.cpp.

◆ buildTiledLocations()

BuildAssistant::TileBuildInfo * BuildAssistant::buildTiledLocations ( const ThingTemplate * thingBeingTiled,
Real angle,
const Coord3D * start,
const Coord3D * end,
Real tilingSize,
Int maxTiles,
Object * builderObject )
virtual

tiling wall object helper function, we can use this to "tile" walls when building

Tiling wall object helper function, we can use this to "tile" walls when building. This function will fill out the ARRAY world positions named 'positions' starting at the 'start' point in the world and going to the 'end' point in the world. No more than 'maxTiles' will be considered and if the position of any one of the objects in the chain is illegal the chain stops there. The number of objects actually used for the tiling is returned along with a pointer to the array of positions in the tile build info.

REQUIRES: Note that the array at 'postions' must be large enough to hold 'maxTiles' entries of positions

Definition at line 1114 of file BuildAssistant.cpp.

◆ canMakeUnit()

CanMakeType BuildAssistant::canMakeUnit ( Object * builder,
const ThingTemplate * whatToBuild ) const
virtual

are all the requirements for making this unit satisfied

This method will check to make sure it is possible to build the requested unit. and that the player has enough money for 'whatToBuild'

Definition at line 1303 of file BuildAssistant.cpp.

◆ clearRemovableForConstruction()

void BuildAssistant::clearRemovableForConstruction ( const ThingTemplate * whatToBuild,
const Coord3D * pos,
Real angle )
protected

clear the area of removable objects for construction

Given that we are about to build 'whatToBuild' remove all the objects that are in the 'footprint' of where the build will take place that can be auto-removed for construction

Definition at line 1389 of file BuildAssistant.cpp.

◆ getBuildLocations()

virtual Coord3D * BuildAssistant::getBuildLocations ( void )
inlinevirtual

return the "scratch pad" array that can be used to create a line of build locations

Definition at line 180 of file BuildAssistant.h.

◆ init()

void BuildAssistant::init ( void )
virtual

for subsytem

Implements SubsystemInterface.

Definition at line 140 of file BuildAssistant.cpp.

◆ isLineBuildTemplate()

Bool BuildAssistant::isLineBuildTemplate ( const ThingTemplate * tTemplate)
virtual

is the template a line build object, like a wall

Is the template passed in one of those wall type structures that we "build" in the world after drawing a line of where we want the object(s) placed. The objects are placed "tiled" in a line

Definition at line 1224 of file BuildAssistant.cpp.

◆ isLocationClearOfObjects()

LegalBuildCode BuildAssistant::isLocationClearOfObjects ( const Coord3D * worldPos,
const ThingTemplate * build,
Real angle,
Object * builderObject,
UnsignedInt options,
Player * thePlayer )
virtual

query if we can build at this location

Check for objects preventing building at this location.

Definition at line 666 of file BuildAssistant.cpp.

◆ isLocationLegalToBuild()

LegalBuildCode BuildAssistant::isLocationLegalToBuild ( const Coord3D * worldPos,
const ThingTemplate * build,
Real angle,
UnsignedInt options,
Object * builderObject,
Player * player )
virtual

query if we can build at this location

Query if we can build at this location. Note that 'build' may be null and is NOT required to be valid to know if a location is legal to build at. 'builderObject' is used for queries that require a pathfind check and should be NULL if not required

todo remove this if we need to change the semantics of this function of the builderObject actually being able to get to the destination

Definition at line 908 of file BuildAssistant.cpp.

◆ isPossibleToMakeUnit()

Bool BuildAssistant::isPossibleToMakeUnit ( Object * builder,
const ThingTemplate * whatToBuild ) const
virtual

are all the requirements for making this unit (except available cash) are satisfied

This method will check to make sure it is possible to build the requested unit. The builder object MUST be present since all construction comes comes from either a Dozer or a production building. The player must have satisfied the prereqs for 'whatToBuild' This does NOT check available money (see canMakeUnit)

Definition at line 1243 of file BuildAssistant.cpp.

◆ isRemovableForConstruction()

Bool BuildAssistant::isRemovableForConstruction ( Object * obj)
protected

some objects will be "cleared" automatically when constructing

Some objects will be automatically removed when something is built on them so they aren't considered as obstacles when placing them

Definition at line 1355 of file BuildAssistant.cpp.

◆ iterateFootprint()

void BuildAssistant::iterateFootprint ( const ThingTemplate * build,
Real buildOrientation,
const Coord3D * worldPos,
Real sampleResolution,
IterateFootprintFunc func,
void * funcUserData )

iterate the "footprint" area of a structure at the given "sample resolution"

This function will call the user callback at each "sample point" across the footprint of where this object would be in the world. The smaller the sample resolution param is the more samples will be taken across the footprint area

Definition at line 554 of file BuildAssistant.cpp.

◆ moveObjectsForConstruction()

Bool BuildAssistant::moveObjectsForConstruction ( const ThingTemplate * whatToBuild,
const Coord3D * pos,
Real angle,
Player * playerToBuild )
protected

will move objects that can move out of the way. will return false if there are objects that cannot be moved out of the way.

clearRemovable is set up to delete objects that should cease to exist (for instance, trees). moveObjects will move objects that are owned by the player. It will also return false if the association with the object is enemy. (We can move neutral things)

Definition at line 1416 of file BuildAssistant.cpp.

◆ reset()

void BuildAssistant::reset ( void )
virtual

for subsytem

Implements SubsystemInterface.

Definition at line 154 of file BuildAssistant.cpp.

◆ sellObject()

void BuildAssistant::sellObject ( Object * obj)
virtual

sell an object

Start the process for selling the object in question

Definition at line 1499 of file BuildAssistant.cpp.

◆ update()

void BuildAssistant::update ( void )
virtual

for subsytem

Update phase for the build assistant

Implements SubsystemInterface.

Definition at line 181 of file BuildAssistant.cpp.

◆ xferTheSellList()

void BuildAssistant::xferTheSellList ( Xfer * xfer)

Xfer the sell list.

Definition at line 295 of file BuildAssistant.cpp.

Member Data Documentation

◆ m_buildPositions

Coord3D* BuildAssistant::m_buildPositions
protected

array used to create a line of build locations (think walls)

Definition at line 210 of file BuildAssistant.h.

◆ m_buildPositionSize

Int BuildAssistant::m_buildPositionSize
protected

number of elements in the build position array

Definition at line 211 of file BuildAssistant.h.

◆ m_sellList

ObjectSellList BuildAssistant::m_sellList
protected

list of objects currently going through the "sell process"

Definition at line 212 of file BuildAssistant.h.


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