Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CombatUnit.h
Go to the documentation of this file.
1 /* Project Starshatter 4.5
2  Destroyer Studios LLC
3  Copyright © 1997-2004. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: CombatUnit.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  A ship, station, or ground unit in the dynamic campaign.
13 */
14 
15 #ifndef CombatUnit_h
16 #define CombatUnit_h
17 
18 #include "Types.h"
19 #include "Geometry.h"
20 #include "Color.h"
21 #include "Text.h"
22 #include "List.h"
23 
24 // +--------------------------------------------------------------------+
25 
26 class CombatGroup;
27 class ShipDesign;
28 
29 // +--------------------------------------------------------------------+
30 
32 {
33 public:
34  static const char* TYPENAME() { return "CombatUnit"; }
35 
36  CombatUnit(const char* n, const char* reg, int t, const char* dname, int number, int i);
37  CombatUnit(const CombatUnit& unit);
38 
39  int operator == (const CombatUnit& u) const { return this == &u; }
40 
41  const char* GetDescription() const;
42 
43  int GetValue() const;
44  int GetSingleValue() const;
45  bool CanDefend(CombatUnit* unit) const;
46  bool CanAssign() const;
47  bool CanLaunch() const;
48  double PowerVersus(CombatUnit* tgt) const;
49  int AssignMission();
50  void CompleteMission();
51 
52  double MaxRange() const;
53  double MaxEffectiveRange() const;
54  double OptimumRange() const;
55 
56  void Engage(CombatUnit* tgt);
57  void Disengage();
58 
59  // accessors and mutators:
60  const Text& Name() const { return name; }
61  const Text& Registry() const { return regnum; }
62  const Text& DesignName() const { return design_name; }
63  const Text& Skin() const { return skin; }
64  void SetSkin(const char* s) { skin = s; }
65  int Type() const { return type; }
66  int Count() const { return count; }
67  int LiveCount() const { return count - dead_count; }
68  int DeadCount() const { return dead_count; }
69  void SetDeadCount(int n) { dead_count = n; }
70  int Kill(int n);
71  int Available() const { return available; }
72  int GetIFF() const { return iff; }
73  bool IsLeader() const { return leader; }
74  void SetLeader(bool l) { leader = l; }
75  Point Location() const { return location; }
76  void MoveTo(const Point& loc);
77  Text GetRegion() const { return region; }
78  void SetRegion(Text rgn) { region = rgn; }
79  CombatGroup* GetCombatGroup() const { return group; }
80  void SetCombatGroup(CombatGroup* g){ group = g; }
81 
82  Color MarkerColor() const;
83  bool IsGroundUnit() const;
84  bool IsStarship() const;
85  bool IsDropship() const;
86  bool IsStatic() const;
87 
88  CombatUnit* GetCarrier() const { return carrier; }
89  void SetCarrier(CombatUnit* c) { carrier = c; }
90 
91  const ShipDesign* GetDesign();
92  int GetShipClass() const;
93 
94  List<CombatUnit>& GetAttackers() { return attackers; }
95 
96  double GetPlanValue() const { return plan_value; }
97  void SetPlanValue(int v) { plan_value = v; }
98 
99  double GetSustainedDamage() const { return sustained_damage; }
100  void SetSustainedDamage(double d) { sustained_damage = d; }
101 
102  double GetHeading() const { return heading; }
103  void SetHeading(double d) { heading = d; }
104 
105  double GetNextJumpTime() const { return jump_time; }
106 
107 private:
108  Text name;
109  Text regnum;
110  Text design_name;
111  Text skin;
112  int type;
113  const ShipDesign* design;
114  int count;
115  int dead_count;
116  int available;
117  int iff;
118  bool leader;
119  Text region;
120  Point location;
121  double plan_value; // scratch pad for plan modules
122  double launch_time;
123  double jump_time;
124  double sustained_damage;
125  double heading;
126 
127  CombatUnit* carrier;
128  List<CombatUnit> attackers;
129  CombatUnit* target;
130  CombatGroup* group;
131 };
132 
133 #endif CombatUnit_h
134