Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FlightDeck.h
Go to the documentation of this file.
1 /* Project STARSHATTER
2  John DiCamillo
3  Copyright © 1997-2002. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: FlightDeck.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Everything needed to launch and recover space craft
13 
14  See Also: Hangar
15 */
16 
17 #ifndef FlightDeck_h
18 #define FlightDeck_h
19 
20 #include "Types.h"
21 #include "Geometry.h"
22 #include "System.h"
23 #include "SimObject.h"
24 #include "Text.h"
25 
26 // +----------------------------------------------------------------------+
27 
28 class Hoop;
29 class Light;
30 class Ship;
31 class ShipDesign;
32 class FlightDeck;
33 class FlightDeckSlot;
34 class InboundSlot;
35 
36 // +======================================================================+
37 
38 class InboundSlot : public SimObserver
39 {
40 public:
41  static const char* TYPENAME() { return "InboundSlot"; }
42 
43  InboundSlot() : ship(0), deck(0), squadron(0), slot(0), cleared(0), final(0), approach(0) { }
44  InboundSlot(Ship* s, FlightDeck* d, int squad, int index);
45 
46  int operator < (const InboundSlot& that) const;
47  int operator <= (const InboundSlot& that) const;
48  int operator == (const InboundSlot& that) const;
49 
50  // SimObserver:
51  virtual bool Update(SimObject* obj);
52  virtual const char* GetObserverName() const;
53 
54  Ship* GetShip() { return ship; }
55  FlightDeck* GetDeck() { return deck; }
56  int Squadron() { return squadron; }
57  int Index() { return slot; }
58  int Cleared() { return cleared; }
59  int Final() { return final; }
60  int Approach() { return approach; }
61  Point Offset() { return offset; }
62  double Distance();
63 
64  void SetApproach(int a) { approach = a; }
65  void SetOffset(const Point& p) { offset = p; }
66  void SetFinal(int f) { final = f; }
67  void Clear(bool clear=true);
68 
69 private:
70  Ship* ship;
71  FlightDeck* deck;
72  int squadron;
73  int slot;
74  int cleared;
75  int final;
76  int approach;
77  Point offset;
78 };
79 
80 // +----------------------------------------------------------------------+
81 
82 class FlightDeck : public System, public SimObserver
83 {
84 public:
85  static const char* TYPENAME() { return "FlightDeck"; }
86 
87  FlightDeck();
88  FlightDeck(const FlightDeck& rhs);
89  virtual ~FlightDeck();
90 
94 
95  static void Initialize();
96  static void Close();
97 
98  virtual void ExecFrame(double seconds);
99  void SetCarrier(Ship* s) { ship = carrier = s; }
100  void SetIndex(int n) { index = n; }
101 
102  virtual int SpaceLeft(int type) const;
103 
104  virtual bool Spot(Ship* s, int& index);
105  virtual bool Clear(int index);
106  virtual bool Launch(int index);
107  virtual bool LaunchShip(Ship* s);
108  virtual bool Recover(Ship* s);
109  virtual bool Dock(Ship* s);
110  virtual int Inbound(InboundSlot*& s);
111  virtual void GrantClearance();
112 
113  virtual void AddSlot(const Point& loc, DWORD filter=0xf);
114 
115  virtual bool IsLaunchDeck() const { return subtype == FLIGHT_DECK_LAUNCH; }
117  virtual bool IsRecoveryDeck() const { return subtype == FLIGHT_DECK_RECOVERY; }
119 
120  Point BoundingBox() const { return box; }
121  Point ApproachPoint(int i) const { return approach_point[i]; }
122  Point RunwayPoint(int i) const { return runway_point[i]; }
123  Point StartPoint() const { return start_point; }
124  Point EndPoint() const { return end_point; }
125  Point CamLoc() const { return cam_loc; }
126  double Azimuth() const { return azimuth; }
127 
128  virtual void SetBoundingBox(Point dimensions) { box = dimensions; }
129  virtual void SetApproachPoint(int i, Point loc);
130  virtual void SetRunwayPoint(int i, Point loc);
131  virtual void SetStartPoint(Point loc);
132  virtual void SetEndPoint(Point loc);
133  virtual void SetCamLoc(Point loc);
134  virtual void SetCycleTime(double time);
135  virtual void SetAzimuth(double az) { azimuth = az; }
136  virtual void SetLight(double l);
137 
138  virtual void Orient(const Physical* rep);
139 
140  // SimObserver:
141  virtual bool Update(SimObject* obj);
142  virtual const char* GetObserverName() const;
143 
144  // accessors:
145  int NumSlots() const { return num_slots; }
146  double TimeRemaining(int index) const;
147  int State(int index) const;
148  int Sequence(int index) const;
149  const Ship* GetCarrier() const { return carrier; }
150  int GetIndex() const { return index; }
151  Ship* GetShip(int index) const;
152  int NumHoops() const { return num_hoops; }
153  Hoop* GetHoops() const { return hoops; }
154  Light* GetLight() { return light; }
155 
157  void PrintQueue();
158 
159  bool OverThreshold(Ship* s) const;
160  bool ContainsPoint(const Point& p) const;
161 
162 protected:
164  int index;
167 
174 
180 
181  double azimuth;
182  double cycle_time;
183 
190 };
191 
192 // +----------------------------------------------------------------------+
193 
194 #endif FlightDeck_h
195