Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
System.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: System.h
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Generic ship System class
13
*/
14
15
#ifndef System_h
16
#define System_h
17
18
#include "
Types.h
"
19
#include "
Physical.h
"
20
#include "
Geometry.h
"
21
22
#include "
List.h
"
23
#include "
text.h
"
24
25
// +--------------------------------------------------------------------+
26
27
class
Component
;
28
class
Ship
;
29
class
SystemDesign
;
30
31
// +--------------------------------------------------------------------+
32
33
class
System
34
{
35
friend
Component
;
36
37
public
:
38
static
const
char
*
TYPENAME
() {
return
"System"
; }
39
40
enum
CATEGORY
{
MISC_SYSTEM
=0,
DRIVE
=1,
WEAPON
,
SHIELD
,
SENSOR
,
41
COMPUTER
,
POWER_SOURCE
,
FLIGHT_DECK
,
FARCASTER
};
42
enum
STATUS
{
DESTROYED
,
CRITICAL
,
DEGRADED
,
NOMINAL
,
MAINT
};
43
enum
POWER_FLAGS
{
POWER_WATTS
=1,
POWER_CRITICAL
=2 };
44
45
System
(
CATEGORY
t,
int
s,
const
char
* n,
int
maxv,
46
double
energy
=0,
double
capacity
=100,
double
sink_rate
=1);
47
System
(
const
System
& s);
48
virtual
~System
();
49
50
int
operator==
(
const
System
& s)
const
{
return
this
== &s; }
51
52
CATEGORY
Type
()
const
{
return
type
; }
53
int
Subtype
()
const
{
return
subtype
; }
54
const
char
*
Name
()
const
{
return
name
; }
55
const
char
*
Abbreviation
()
const
{
return
abrv
; }
56
57
void
SetName
(
const
char
* n) {
name
= n; }
58
void
SetAbbreviation
(
const
char
* a) {
abrv
= a; }
59
void
SetDesign
(
SystemDesign
* d);
60
61
virtual
int
Value
()
const
{
return
(
int
) (
max_value
*
availability
*100); }
62
int
MaxValue
()
const
{
return
(
int
) (
max_value
*100); }
63
STATUS
Status
()
const
{
return
status
; }
64
double
Availability
()
const
{
return
availability
*100; }
65
double
Safety
()
const
{
return
safety
*100; }
66
double
Stability
()
const
{
return
stability
*100; }
67
virtual
void
CalcStatus
();
68
virtual
void
Repair
();
69
70
double
NetAvail
()
const
{
return
net_avail
; }
71
void
SetNetAvail
(
double
d){
net_avail
= (float) d; }
72
73
List<Component>
&
GetComponents
() {
return
components
; }
74
75
virtual
void
ApplyDamage
(
double
damage);
76
virtual
void
ExecFrame
(
double
seconds);
77
virtual
void
ExecMaintFrame
(
double
seconds);
78
virtual
void
DoEMCON
(
int
emcon
);
79
80
// PHYSICAL LOCATION (for inflicting system damage):
81
virtual
void
Orient
(
const
Physical
* rep);
82
virtual
void
Mount
(
Point
loc,
float
radius
,
float
hull_factor
=0.5f);
83
virtual
void
Mount
(
const
System
& system);
84
85
Point
MountLocation
()
const
{
return
mount_loc
; }
86
double
Radius
()
const
{
return
radius
; }
87
double
HullProtection
()
const
{
return
hull_factor
; }
88
89
// POWER UTILIZATION:
90
bool
IsPowerCritical
()
const
{
return
(
power_flags
&
POWER_CRITICAL
)?
true
:
false
; }
91
bool
UsesWatts
()
const
{
return
(
power_flags
&
POWER_WATTS
)?
true
:
false
; }
92
93
virtual
double
GetRequest
(
double
seconds)
const
;
94
virtual
void
Distribute
(
double
delivered_energy,
double
seconds);
95
96
int
GetSourceIndex
()
const
{
return
source_index
; }
97
void
SetSourceIndex
(
int
i) {
source_index
= i; }
98
99
virtual
int
Charge
()
const
{
return
(
int
) (100 *
energy
/
capacity
); }
100
101
bool
IsPowerOn
()
const
{
return
power_on
; }
102
virtual
void
PowerOn
() {
power_on
=
true
; }
103
virtual
void
PowerOff
() {
power_on
=
false
; }
104
105
// percentage, but stored as 0-1
106
virtual
double
GetPowerLevel
()
const
{
return
power_level
* 100; }
107
virtual
void
SetPowerLevel
(
double
level);
108
virtual
void
SetOverride
(
bool
over);
109
110
// for power drain damage:
111
virtual
void
DrainPower
(
double
to_level);
112
113
void
SetCapacity
(
double
c) {
capacity
= (float) c; }
114
double
GetCapacity
()
const
{
return
capacity
; }
115
double
GetEnergy
()
const
{
return
energy
; }
116
double
GetSinkRate
()
const
{
return
sink_rate
; }
117
void
SetEMCONPower
(
int
emcon
,
int
power_level
);
118
int
GetEMCONPower
(
int
emcon
);
119
120
int
GetExplosionType
()
const
{
return
explosion_type
; }
121
void
SetExplosionType
(
int
t) {
explosion_type
= t; }
122
123
Ship
*
GetShip
()
const
{
return
ship
; }
124
void
SetShip
(
Ship
* s) {
ship
= s; }
125
int
GetID
()
const
{
return
id
; }
126
void
SetID
(
int
n) {
id
= n; }
127
128
protected
:
129
// AI information:
130
CATEGORY
type
;
131
Ship
*
ship
;
132
int
id
;
133
int
subtype
;
134
int
max_value
;
135
136
// Displayable name:
137
Text
name
;
138
Text
abrv
;
139
140
// System health status:
141
STATUS
status
;
142
float
crit_level
;
143
float
availability
;
144
float
safety
;
145
float
stability
;
146
float
safety_overload
;
147
float
net_avail
;
148
149
// Mounting:
150
Point
mount_loc
;
// world space
151
Point
mount_rel
;
// object space
152
float
radius
;
153
float
hull_factor
;
154
155
// Power Sink:
156
float
energy
;
157
float
capacity
;
158
float
sink_rate
;
159
float
power_level
;
160
int
source_index
;
161
DWORD
power_flags
;
162
bool
power_on
;
163
BYTE
emcon_power
[3];
164
BYTE
emcon
;
165
166
int
explosion_type
;
167
168
// Subcomponents:
169
SystemDesign
*
design
;
170
List<Component>
components
;
171
};
172
173
#endif System_h
174
Stars45
System.h
Generated on Thu May 31 2012 16:31:17 for Starshatter_Open by
1.8.1