Advanced Strategic Command
objects.h
Go to the documentation of this file.
1 
5 /***************************************************************************
6  gamemap.h - description
7  -------------------
8  begin : Tue Feb 17 2001
9  copyright : (C) 2001 by Martin Bickel
10  email : bickel@asc-hq.org
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 
22 
23 #ifndef objectsH
24  #define objectsH
25 
26  #include <vector>
27 
28  #include "typen.h"
29  #include "mapitemtype.h"
30  #include "overviewmapimage.h"
31  #include "graphics/surface.h"
32 
33  class ObjectType;
34 
35 class AgeableItem {
36  protected:
37  AgeableItem() : lifetimer(-1) {};
38  public:
39  int lifetimer;
40 
42  static bool age( AgeableItem& obj );
43 };
44 
46 class Object : public AgeableItem {
47  public:
48  const ObjectType* typ;
49  const ObjectType* getType() const { return typ; };
50  int damage;
51  int dir;
53 
54  Object ();
55  Object ( const ObjectType* o );
56  void display ( Surface& surface, const SPoint& pos, int weather = 0 ) const;
57  const OverviewMapImage* getOverviewMapImage( int weather );
58  void setDir ( int dir );
59  int getDir() const;
60 
61  void write ( tnstream& stream );
62  void read ( tnstream& stream );
63 
64 };
65 
66 const int cminenum = 4;
67 extern const char* MineNames[cminenum] ;
68 extern const int MineBasePunch[cminenum] ;
69 
71 
72 class MineType : public MapItemType {
73  MineTypes type;
74  public:
75  int id;
76 
78  vector<int> secondaryIDs;
79 
82 
83  int getID() const { return id; };
84 
85  MineType( MineTypes t ) : type ( t ), id( int(t)) {};
86  MineType( const MineType& w ) : type ( w.type ) {};
87  ASCString getName() const {
88  return MineNames[int(type)-1];
89  };
90 
91  void paint ( Surface& surface, const SPoint& pos ) const ;
92  static void paint( MineTypes type, int player, Surface& surf, const SPoint& pos );
93 };
94 
95 #endif
96 
ASCString getName() const
Definition: objects.h:87
ASCString location
Definition: objects.h:81
int damage
Definition: objects.h:49
ASCString name
Definition: objects.h:80
void read(tnstream &stream)
Definition: objects.cpp:130
Object()
Definition: objects.cpp:81
int id
Definition: objects.h:75
const ObjectType * getType() const
Definition: objects.h:49
vector< int > secondaryIDs
not really used for minetypes.
Definition: objects.h:78
The interface for all kinds of IO stream.
int getID() const
Definition: objects.h:83
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
MineType(MineTypes t)
Definition: objects.h:85
MineTypes
Definition: objects.h:70
void setDir(int dir)
Definition: objects.cpp:99
The base class for everything that can be placed on a map field.
Definition: mapitemtype.h:16
const ObjectType * typ
Definition: objects.h:48
void write(tnstream &stream)
Definition: objects.cpp:121
An object that can be placed on fields. Roads, pipelines and ditches are examples of objects...
Definition: objecttype.h:30
int lifetimer
Definition: objects.h:37
void paint(Surface &surface, const SPoint &pos) const
Definition: objects.cpp:41
int dir
Definition: objects.h:51
void display(Surface &surface, const SPoint &pos, int weather=0) const
Definition: objects.cpp:109
SDLmm::SPoint SPoint
Definition: surface.h:27
const OverviewMapImage * getOverviewMapImage(int weather)
Definition: objects.cpp:114
const char * MineNames[cminenum]
Definition: objects.cpp:38
int remainingGrowthTime
Definition: objects.h:52
int getDir() const
Definition: objects.cpp:104
AgeableItem()
Definition: objects.h:37
static bool age(AgeableItem &obj)
ages the object by one turn. Returns true if the object shall be removed
Definition: objects.cpp:71
an instance of an object type (ObjectType) on the map
Definition: objects.h:46
the image for a TerrainType that is shown on the small map
MineType(const MineType &w)
Definition: objects.h:86
const int MineBasePunch[cminenum]
Definition: objects.cpp:39
const int cminenum
Definition: objects.h:66