_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

action_build.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1998-2012 by Lutz Sammer and Jimmy Salmon
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; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 //
29 
30 #ifndef __ACTION_BUILD_H__
31 #define __ACTION_BUILD_H__
32 
33 #include "actions.h"
34 
36 
37 class COrder_Build : public COrder
38 {
39  friend COrder *COrder::NewActionBuild(const CUnit &builder, const Vec2i &pos, CUnitType &building);
40 public:
41  COrder_Build() : COrder(UnitActionBuild), Type(NULL), State(0), Range(0)
42  {
43  goalPos.x = -1;
44  goalPos.y = -1;
45  }
46 
47  virtual COrder_Build *Clone() const { return new COrder_Build(*this); }
48 
49  virtual bool IsValid() const;
50 
51  virtual void Save(CFile &file, const CUnit &unit) const;
52  virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit);
53 
54  virtual void Execute(CUnit &unit);
55  virtual void Cancel(CUnit &unit);
56  virtual PixelPos Show(const CViewport &vp, const PixelPos &lastScreenPos) const;
57  virtual void UpdatePathFinderData(PathFinderInput &input);
58 
59  virtual void UpdateUnitVariables(CUnit &unit) const;
60 
61  virtual void AiUnitKilled(CUnit &unit);
62 
63  const CUnitType &GetUnitType() const { return *Type; }
64  virtual const Vec2i GetGoalPos() const;
65 
66  CUnit *GetBuildingUnit() const;
67 
68 private:
69  bool MoveToLocation(CUnit &unit);
70  CUnit *CheckCanBuild(CUnit &unit);
71  bool StartBuilding(CUnit &unit, CUnit &ontop);
72  bool BuildFromOutside(CUnit &unit) const;
73 private:
74  CUnitType *Type;
75  CUnitPtr BuildingUnit;
76  int State;
77  int Range;
78  Vec2i goalPos;
79 };
80 
82 
83 #endif // !__ACTION_BUILD_H__
COrder_Build::GetUnitType
const CUnitType & GetUnitType() const
Definition: action_build.h:63
COrder_Build::AiUnitKilled
virtual void AiUnitKilled(CUnit &unit)
Definition: action_build.cpp:170
UnitActionBuild
@ UnitActionBuild
unit paroling area
Definition: actions.h:72
CUnitPtr
Definition: unitptr.h:41
COrder_Build::Show
virtual PixelPos Show(const CViewport &vp, const PixelPos &lastScreenPos) const
Definition: action_build.cpp:143
COrder_Build::IsValid
virtual bool IsValid() const
Definition: action_build.cpp:138
COrder_Build::UpdatePathFinderData
virtual void UpdatePathFinderData(PathFinderInput &input)
Definition: action_build.cpp:158
COrder_Build::ParseSpecificData
virtual bool ParseSpecificData(lua_State *l, int &j, const char *value, const CUnit &unit)
Definition: action_build.cpp:111
COrder
Definition: actions.h:94
Vec2T::y
T y
Definition: vec2i.h:43
CViewport
Definition: viewport.h:63
CUnitType
Definition: unittype.h:508
COrder_Build::Execute
virtual void Execute(CUnit &unit)
Definition: action_build.cpp:447
COrder_Build::Save
virtual void Save(CFile &file, const CUnit &unit) const
Definition: action_build.cpp:93
Vec2T< short int >
PathFinderInput
Definition: pathfinder.h:67
COrder_Build::GetBuildingUnit
CUnit * GetBuildingUnit() const
Definition: action_build.cpp:434
actions.h
COrder::NewActionBuild
static COrder * NewActionBuild(const CUnit &builder, const Vec2i &pos, CUnitType &building)
Definition: action_build.cpp:72
COrder_Build::COrder_Build
COrder_Build()
Definition: action_build.h:41
COrder_Build::GetGoalPos
virtual const Vec2i GetGoalPos() const
Definition: action_build.cpp:508
COrder_Build::Cancel
virtual void Cancel(CUnit &unit)
Definition: action_build.cpp:497
COrder_Build
Definition: action_build.h:37
Vec2T::x
T x
Definition: vec2i.h:42
COrder_Build::UpdateUnitVariables
virtual void UpdateUnitVariables(CUnit &unit) const
Definition: action_build.cpp:439
COrder_Build::Clone
virtual COrder_Build * Clone() const
Definition: action_build.h:47
CFile
Definition: iolib.h:102
CUnit
The big unit structure.
Definition: unit.h:135
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.