123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- //---------------------------------------------------------------------------
- //
- // terrobj.h -- File contains the Terrain Object Definition
- //
- // MechCommander 2
- //
- //---------------------------------------------------------------------------//
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- //===========================================================================//
- #ifndef TERROBJ_H
- #define TERROBJ_H
- #ifndef DTERROBJ_H
- #include "dterrobj.h"
- #endif
- #ifndef OBJTYPE_H
- #include "objtype.h"
- #endif
- #ifndef GAMEOBJ_H
- #include "gameobj.h"
- #endif
- #ifndef DCARNAGE_H
- #include "dcarnage.h"
- #endif
- #include <gosFX\gosfxheaders.hpp>
- //---------------------------------------------------------------------------
- // Macro Definitions
- //#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
- //---------------------------------------------------------------------------
- typedef enum {
- TERROBJ_NONE,
- TERROBJ_TREE,
- TERROBJ_BRIDGE,
- TERROBJ_FOREST,
- TERROBJ_WALL_HEAVY,
- TERROBJ_WALL_MEDIUM,
- TERROBJ_WALL_LIGHT,
- NUM_TERROBJ_SUBTYPES
- } TerrainObjectSubType;
- class TerrainObjectType : public ObjectType {
- public:
- char subType;
- float damageLevel;
- long collisionOffsetX;
- long collisionOffsetY;
- bool setImpassable;
- long xImpasse;
- long yImpasse;
- float explDmg;
- float explRad;
- unsigned long fireTypeHandle;
-
- public:
- void init (void);
-
- TerrainObjectType (void) {
- ObjectType::init();
- init();
- }
-
- virtual void initMiscTerrObj (long objTypeNum);
- virtual long init (FilePtr objFile, unsigned long fileSize);
- long init (FitIniFilePtr objFile);
-
- ~TerrainObjectType (void) {
- destroy();
- }
- float getDamageLevel (void) {
- return(damageLevel);
- }
-
- virtual void destroy (void);
-
- virtual GameObjectPtr createInstance (void);
- virtual float getBurnDmg (void) {
- return(0.0);
- }
- virtual float getBurnTime (void) {
- return(0.0);
- }
-
- virtual bool handleCollision (GameObjectPtr collidee, GameObjectPtr collider);
- virtual bool handleDestruction (GameObjectPtr collidee, GameObjectPtr collider);
- };
- //---------------------------------------------------------------------------
- typedef struct _TerrainObjectData : public GameObjectData
- {
- float damage;
- long vertexNumber;
- long blockNumber;
- float pitchAngle;
- float fallRate;
- GameObjectWatchID powerSupply;
- short cellFootprint[4];
- Stuff::Vector3D vectorFootprint[4];
- short numSubAreas0;
- short numSubAreas1;
- short subAreas0[MAX_SPECIAL_SUB_AREAS];
- short subAreas1[MAX_SPECIAL_SUB_AREAS];
- unsigned char listID;
- unsigned char numCellsCovered;
- short cellsCovered[81];
- } TerrainObjectData;
- #define MAXLEN_TERRAINOBJECT_NAME 35
- class TerrainObject : public GameObject {
- public:
- float damage;
- long vertexNumber;
- long blockNumber;
- float pitchAngle;
- float fallRate;
- GameObjectWatchID powerSupply;
- short cellFootprint[4];
- Stuff::Vector3D vectorFootprint[4];
- short numSubAreas0;
- short numSubAreas1;
- short *subAreas0;
- short *subAreas1;
- unsigned char listID;
-
- unsigned char numCellsCovered;
- short* cellsCovered;
- gosFX::Effect *bldgDustPoofEffect;
-
- static long cellArray[9];
- public:
- virtual void init (bool create) {
- objectClass = TERRAINOBJECT;
- setFlag(OBJECT_FLAG_JUSTCREATED, true);
- appearance = NULL;
- vertexNumber = 0;
- blockNumber = 0;
- damage = 0.0;
- pitchAngle = 0.0f;
- fallRate = 0.0f;
- powerSupply = NULL;
- cellFootprint[0] = -1;
- cellFootprint[1] = -1;
- cellFootprint[2] = -1;
- cellFootprint[3] = -1;
- numSubAreas0 = 0;
- numSubAreas1 = 0;
- subAreas0 = NULL;
- subAreas1 = NULL;
- listID = 255;
- numCellsCovered = 0;
- cellsCovered = NULL;
- bldgDustPoofEffect = NULL;
- }
- TerrainObject (void) : GameObject() {
- init(true);
- }
- ~TerrainObject (void) {
- destroy();
- }
- virtual void updateDebugWindow (GameDebugWindow* debugWindow);
- virtual char* getName (void);
- virtual void killFire (void);
-
- void lightOnFire (float timeToBurn);
-
- virtual void destroy (void);
-
- virtual long update (void);
- virtual void render (void);
- virtual void renderShadows (void);
-
- virtual void init (bool create, ObjectTypePtr objType);
- virtual long handleWeaponHit (WeaponShotInfoPtr shotInfo, bool addMultiplayChunk = false);
- virtual void setTerrainPosition (const Stuff::Vector3D& position, const Stuff::Vector2DOf<long>& numbers);
- virtual void setDamage (long newDamage); //Damage encodes which groundtile to use, too.
- virtual void setRotation( float rot );
-
- virtual float getDamage (void)
- {
- return(damage);
- }
- virtual float getDamageLevel (void)
- {
- return ((TerrainObjectTypePtr)getObjectType())->getDamageLevel();
- }
- virtual float getDestructLevel (void)
- {
- return (getDamageLevel() - damage);
- }
- virtual float getStatusRating (void);
- long getSubType (void) {
- return(((TerrainObjectTypePtr)getObjectType())->subType);
- }
- virtual long kill (void) {
- //Do nothing for now. Later, Buildings may do something.
- return NO_ERR;
- }
-
- bool isVisible (void);
- virtual long getLineOfSightNodes (long eyeCellRow, long eyeCellCol, long* cells);
-
- virtual bool isTerrainObject (void) {
- return(true);
- }
- virtual void getBlockAndVertexNumber (long& blockNum, long& vertexNum) {
- blockNum = blockNumber;
- vertexNum = vertexNumber;
- }
-
- virtual void rotate (float yaw, float pitch);
-
- virtual float getAppearRadius (void)
- {
- return appearance->getRadius();
- }
-
- virtual void setPowerSupply (GameObjectPtr power)
- {
- powerSupply = power->getWatchID();
- }
- virtual void calcCellFootprint (Stuff::Vector3D& pos);
- virtual bool calcAdjacentAreaCell (long moveLevel, long areaID, long& adjRow, long& adjCol);
- void calcSubAreas (long numCells, short cells[MAX_GAME_OBJECT_CELLS][2]);
- void markMoveMap (bool passable);
- void openSubAreas (void);
- void closeSubAreas (void);
- void setSubAreasTeamId (long id);
- virtual void Save (PacketFilePtr file, long packetNum);
- void Load (TerrainObjectData *data);
- void CopyTo (TerrainObjectData *data);
- 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.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;
- return(hsPos);
- }
- };
- //---------------------------------------------------------------------------
- #endif
|