buildings.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           buildings.h  -  description
00003                              -------------------
00004     begin                : Sat Feb 17 2001
00005     copyright            : (C) 2001 by Martin Bickel
00006     email                : bickel@asc-hq.org
00007  ***************************************************************************/
00008 
00013 /***************************************************************************
00014  *                                                                         *
00015  *   This program is free software; you can redistribute it and/or modify  *
00016  *   it under the terms of the GNU General Public License as published by  *
00017  *   the Free Software Foundation; either version 2 of the License, or     *
00018  *   (at your option) any later version.                                   *
00019  *                                                                         *
00020  ***************************************************************************/
00021 
00022 #ifndef buildingsH
00023  #define buildingsH
00024 
00025  #include "typen.h"
00026  #include "containerbase.h"
00027  #include "ascstring.h"
00028  #include "buildingtype.h"
00029  #include "mapalgorithms.h"
00030 
00031 class MapField;
00032 
00038 class  Building : public ContainerBase {
00039     MapCoordinate entryPosition;
00040 
00041     char         _completion;
00042 
00043     friend class tprocessminingfields;
00044     
00045     bool viewOnMap;
00046     
00047    public:
00048     const BuildingType* typ;
00049     
00050     const BuildingType* getType() const { return typ; };
00051     
00052 
00054     int         ammo[waffenanzahl];
00055 
00057     int          netcontrol;
00058 
00060     int          connection;
00061 
00063     bool         visible;
00064 
00065 
00066     AiValue*      aiparam[8];
00067 
00068     Building( GameMap* map, const MapCoordinate& entryPosition, const BuildingType* type , int player, bool setupImages = true, bool chainToField = true);
00069 
00070     int lastmineddist;
00071 
00072     bool canRepair ( const ContainerBase* item ) const;
00073 
00074     static Building* newFromStream ( GameMap* gamemap, tnstream& stream, bool chainToField = true );
00075     void write ( tnstream& stream, bool includeLoadedUnits = true ) const;
00076     void read ( tnstream& stream );
00077   private:
00078     void readData ( tnstream& stream, int version );
00079   public:
00080  
00082     void execnetcontrol ( void );
00083     // int  getmininginfo ( int res );
00084 
00085     int  putResource ( int amount,    int resourcetype, bool queryonly, int scope = 1, int player = -1 );
00086     int  getResource ( int amount,    int resourcetype, bool queryonly, int scope = 1, int player = -1 );
00087     int  getAvailableResource ( int amount,    int resourcetype, int scope = 1 ) const;
00088     Resources putResource ( const Resources& res, bool queryonly, int scope = 1, int player = -1 ) { return ContainerBase::putResource ( res, queryonly, scope, player ); };
00089     Resources getResource ( const Resources& res, bool queryonly, int scope = 1, int player = -1 ) { return ContainerBase::getResource ( res, queryonly, scope, player ); };
00090 
00091 
00093     Resources   actstorage;
00094     
00095     int getIdentification() const;
00096 
00097 
00099     const Surface& getPicture ( const BuildingType::LocalCoordinate& localCoordinate ) const;
00100 
00101     void paintSingleField ( Surface& s, SPoint imgpos, BuildingType::LocalCoordinate pos ) const;
00102 
00103     virtual Surface getImage() const;
00104 
00105 
00106     bool isBuilding() const { return true; };
00107     
00108     
00110     void convert ( int player, bool recursive = true );
00111 
00113     void registerForNewOwner( int player );
00114 
00115     
00117     void addview();
00118     
00120     void resetview();
00121 
00123     void removeview();
00124 
00127     bool isViewing ( ) const { return viewOnMap; };
00128     
00129     
00131     int  getArmor() const;
00132 
00134     MapField* getEntryField() const;
00135 
00137     MapCoordinate3D getEntry ( ) const;
00138 
00140     MapField* getField( const BuildingType::LocalCoordinate& localCoordinates ) const;
00141     
00143     MapCoordinate getFieldCoordinates( const BuildingType::LocalCoordinate& localCoordinates ) const;
00144 
00145     
00147     BuildingType::LocalCoordinate getLocalCoordinate( const MapCoordinate& field ) const;
00148     
00150     MapCoordinate3D getPosition ( ) const { return getEntry(); };
00151 
00153     MapCoordinate3D getPosition3D( ) const;
00154 
00156     int  chainbuildingtofield ( const MapCoordinate& entryPos, bool setupImages = true );
00157 
00159     int  unchainbuildingfromfield ( void );
00160 
00162     int getCompletion() const { return _completion; };
00163 
00169     void setCompletion ( int completion, bool setupImages = true  );
00170 
00172     void endRound( void );
00173 
00175     ASCString getName() const;
00176 
00177     
00178     int getAmmo( int type, int num, bool queryOnly );
00179     int getAmmo( int type, int num ) const;
00180     int putAmmo( int type, int num, bool queryOnly );
00181     int maxAmmo( int type ) const { return maxint; };
00182 
00183 
00185     int getHeight() const { return typ->height; };
00186     
00187     
00188     ~Building();
00189 
00190     virtual int repairableDamage() const;
00191 
00192      int getMemoryFootprint() const;
00193 
00194   protected:
00195      ResourceMatrix repairEfficiency;
00196      const ResourceMatrix& getRepairEfficiency() const { return repairEfficiency; };
00197      virtual void postRepair ( int oldDamage );
00198      vector<MapCoordinate> getCoveredFields();
00199 };
00200 
00201 
00202 extern void doresearch ( GameMap* actmap, int player );
00203 extern ASCString getBuildingReference ( Building* bld );
00204 
00205 #endif

Generated on Mon May 21 01:26:29 2012 for Advanced Strategic Command by  doxygen 1.5.1