Oolite
1.91.0.7659-250410-0031890
Toggle main menu visibility
Main Page
Topics
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
z
Enumerations
g
k
m
o
r
s
t
w
Enumerator
a
b
c
d
e
g
j
k
m
n
o
p
r
s
t
u
w
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Macros
Modules
Pages
Loading...
Searching...
No Matches
src
Core
Entities
OOPlasmaShotEntity.m
Go to the documentation of this file.
1
/*
2
3
OOPlasmaShotEntity.m
4
5
6
Oolite
7
Copyright (C) 2004-2013 Giles C Williams and contributors
8
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or (at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
18
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22
MA 02110-1301, USA.
23
24
*/
25
26
#import "
OOPlasmaShotEntity.h
"
27
#import "
Universe.h
"
28
#import "
PlayerEntity.h
"
29
#import "
OOColor.h
"
30
#import "
OOPlasmaBurstEntity.h
"
31
32
33
#define kPlasmaShotSize 12.0f
34
#define kPlasmaShotActivationDelay 0.05f
35
36
37
/* If nonzero, plasma shots fade with distance. Bits of this were in the old
38
ParticleEntity code, but I think it was disabled on purpose.
39
-- Ahruman 2009-09-25
40
*/
41
#define PLASMA_ATTENUATION 0
42
43
44
@implementation
OOPlasmaShotEntity
45
46
- (id) initWithPosition:(HPVector)inPosition
47
velocity:(Vector)inVelocity
48
energy:(
float
)inEnergy
49
duration:(
OOTimeDelta
)duration
50
color:(
OOColor
*)color
51
{
52
if
((
self
= [super initWithDiameter:
kPlasmaShotSize
]))
53
{
54
[
self
setPosition
:inPosition];
55
[
self
setVelocity
:inVelocity];
56
[
self
setCollisionRadius
:2.0];
57
58
[
self
setColor
:color
alpha
:1.0];
59
_colorComponents
[3] = 1.0f;
60
61
[
self
setEnergy
:inEnergy];
62
_duration
= duration;
63
}
64
65
return
self
;
66
}
46
- (id) initWithPosition:(HPVector)inPosition {
…
}
67
68
69
- (BOOL)
canCollide
70
{
71
return
[UNIVERSE getTime] > [
self
spawnTime
] +
kPlasmaShotActivationDelay
;
72
}
69
- (BOOL)
canCollide
{
…
}
73
74
75
- (BOOL) checkCloseCollisionWith:(
Entity
*)other
76
{
77
return
([other
rootShipEntity
] != [
self
owner
]) && ![
other
isEffect
];
78
}
75
- (BOOL) checkCloseCollisionWith:(
Entity
*)other {
…
}
79
80
81
- (void) update:(
double
)delta_t
82
{
83
[
super
update
:delta_t];
84
85
OOTimeDelta
lifeTime = [
self
timeElapsedSinceSpawn
];
86
87
#if PLASMA_ATTENUATION
88
float
attenuation = OOClamp_0_1_f(1.0f - lifeTime /
_duration
);
89
#else
90
const
float
attenuation = 1.0f;
91
#endif
92
93
NSUInteger i,
count
= [collidingEntities count];
94
for
(i = 0; i <
count
; i++)
95
{
96
Entity
*e = (
Entity
*)[
collidingEntities
objectAtIndex:i];
97
if
([e
rootShipEntity
] != [
self
owner
])
98
{
99
// we're going to force the weapon id to be a phantom equipment key so there is something for
100
// the PlayerEntitySound to reference. it allow allows for the sound effects to be overridden by OXP.
101
[
e
takeEnergyDamage
:[
self
energy
] * attenuation
102
from
:
self
103
becauseOf
:[
self
owner
]
104
weaponIdentifier
:@"EQ_WEAPON_PLASMA_SHOT"];
105
[UNIVERSE removeEntity:
self
];
106
107
// Spawn a plasma burst.
108
OOPlasmaBurstEntity
*burst = [[
OOPlasmaBurstEntity
alloc] initWithPosition:[
self
position
]];
109
[UNIVERSE addEntity:burst];
110
[
burst
release];
111
}
112
}
113
114
#if PLASMA_ATTENUATION
115
_colorComponents
[3] = attenuation;
116
#endif
117
118
if
(lifeTime >
_duration
) [UNIVERSE removeEntity:
self
];
119
}
81
- (void) update:(
double
)delta_t {
…
}
120
121
@end
OOColor.h
count
unsigned count
Definition
OOParticleSystem.m:270
OOPlasmaBurstEntity.h
OOPlasmaShotEntity.h
kPlasmaShotActivationDelay
#define kPlasmaShotActivationDelay
Definition
OOPlasmaShotEntity.m:34
kPlasmaShotSize
#define kPlasmaShotSize
Definition
OOPlasmaShotEntity.m:33
OOTimeDelta
double OOTimeDelta
Definition
OOTypes.h:224
PlayerEntity.h
Universe.h
Entity
Definition
Entity.h:79
-[Entity timeElapsedSinceSpawn]
GLfloat timeElapsedSinceSpawn()
Definition
Entity.m:1069
Entity::collidingEntities
NSMutableArray * collidingEntities
Definition
Entity.h:148
-[Entity setVelocity:]
void setVelocity:(Vector vel)
Definition
Entity.m:757
-[Entity update:]
void update:(OOTimeDelta delta_t)
Definition
Entity.m:929
Entity::energy
GLfloat energy
Definition
Entity.m:817
Entity::spawnTime
OOTimeAbsolute spawnTime
Definition
Entity.m:1063
-[Entity setCollisionRadius:]
void setCollisionRadius:(GLfloat amount)
Definition
Entity.m:917
-[Entity isEffect]
BOOL isEffect()
Definition
Entity.m:196
-[Entity rootShipEntity]
ShipEntity * rootShipEntity()
Definition
Entity.m:603
Entity::position
HPVector position
Definition
Entity.m:612
-[Entity setEnergy:]
void setEnergy:(GLfloat amount)
Definition
Entity.m:811
-[Entity takeEnergyDamage:from:becauseOf:weaponIdentifier:]
void takeEnergyDamage:from:becauseOf:weaponIdentifier:(double amount,[from] Entity *ent,[becauseOf] Entity *other,[weaponIdentifier] NSString *weaponIdentifier)
Definition
Entity.m:990
-[Entity owner]
id owner()
Definition
Entity.m:583
-[Entity setPosition:]
void setPosition:(HPVector posn)
Definition
Entity.m:647
OOColor
Definition
OOColor.h:46
-[OOLightParticleEntity setColor:alpha:]
void setColor:alpha:(OOColor *color,[alpha] GLfloat alpha)
Definition
OOLightParticleEntity.m:93
OOLightParticleEntity::_colorComponents
GLfloat _colorComponents[4]
Definition
OOLightParticleEntity.h:36
OOPlasmaBurstEntity
Definition
OOPlasmaBurstEntity.h:30
OOPlasmaShotEntity
Definition
OOPlasmaShotEntity.h:30
OOPlasmaShotEntity::_duration
OOTimeDelta _duration
Definition
OOPlasmaShotEntity.h:32
-[OOPlasmaShotEntity canCollide]
BOOL canCollide()
Definition
OOPlasmaShotEntity.m:69
Generated by
1.13.2