1 /*
2  *  This file is part of Dune Legacy.
3  *
4  *  Dune Legacy is free software: you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation, either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  Dune Legacy is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with Dune Legacy.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef HARVESTER_H
19 #define HARVESTER_H
20 
21 #include <units/TrackedUnit.h>
22 
23 class Harvester : public TrackedUnit
24 {
25 public:
26 
27     explicit Harvester(House* newOwner);
28     explicit Harvester(InputStream& stream);
29     void init();
30     virtual ~Harvester();
31 
32     virtual void save(OutputStream& stream) const;
33 
34     void blitToScreen();
35 
36     void checkPos();
37     virtual void deploy(const Coord& newLocation);
38     void destroy();
39     virtual void drawSelectionBox();
40     void handleDamage(int damage, Uint32 damagerID, House* damagerOwner);
41 
42     void handleReturnClick();
43 
44     /**
45         Order this harvester to return to a refinery.
46     */
47     void doReturn();
48 
49     void move();
50     void setAmountOfSpice(FixPoint newSpice);
51     void setReturned();
52 
53     void setDestination(int newX, int newY);
setDestination(const Coord & location)54     inline void setDestination(const Coord& location) { setDestination(location.x, location.y); }
55 
56     void setTarget(const ObjectBase* newTarget);
57 
58     bool canAttack(const ObjectBase* object) const;
59 
60     FixPoint extractSpice(FixPoint extractionSpeed);
61 
getAmountOfSpice()62     inline FixPoint getAmountOfSpice() const { return spice; }
isReturning()63     inline bool isReturning() const { return returningToRefinery; }
64     bool isHarvesting() const;
65 
66 private:
67 
68     virtual void setSpeeds();
69 
70     // harvester state
71     bool     harvestingMode;         ///< currently harvesting
72     bool     returningToRefinery;    ///< currently on the way back to the refinery
73     FixPoint spice;                  ///< loaded spice
74     Uint32   spiceCheckCounter;      ///< Check for available spice on map to harvest
75 };
76 
77 #endif // HARVESTER_H
78