Advanced Strategic Command
objecttype.h
Go to the documentation of this file.
1 /***************************************************************************
2  objecttype.h - description
3  -------------------
4  begin : Fri Jul 27 2001
5  copyright : (C) 2001 by Martin Bickel
6  email : bickel@asc-hq.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef objecttypeH
19  #define objecttypeH
20 
21  #include "typen.h"
22  #include "terraintype.h"
23  #include "research.h"
24  #include "overviewmapimage.h"
25  #include "mapitemtype.h"
26  #include "mapfield.h"
27 
28 
30  class ObjectType : public MapItemType, public LoadableItemType {
31  bool rotateImage;
32  void realDisplay ( Surface& surface, const SPoint& pos, int dir, int weather ) const;
33  public:
35  int id;
36 
38  vector<int> secondaryIDs;
39 
41  int groupID;
42 
45 
47  bool visibleago;
48 
50  vector<IntRange> linkableObjects;
51 
53  vector<IntRange> linkableTerrain;
54 
56  int armor;
57 
60 
63 
66 
69 
73  void runTextIO ( PropertyContainer& pc );
75 
76  const FieldModification& getFieldModification( int weather ) const;
77 
82 
87 
92 
97 
98 
99 
102 
105 
108 
111 
114 
117 
120 
123 
124  ASCString getName() const { return name; };
125 
128  static const char* namingMethodNames[];
129  static const int namingMethodNum;
130 
131  int getID() const { return id; };
132 
133 
134  static const int netBehaviourNum = 7;
136 
139 
140  ObjectType ( void );
141 
143 
144  const OverviewMapImage* getOverviewMapImage( int picnum, int weather ) const ;
145 
147  struct WeatherPicture {
148  mutable vector<OverviewMapImage> overviewMapImage;
149  vector<Surface> images;
150  vector<int> bi3pic;
151  vector<int> flip;
152  void resize(int i) { flip.resize(i); bi3pic.resize(i); images.resize(i); };
155 
157  void display ( Surface& surface, const SPoint& pos ) const ;
158  void display ( Surface& surface, const SPoint& pos, int dir, int weather = 0 ) const;
159 
161  const Surface& getPicture ( int i = 0, int weather = 0 ) const;
162 
164  bool buildable ( MapField* fld ) const;
165 
167  void read ( tnstream& stream );
169  void write ( tnstream& stream ) const;
170 
172  void runTextIO ( PropertyContainer& pc );
173 
176 
178  int getEffectiveHeight() const;
179 
181  double growthRate;
182 
185 
187  int lifetime;
188 
192 
193 
194  int getMemoryFootprint() const;
195  protected:
196  int getWeather( int weather ) const;
197 
198  private:
200  void setupImages();
201  };
202 
203 
204 
206 
207 namespace ForestCalculation {
209  extern void smooth ( int what, GameMap* gamemap, ObjectType* woodObj );
210 };
211 
212 
213 #endif
int viewbonus_plus
units standing on this object will get a bonus to their view
Definition: objecttype.h:94
TerrainType::MoveMalus movemalus_abs
The movemalus_abs replaces the current movemalus of the field by a new one. Values of 0 and -1 won't ...
Definition: objecttype.h:65
int getMemoryFootprint() const
Definition: objecttype.cpp:828
void runTextIO(PropertyContainer &pc)
int displayMethod
some objects require special displaying methods, for example shading the terrain they are build on ...
Definition: objecttype.h:175
ASCString getName() const
Definition: objecttype.h:124
int id
the id of the object, used when referencing objects in files
Definition: objecttype.h:35
const int objectDisplayingMethodNum
Definition: objecttype.h:205
TerrainBits terrain_and
the terrain properties of the field will be AND-masked with this field and then OR-masked with terrai...
Definition: objecttype.h:71
bool visibleago
is the object displayed under fog of war
Definition: objecttype.h:47
int lifetime
the object is removed when it is lifetime turns old. -1 disables removal
Definition: objecttype.h:187
int build_movecost
The movement points that are needed to build this object.
Definition: objecttype.h:113
int netBehaviour
specifies how the object is going to connect to other things
Definition: objecttype.h:138
BitSet weather
bitmapped variable containing the different weather types the objects exist for
Definition: objecttype.h:44
int getID() const
Definition: objecttype.h:131
void display(Surface &surface, const SPoint &pos) const
displays the objecttype at x/y on the screen
Definition: objecttype.cpp:289
int getWeather(int weather) const
Definition: objecttype.cpp:96
The interface for all kinds of IO stream.
a single field of the map
Definition: mapfield.h:26
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
the images of the objects
Definition: objecttype.h:147
static const char * namingMethodNames[]
Definition: objecttype.h:128
bool growOnUnits
is the object growth stopped by units and buildings
Definition: objecttype.h:184
const OverviewMapImage * getOverviewMapImage(int picnum, int weather) const
Definition: objecttype.cpp:111
int attackbonus_abs
The attackbonus_abs replaces the current attackbonus of the field by a new one. A value of -1 won't a...
Definition: objecttype.h:81
bool canExistBeneathBuildings
if a building is constructed on the field containing the object, will the object be removed or will i...
Definition: objecttype.h:119
int basicjamming_abs
basicjamming_abs replaces the current basicjamming of the field by a new one. A value < 0 won't affect...
Definition: objecttype.h:91
const Surface & getPicture(int i=0, int weather=0) const
returns the pointer to the image i
Definition: objecttype.cpp:132
int defensebonus_abs
The defensebonus_abs replaces the current defensebonus of the field by a new one. A value of -1 won't...
Definition: objecttype.h:86
double growthRate
the probability that an object of this type spawns another object on a neighbouring field ...
Definition: objecttype.h:181
int remove_movecost
The movement points that are needed to remove this object.
Definition: objecttype.h:116
vector< Surface > images
Definition: objecttype.h:149
int defensebonus_plus
this is added to the current defensebonus of the field to form the new defensebonus.
Definition: objecttype.h:84
Resources buildcost
The resources required to construct the object with a unit; Note that units usually don't have any en...
Definition: objecttype.h:107
This class is used by buildings, vehicles and objects to specify which terrain it can move to / be bu...
Definition: terraintype.h:42
TerrainAccess terrainaccess
The terrain on which this object can be placed.
Definition: objecttype.h:68
the properties of a terrain describing which units can move onto this field and which can't ...
Definition: terraintype.h:32
The base class for everything that can be placed on a map field.
Definition: mapitemtype.h:16
An abstract base class that provides the interface for all kinds of items that ASC loads from disk...
Definition: typen.h:287
An object that can be placed on fields. Roads, pipelines and ditches are examples of objects...
Definition: objecttype.h:30
int imageHeight
the level of height the object is on. This is not the simple system of 8 levels used for units and bu...
Definition: objecttype.h:101
vector< int > secondaryIDs
when loading a file and these IDs are encountered, this object will be used.
Definition: objecttype.h:38
const FieldModification & getFieldModification(int weather) const
Definition: objecttype.cpp:72
void write(tnstream &stream) const
write the objecttype from a stream
Definition: objecttype.cpp:992
static const int namingMethodNum
Definition: objecttype.h:129
int getEffectiveHeight() const
returns the level of height of this object in the normal 8 level scheme of asc (deep submerged...
Definition: objecttype.cpp:90
struct ObjectType::FieldModification fieldModification[cwettertypennum]
void runTextIO(PropertyContainer &pc)
reads or writes the objecttype to the text stream pc
int namingMethod
Definition: objecttype.h:127
vector< IntRange > linkableTerrain
objects can be graphically linked to terrain, as if the terrain was an object of the same type...
Definition: objecttype.h:53
int growthDuration
the time after which any growth stops.
Definition: objecttype.h:191
int attackbonus_plus
this is added to the current attackbonus of the field to form the new attackbonus.
Definition: objecttype.h:79
SDLmm::SPoint SPoint
Definition: surface.h:27
bool buildable(MapField *fld) const
can the object be build on the field fld
Definition: objecttype.cpp:77
TechAdapterDependency techDependency
Definition: objecttype.h:142
ObjectType(void)
Definition: objecttype.cpp:47
void read(tnstream &stream)
reads the objecttype from a stream
Definition: objecttype.cpp:843
TerrainType::MoveMalus movemalus_plus
the movemalus_plus is added to the current movemalus of the field to form the new movemalus...
Definition: objecttype.h:62
int groupID
the group ID allows units to specify whole groups of objects to be buildable / removable without spec...
Definition: objecttype.h:41
int viewbonus_abs
units standing on this object will get a bonus to their view
Definition: objecttype.h:96
struct ObjectType::WeatherPicture weatherPicture[cwettertypennum]
void smooth(int what, GameMap *gamemap, ObjectType *woodObj)
automatically adjusting the pictures of woods and coasts to form coherent structures ...
Definition: objecttype.cpp:748
vector< IntRange > linkableObjects
some objects are graphically linked with others on neighbouring fields.
Definition: objecttype.h:50
the image for a TerrainType that is shown on the small map
Resources are basically the currency of ASC.
Definition: typen.h:97
int basicjamming_plus
this is added to the current basicjamming of the field to form the new jamming.
Definition: objecttype.h:89
std::bitset< 64 > BitSet
Definition: basictypes.h:48
vector< OverviewMapImage > overviewMapImage
Definition: objecttype.h:148
Resources removecost
The resources required to remove the object with a unit; Note that units usually don't have any energ...
Definition: objecttype.h:110
Everything related to research.
const int cwettertypennum
The number of different weather.
Definition: typen.h:61
int armor
if an object should not be attackable, set armor to 0
Definition: objecttype.h:56
int physicalHeight
the 'real' height of the object, which evaluated for construction and attack. The destinction between...
Definition: objecttype.h:104
static const int netBehaviourNum
Definition: objecttype.h:134
The map. THE central structure of ASC, which holds everything not globally available together...
Definition: gamemap.h:182
ASCString name
The name of the object.
Definition: objecttype.h:122