123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- //---------------------------------------------------------------------------
- //
- // bldng.h -- File contains the Building Object Class
- //
- // MechCommander 2
- //
- //---------------------------------------------------------------------------//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #ifndef BLDNG_H
- #define BLDNG_H
- #ifndef DBLDNG_H
- #include "dbldng.h"
- #endif
- #ifndef TERROBJ_H
- #include "terrobj.h"
- #endif
- #ifndef GAMEOBJ_H
- #include "gameobj.h"
- #endif
- #ifndef OBJTYPE_H
- #include "objtype.h"
- #endif
- #ifndef DWARRIOR_H
- #include "dwarrior.h"
- #endif
- //---------------------------------------------------------------------------
- #define NO_RAM_FOR_BUILDING 0xDCDC0006
- #define NO_APPEARANCE_TYPE_FOR_BLD 0xDCDC0007
- #define NO_APPEARANCE_FOR_BLD 0xDCDC0008
- #define APPEARANCE_NOT_VFX_APPEAR 0xDCDC0009
- #define MAX_PRISONERS 4
- typedef enum {
- BUILDING_SUBTYPE_NONE,
- BUILDING_SUBTYPE_WALL,
- BUILDING_SUBTYPE_LANDBRIDGE,
- NUM_BUILDING_SUBTYPES
- } BuildingSubType;
- //---------------------------------------------------------------------------
- class BuildingType : public ObjectType {
- public:
- float damageLevel;
- float sensorRange;
- long teamId;
- float baseTonnage;
- float explDmg;
- float explRad;
- long buildingTypeName;
- long buildingDescriptionID;
- long startBR;
- long numMarines;
- long resourcePoints;
- bool marksImpassableWhenDestroyed;
- bool canRefit;
- bool mechBay; // otherwise it's a vehicle bay.
- bool capturable;
- bool powerSource;
- float perimeterAlarmRange;
- float perimeterAlarmTimer;
- float lookoutTowerRange;
-
- unsigned long activityEffectId;
-
- public:
- void init (void);
-
- BuildingType (void) {
- ObjectType::init();
- init();
- }
-
- virtual long init (FilePtr objFile, unsigned long fileSize);
- long init (FitIniFilePtr objFile);
-
- ~BuildingType (void) {
- destroy();
- }
- float getDamageLevel (void) {
- return(damageLevel);
- }
-
- virtual void destroy (void);
-
- virtual GameObjectPtr createInstance (void);
- virtual bool handleCollision (GameObjectPtr collidee, GameObjectPtr collider);
- virtual bool handleDestruction (GameObjectPtr collidee, GameObjectPtr collider);
- };
- //---------------------------------------------------------------------------
- typedef struct _BuildingData : public TerrainObjectData
- {
- char teamId;
- unsigned char baseTileId;
- char commanderId;
- GameObjectWatchID refitBuddyWID;
- DWORD parentId;
- GameObjectWatchID parent;
- unsigned char listID;
- float captureTime;
- //PerimeterAlarms
- bool moverInProximity;
- float proximityTimer;
- long updatedTurn;
- } BuildingData;
- class Building : public TerrainObject
- {
- public:
-
- char teamId;
- unsigned char baseTileId;
- SensorSystemPtr sensorSystem;
- char commanderId; //If capturable, who last captured it...
- GameObjectWatchID refitBuddyWID;
- DWORD parentId;
- GameObjectWatchID parent;
- unsigned char listID;
- float captureTime;
- float scoreTime;
- //PerimeterAlarms
- bool moverInProximity;
- float proximityTimer;
- long updatedTurn;
- public:
- virtual void init (bool create) {
- sensorSystem = NULL;
- setFlag(OBJECT_FLAG_JUSTCREATED, true);
- appearance = NULL;
- vertexNumber = 0;
- blockNumber = 0;
- baseTileId = 0;
- commanderId = -1;
- teamId = -1;
- refitBuddyWID = 0;
- parentId = 0xffffffff;
- parent = NULL;
- powerSupply = NULL;
- numSubAreas0 = 0;
- numSubAreas1 = 0;
- subAreas0 = NULL;
- subAreas1 = NULL;
- listID = 255;
- captureTime = 0.0;
- scoreTime = 0.0;
- moverInProximity = false;
- proximityTimer = 0.0f;
- updatedTurn = -1;
- }
- Building (void) : TerrainObject() {
- init(true);
- }
- ~Building (void) {
- destroy();
- }
-
- virtual void destroy (void);
-
- virtual long update (void);
- virtual void render (void);
-
- virtual void init (bool create, ObjectTypePtr objType);
- virtual void setSensorRange (float range);
- void setSensorData (TeamPtr team, float range = -1.0, bool setTeam = true);
- virtual long setTeamId (long _teamId, bool setup);
-
- virtual long getTeamId (void) {
- return(teamId);
- }
- virtual long getDescription(){ return ((BuildingType*)getObjectType())->buildingDescriptionID; }
- virtual TeamPtr getTeam (void);
- virtual bool isFriendly (TeamPtr team);
- virtual bool isEnemy (TeamPtr team);
- virtual bool isNeutral (TeamPtr team);
- void lightOnFire (float timeToBurn);
- long updateAnimations (void);
-
- virtual long handleWeaponHit (WeaponShotInfoPtr shotInfo, bool addMultiplayChunk = false);
- virtual void setDamage (float newDamage); //Damage encodes which groundtile to use, too.
-
- virtual long kill (void) {
- return(NO_ERR);
- }
- virtual char* getName (void);
- virtual Stuff::Vector3D getPositionFromHS (long weaponType)
- {
- //-----------------------------------------
- // Hotspot for buildings is position plus
- // some Z based on OBB to make Effect visible.
- // If this doesn't work, replace with art defined site.
- Stuff::Vector3D hsPos = position;
- if (appearance)
- {
- hsPos = appearance->getHitNode();
- if (hsPos == position)
- {
- hsPos.z += appearance->getTopZ() * 0.5f;
- }
- }
- return(hsPos);
- }
- virtual Stuff::Vector3D getLOSPosition (void)
- {
- //-----------------------------------------
- // Hotspot for buildings is position plus
- // some Z based on OBB to make Effect visible.
- //
- // Use THIS position for LOS Calc!!!
- Stuff::Vector3D hsPos = position;
- if (appearance)
- hsPos.z += appearance->getTopZ() * 0.5f;
- BuildingTypePtr bldgType = ((BuildingTypePtr)getObjectType());
- if ((bldgType->lookoutTowerRange > 0.0f) ||
- (bldgType->sensorRange > 0.0f))
- {
- hsPos.z = position.z + 75.0f;
- }
- return(hsPos);
- }
- virtual float getDestructLevel (void)
- {
- return (getDamageLevel() - damage);
- }
- virtual void setRefitBuddy (GameObjectWatchID objWID) {
- refitBuddyWID = objWID;
- }
- virtual void openFootPrint (void);
- virtual void closeFootPrint (void);
- bool isVisible (void);
- virtual bool isCaptureable (long capturingTeamID);
- virtual void setCommanderId (long _commanderId);
- virtual long getCommanderId (void) {
- return(commanderId);
- }
- virtual float getDamageLevel (void);
- virtual void getBlockAndVertexNumber (long& blockNum, long& vertexNum) {
- blockNum = blockNumber;
- vertexNum = vertexNumber;
- }
- virtual bool isBuilding(void) {
- return(true);
- }
- virtual bool isTerrainObject (void) {
- return(true);
- }
-
- void createBuildingMarines (void);
- virtual bool isLinked (void);
- virtual GameObjectPtr getParent (void);
- virtual void setParentId (DWORD pId);
- virtual SensorSystem* getSensorSystem(){ return sensorSystem; }
-
- virtual float getAppearRadius (void)
- {
- return appearance->getRadius();
- }
- virtual bool canBeCaptured (void)
- {
- return ((BuildingTypePtr)getObjectType())->capturable;
- }
- virtual bool isSelectable()
- {
- return appearance->isSelectable();
- }
- virtual bool isPowerSource(void)
- {
- return ((BuildingTypePtr)getObjectType())->powerSource;
- }
-
- virtual bool isLit (void)
- {
- if (appearance)
- return appearance->getIsLit();
-
- return false;
- }
-
- virtual bool isSpecialBuilding(void)
- {
- BuildingTypePtr bldgType = ((BuildingTypePtr)getObjectType());
- // if ((bldgType->getObjTypeNum() == GENERIC_HQ_BUILDING_OBJNUM) ||
- // (bldgType->getObjTypeNum() == GENERIC_DESTRUCTIBLE_RESOURCE_BUILDING_OBJNUM) ||
- // (bldgType->getObjTypeNum() == GENERIC_INDESTRUCTIBLE_RESOURCE_BUILDING_OBJNUM))
- // return(true);
- if ((bldgType->perimeterAlarmRange > 0.0f) &&
- (bldgType->perimeterAlarmTimer > 0.0f) ||
- (bldgType->lookoutTowerRange > 0.0f) ||
- (bldgType->sensorRange > 0.0f))
- {
- return true;
- }
-
- return false;
- }
-
- virtual bool isLookoutTower (void)
- {
- BuildingTypePtr bldgType = ((BuildingTypePtr)getObjectType());
- if (bldgType->lookoutTowerRange > 0.0f)
- {
- return true;
- }
-
- return false;
- }
-
- virtual float getRefitPoints(void)
- {
- return getDamageLevel() - getDamage();
- }
- virtual bool burnRefitPoints(float pointsToBurn);
- virtual void Save (PacketFilePtr file, long packetNum);
- void Load (BuildingData *data);
- void CopyTo (BuildingData *data);
- };
- #endif
- //***************************************************************************
|