Reinstated plasma impact bursts.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2601 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
3132dc8fe4
commit
6b2e74be02
@ -503,6 +503,8 @@
|
||||
1A817C17106D123F00AA2F97 /* oolite-particle-blur.png in Copy Textures */ = {isa = PBXBuildFile; fileRef = 1A817C16106D123F00AA2F97 /* oolite-particle-blur.png */; };
|
||||
1A817CFC106D232100AA2F97 /* OOPlasmaShotEntity.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A817CFA106D232100AA2F97 /* OOPlasmaShotEntity.h */; };
|
||||
1A817CFD106D232100AA2F97 /* OOPlasmaShotEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A817CFB106D232100AA2F97 /* OOPlasmaShotEntity.m */; };
|
||||
1A817DA0106D3FF000AA2F97 /* OOPlasmaBurstEntity.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A817D9E106D3FF000AA2F97 /* OOPlasmaBurstEntity.h */; };
|
||||
1A817DA1106D3FF000AA2F97 /* OOPlasmaBurstEntity.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A817D9F106D3FF000AA2F97 /* OOPlasmaBurstEntity.m */; };
|
||||
1A81F7090A7BAC4D006580AD /* OOCAMusic.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A81F7070A7BAC4D006580AD /* OOCAMusic.m */; };
|
||||
1A81F70A0A7BAC4D006580AD /* OOCAMusic.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A81F7080A7BAC4D006580AD /* OOCAMusic.h */; };
|
||||
1A8A37560B960337007D20B8 /* NSMutableDictionaryOOExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A8A37540B960337007D20B8 /* NSMutableDictionaryOOExtensions.m */; };
|
||||
@ -1584,6 +1586,8 @@
|
||||
1A817C16106D123F00AA2F97 /* oolite-particle-blur.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "oolite-particle-blur.png"; sourceTree = "<group>"; };
|
||||
1A817CFA106D232100AA2F97 /* OOPlasmaShotEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOPlasmaShotEntity.h; sourceTree = "<group>"; };
|
||||
1A817CFB106D232100AA2F97 /* OOPlasmaShotEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOPlasmaShotEntity.m; sourceTree = "<group>"; };
|
||||
1A817D9E106D3FF000AA2F97 /* OOPlasmaBurstEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOPlasmaBurstEntity.h; sourceTree = "<group>"; };
|
||||
1A817D9F106D3FF000AA2F97 /* OOPlasmaBurstEntity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOPlasmaBurstEntity.m; sourceTree = "<group>"; };
|
||||
1A81F7070A7BAC4D006580AD /* OOCAMusic.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OOCAMusic.m; sourceTree = "<group>"; };
|
||||
1A81F7080A7BAC4D006580AD /* OOCAMusic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OOCAMusic.h; sourceTree = "<group>"; };
|
||||
1A846BA90D79F9570081280D /* oolite-version.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "oolite-version.xcconfig"; path = "src/Cocoa/oolite-version.xcconfig"; sourceTree = "<group>"; };
|
||||
@ -2628,6 +2632,8 @@
|
||||
1A1F2841105AAB7900ADB8C5 /* OOSparkEntity.m */,
|
||||
1A817CFA106D232100AA2F97 /* OOPlasmaShotEntity.h */,
|
||||
1A817CFB106D232100AA2F97 /* OOPlasmaShotEntity.m */,
|
||||
1A817D9E106D3FF000AA2F97 /* OOPlasmaBurstEntity.h */,
|
||||
1A817D9F106D3FF000AA2F97 /* OOPlasmaBurstEntity.m */,
|
||||
1A112739105994D000DF9D12 /* OOExhaustPlumeEntity.h */,
|
||||
1A11273A105994D000DF9D12 /* OOExhaustPlumeEntity.m */,
|
||||
1A00C7B810667D3100A8737D /* OOECMBlastEntity.h */,
|
||||
@ -3083,6 +3089,7 @@
|
||||
1A00C7BA10667D3100A8737D /* OOECMBlastEntity.h in Headers */,
|
||||
1A00C7DF1066814C00A8737D /* OOAsyncWorkManager.h in Headers */,
|
||||
1A817CFC106D232100AA2F97 /* OOPlasmaShotEntity.h in Headers */,
|
||||
1A817DA0106D3FF000AA2F97 /* OOPlasmaBurstEntity.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -3431,6 +3438,7 @@
|
||||
1A00C7BB10667D3100A8737D /* OOECMBlastEntity.m in Sources */,
|
||||
1A00C7E01066814C00A8737D /* OOAsyncWorkManager.m in Sources */,
|
||||
1A817CFD106D232100AA2F97 /* OOPlasmaShotEntity.m in Sources */,
|
||||
1A817DA1106D3FF000AA2F97 /* OOPlasmaBurstEntity.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
33
src/Core/Entities/OOPlasmaBurstEntity.h
Normal file
33
src/Core/Entities/OOPlasmaBurstEntity.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
|
||||
OOPlasmaBurstEntity.h
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright (C) 2004-2009 Giles C Williams and contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "OOLightParticleEntity.h"
|
||||
|
||||
|
||||
@interface OOPlasmaBurstEntity: OOLightParticleEntity
|
||||
|
||||
- (id) initWithPosition:(Vector)position;
|
||||
|
||||
@end
|
69
src/Core/Entities/OOPlasmaBurstEntity.m
Normal file
69
src/Core/Entities/OOPlasmaBurstEntity.m
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
|
||||
OOPlasmaBurstEntity.m
|
||||
|
||||
|
||||
Oolite
|
||||
Copyright (C) 2004-2009 Giles C Williams and contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#import "OOPlasmaBurstEntity.h"
|
||||
#import "Universe.h"
|
||||
|
||||
|
||||
#define kPlasmaBurstInitialSize 64.0f
|
||||
#define kPlasmaBurstGrowthRate 64.0f
|
||||
#define kPlasmaBurstDuration 2.0f
|
||||
|
||||
|
||||
@implementation OOPlasmaBurstEntity
|
||||
|
||||
- (id) initWithPosition:(Vector)inPosition
|
||||
{
|
||||
if ((self = [super initWithSize:NSMakeSize(kPlasmaBurstInitialSize, kPlasmaBurstInitialSize)]))
|
||||
{
|
||||
[self setPosition:inPosition];
|
||||
[self setCollisionRadius:2.0];
|
||||
|
||||
_colorComponents[0] = 1.0f;
|
||||
_colorComponents[1] = 0.0f;
|
||||
_colorComponents[2] = 0.0f;
|
||||
_colorComponents[3] = 1.0f;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
- (void) update:(double)delta_t
|
||||
{
|
||||
[super update:delta_t];
|
||||
|
||||
OOTimeDelta lifeTime = [self timeElapsedSinceSpawn];
|
||||
float attenuation = OOClamp_0_1_f(1.0f - lifeTime / kPlasmaBurstDuration);
|
||||
|
||||
float diameter = kPlasmaBurstInitialSize + lifeTime * kPlasmaBurstGrowthRate;
|
||||
[self setSize:NSMakeSize(diameter, diameter)];
|
||||
|
||||
_colorComponents[3] = attenuation;
|
||||
|
||||
if (lifeTime > kPlasmaBurstDuration) [UNIVERSE removeEntity:self];
|
||||
}
|
||||
|
||||
@end
|
@ -27,6 +27,7 @@ MA 02110-1301, USA.
|
||||
#import "Universe.h"
|
||||
#import "PlayerEntity.h"
|
||||
#import "OOColor.h"
|
||||
#import "OOPlasmaBurstEntity.h"
|
||||
|
||||
|
||||
#define kPlasmaShotSize 12.0f
|
||||
@ -65,12 +66,6 @@ MA 02110-1301, USA.
|
||||
}
|
||||
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
- (void) setColor:(OOColor *)color
|
||||
{
|
||||
float alpha;
|
||||
@ -92,7 +87,9 @@ MA 02110-1301, USA.
|
||||
|
||||
- (void) update:(double)delta_t
|
||||
{
|
||||
OOTimeDelta lifeTime = [UNIVERSE getTime] - [self spawnTime];
|
||||
[super update:delta_t];
|
||||
|
||||
OOTimeDelta lifeTime = [self timeElapsedSinceSpawn];
|
||||
|
||||
#if PLASMA_ATTENUATION
|
||||
float attenuation = OOClamp_0_1_f(1.0f - lifeTime / _duration);
|
||||
@ -109,18 +106,12 @@ MA 02110-1301, USA.
|
||||
[e takeEnergyDamage:[self energy] * attenuation
|
||||
from:self
|
||||
becauseOf:[self owner]];
|
||||
|
||||
// FIXME: spawn an explosion particle.
|
||||
#if 0
|
||||
[self setVelocity:kZeroVector];
|
||||
[self setColor:[OOColor redColor]];
|
||||
[self setSize:NSMakeSize(64.0,64.0)];
|
||||
duration = 2.0;
|
||||
time_counter = 0.0;
|
||||
particle_type = PARTICLE_EXPLOSION;
|
||||
#else
|
||||
[UNIVERSE removeEntity:self];
|
||||
#endif
|
||||
|
||||
// Spawn a plasma burst.
|
||||
OOPlasmaBurstEntity *burst = [[OOPlasmaBurstEntity alloc] initWithPosition:[self position]];
|
||||
[UNIVERSE addEntity:burst];
|
||||
[burst release];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,6 @@ MA 02110-1301, USA.
|
||||
|
||||
|
||||
/* Entities that can easily be migrated to OOLightParticleEntity:
|
||||
PARTICLE_EXPLOSION
|
||||
PARTICLE_FLASH
|
||||
*/
|
||||
|
||||
@ -45,7 +44,6 @@ MA 02110-1301, USA.
|
||||
typedef enum
|
||||
{
|
||||
PARTICLE_LASER_BEAM = 160,
|
||||
PARTICLE_EXPLOSION = 201,
|
||||
PARTICLE_FLASH = 230,
|
||||
PARTICLE_FRAGBURST = 250,
|
||||
PARTICLE_BURST2 = 270,
|
||||
@ -57,9 +55,7 @@ typedef enum
|
||||
|
||||
@interface ParticleEntity (OOPrivate)
|
||||
|
||||
- (void) updateExplosion:(double) delta_t;
|
||||
- (void) updateEnergyMine:(double) delta_t;
|
||||
- (void) updateShot:(double) delta_t;
|
||||
- (void) updateSpark:(double) delta_t;
|
||||
- (void) updateLaser:(double) delta_t;
|
||||
- (void) updateHyperring:(double) delta_t;
|
||||
@ -499,7 +495,6 @@ FAIL:
|
||||
{
|
||||
#define CASE(x) case x: type_string = @#x; break;
|
||||
CASE(PARTICLE_LASER_BEAM);
|
||||
CASE(PARTICLE_EXPLOSION);
|
||||
CASE(PARTICLE_FLASH);
|
||||
CASE(PARTICLE_FRAGBURST);
|
||||
CASE(PARTICLE_BURST2);
|
||||
@ -605,7 +600,6 @@ FAIL:
|
||||
{
|
||||
switch ([self particleType])
|
||||
{
|
||||
case PARTICLE_EXPLOSION:
|
||||
case PARTICLE_FRAGBURST:
|
||||
case PARTICLE_BURST2:
|
||||
case PARTICLE_FLASH:
|
||||
@ -621,10 +615,6 @@ FAIL:
|
||||
}
|
||||
switch ([self particleType])
|
||||
{
|
||||
case PARTICLE_EXPLOSION:
|
||||
[self updateExplosion:delta_t];
|
||||
break;
|
||||
|
||||
case PARTICLE_HYPERRING:
|
||||
[self updateHyperring:delta_t];
|
||||
break;
|
||||
@ -661,16 +651,6 @@ FAIL:
|
||||
}
|
||||
|
||||
|
||||
- (void) updateExplosion:(double) delta_t
|
||||
{
|
||||
float diameter = (1.0 + time_counter)*64.0;
|
||||
[self setSize:NSMakeSize(diameter, diameter)];
|
||||
alpha = (duration - time_counter);
|
||||
if (time_counter > duration)
|
||||
[UNIVERSE removeEntity:self];
|
||||
}
|
||||
|
||||
|
||||
- (void) updateEnergyMine:(double) delta_t
|
||||
{
|
||||
// new billboard routine (working at last!)
|
||||
@ -718,37 +698,6 @@ FAIL:
|
||||
}
|
||||
|
||||
|
||||
- (void) updateShot:(double) delta_t
|
||||
{
|
||||
if ([collidingEntities count] > 0)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < [collidingEntities count]; i++)
|
||||
{
|
||||
Entity * e = (Entity *)[collidingEntities objectAtIndex:i];
|
||||
if (e != [self owner])
|
||||
{
|
||||
[e takeEnergyDamage:energy from:self becauseOf:[self owner]];
|
||||
velocity.x = 0.0;
|
||||
velocity.y = 0.0;
|
||||
velocity.z = 0.0;
|
||||
[self setColor:[OOColor redColor]];
|
||||
[self setSize:NSMakeSize(64.0,64.0)];
|
||||
duration = 2.0;
|
||||
time_counter = 0.0;
|
||||
particle_type = PARTICLE_EXPLOSION;
|
||||
}
|
||||
}
|
||||
}
|
||||
position.x += velocity.x * delta_t;
|
||||
position.y += velocity.y * delta_t;
|
||||
position.z += velocity.z * delta_t;
|
||||
alpha = (duration - time_counter);
|
||||
if (time_counter > duration)
|
||||
[UNIVERSE removeEntity:self];
|
||||
}
|
||||
|
||||
|
||||
- (void) updateSpark:(double) delta_t
|
||||
{
|
||||
position.x += velocity.x * delta_t;
|
||||
|
@ -374,7 +374,7 @@ static JSBool SystemInfoGetProperty(JSContext *context, JSObject *this, jsval na
|
||||
|
||||
if (value != nil)
|
||||
{
|
||||
if (OOIsNumberLiteral(value, YES))
|
||||
if ([value isKindOfClass:[NSNumber class]] || OOIsNumberLiteral(value, YES))
|
||||
{
|
||||
BOOL OK = JS_NewDoubleValue(context, [value doubleValue], outValue);
|
||||
if (!OK)
|
||||
|
Loading…
x
Reference in New Issue
Block a user