File: objects.h

package info (click to toggle)
asc 2.6.1.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 81,740 kB
  • sloc: cpp: 158,704; sh: 11,544; ansic: 6,736; makefile: 604; perl: 138
file content (96 lines) | stat: -rw-r--r-- 3,000 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*! \file objects.h
    \brief Mine and Objects which can be placed on a map field
*/

/***************************************************************************
                          gamemap.h  -  description
                             -------------------
    begin                : Tue Feb 17 2001
    copyright            : (C) 2001 by Martin Bickel
    email                : bickel@asc-hq.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/


#ifndef objectsH
 #define objectsH

 #include <vector>

 #include "typen.h"
 #include "mapitemtype.h"
 #include "overviewmapimage.h"
 #include "graphics/surface.h"
 
 class ObjectType;

class AgeableItem {
    protected:
       AgeableItem() : lifetimer(-1) {};
    public:
       int lifetimer;

       //! ages the object by one turn. Returns true if the object shall be removed
       static bool age( AgeableItem& obj );
};

//! an instance of an object type (#ObjectType) on the map
class Object : public AgeableItem {
    public:
       const ObjectType* typ;
       const ObjectType* getType() const { return typ; };
       int damage;
       int dir;
       int remainingGrowthTime;
       
       Object ();
       Object ( const ObjectType* o );
       void display ( Surface& surface, const SPoint& pos, int weather = 0 ) const;
       const OverviewMapImage* getOverviewMapImage( int weather );
       void setDir ( int dir );
       int  getDir() const;

       void write ( tnstream& stream );
       void read ( tnstream& stream );
       
};

const int cminenum = 4;
extern const char* MineNames[cminenum] ;
extern const int MineBasePunch[cminenum]  ;

enum MineTypes { cmantipersonnelmine = 1 , cmantitankmine, cmmooredmine, cmfloatmine  };

class MineType : public MapItemType {
      MineTypes type;
   public:
      int id;

      //! not really used for minetypes.
      vector<int> secondaryIDs;

      ASCString name;
      ASCString location;
      
      int getID() const { return id; }; 
      
      MineType( MineTypes t ) : type ( t ), id( int(t)) {};
      MineType( const MineType& w ) : type ( w.type ) {};
      ASCString getName() const {
         return MineNames[int(type)-1];
      };
      
      void paint ( Surface& surface, const SPoint& pos ) const ;
      static void paint( MineTypes type, int player, Surface& surf, const SPoint& pos );
};

#endif