File: containerbasetype.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 (255 lines) | stat: -rw-r--r-- 8,433 bytes parent folder | download | duplicates (5)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/***************************************************************************
                          containerbasetype.h  -  description
                             -------------------
    begin                : Sun Feb 18 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 containerbasetypeH
 #define containerbasetypeH

 #include "objects.h"
 #include "typen.h"
 #include "research.h"
 #include "mapitemtype.h"
 #include "memsize_interface.h"

class ContainerBaseType: public MapItemType, public LoadableItemType, public MemorySizeQueryInterface {
   protected:
      std::bitset<64> features;
   public:
     ContainerBaseType ();

     enum ContainerFunctions { TrainingCenter,
        InternalVehicleProduction,
        AmmoProduction,
        InternalUnitRepair,
        RecycleUnits,
        Research,
        Sonar,
        SatelliteView,
        MineView,
        WindPowerPlant,
        SolarPowerPlant,
        MatterConverter,
        MiningStation,
        ProduceNonLeavableUnits,
        ResourceSink,
        ExternalEnergyTransfer,
        ExternalMaterialTransfer,
        ExternalFuelTransfer,
        ExternalAmmoTransfer,
        ExternalRepair,
        NoObjectChaining,
        SelfDestructOnConquer,
        Paratrooper,
        PlaceMines,
        CruiserLanding,
        ConquerBuildings,
        MoveAfterAttack,
        ExternalVehicleProduction,
        ConstructBuildings,
        IceBreaker,
        NoInairRefuelling,
        MakesTracks,
        DetectsMineralResources,
        NoReactionfire,
        AutoRepair,
        KamikazeOnly,
        ImmuneToMines,
        JamsOnlyOwnField,
        MoveWithReactionFire,
        OnlyMoveToAndFromTransports,
        AutoHarvestObjects,
        NoProductionCustomization,
        ManualSelfDestruct,
        NoMineRemoval };

     
     static const int functionNum = 44;

     bool hasFunction( ContainerFunctions function ) const;
     bool hasAnyFunction( std::bitset<64> functions ) const;
     static const char* getFunctionName( ContainerFunctions function );

   protected:
      void setFunction( ContainerFunctions function );
   public:
     
     int id;

     //! when loading a file and these IDs are encountered, this object will be used.
     vector<int> secondaryIDs;


     //! a short name, for example B-52
     ASCString    name;

     //! short description of the units role, for example "strategic bomber"
     ASCString    description;
     
     ASCString getName() const { return name; };
     int getID() const { return id; };
     
     
     //! an extensive information about the unit/building which may be several paragraphs long
     ASCString    infotext;

     //! the radar jamming power
     int          jamming;

     //! the visibility range
     int          view;

     //! the levels of height which this unit can enter
     int          height;
     int getHeight() const { return height; };

     Resources productionCost;
     virtual ~ContainerBaseType() {};

     //! the maximum number of units that can be loaded
     int maxLoadableUnits;

     //! the maximum size of a unit that may enter the building
     int maxLoadableUnitSize;

     //! the maximum total weight of all loaded units
     int maxLoadableWeight;

     //! bitmapped: vehicle categories that can be stored the container
     int vehicleCategoriesStorable;

     //! bitmapped: vehicle categories that can be produced in the container
     int vehicleCategoriesProduceable;

     /** the default production capabilities of this container.
         Please be aware that a VehicleType has additional production for building units externally */
     vector<IntRange> vehiclesInternallyProduceable;

     class TransportationIO {
         public:
            TransportationIO ();
            static const int entranceModeNum = 3;
            enum { In = 1, Out = 2, Docking = 4 };
            int mode;

            // int functionbits

            //! a loadable unit must be on this level of height; 0 if not used
            int height_abs;

            //! a height of a loadable unit have this height relative to the container; -100 if not used
            int height_rel;

            //! the container must be on this height
            int container_height;

            //! bitmapped: vehicle categories that may enter the container
            int vehicleCategoriesLoadable;

            int dockingHeight_abs;

            int dockingHeight_rel;

            std::bitset<64> requiresUnitFeature;

            int movecost;

            bool disableAttack;

            void runTextIO ( PropertyContainer& pc );
            void read ( tnstream& stream ) ;
            void write ( tnstream& stream ) const ;
     };

     typedef vector<TransportationIO> EntranceSystems;
     EntranceSystems   entranceSystems;

     TechAdapterDependency techDependency;

     //! the filename of an image that is shown in info dialogs
     ASCString infoImageFilename;
     ASCString infoImageSmallFilename;

     void runTextIO ( PropertyContainer& pc );

     //! can units of the given type be moved into this buildtype? This is a prerequisite - but not the only requirement - for a real unit to move into a real building
     bool vehicleFit ( const VehicleType* type ) const ;

     /** checks the unloading of a unit type
         \param vehicleType the vehicletype for which the unloading is checked
         \param carrierHeight assume the carrier was on this height (numerical: 0 - 7).
         \return the levels of height on which this unit can be unloaded; or 0 if no unloading is possible
     */
     int  vehicleUnloadable ( const VehicleType* vehicleType, int carrierHeight ) const;


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

     

        //! currently only used by mining stations: the efficiency of the resource extraction from the ground. Base is 1024
     int          efficiencyfuel;

        //! currently only used by mining stations: the efficiency of the resource extraction from the ground. Base is 1024
     int          efficiencymaterial;

        //! the maximum number of research points a research center may produce
     int          maxresearchpoints;

        //! when a building of this type is placed on a map, its maxResearch property will be set to this value
     int          defaultMaxResearchpoints;

        //! the number of reseach points for which the plus settings apllies
     int          nominalresearchpoints;

     //! if the unit is repaired in the field (that is, not inside a transport or building), it can only be repaired up to this level
     //! 0 would result in a complete repair being possible, 20 that it can only be restored to 20% damage (80% health).
     int  minFieldRepairDamage;
     
     Resources    maxplus;

        //! if a new building is constructed, this will be the resource production of the building
     Resources    defaultProduction;

     virtual int getMoveMalusType() const = 0;
     
     /**  returns the Storage capacity of the unit
          \param mode: 0 = ASC Resource mode ; 1 = BI Resource mode
     */
     Resources   getStorageCapacity( int mode ) const;
   protected:
     Resources    asc_mode_tank;
     Resources    bi_mode_tank;
     
   public:

      ResourceMatrix productionEfficiency;
      
      struct {
         int range;
         
         int maxFieldsPerTurn;
         
        //! the ids of objects this unit can construct
        vector<IntRange> objectsHarvestable;

        //! the group-ids of objects this unit can construct
        vector<IntRange> objectGroupsHarvestable;
      } autoHarvest;
     
 };

#endif