Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Computer.cpp
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: Computer.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Computer System class
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
Computer.h
"
17
#include "
Game.h
"
18
19
// +----------------------------------------------------------------------+
20
21
static
int
computer_value[] = {
22
0, 1, 1, 1, 1
23
};
24
25
// +----------------------------------------------------------------------+
26
27
Computer::Computer
(
int
comp_type,
const
char
* comp_name)
28
:
System
(COMPUTER, comp_type, comp_name, 1, 1, 1, 1)
29
{
30
SetAbbreviation
(
Game::GetText
(
"sys.computer.abrv"
));
31
power_flags
=
POWER_WATTS
|
POWER_CRITICAL
;
32
33
if
(
subtype
==
FLIGHT
) {
34
crit_level
= -1.0f;
35
}
36
}
37
38
// +----------------------------------------------------------------------+
39
40
Computer::Computer
(
const
Computer
& c)
41
:
System
(c)
42
{
43
Mount
(c);
44
SetAbbreviation
(c.
Abbreviation
());
45
power_flags
=
POWER_WATTS
|
POWER_CRITICAL
;
46
47
if
(
subtype
==
FLIGHT
) {
48
crit_level
= -1.0f;
49
}
50
}
51
52
// +--------------------------------------------------------------------+
53
54
Computer::~Computer
()
55
{ }
56
57
// +--------------------------------------------------------------------+
58
59
void
60
Computer::ApplyDamage
(
double
damage)
61
{
62
System::ApplyDamage
(damage);
63
}
64
65
// +--------------------------------------------------------------------+
66
67
void
68
Computer::ExecFrame
(
double
seconds)
69
{
70
energy
= 0.0f;
71
System::ExecFrame
(seconds);
72
}
73
74
// +--------------------------------------------------------------------+
75
76
void
77
Computer::Distribute
(
double
delivered_energy,
double
seconds)
78
{
79
if
(
IsPowerOn
()) {
80
// convert Joules to Watts:
81
energy
= (float) (delivered_energy/seconds);
82
83
// brown out:
84
if
(
energy
<
capacity
*0.75f)
85
power_on
=
false
;
86
87
// spike:
88
else
if
(
energy
>
capacity
*1.5f) {
89
power_on
=
false
;
90
ApplyDamage
(50);
91
}
92
}
93
}
Stars45
Computer.cpp
Generated on Thu May 31 2012 16:31:04 for Starshatter_Open by
1.8.1