var unloadCarButton = { components: [
	{
		c: TransformComponent,
		d: {
			x: 0,
			y: -0.2,
			scaleX: 0.5,
			scaleY: 0.5,
			ignoreParentRotation: true,
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			allowRotation: false,
			isKinematic: false,
			isSensor: true,
		}
	},
	{
		c: ClickableComponent,
		d: {
			animateOnHover: true
		}
	},
	{
		c: TweenerComponent,
		d: {
			duration: 0.15,
			component: "TransformComponent",
			field: "simpleLocalScale",
			values: [0.6, 0.5],
			easing: EasingFunctions.easeInOut
		}
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_UI,
			senses: [CollisionCategoryDefinitions.CC_MOUSE],
			width: 1.2,
			height: 0.3,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			sheet: "ingame-ui",
			name: "button-car-exit",
		}
	},
	{
		c: PixelTextComponent,
		d: {
			text: "Exit car",
			spacing: -2,
			fontDefinition: {
				layer: LayerDefinitions.LAYER_IN_GAME_UI,
				sheet: "fontGreasyStroke",
				scale: 1 / 2,
			}
		}
	},
]};

var unloadSewerButton = { components: [
	{
		c: TransformComponent,
		d: {
			x: 0,
			y: -0.2,
			scaleX: 0.5,
			scaleY: 0.5,
			ignoreParentRotation: true,
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			allowRotation: false,
			isKinematic: false,
			isSensor: true,
		}
	},
	{
		c: ClickableComponent,
		d: {
			animateOnHover: true
		}
	},
	{
		c: TweenerComponent,
		d: {
			duration: 0.15,
			component: "TransformComponent",
			field: "simpleLocalScale",
			values: [0.6, 0.5],
			easing: EasingFunctions.easeInOut
		}
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_UI,
			senses: [CollisionCategoryDefinitions.CC_MOUSE],
			width: 1.2,
			height: 0.3,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			sheet: "ingame-ui",
			name: "button-lift",
		}
	},
	{
		c: PixelTextComponent,
		d: {
			text: "Exit lift",
			spacing: -2,
			fontDefinition: {
				layer: LayerDefinitions.LAYER_IN_GAME_UI,
				sheet: "fontGreasyStroke",
				scale: 1 / 2,
			}
		}
	},
]};

var getawayButton = { components: [
	{
		c: TransformComponent,
		d: {
			x: 0,
			y: 0.2,
			scaleX: 0.5,
			scaleY: 0.5,
			ignoreParentRotation: true,
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			allowRotation: false,
			isKinematic: false,
			isSensor: true,
			dynamicFriction: 0,
		}
	},
	{
		c: ClickableComponent,
		d: {
			animateOnHover: true,
		}
	},
	{
		c: ColliderComponent,
		d: {
			width: 1.2,
			height: 0.3,
			collisionGroup: CollisionCategoryDefinitions.CC_UI,
			senses: [CollisionCategoryDefinitions.CC_MOUSE],
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			sheet: "ingame-ui",
			name: "button-car-getaway",
		//	alpha: 0.5,
		}
	},
	{
		c: PixelTextComponent,
		d: {
			text: "Drive!",
			spacing: -2,
			fontDefinition: {
				layer: LayerDefinitions.LAYER_IN_GAME_UI,
				sheet: "fontGreasyStroke",
				scale: 3 / 4,
			}
		}
	},
	{
		c: TweenerComponent,
		d: {
			duration: 0.15,
			component: "TransformComponent",
			field: "simpleLocalScale",
			values: [0.6, 0.5],
			easing: EasingFunctions.easeInOut
		}
	},
]};

var getSewerButton = { components: [
	{
		c: TransformComponent,
		d: {
			x: 0,
			y: 0.2,
			scaleX: 0.5,
			scaleY: 0.5,
			ignoreParentRotation: true,
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			allowRotation: false,
			isKinematic: false,
			isSensor: true,
			dynamicFriction: 0,
		}
	},
	{
		c: ClickableComponent,
		d: {
			animateOnHover: true,
		}
	},
	{
		c: ColliderComponent,
		d: {
			width: 1.2,
			height: 0.3,
			collisionGroup: CollisionCategoryDefinitions.CC_UI,
			senses: [CollisionCategoryDefinitions.CC_MOUSE],
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			sheet: "ingame-ui",
			name: "button-lift-getaway",
		//	alpha: 0.5,
		}
	},
	{
		c: PixelTextComponent,
		d: {
			text: "Enter",
			spacing: -2,
			fontDefinition: {
				layer: LayerDefinitions.LAYER_IN_GAME_UI,
				sheet: "fontGreasyStroke",
				scale: 1 / 2,
			}
		}
	},
	{
		c: TweenerComponent,
		d: {
			duration: 0.15,
			component: "TransformComponent",
			field: "simpleLocalScale",
			values: [0.6, 0.5],
			easing: EasingFunctions.easeInOut
		}
	},
]};

var sewerExitButton = { extend: getSewerButton, components: [
	{
		c: PixelTextComponent,
		d: {
			text: "Exit Knox",
		}
	},	
]};

var carBaseLow = { components: [
	{
		c: TransformComponent
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith: [
			CollisionCategoryDefinitions.CC_CHARACTERS,
			CollisionCategoryDefinitions.CC_CHARACTER_CORE,
			CollisionCategoryDefinitions.CC_WALLS,
			CollisionCategoryDefinitions.CC_DOORS,
			CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
			CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY,
			CollisionCategoryDefinitions.CC_PLANNING_TARGET,
			CollisionCategoryDefinitions.CC_HOTSPOTS
			],
			senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET],
			width: 2,
			height: 4
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
]};

var carBaseLowTruck = { components: [
	{
		c: TransformComponent
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith: [
			CollisionCategoryDefinitions.CC_CHARACTERS,
			CollisionCategoryDefinitions.CC_CHARACTER_CORE,
			CollisionCategoryDefinitions.CC_WALLS,
			CollisionCategoryDefinitions.CC_DOORS,
			CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
			CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY,
			CollisionCategoryDefinitions.CC_PLANNING_TARGET,
			CollisionCategoryDefinitions.CC_HOTSPOTS
			],
			senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET],
			width: 2,
			height: 5
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
]};

var car = { components: [
	{
		c: TransformComponent
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith: [CollisionCategoryDefinitions.CC_CHARACTERS, CollisionCategoryDefinitions.CC_WALLS, CollisionCategoryDefinitions.CC_DOORS, CollisionCategoryDefinitions.CC_STATIC_OBSTACLE, CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE, CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY, CollisionCategoryDefinitions.CC_PLANNING_TARGET, CollisionCategoryDefinitions.CC_HOTSPOTS, CollisionCategoryDefinitions.CC_BULLETS, CollisionCategoryDefinitions.CC_VISION],
			senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET],
			width: 2,
			height: 2
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
	{
		c: InventoryComponent,
		d: {
			dropItemsToOriginalPosition: true,
			maxSize: 4,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "perpetrator",
		}
	},
	{
		c: CarComponent,
		d: {
			unloadButtonDefinition: unloadCarButton,
			getawayButtonDefinition: getawayButton,
		}
	},
	// So that npcs can see it and possibly engage
	{
		c: FieldOfViewMarkerComponent,
	},
	// So that we can see when inside the car
	{
		c: FogOfWarObserverComponent,
		d: {
			enabled: true,
		}
	},
	{
		c: FieldOfViewComponent,
		d: {
			enabled: false,
			fov: 360,
			radius: 16,
			nearRadius: 0,
			visionGroup: CollisionCategoryDefinitions.CC_VISION,
			obstructors: [CollisionCategoryDefinitions.CC_WALLS | CollisionCategoryDefinitions.CC_DOORS],
		}
	},
	{
		c: TeamComponent,
		d: {
			// Can switch to goons when there is a goon inside so that npcs
			// can engage it
			name: "civilians",
		}
	},
	{
		c: HealthBarComponent,
		d: {
			onlyDrawIfNotFull: true,
		}
	},
	{
		c: ActionableComponent,
		d: {
			actionDefinitions: [ActionDefinitions.getIn],
		}
	},
], children: [
	{ extend: hotspotBase, components: [
		{
			c: TransformComponent,
			d: {
				y: 0.75,
				x: 1.2,
			}
		},
		{
			c: ColliderComponent,
			d: {
				radius: 0.4
			}
		},
		{
			c: HotspotComponent,
			d: {
				// Right door, face left
				facing: -90
			}
		},
	]},
	{ extend: hotspotBase, components: [
		{
			c: TransformComponent,
			d: {
				y: 0.75,
				x: -1.2,
			}
		},
		{
			c: ColliderComponent,
			d: {
				radius: 0.4
			}
		},
		{
			c: HotspotComponent,
			d: {
				// Left door, face right
				facing: 90
			}
		},
	]},
	carBaseLow
]};

var sewerEntrance = { components: [
	{
		c: TransformComponent
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith: [CollisionCategoryDefinitions.CC_CHARACTERS, CollisionCategoryDefinitions.CC_WALLS, CollisionCategoryDefinitions.CC_DOORS, CollisionCategoryDefinitions.CC_STATIC_OBSTACLE, CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE, CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY, CollisionCategoryDefinitions.CC_PLANNING_TARGET, CollisionCategoryDefinitions.CC_HOTSPOTS, CollisionCategoryDefinitions.CC_BULLETS, CollisionCategoryDefinitions.CC_VISION],
			senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET],
			width: 1,
			height: 1
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
	{
		c: InventoryComponent,
		d: {
			dropItemsToOriginalPosition: true,
			maxSize: 4,
		}
	},
	/*
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "perpetrator",
		}
	},
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "carIdle",
		}
	},
	*/
	{
		c: CarComponent,
		d: {
			unloadButtonDefinition: unloadSewerButton,
			getawayButtonDefinition: getSewerButton,
		}
	},
	// So that npcs can see it and possibly engage
	{
		c: FieldOfViewMarkerComponent,
	},
	// So that we can see when inside the car
	{
		c: FogOfWarObserverComponent,
		d: {
			enabled: true,
		}
	},
	{
		c: FieldOfViewComponent,
		d: {
			enabled: false,
			fov: 360,
			radius: 16,
			nearRadius: 0,
			visionGroup: CollisionCategoryDefinitions.CC_VISION,
			obstructors: [CollisionCategoryDefinitions.CC_WALLS | CollisionCategoryDefinitions.CC_DOORS],
		}
	},
	{
		c: TeamComponent,
		d: {
			// Can switch to goons when there is a goon inside so that npcs
			// can engage it
			name: "civilians",
		}
	},
	{
		c: HealthBarComponent,
		d: {
			onlyDrawIfNotFull: true,
		}
	},
	{
		c: ActionableComponent,
		d: {
			actionDefinitions: [ActionDefinitions.getIn],
		}
	},
], children: [
	{ extend: hotspotBase, components: [
		{
			c: TransformComponent,
			d: {
				y: -0.6,
			//	x: 1.2,
			}
		},
		{
			c: ColliderComponent,
			d: {
				radius: 0.4
			}
		},
		{
			c: HotspotComponent,
			d: {
				facing: 0
			}
		},
	]},
//	carBaseLow
]};

var sewerExit = { extend: sewerEntrance, components: [
	{
		c: CarComponent,
		d: {
			unloadButtonDefinition: unloadSewerButton,
			getawayButtonDefinition: sewerExitButton,
		}
	},
]};

var carStatic = { components: [
	{
		c: TransformComponent
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith: [CollisionCategoryDefinitions.CC_CHARACTERS, CollisionCategoryDefinitions.CC_WALLS, CollisionCategoryDefinitions.CC_DOORS, CollisionCategoryDefinitions.CC_STATIC_OBSTACLE, CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE, CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY, CollisionCategoryDefinitions.CC_PLANNING_TARGET, CollisionCategoryDefinitions.CC_HOTSPOTS, CollisionCategoryDefinitions.CC_BULLETS, CollisionCategoryDefinitions.CC_VISION],
			senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET],
			width: 2,
			height: 2
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
	{
		c: InventoryComponent,
		d: {
			dropItemsToOriginalPosition: true
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "perpetrator",
		}
	},
	{
		c: HealthBarComponent,
		d: {
			onlyDrawIfNotFull: true,
		}
	},
], children: [
	carBaseLow
]};

var destroyedCarVan = { components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-dodgyVan",
			tint: 0x1b130f,
		}
	},
	{
		c: TransformComponent
	},
			], children: [
	explosionCar,
	carBaseLow
]};

var destroyedCarPolice = { components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-vigilant",
			tint: 0x1b130f,
		}
	},
	{
		c: TransformComponent
	},
	{
		c: ColliderComponent,
		d: {
			width: 2,
			height: 2,
			offsetY: -0.36
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
	], children: [
	explosionCar,
	carBaseLow
]};

var inactiveCarPolice = { extend: carStatic, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-vigilant",
		//	tint: 0x1b130f,
		}
	},
	{
		c: TransformComponent
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith:[
				CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
				CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY,
				CollisionCategoryDefinitions.CC_PLANNING_TARGET,
				CollisionCategoryDefinitions.CC_HOTSPOTS,
				CollisionCategoryDefinitions.CC_BULLETS,
				CollisionCategoryDefinitions.CC_VISION],
				senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET
			],
			width: 2,
			height: 2,
			offsetY: -0.36
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 30,
			maxHealth: 30,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["destroyedCarPolice"],
			},
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
]};

var carPerpetrator = { extend: car, components: [
	{
		c: SpriteComponent,
		d: {
			name: "perpetrator",
		}
	},
]};

var getAwayVehicleHelper = { components: [
	{
		c: TransformComponent,
		d: {
			scaleX: 1,
			scaleY: 1,
			ignoreParentRotation: true,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 60
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			sheet: "ingame-ui",
			name: "textHelperGetawayVehicle",
		}
	},
	{
		c: TweenerComponent,
		d: {
			component: "SpriteComponent",
			field: "alpha",
			duration: 0.3,
			values: [1.0, 0.4, 1.0, 0.4, 1.0, 0.4, 1.0, 0.4, 1.0, 0.4, 1.0, 0.4, 1.0, 0.4, 1.0, 0.0],
			repeat: false
		}
	}
]};

var carDodgyVan = { extend: car, components: [
	{
		c: SpriteComponent,
		d: {
			name: "car-dodgyVan",
		}
	},
	{
		c: ColliderComponent,
		d: {
			width: 2,
			height: 3.5,
			offsetY: -0.25
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 30,
			maxHealth: 30,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["destroyedCarVan"],
			},
		}
	},
	], children: [
	// Extra ways to get in to the van
	{ extend: hotspotBase, components: [
		{
			c: TransformComponent,
			d: {
				y: -2.2,
				x: 0,
			}
		},
		{
			c: ColliderComponent,
			d: {
				radius: 0.4
			}
		},
		{
			c: HotspotComponent,
			d: {
				// Back door, face up
				facing: 0
			}
		},
	]},
	{ extend: hotspotBase, components: [
		{
			c: TransformComponent,
			d: {
				y: 0,
				x: 1.2,
			}
		},
		{
			c: ColliderComponent,
			d: {
				radius: 0.4
			}
		},
		{
			c: HotspotComponent,
			d: {
				// Right side door, face left
				facing: -90
			}
		},
	]},
	headlightsYellow,
	headlightsYellowAtmosphere,
//	getAwayVehicleHelper,
]};

var carDodgyVanInactive = { extend: carStatic, components: [
	{
		c: SpriteComponent,
		d: {
			name: "car-dodgyVan",
		}
	},
	{
		c: ColliderComponent,
		d: {
			width: 2,
			height: 3.5,
			offsetY: -0.25
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 30,
			maxHealth: 30,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["destroyedCarVan"],
			},
		}
	},
	], children: [
	headlightsYellow,
	headlightsYellowAtmosphere,
//	getAwayVehicleHelper,
]};

var carGoldTruckLoad = { components: [
	{
		c: TransformComponent,
		d: {
			y: 1 / 128,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "knox",
			name: "car-gold-load",
		}
	},
]};

var carGoldTruck = { extend: car, components: [
	{
		c: InventoryComponent,
		d: {
			maxSize: 2,
			items: [
				"truckloadOfGold",
			]

		}
	},
	{
		c: CarComponent,
		d: {
			requiresAllGoons: true,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "knox",
			name: "car-gold",
		}
	},
	{
		c: ColliderComponent,
		d: {
			width: 2,
			height: 3.5,
			offsetY: -0.25
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 3000,
			maxHealth: 3000,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["destroyedCarVan"],
			},
		}
	},
], children: [
	carGoldTruckLoad,
]};

var dodgyDoorFrontLeftCircuit = { extend: areaCircuitSwitch, components: [
	{
		c: ColliderComponent,
		d: {
			radius: 0.4
		}
	},
	{
		c: CircuitComponent,
		d: {
			areaSwitchTriggerConditions: [
				{ component: "TeamComponent", field: "name", value: "goons" },
			],
			circuit: "dodgyDoorFrontLeft",
		}
	},
]};

var dodgyDoorFrontLeft = { components: [
	{
		c: TransformComponent,
		d: {
			x: 0,
			y: 0,
			scaleX: 1,
			scaleY: 1,
			zIndex: 4,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_FLOOR_OBJECTS,
			sheet: "cars",
			name: "car-dodgyVanDoorFR",
		}
	},
	{
		c: TweenerComponent,
		d: {
			component: "TransformComponent",
			field: "localRotation",
			duration: 0.1,
			values: [-Math.PI / 2, 1, 1, 1, 1, -Math.PI / 2],
			repeat: false
		}
	},
	{
		c: CircuitComponent,
		d: {
			toggleComponents: ["TweenerComponent"],
			circuit: "dodgyDoorFrontLeft",
		}
	},
]};

var dodgyDoorFrontLeftParent = { components: [
	{
		c: TransformComponent,
		d: {
			rotation: -Math.PI / 2,
		}
	},
], children: [
	dodgyDoorFrontLeft,
]};

var carPolice = { tag: "carPolice", extend: car, components: [
	{
		c: SpriteComponent,
		d: {
			name: "car-vigilant",
		}
	},
	{
		c: ColliderComponent,
		d: {
			width: 2,
			height: 2,
			offsetY: -0.36
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 30,
			maxHealth: 30,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["destroyedCarPolice"],
			},
		}
	},
], children: [
	lightCarPoliceBlue,
	lightCarPoliceRed,
	lightCarPoliceBlueBulb,
	lightCarPoliceRedBulb,
]};


var carZombiePolice = { tag: "carPolice", extend: car, components: [
	{
		c: SpriteComponent,
		d: {
			name: "car-vigilant-damaged",
		}
	},
	{
		c: ColliderComponent,
		d: {
			width: 2,
			height: 2,
			offsetY: -0.36
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 30,
			maxHealth: 30,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["destroyedCarPolice"],
			},
		}
	},
], children: [
	lightCarPoliceBlue,
	lightCarPoliceBlueBulb,
]};

//ARMORED VAN
var carArmoredVanDoor = { components: [
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["explosionShrapnelTrail"],
			total: 14,
			interval: 0.04,
			timeLeft: 0.09,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_FLOOR_OBJECTS,
			sheet: "cars",
			name: "car-armored-door",
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			density: 10,
			elasticity: 1,
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.3,
			collisionGroup: CollisionCategoryDefinitions.CC_BULLETS,
			collidesWith: [
				//CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DOORS,
				CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE
			],
		}
	},
]};

var carArmoredVanRearDestroyed = { components: [
	{
		c: TransformComponent
	},
		{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "cars",
			name: "car-armored-damage-rear",
			alpha: 0,
		}
	},
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["carArmoredVanDoor"],
			spawnDirections: [130, 157.5, 202.5, 230],
			total: 2,
			initialImpulse: 650,
			spawnsPerRound: 2,
			spawnOrder: SpawnOrder.RANDOM
		}
	},
	{
		c: TweenerComponent,
		d: {
			component: "SpriteComponent",
			field: "alpha",
			duration: 0.7,
			values: [0, 1],
		}
	},
	], children: [
	{ components: [
		{
			c: TransformComponent,
			d: {
			}
		},
		{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["lootableVanCash"],
			spawnDirections: [130, 157.5, 182.5, 210, 230],
			total: 5,
			initialImpulse: 0.03,
			spawnsPerRound: 5,
		//	spawnOrder: SpawnOrder.RANDOM
		}
	},
	]},
]};

var carArmoredVanGoods = { components: [
	{
		c: TransformComponent,
		d: {
			x: 0,
			y: -1.5,
		}
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith: [
				CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
				CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
				//CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY,
				//CollisionCategoryDefinitions.CC_PLANNING_TARGET,
				CollisionCategoryDefinitions.CC_BULLETS],
			senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET],
			width: 2.1,
			height: 1
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false,
		//	density: 1,
		}
	},
	{
		c: ActionableComponent,
		d: {
			actionDefinitions: [ActionDefinitions.attack, ActionDefinitions.shoot],
		}
	},
	{
		c: FieldOfViewMarkerComponent,
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 5,
			maxHealth: 5,
			minDamage: 5,
			spawnOnDamage: {
				base: ["fxHitElectric"],
			},
			spawnOnZeroHealth: {
				base: ["fxHitElectric"],
			},
			spawnAsBody: {
				base: ["carArmoredVanRearDestroyed"],
			},
		}
	},
]};

var carArmoredVan = { components: [
	{
		c: TransformComponent
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith:[
				CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
				CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY,
				CollisionCategoryDefinitions.CC_PLANNING_TARGET,
				CollisionCategoryDefinitions.CC_HOTSPOTS,
				CollisionCategoryDefinitions.CC_BULLETS,
				CollisionCategoryDefinitions.CC_VISION],
				senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET
			],
			width: 2,
			height: 3.5,
			offsetY: -0.25
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-armored",
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 100,
			maxHealth: 100,
			minDamage: 5,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["destroyedCarVan"],
			},
		}
	},
], children: [
	carBaseLow,
	carArmoredVanGoods
	//Shadow with black tint and alpha
]};
//ARMORED VAN END

//RECOLORABLE CAR
var carBeaterWindows = { components: [
	{
		c: TransformComponent
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-beater-windows",
		}
	},
]};

var carBeaterRear = { components: [
	{
		c: TransformComponent
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-beater-rear",
		}
	},
]};

var carBeaterFront = { components: [
	{
		c: TransformComponent
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-beater-front",
		}
	},
]};

var carBeater = { extend: carStatic, components: [
	{
		c: SpriteComponent,
		d: {
			name: "car-beater-body",
			tint: 0xc5b184,
		}
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith:[
				CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
				CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY,
				CollisionCategoryDefinitions.CC_PLANNING_TARGET,
				CollisionCategoryDefinitions.CC_HOTSPOTS,
				CollisionCategoryDefinitions.CC_BULLETS,
				CollisionCategoryDefinitions.CC_VISION],
				senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET
			],
			width: 2,
			height: 2,
			offsetY: -0.36
		}
	},
	{
		c: ColliderComponent,
		d: {
			width: 2,
			height: 2,
			offsetY: -0.36
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 30,
			maxHealth: 30,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["carBeaterDestroyed"],
			},
		}
	},
], children: [
	carBeaterWindows,
	carBeaterFront,
	carBeaterRear,
]};

var carBeaterWindowsDestroyed = { components: [
	{
		c: TransformComponent
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-beater-windows",
			tint: 0x1b130f,
		}
	},
]};

var carBeaterRearDestroyed = { components: [
	{
		c: TransformComponent
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-beater-rear",
			tint: 0x1b130f,
		}
	},
]};

var carBeaterFrontDestroyed = { components: [
	{
		c: TransformComponent
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-beater-front",
			tint: 0x1b130f,
		}
	},
]};

var carBeaterDestroyed = { components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "cars",
			name: "car-beater-body",
			tint: 0x1b130f,
		}
	},
	{
		c: TransformComponent
	},
	{
		c: ColliderComponent,
		d: {
			width: 2,
			height: 2,
			offsetY: -0.36
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
], children: [
	carBeaterWindowsDestroyed,
	carBeaterFrontDestroyed,
	carBeaterRearDestroyed,
	explosionCar,
	carBaseLow,
]};


//EL HOMBRE START
var elHombreTrunkOpen = { components: [
	{
		c: TransformComponent,
		d: {
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "cars",
			name: "elHombreTrunk",
			defaultAnimationName: "open",
			loop: false,
		}
	},
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["superFlyUnlock", "lootableTonOfCokeImpound", "lootableCocaineSmall"],
			spawnDirections: [130, 157.5, 182.5, 230],
			total: 3,
			initialImpulse: 0.01,
			spawnsPerRound: 4,
		//	spawnOrder: SpawnOrder.RANDOM
		}
	},
]};

var elHombreTrunk = { components: [
	{
		c: TransformComponent,
		d: {
			x: 0,
			y: -1.75,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "cars",
			name: "elHombreTrunk",
			defaultAnimationName: "closed",
			loop: false,
		}
	},
	{
		c: ActionableComponent,
		d: {
			actionDefinitions: [ActionDefinitions.attack, ActionDefinitions.shoot],
		}
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith:[
				CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
				CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY,
				CollisionCategoryDefinitions.CC_PLANNING_TARGET,
				CollisionCategoryDefinitions.CC_HOTSPOTS,
				CollisionCategoryDefinitions.CC_BULLETS,
				CollisionCategoryDefinitions.CC_VISION],
				senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET
			],
			width: 2,
			height: 0.8,
		//	offsetY: -0.36
		}
	},
	{
		c: FieldOfViewMarkerComponent,
	},
	// So that we can see when inside the car
	{
		c: FogOfWarObserverComponent,
		d: {
			enabled: true,
		}
	},
	{
		c: FieldOfViewComponent,
		d: {
			enabled: false,
			fov: 360,
			radius: 16,
			nearRadius: 0,
			visionGroup: CollisionCategoryDefinitions.CC_VISION,
			obstructors: [CollisionCategoryDefinitions.CC_WALLS | CollisionCategoryDefinitions.CC_DOORS],
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: false
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 3,
			maxHealth: 3,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["elHombreTrunkOpen"],
			},
		}
	},
]};

var carElHombreSpecial = { extend: carStatic, components: [
	{
		c: SpriteComponent,
		d: {
			name: "car-ElHombreSpecial",
			layer: LayerDefinitions.LAYER_FLOOR_OBJECTS,
		}
	},
	{
		c: ColliderComponent,
		d: {
			collisionGroup: CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
			collidesWith:[
				CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
				CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_AI_PATH_GENERATION_RAY,
				CollisionCategoryDefinitions.CC_PLANNING_TARGET,
				CollisionCategoryDefinitions.CC_HOTSPOTS,
				CollisionCategoryDefinitions.CC_BULLETS,
				CollisionCategoryDefinitions.CC_VISION],
				senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET
			],
			width: 1.95,
			height: 2.1,
			offsetY: -0.36
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 30,
			maxHealth: 30,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnOnZeroHealth: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["carBeaterDestroyed"],
			},
		}
	},
], children: [
	elHombreTrunk,
]};