]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AICarrier.hxx
fd03644a31f8e954173c04e4335dea1b1fd51c10
[flightgear.git] / src / AIModel / AICarrier.hxx
1 // FGAICarrier - AIShip-derived class creates an AI aircraft carrier
2 //
3 // Written by David Culp, started October 2004.
4 //
5 // Copyright (C) 2004  David P. Culp - davidculp2@comcast.net
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 #ifndef _FG_AICARRIER_HXX
22 #define _FG_AICARRIER_HXX
23
24 #include <string>
25 #include <list>
26 #include <plib/ssg.h>
27 #include <simgear/compiler.h>
28
29 SG_USING_STD(string);
30 SG_USING_STD(list);
31
32 #include "AIShip.hxx"
33 class FGAIManager;
34 class FGAICarrier;
35
36 class FGAICarrierHardware : public ssgBase {
37 public:
38
39   enum Type { Catapult, Wire, Solid };
40
41   FGAICarrier *carrier;
42   int id;
43   Type type;
44
45   static FGAICarrierHardware* newCatapult(FGAICarrier *c) {
46     FGAICarrierHardware* ch = new FGAICarrierHardware;
47     ch->carrier = c;
48     ch->type = Catapult;
49     ch->id = unique_id++;
50     return ch;
51   }
52   static FGAICarrierHardware* newWire(FGAICarrier *c) {
53     FGAICarrierHardware* ch = new FGAICarrierHardware;
54     ch->carrier = c;
55     ch->type = Wire;
56     ch->id = unique_id++;
57     return ch;
58   }
59   static FGAICarrierHardware* newSolid(FGAICarrier *c) {
60     FGAICarrierHardware* ch = new FGAICarrierHardware;
61     ch->carrier = c;
62     ch->type = Solid;
63     ch->id = unique_id++;
64     return ch;
65   }
66
67 private:
68   static int unique_id;
69 };
70
71 class FGAICarrier  : public FGAIShip {
72         
73 public:
74         
75         FGAICarrier(FGAIManager* mgr);
76         ~FGAICarrier();
77
78         void setSolidObjects(const list<string>& solid_objects);
79         void setWireObjects(const list<string>& wire_objects);
80         void setCatapultObjects(const list<string>& catapult_objects);
81         void setParkingPositions(const list<ParkPosition>& p);
82         void setSign(const string& );
83         void setFlolsOffset(const Point3D& off);
84
85         void getVelocityWrtEarth(sgVec3 v);
86         virtual void bind();
87     virtual void unbind();
88     void UpdateFlols ( double dt );
89         
90         bool init();
91
92         bool getParkPosition(const string& id, Point3D& geodPos,
93                              double& hdng, sgdVec3 uvw);
94
95 private:
96
97         void update(double dt);
98         void mark_nohot(ssgEntity*);
99         bool mark_wires(ssgEntity*, const list<string>&, bool = false);
100         bool mark_cat(ssgEntity*, const list<string>&, bool = false);
101         bool mark_solid(ssgEntity*, const list<string>&, bool = false);
102
103         list<string> solid_objects;       // List of solid object names
104         list<string> wire_objects;        // List of wire object names
105         list<string> catapult_objects;    // List of catapult object names
106         list<ParkPosition> ppositions;    // List of positions where an aircraft can start.
107         string sign;                      // The sign of this carrier.
108
109         // Velocity wrt earth.
110         sgVec3 vel_wrt_earth;
111
112         // these describe the flols 
113         Point3D flols_off;
114     
115         double dist;            // the distance of the eyepoint from the flols
116         double angle;
117         int source;             // the flols light which is visible at the moment
118 };
119
120 #endif  // _FG_AICARRIER_HXX