Oolite
Loading...
Searching...
No Matches
ShipEntity.m File Reference
import "ShipEntity.h"
import "ShipEntityAI.h"
import "ShipEntityScriptMethods.h"
import "OOMaths.h"
import "OOOpenGLExtensionManager.h"
import "OOShaderMaterial.h"
import "Universe.h"
import "AI.h"
import "GameController.h"
import "MyOpenGLView.h"
import "NSScannerOOExtensions.h"
import "OOCharacter.h"
import "OOCollectionExtractors.h"
import "OOConstToJSString.h"
import "OOConstToString.h"
import "OOExcludeObjectEnumerator.h"
import "OOFilteringEnumerator.h"
import "OORoleSet.h"
import "OOShipGroup.h"
import "OOStringExpander.h"
import "OOStringParsing.h"
import "OOSystemDescriptionManager.h"
import "OOWeakSet.h"
import "ResourceManager.h"
import "OOMesh.h"
import "OOPlanetDrawable.h"
import "OOColor.h"
import "OOPolygonSprite.h"
import "Octree.h"
import "DockEntity.h"
import "OOECMBlastEntity.h"
import "OOExhaustPlumeEntity.h"
import "OOExplosionCloudEntity.h"
import "OOFlashEffectEntity.h"
import "OOFlasherEntity.h"
import "OOLaserShotEntity.h"
import "OOParticleSystem.h"
import "OOPlanetEntity.h"
import "OOPlasmaShotEntity.h"
import "OOQuiriumCascadeEntity.h"
import "OORingEffectEntity.h"
import "OOSparkEntity.h"
import "OOSunEntity.h"
import "PlanetEntity.h"
import "PlayerEntity.h"
import "ProxyPlayerEntity.h"
import "StationEntity.h"
import "WormholeEntity.h"
import "GuiDisplayGen.h"
import "HeadUpDisplay.h"
import "OOEntityFilterPredicate.h"
import "OOEquipmentType.h"
import "OOShipRegistry.h"
import "PlayerEntityLegacyScriptEngine.h"
import "PlayerEntitySound.h"
import "OODebugFlags.h"
import "OODebugGLDrawing.h"
import "OODebugStandards.h"
import "OOJSEngineTimeManagement.h"
import "OOJSScript.h"
import "OOJSVector.h"
Include dependency graph for ShipEntity.m:

Go to the source code of this file.

Classes

category  ShipEntity(Private)

Macros

#define USEMASC   1
#define kMassCharge   0.65
#define kBaseCharge   (1.0 - kMassCharge)
#define kBoulderRole   (@"boulder")
#define MAKE_VECTOR_ARRAY(v)

Functions

static GLfloat calcFuelChargeRate (GLfloat myMass)
static ShipEntity * doOctreesCollide (ShipEntity *prime, ShipEntity *other)
NSDictionary * OODefaultShipShaderMacros (void)
BOOL OOUniformBindingPermitted (NSString *propertyName, id bindingTarget)
GLfloat getWeaponRangeFromType (OOWeaponType weapon_type)
BOOL isWeaponNone (OOWeaponType weapon)

Variables

static NSString *const kOOLogSyntaxAddShips = @"script.debug.syntax.addShips"
static GLfloat cargo_color [4] = { 0.9, 0.9, 0.9, 1.0 }
static GLfloat hostile_color [4] = { 1.0, 0.25, 0.0, 1.0 }
static GLfloat neutral_color [4] = { 1.0, 1.0, 0.0, 1.0 }
static GLfloat friendly_color [4] = { 0.0, 1.0, 0.0, 1.0 }
static GLfloat missile_color [4] = { 0.0, 1.0, 1.0, 1.0 }
static GLfloat police_color1 [4] = { 0.5, 0.0, 1.0, 1.0 }
static GLfloat police_color2 [4] = { 1.0, 0.0, 0.5, 1.0 }
static GLfloat jammed_color [4] = { 0.0, 0.0, 0.0, 0.0 }
static GLfloat mascem_color1 [4] = { 0.3, 0.3, 0.3, 1.0 }
static GLfloat mascem_color2 [4] = { 0.4, 0.1, 0.4, 1.0 }
static GLfloat scripted_color [4] = { 0.0, 0.0, 0.0, 0.0 }

Macro Definition Documentation

◆ kBaseCharge

#define kBaseCharge   (1.0 - kMassCharge)

Referenced by calcFuelChargeRate().

◆ kBoulderRole

#define kBoulderRole   (@"boulder")

Definition at line 1502 of file ShipEntity.m.

◆ kMassCharge

#define kMassCharge   0.65

Referenced by calcFuelChargeRate().

◆ MAKE_VECTOR_ARRAY

#define MAKE_VECTOR_ARRAY ( v)
Value:
[[[OONativeVector alloc] initWithVector:v] autorelease]
#define MAKE_VECTOR_ARRAY(v)

Definition at line 1795 of file ShipEntity.m.

◆ USEMASC

#define USEMASC   1

Definition at line 96 of file ShipEntity.m.

Function Documentation

◆ calcFuelChargeRate()

GLfloat calcFuelChargeRate ( GLfloat myMass)
static

Definition at line 104 of file ShipEntity.m.

105{
106#define kMassCharge 0.65 // the closer to 1 this number is, the more the fuel price changes from ship to ship.
107#define kBaseCharge (1.0 - kMassCharge) // proportion of price that doesn't change with ship's mass.
108
109 GLfloat baseMass = [PLAYER baseMass];
110 // if anything is wrong, use 1 (the default charge rate).
111 if (myMass <= 0.0 || baseMass <= 0.0)
112 return 1.0;
113
114 GLfloat result = (kMassCharge * myMass / baseMass) + kBaseCharge;
115
116 // round the result to the second decimal digit.
117 result = roundf(result * 100.0f) / 100.0f;
118
119 // Make sure that the rate is clamped to between three times and a third of the standard charge rate.
120 if (result > 3.0f)
121 result = 3.0f;
122 else if (result < 0.33f)
123 result = 0.33f;
124
125 return result;
126
127#undef kMassCharge
128#undef kBaseCharge
129}
#define kMassCharge
#define kBaseCharge

References kBaseCharge, and kMassCharge.

Referenced by ShipEntity::fuelChargeRate.

Here is the caller graph for this function:

◆ doOctreesCollide()

ShipEntity * doOctreesCollide ( ShipEntity * prime,
ShipEntity * other )
static

Referenced by ShipEntity::checkCloseCollisionWith:, and ShipEntity::doOctreesCollide.

Here is the caller graph for this function:

◆ getWeaponRangeFromType()

GLfloat getWeaponRangeFromType ( OOWeaponType weapon_type)

Definition at line 13056 of file ShipEntity.m.

13057{
13058 return [weapon_type weaponRange];
13059}

References OOEquipmentType::weaponRange.

Referenced by ShipEntity::behaviour_attack_broadside_target:leftside:, ShipEntity::behaviour_attack_target:, and ShipEntity::setWeaponDataFromType:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isWeaponNone()

BOOL isWeaponNone ( OOWeaponType weapon)

◆ OODefaultShipShaderMacros()

NSDictionary * OODefaultShipShaderMacros ( void )

Definition at line 13009 of file ShipEntity.m.

13010{
13011 static NSDictionary* macros = nil;
13012
13013 if (macros == nil) {
13014 macros = [[[ResourceManager materialDefaults] oo_dictionaryForKey:@"ship-prefix-macros" defaultValue:[NSDictionary dictionary]] retain];
13015 }
13016
13017 return macros;
13018}

References ResourceManager::materialDefaults, and nil.

Here is the call graph for this function:

◆ OOUniformBindingPermitted()

BOOL OOUniformBindingPermitted ( NSString * propertyName,
id bindingTarget )

Definition at line 13021 of file ShipEntity.m.

13022{
13023 static NSSet* entityWhitelist = nil;
13024 static NSSet* shipWhitelist = nil;
13025 static NSSet* playerShipWhitelist = nil;
13026 static NSSet* visualEffectWhitelist = nil;
13027
13028 if (entityWhitelist == nil) {
13029 NSDictionary* wlDict = [ResourceManager whitelistDictionary];
13030 entityWhitelist = [[NSSet alloc] initWithArray:[wlDict oo_arrayForKey:@"shader_entity_binding_methods"]];
13031 shipWhitelist = [[NSSet alloc] initWithArray:[wlDict oo_arrayForKey:@"shader_ship_binding_methods"]];
13032 playerShipWhitelist = [[NSSet alloc] initWithArray:[wlDict oo_arrayForKey:@"shader_player_ship_binding_methods"]];
13033 visualEffectWhitelist = [[NSSet alloc] initWithArray:[wlDict oo_arrayForKey:@"shader_visual_effect_binding_methods"]];
13034 }
13035
13036 if ([bindingTarget isKindOfClass:[Entity class]]) {
13037 if ([entityWhitelist containsObject:propertyName])
13038 return YES;
13039 if ([bindingTarget isShip]) {
13040 if ([shipWhitelist containsObject:propertyName])
13041 return YES;
13042 }
13043 if ([bindingTarget isPlayerLikeShip]) {
13044 if ([playerShipWhitelist containsObject:propertyName])
13045 return YES;
13046 }
13047 if ([bindingTarget isVisualEffect]) {
13048 if ([visualEffectWhitelist containsObject:propertyName])
13049 return YES;
13050 }
13051 }
13052
13053 return NO;
13054}

References nil, and ResourceManager::whitelistDictionary.

Here is the call graph for this function:

Variable Documentation

◆ cargo_color

GLfloat cargo_color[4] = { 0.9, 0.9, 0.9, 1.0 }
static

◆ friendly_color

GLfloat friendly_color[4] = { 0.0, 1.0, 0.0, 1.0 }
static

◆ hostile_color

GLfloat hostile_color[4] = { 1.0, 0.25, 0.0, 1.0 }
static

◆ jammed_color

GLfloat jammed_color[4] = { 0.0, 0.0, 0.0, 0.0 }
static

◆ kOOLogSyntaxAddShips

NSString* const kOOLogSyntaxAddShips = @"script.debug.syntax.addShips"
static

Definition at line 98 of file ShipEntity.m.

◆ mascem_color1

GLfloat mascem_color1[4] = { 0.3, 0.3, 0.3, 1.0 }
static

◆ mascem_color2

GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0 }
static

◆ missile_color

GLfloat missile_color[4] = { 0.0, 1.0, 1.0, 1.0 }
static

◆ neutral_color

GLfloat neutral_color[4] = { 1.0, 1.0, 0.0, 1.0 }
static

◆ police_color1

GLfloat police_color1[4] = { 0.5, 0.0, 1.0, 1.0 }
static

◆ police_color2

GLfloat police_color2[4] = { 1.0, 0.0, 0.5, 1.0 }
static

◆ scripted_color

GLfloat scripted_color[4] = { 0.0, 0.0, 0.0, 0.0 }
static

Definition at line 5599 of file ShipEntity.m.

5599{ 0.0, 0.0, 0.0, 0.0 }; // to be defined by script