// remember to define entities spawned by other entities before the spawners
var bulletHit = { components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "fx",
			name: "bullet",
			defaultAnimationName: "hit",
			loop: false,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 0.25
		}
	},
]};

var bulletDefinition = { components: [
	{
		c: TransformComponent,
	},
	{
		c: DamageComponent,
		d: {
			amount: 1,
			type: DamageType.bullet,
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.01,
			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
			],
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 5,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 0.5,
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 1,
			maxHealth: 1,
			spawnAsBody: {
				base: ["bulletHit"],
			},
			// We want hits to stay at the hit position
			dontCopyVelocitiesToBody: true,
		}
	},
	// always destroy on collision
	{
		c: CollisionDamageComponent,
		d: {
			amount: 1,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "fx",
			name: "bullet",
			defaultAnimationName: "idle",
			loop: false,
		}
	},
]};

var rubberBulletDefinition = { extend: bulletDefinition, components: [
	{
		c: DamageComponent,
		d: {
			amount: 100,
			type: DamageType.bullet,
		}
	},
]};

var tranqDart = { extend: bulletDefinition, components: [
	{
		c: DamageComponent,
		d: {
			amount: 4,
			unconsciousDuration: 240,
			type: DamageType.fist,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "fx",
			name: "tranqDart",
			defaultAnimationName: "idle",
			loop: false,
		}
	},
]};

var revolverBullet = { extend: bulletDefinition, components: [
	{
		c: DamageComponent,
		d: {
			amount: 4,
			type: DamageType.bullet,
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 20,
		}
	},
]};

var rifleBullet = { extend: bulletDefinition, components: [
	{
		c: DamageComponent,
		d: {
			amount: 3,
			type: DamageType.bullet,
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 8,
		}
	},
]};

var explosionShrapnelTrail = { components: [
	{
		c: TransformComponent,
		d: {
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_FLOOR_OBJECTS,
			sheet: "fxExplosionBig",
			name: "explosionBig",
			loop: false,
			fps: 60,
			scale: 2,
			tint: 0x242424,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 2,
		}
	},
	{
		c: TweenerComponent,
		d: {
			enabled: true,
			component: "SpriteComponent",
			field: "scale",
			duration: 0.5,
			values: [1, 2],
		}
	},
]};

var explosionShrapnelHuge = { components: [
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 12,
			elasticity: 1,
		}
	},
	{
		c: DamageComponent,
		d: {
			amount: 5,
			type: DamageType.explosion,
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.4,
			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
			],
		}
	},
	{
		c: DistanceDestroyerComponent,
		d: {
			distance: 1.2,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 1,
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 2,
			maxHealth: 2,
			// We want hits to stay at the hit position
			dontCopyVelocitiesToBody: true,
		}
	},
]};

var explosionShrapnelBig = { components: [
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["explosionShrapnelTrail"],
			total: 14,
			interval: 0.04,
			timeLeft: 0.09,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "fxExplosionBig",
			name: "explosionBig",
			loop: false,
			fps: 60,
			scale: 1,
			enabled: false,
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 40,
			elasticity: 1,
		}
	},
	{
		c: DamageComponent,
		d: {
			amount: 0.9,
			type: DamageType.bullet,
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.1,
			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
			],
		}
	},
	{
		c: DistanceDestroyerComponent,
		d: {
			distance: 6,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 1.5,
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 2,
			maxHealth: 2,
			// We want hits to stay at the hit position
			dontCopyVelocitiesToBody: true,
		}
	},
]};

var explosionShrapnelSmall = { components: [
	/*
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "fx",
			name: "bullet",
			defaultAnimationName: "idle",
			loop: false,
			alpha: 0.1
		}
	},
	*/
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 40,
			elasticity: 1,
		}
	},
	{
		c: DamageComponent,
		d: {
			amount: 0.6,
			type: DamageType.bullet,
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.1,
			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
			],
		}
	},
	{
		c: DistanceDestroyerComponent,
		d: {
			distance: 5,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 1,
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 3,
			maxHealth: 3,
			// We want hits to stay at the hit position
			dontCopyVelocitiesToBody: true,
		}
	},
]};

var muzzleFlash = { extend: lightMedium, components: [
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 3/30,
		}
	},
	{
		c: TweenerComponent,
		d: {
			enabled: true,
			component: "SpriteComponent",
			field: "alpha",
			duration: 3/30,
			values: [1.0, 0],
		}
	},
	{
		c: CameraShakerComponent,
		d: {
			duration: 0.15,
			magnitude: 0.02,
			useUnadjustedFrameTime: true,
		}
	}
]};

var muzzleFlashShogtun = { extend: lightMedium, components: [
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 3/30,
		}
	},
	{
		c: TweenerComponent,
		d: {
			enabled: true,
			component: "SpriteComponent",
			field: "alpha",
			duration: 3/30,
			values: [1.0, 0],
		}
	},
	{
		c: CameraShakerComponent,
		d: {
			duration: 0.2,
			magnitude: 0.15,
			useUnadjustedFrameTime: true,
		}
	}
]};

var shellDropBrassSFX = { components: [
	{
		c: TransformComponent,
		d: {
		}
	},
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "shellDropBrass",
		}
	},
]};

var ejectedShell = { extend: lightObstacleBase, components: [
	{
		c: ColliderComponent,
		d: {
			radius: 0.05
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_FLOOR_OBJECTS,
			sheet: "fx",
			name: "shell9mm",
			loop: false,
		}
	},
	{
		c: TweenerComponent,
		d: {
			enabled: true,
			component: "SpriteComponent",
			field: "scale",
			duration: 0.2,
			values: [1.0, 1.6, 1, 1.3, 1],
		}
	},
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["shellDropBrassSFX"],
			timeLeft: 0.4,
		}
	},
	/*
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 15,
		}
	},
	*/
]};

var ejectedShellShotgun = { extend: lightObstacleBase, components: [
	{
		c: ColliderComponent,
		d: {
			radius: 0.05
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_FLOOR_OBJECTS,
			sheet: "fx",
			name: "shellShotgun",
			loop: false,
		}
	},
	{
		c: TweenerComponent,
		d: {
			enabled: true,
			component: "SpriteComponent",
			field: "scale",
			duration: 0.2,
			values: [1.0, 1.6, 1, 1.3, 1],
		}
	},
	/*
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 15,
		}
	},
	*/
]};

var outOfAmmo = { components: [
	{
		c: TransformComponent,
		d: {
			ignoreParentRotation: true,
		}
	},
	{
		c: PixelTextComponent,
		d: {
			text: "$outOfAmmo",
			align: TextAlign.center,
			spacing: -1,
			spaceWidth: 3,
			fontDefinition: {
				layer: LayerDefinitions.LAYER_IN_GAME_UI,
				sheet: "fontGreasyStroke",
				scale: 1 / 3,
				tint: 0xe0b86c
			}
		}
	},
	{
		c: TweenerComponent,
		d: {
			component: "PixelTextComponent",
			field: "alpha",
			duration: 1,
			values: [1.0, 0],
			repeat: false,
			useUnadjustedFrameTime: true,
		}
	},
]};

var outOfAmmoNull = { components: [
	{
		c: TransformComponent,
		d: {
		}
	},
], children: [
	outOfAmmo
]};

var gunBase = { components: [
	{
		c: WeaponComponent,
		d: {
			maxRange: 10,
			maxAngle: 5,
			randomAngle: 8,
			minRandomAngle: 1,
			projectile: bulletDefinition,
			effect: muzzleFlash,
			impulse: 5,
			interval: 0.3,
			aimAnimation: "aim",
			firingSoundClipName: "gunshot",
			attackAnimations: ["shoot"],
			outOfAmmoEffect: outOfAmmoNull,
			// See WeaponComponent.hx for details
			ejectedShell: ejectedShell,
			shellImpulse: 0.0002,
			shellImpulseRandom: 4.0,
			shellAngularImpulse: 0.3,
			shellAngularImpulseRandom: 0.5,
			shellAngle: Math.PI / 2,
			shellAngleRandom: 0.2,
			ammoType: "pistolAmmo"

		}
	},
	{
		c: TransformComponent,
		d: {
			x: 0,
			y: 0.5 * 1 // make sure we shoot outside the shooting character's collider
		}
	},
]};

var uzi = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 4,
			randomAngle: 11,
			interval: 0.1,
			ammoType: "uziAmmo"
		}
	},
]};

var NPCUzi = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 4,
			randomAngle: 11,
			interval: 0.1,
			ammoType: "uziAmmo",
		//	minAimTime: 0.5,
		}
	},
]};

var toyPistol = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 2,
			randomAngle: 11,
			interval: 1,
			ammoType: "toyAmmo"
		}
	},
]};

var tutorialPistol = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 2,
			randomAngle: 11,
		}
	},
]};

var rubberPistol = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 2,
			randomAngle: 11,
			interval: 3600,
		}
	},
]};

var policeStandardIssueHandgun = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 2,
			randomAngle: 5,
			interval: 0.6,
			// Make the police less sneaky sharpshooters and allow player some
			// time to react before firing
			minAimTime: 0.2,
		}
	},
]};

var shotgun = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxRange: 8,
			maxAngle: 10,
			randomAngle: 30,
			projectilesPerShot: 15,
			ejectedShell: ejectedShellShotgun,
			effect: muzzleFlashShogtun,
			ejectedShellsPerShot: 2,
			impulse: 2.5,
			interval: 1.5,
			firingSoundClipName: "shotgunShot",
			ammoType: "shotgunAmmo"
		}
	},
]};

var python = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxRange: 8,
			maxAngle: 10,
			randomAngle: 10,
			projectile: revolverBullet,
			projectilesPerShot: 1,
			effect: muzzleFlashShogtun,
			ejectedShellsPerShot: 0,
			impulse: 20,
			interval: 1,
			firingSoundClipName: "revolverShot",
			ammoType: "revolverAmmo"
		}
	},
]};

var silencedPistol = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 3,
			randomAngle: 7,
			interval: 1,
			firingSoundClipName: "silencedGunshot",
		}
	},
]};

var tranqGun = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 3,
			randomAngle: 7,
			projectile: tranqDart,
			impulse: 3,
			interval: 3,
			firingSoundClipName: "tranqGunshot",
			ammoType: "tranqDarts"
		}
	},
]};

var sniperRifle = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxRange: 34,
			maxAngle: 0.5,
			randomAngle: 0,
			projectile: rifleBullet,
			impulse: 6,
			interval: 3,
			firingSoundClipName: "rifleShot",
			ammoType: "rifleAmmo"
		}
	},
]};

var meleeHitBase = { components: [
	{
		c: TransformComponent,
	},
	{
		c: DamageComponent,
		d: {
			amount: 0.5,
			unconsciousDuration: 100,
			type: DamageType.fist,
		}
	}, {
		c: ColliderComponent,
		d: {
			width: 0.24,
			height: 0.05,
			collisionGroup: CollisionCategoryDefinitions.CC_BULLETS,
			collidesWith: [
				CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_STATIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DYNAMIC_OBSTACLE,
				CollisionCategoryDefinitions.CC_DOORS
			],
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 0.5,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 1,
		}
	},
	{
		c: DistanceDestroyerComponent,
		d: {
			distance: 0.9,
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 1,
			maxHealth: 1,
		}
	},
	// always destroy on collision
	{
		c: CollisionDamageComponent,
		d: {
			amount: 1,
		}
	},
]};

var fistHit = { extend: meleeHitBase, components: [
	{
		c: DamageComponent,
		d: {
			unconsciousDuration: 100,
			amount: 0.7,
		}
	},
]};

var brassKnucklesHit = { extend: meleeHitBase, components: [
	{
		c: DamageComponent,
		d: {
			amount: 1.2,
			unconsciousDuration: 150,
		}
	},
]};

var nightstickHit = { extend: meleeHitBase, components: [
	{
		c: DamageComponent,
		d: {
			amount: 2,
			unconsciousDuration: 150,
			type: DamageType.blunt,
		}
	},
]};

var metalDrillHit = { extend: meleeHitBase, components: [
	{
		c: DamageComponent,
		d: {
			amount: 0.1,
			unconsciousDuration: 150,
			type: DamageType.drill,
		}
	},
]};

var meleeWeaponBase = { components: [
	{
		c: WeaponComponent,
		d: {
			maxRange: 0.85,
			maxAngle: 15,
			unconsciousDuration: 100,
			damage: 0.7,
			damageType: DamageType.fist,
			impulse: 0,
			interval: 1,
			attackAnimations: ["melee"],
			aimAnimation: "idle",
			firingSoundClipName: "nightstickHit",
		}
	},
	{
		c: TransformComponent,
		d: {
			x: 0,
			y: 0.28 // make sure we shoot outside the shooting character's collider
		}
	},
]};

var fist = { extend: meleeWeaponBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 15,
			impulse: 1,
			damage: 0.7,
			damageType: DamageType.fist,
			unconsciousDuration: 100,
			interval: 0.6,
			attackAnimations: ["melee", "melee", "kick", "meleeLeft", "meleeLeft"],
			firingSoundClipName: "nightstickHit",
		}
	},
]};

var nightstick = { extend: meleeWeaponBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 20,
			damage: 2,
			unconsciousDuration: 150,
			damageType: DamageType.blunt,
			impulse: 7,
			interval: 1,
			attackAnimations: ["nightStick"],
			firingSoundClipName: "nightstickHit",
		}
	},
]};

var brassKnuckles = { extend: meleeWeaponBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 20,
			damage: 1.2,
			unconsciousDuration: 150,
			damageType: DamageType.fist,
			impulse: 1.5,
			interval: 0.6,
			attackAnimations: ["melee"],
			firingSoundClipName: "nightstickHit",
		}
	},
]};

var metalDrill = { extend: meleeWeaponBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 20,
			damage: 0.2,
			damageType: DamageType.drill,
			impulse: 1,
			interval: 0.12,
			attackAnimations: ["shoot"],
			firingSoundClipName: "drillEnd",
		}
	},
]};

var glassCutter = { extend: meleeWeaponBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxAngle: 20,
			impulse: 10,
			interval: 1,
			attackAnimations: ["melee"],
			firingSoundClipName: "nightstickHit",
		//	ammoType: "glassCutter",
		}
	},
]};

var fistItem = { components: [
	{
		c: ItemComponent,
		d: {
			name: "fist",
			type: "melee",
			lootable: false,
			equippedDefinition: "fist",
			equippable: true,
			equipByDefault: true,
			equipSlot: EquipmentSlot.rightHand,
			inventorySpriteName: "ui-base-icon-fist",
			stackable: false
		}
	},
]};

var stickItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "stick",
			type: "melee",
			suspiciousness: 5.0,
			lootable: false,
			equippedDefinition: "nightstick",
			equippable: true,
			equipByDefault: true,
			equipSlot: EquipmentSlot.rightHand,
			inventorySpriteName: "ui-base-icon-fist",
			stackable: false
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableCrowbarA"
		}
	},
]};

var brassKnucklesItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "knuckles",
			type: "melee",
		//	suspiciousness: 5.0,
			lootable: true,
			equippedDefinition: "brassKnuckles",
			equippable: true,
		//	equipByDefault: false,
			equipSlot: EquipmentSlot.rightHand,
			inventorySpriteName: "ui-base-icon-brassKnuckles",
			stackable: false
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableBrassKnuckles"
		}
	},
]};

var metalDrillItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "safecracker",
			type: "drill",
			lootable: true,
			equippedDefinition: "metalDrill",
			equippable: true,
			animationPrefix: "drill",
			equipSlot: EquipmentSlot.rightHand,
			inventorySpriteName: "ui-base-icon-drill",
			stackable: false
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableDrill"
		}
	},
]};

var glassCutterItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "glassCutter",
			type: "glassCutter",
		//	suspiciousness: 5.0,
			lootable: true,
			equippedDefinition: "glassCutter",
			equippable: true,
		//	equipByDefault: false,
			equipSlot: EquipmentSlot.rightHand,
			inventorySpriteName: "ui-base-icon-brassKnuckles",
			amount: 1,
			stackable: true,
			maxStack: 10,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableBrassKnuckles"
		}
	},
]};

var toyPistolItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "toyPistol",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: true,
			equippedDefinition: "toyPistol",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			animationPrefix: "toyPistol",
			inventorySpriteName: "ui-base-icon-handgun",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getGun",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunToy",
		}
	},
]};

var tutorialPistolItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "rustyPistol",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: true,
			equippedDefinition: "tutorialPistol",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			animationPrefix: "pistol",
			inventorySpriteName: "ui-base-icon-handgun",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getGun",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunA",
		}
	},
]};

var oldPistolItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "oldPistol",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: true,
			equippedDefinition: "gunBase",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			animationPrefix: "pistol",
			inventorySpriteName: "ui-base-icon-handgun",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getGun",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunA",
		}
	},
]};

var uziItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "SMG",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: true,
			equippedDefinition: "uzi",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			animationPrefix: "smg",
			inventorySpriteName: "ui-base-icon-uzi",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getUzi",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableUzi",
		}
	},
]};

var unpickableUziItem = { extend: uziItem, components: [
	{
		c: ItemComponent,
		d: {
			equippedDefinition: "NPCUzi",
			equipByDefault: true,
			lootable: false,
		}
	},
]};

// Found in a pick up place(such as in hideout). Is removed if "UziUnlock" is NOT unlocked yet.
var uziUnlockedPickup = { extend: uziItem, components: [
	{
		c: UnlockTargetComponent,
		d: {
			name: "UziUnlock",
		}
	},
]};

// Found on a level. If player leaves level with this item, the target "UziUnlock" will be unlocked.
var uziUnlocker = { extend: uziItem, components: [
	{
		c: UnlockComponent,
		d: {
			target: "UziUnlock",
		}
	},
]};

var standardIssueHandgunItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "policePistol",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: false,
			equippedDefinition: "policeStandardIssueHandgun",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			animationPrefix: "pistol",
			equipByDefault: true,
			inventorySpriteName: "ui-base-icon-handgun",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getGun",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunA"
		}
	},
]};

var silencedPistolItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "silencedPistol",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: true,
			equippedDefinition: "silencedPistol",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			animationPrefix: "silencedPistol",
			inventorySpriteName: "ui-base-icon-silenced",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getGun",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunASilenced",
		}
	},
]};

// Found in a pick up place(such as in hideout). Is removed if "UziUnlock" is NOT unlocked yet.
var silencedPistolUnlockedPickup = { extend: silencedPistolItem, components: [
	{
		c: UnlockTargetComponent,
		d: {
			name: "SilencedPistolUnlock",
		}
	},
]};

// Found on a level. If player leaves level with this item, the target "UziUnlock" will be unlocked.
var silencedPistolUnlocker = { extend: silencedPistolItem, components: [
	{
		c: UnlockComponent,
		d: {
			target: "SilencedPistolUnlock",
		}
	},
]};

var tranqGunItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "tranquilizer",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: true,
			equippedDefinition: "tranqGun",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			animationPrefix: "tranqGun",
			inventorySpriteName: "ui-base-icon-tranqGun",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getGun",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableTranqGun",
		}
	},
]};

var sniperRifleItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "sniper",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: true,
			equippedDefinition: "sniperRifle",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			inventorySpriteName: "ui-base-icon-sniper",
			animationPrefix: "sniper",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getGun",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableSniper",
		}
	},
]};

// Found on a level. If player leaves level with this item, the target "UziUnlock" will be unlocked.
var sniperUnlocker = { extend: sniperRifleItem, components: [
	{
		c: UnlockComponent,
		d: {
			target: "SniperUnlock",
		}
	},
]};

var pickableShotgun = { name: "pickableShotgun", extend: userPickableItemBase, components: [
	/*
	{
		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],
			senses: [CollisionCategoryDefinitions.CC_PLANNING_TARGET],
			radius: 0.15
		}
	},
	*/
	/*{
		c: RigidBodyComponent,
		d: {
			// Keep shotgun firmly in it's place
			isDynamic: false
		}
	},*/
	{
		c: ItemComponent,
		d: {
			name: "shotgun",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: true,
			equippedDefinition: "shotgun",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			animationPrefix: "shotgun",
			inventorySpriteName: "ui-base-icon-shotgun",
			stackable: false
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableShotgunA",
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getShotgun",
		}
	},
]};

var unPickableShotgun = { extend: pickableShotgun, components: [
	{
		c: ItemComponent,
		d: {
			equipByDefault: true,
			lootable: false,
		}
	},
]};

// Found in a pick up place(such as in hideout). Is removed if "UziUnlock" is NOT unlocked yet.
var shotgunUnlockedPickup = { extend: pickableShotgun, components: [
	{
		c: UnlockTargetComponent,
		d: {
			name: "ShotgunUnlock",
		}
	},
]};

// Found on a level. If player leaves level with this item, the target "UziUnlock" will be unlocked.
var shotgunUnlocker = { extend: pickableShotgun, components: [
	{
		c: UnlockComponent,
		d: {
			target: "ShotgunUnlock",
		}
	},
]};

// Found on a level. If player leaves level with this item, the target "UziUnlock" will be unlocked.
var tranqGunUnlocker = { extend: tranqGunItem, components: [
	{
		c: UnlockComponent,
		d: {
			target: "TranqGunUnlock",
		}
	},
]};

var pythonItem = { name: "pickablePython", extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "revolver",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: true,
			equippedDefinition: "python",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			animationPrefix: "python",
			inventorySpriteName: "ui-base-icon-python",
			stackable: false
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsablePython",
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getPython",
		}
	},
]};

// Found on a level. If player leaves level with this item, the target "UziUnlock" will be unlocked.
var pythonUnlocker = { extend: pythonItem, components: [
	{
		c: UnlockComponent,
		d: {
			target: "PythonUnlock",
		}
	},
]};

var ammoPickupBase = { extend: userPickableItemBase, components: [
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getAmmo",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunAmmo",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "pistolAmmo",
			type: "pistolAmmo",
			lootable: true,
			equippable: false,
			amount: 20,
			maxStack: 40,
			stackable: true,
			inventorySpriteName: "ui-base-icon-ammo-pistol",
		}
	},
]};


var handgunAmmoPickup = { extend: ammoPickupBase, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunAmmo",
		}
	},
	{
		c: LootableComponent,
		d: {
			spawnWhenLooted: "getPistolAmmo",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "pistolAmmo",
			type: "pistolAmmo",
			lootable: true,
			equippable: false,
			amount: 5,
			maxStack: 40,
			stackable: true,
			inventorySpriteName: "ui-base-icon-ammo-pistol",
		}
	},
]};

var handgunAmmoPickup2 = { extend: handgunAmmoPickup, components: [
	{
		c: ItemComponent,
		d: {
			amount: 2,
		}
	},
]};

var handgunAmmoPickup20 = { extend: handgunAmmoPickup, components: [
	{
		c: ItemComponent,
		d: {
			amount: 20,
		}
	},
]};

var silencedPistolnlockedAmmoPickup = { extend: handgunAmmoPickup20, components: [
	{
		c: UnlockTargetComponent,
		d: {
			name: "SilencedPistolUnlock",
		}
	},
]};

var handgunAmmoPickupSpawner = { components: [
	/*
	#if debug
	{
		c: EntityStatsComponent,
	},
	#end
	*/
	{
		c: TransformComponent
	},
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["handgunAmmoPickup20"],
			total: -1,
			maxInWorld: 1,
			interval: 6,
		}
	}
]};

var handgunAmmoPickup1 = { extend: handgunAmmoPickup, components: [
	{
		c: ItemComponent,
		d: {
			amount: 1,
		}
	},
]};

var uziAmmoPickup = { extend: ammoPickupBase, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableSMGAmmo",
		}
	},
	{
		c: LootableComponent,
		d: {
			spawnWhenLooted: "getUziAmmo",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "SMGAmmo",
			type: "uziAmmo",
			lootable: true,
			equippable: false,
			amount: 20,
			maxStack: 80,
			stackable: true,
			inventorySpriteName: "ui-base-icon-ammo-smg",
		}
	},
]};

var uziUnlockedAmmoPickup = { extend: uziAmmoPickup, components: [
	{
		c: UnlockTargetComponent,
		d: {
			name: "UziUnlock",
		}
	},
]};

var shotgunAmmoPickup = { extend: ammoPickupBase, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableShotgunAmmo",
		}
	},
	{
		c: LootableComponent,
		d: {
			spawnWhenLooted: "getShotgunAmmo",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "shotgunAmmo",
			type: "shotgunAmmo",
			lootable: true,
			equippable: false,
			amount: 4,
			maxStack: 12,
			stackable: true,
			inventorySpriteName: "ui-base-icon-ammo-shotgun",
		}
	},
]};

var shotgunUnlockedAmmoPickup = { extend: shotgunAmmoPickup, components: [
	{
		c: UnlockTargetComponent,
		d: {
			name: "ShotgunUnlock",
		}
	},
]};

// Whats up with this entity? it does not change anything from its extended entity. -Samu 9.12.2014
var shotgunAmmo2 = { extend: shotgunAmmoPickup, components: [
	{
		c: ItemComponent,
		d: {
			amount: 2,
		}
	},
]};

var shotgunAmmo1 = { extend: shotgunAmmoPickup, components: [
	{
		c: ItemComponent,
		d: {
			amount: 1,
		}
	},
]};

var revolverAmmoPickup = { extend: ammoPickupBase, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableRevolverAmmo",
		}
	},
	{
		c: LootableComponent,
		d: {
			spawnWhenLooted: "getRevolverAmmo",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "revolverAmmo",
			type: "revolverAmmo",
			lootable: true,
			equippable: false,
			amount: 6,
			maxStack: 12,
			stackable: true,
			inventorySpriteName: "ui-base-icon-ammo-revolver",
		}
	},
]};

var tranqDartPickup = { extend: ammoPickupBase, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableTranqDarts",
		}
	},
	{
		c: LootableComponent,
		d: {
			spawnWhenLooted: "getTranqAmmo",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "darts",
			type: "tranqDarts",
			lootable: true,
			equippable: false,
			amount: 4,
			maxStack: 8,
			stackable: true,
			inventorySpriteName: "ui-base-icon-ammo-tranq",
		}
	},
]};

var rifleAmmoPickup = { extend: ammoPickupBase, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableRifleAmmo",
		}
	},
	{
		c: LootableComponent,
		d: {
			spawnWhenLooted: "getRifleAmmo",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "sniperAmmo",
			type: "rifleAmmo",
			lootable: true,
			equippable: false,
			amount: 6,
			maxStack: 12,
			stackable: true,
			inventorySpriteName: "ui-base-icon-ammo-rifle",
		}
	},
]};
//MULTIPLAYER STARTER AMMO

var handgunAmmoStarter = { extend: handgunAmmoPickup, components: [
	{
		c: ItemComponent,
		d: {
			amount: 20,
		}
	},
]};

var uziAmmoStarter = { extend: uziAmmoPickup, components: [
	{
		c: ItemComponent,
		d: {
			amount: 40,
		}
	},
]};

var shotgunAmmoStarter = { extend: shotgunAmmoPickup, components: [
	{
		c: ItemComponent,
		d: {
			amount: 10,
		}
	},
]};

//UNPICKABLE INF AMMO FOR COPS ETC.
var infAmmoPickupBase = { extend: userPickableItemBase, components: [
/*		{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getAmmo",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunAmmo",
		}
	},
*/
	{
		c: ItemComponent,
		d: {
			name: "Inf Ammo",
			type: "pistolAmmo",
			lootable: false,
			equippable: false,
			showInInventory: false,
			amount: 500000,
			stackable: false,
			inventorySpriteName: "ui-base-icon-dollar",
			//hidden: true,   -hide inf ammo from cop inventory
		}
	},
]};

var infPistolAmmo = { extend: infAmmoPickupBase, components: [
	{
		c: ItemComponent,
		d: {
			type: "pistolAmmo",
		}
	},
]};

var infShotgunAmmo = { extend: infAmmoPickupBase, components: [
	{
		c: ItemComponent,
		d: {
			type: "shotgunAmmo",
		}
	},
]};

var infRevolverAmmo = { extend: infAmmoPickupBase, components: [
	{
		c: ItemComponent,
		d: {
			type: "revolverAmmo",
		}
	},
]};

var infSMGAmmo = { extend: infAmmoPickupBase, components: [
	{
		c: ItemComponent,
		d: {
			type: "uziAmmo",
		}
	},
]};

var bombTimed = { extend: userPickableItemBase, components: [

	{
		c: TransformComponent,
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableBombTimed",
		}
	},
	{
		c: LootableComponent,
		d: {
			spawnWhenLooted: "getCash",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "active",
			type: "Timebomb ACTIVE",
			lootable: true,
			equippable: true,
			mustBeEquipped: true,
			//equippedDefinition: bombTimedCarriedActive,
			selfEquip: true,
			stackable: false,
			inventorySpriteName: "ui-base-icon-timebomb",
			// Swap all lootables to pile of cash when put to inventory
			// inventoryEntityDefinition: "lootablePileOfCash",
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.24,
			collisionGroup: CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
			collidesWith: [
			//	CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_BULLETS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
			],
			senses: [CollisionCategoryDefinitions.CC_CHARACTERS],
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: true,
			isSensor: true,

		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 1,
			maxHealth: 1,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["explosionCar"],
			},
		}
	},
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "timeBombTick",
		}
	},
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["detonator"],
			maxInWorld: 1,
			timeLeft: 5,
		}
	}
], children: [
	{ components: [
		{
			c: TransformComponent,
			d: {
				zIndex: 1,
			}
		},
		{
			c: SpriteComponent,
			d: {
				layer: LayerDefinitions.LAYER_OBJECTS,
				sheet: "inventory",
				name: "itemUsableBombTimed",
				tint: 0xff5400
			}
		},
		{
			c: TweenerComponent,
			d: {
				enabled: true,
				component: "SpriteComponent",
				field: "alpha",
				duration: 1/8,
				values: [0, 0.2, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0.4, 0, 0, 0.4, 0, 0, 0.4, 0, 0, 1.0, 0, 1.0, 0, 1.0, 0, 1.0, ],
			}
		},
	]}
]};

var bombTimedInactive = { extend: userPickableItemBase, components: [

	{
		c: TransformComponent,
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableBombTimed",
		}
	},
	{
		c: LootableComponent,
		d: {
			spawnWhenLooted: "getCash",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "bigBomb",
			type: "Big time bomb",
			lootable: true,
			equippable: false,
		//	amount: 1,
			stackable: false,
			deployableEntityDefinition: bombTimed,
			inventorySpriteName: "ui-base-icon-timebomb",
			// Swap all lootables to pile of cash when put to inventory
			// inventoryEntityDefinition: "lootablePileOfCash",
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.24,
			collisionGroup: CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
			collidesWith: [
			//	CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_BULLETS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
			],
			senses: [CollisionCategoryDefinitions.CC_CHARACTERS],
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: true,
			isSensor: true,

		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 1,
			maxHealth: 1,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnAsBody: {
				base: ["explosionCar"],
			},
		}
	},
]};

// Found on a level. If player leaves level with this item, the target "UziUnlock" will be unlocked.
var bombClockUnlocker = { extend: bombTimedInactive, components: [
	{
		c: UnlockComponent,
		d: {
			target: "ClockBombUnlock",
		}
	},
]};

var watchShrapnelDMG = { extend: explosionShrapnelHuge, components: [
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 12,
			elasticity: 1,
		}
	},
	{
		c: DamageComponent,
		d: {
			amount: 5,
			type: DamageType.explosion,
		}
	},
	{
		c: DistanceDestroyerComponent,
		d: {
			distance: 1,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 1,
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 2,
			maxHealth: 2,
			dontCopyVelocitiesToBody: true,
		}
	},
]};

var bombWatch = { extend: userPickableItemBase, components: [

	{
		c: TransformComponent,
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableBombWatch",
		}
	},
	{
		c: LootableComponent,
		d: {
			spawnWhenLooted: "getCash",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "active",
			type: "Watchbomb ACTIVE",
			lootable: true,
			equippable: true,
			mustBeEquipped: true,
			//equippedDefinition: bombTimedCarriedActive,
			selfEquip: true,
			stackable: false,
			inventorySpriteName: "ui-base-icon-timebomb",
			// Swap all lootables to pile of cash when put to inventory
			// inventoryEntityDefinition: "lootablePileOfCash",
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.24,
			collisionGroup: CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
			collidesWith: [
			//	CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_BULLETS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
			],
			senses: [CollisionCategoryDefinitions.CC_CHARACTERS],
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isDynamic: true,
			isSensor: true,

		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 1,
			maxHealth: 1,
			spawnOnDamage: {
				base: ["fxHitCar"],
			},
			spawnOnZeroHealth: {
				base: ["explosionSmall"],
			},
		}
	},
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "timeBombTick",
		}
	},
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["detonator"],
			maxInWorld: 1,
			timeLeft: 5,
		}
	}
], children: [
	{ components: [
		{
			c: TransformComponent,
			d: {
				zIndex: 1,
			}
		},
		{
			c: SpriteComponent,
			d: {
				layer: LayerDefinitions.LAYER_OBJECTS,
				sheet: "inventory",
				name: "itemUsableBombWatch",
				tint: 0xff5400
			}
		},
		{
			c: TweenerComponent,
			d: {
				enabled: true,
				component: "SpriteComponent",
				field: "alpha",
				duration: 1/8,
				values: [0, 0.2, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0.2, 0, 0, 0.4, 0, 0, 0.4, 0, 0, 0.4, 0, 0, 1.0, 0, 1.0, 0, 1.0, 0, 1.0, ],
			}
		},
	]}
]};

var bombWatchItem = { extend: bombTimedInactive, components: [
	{
		c: SpriteComponent,
		d: {
			name: "itemUsableBombWatch",
		}
	},
	{
		c: ItemComponent,
		d: {
			name: "smallBomb",
			type: "Timebomb",
			deployableEntityDefinition: bombWatch,
			inventorySpriteName: "ui-base-icon-timebomb",
		}
	},
	{
		c: HealthComponent,
		d: {
			spawnAsBody: {
				base: ["explosionSmall"],
			},
		}
	},
]};

// Found on a level. If player leaves level with this item, the target "UziUnlock" will be unlocked.
var bombWatchUnlocker = { extend: bombWatchItem, components: [
	{
		c: UnlockComponent,
		d: {
			target: "WatchBombUnlock",
		}
	},
]};

var womitSplatA = { components: [
	{
		c: TransformComponent,
	},
	{
		c: DamageComponent,
		d: {
			amount: 0.3,
			type: DamageType.acid,
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.05,
			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
			],
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 2,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 5,
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 0.5,
			maxHealth: 0.5,
			spawnAsBody: {
				base: ["bulletHit"],
			},
			// We want hits to stay at the hit position
			dontCopyVelocitiesToBody: true,
		}
	},
	// always destroy on collision
	{
		c: CollisionDamageComponent,
		d: {
			amount: 0.5,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "projectiles",
			name: "womitSplatA",
			defaultAnimationName: "active",
			loop: false,
		}
	},
	{
		c: TweenerComponent,
		d: {
			enabled: true,
			component: "SpriteComponent",
			field: "alpha",
			duration: 5,
			values: [1.0, 0],
		}
	},
]};

var womitSplatB = { extend: womitSplatA, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "projectiles",
			name: "womitSplatB",
			defaultAnimationName: "active",
			loop: false,
		}
	},
]};

var womitSplatC = { extend: womitSplatA, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "projectiles",
			name: "womitSplatC",
			defaultAnimationName: "active",
			loop: false,
		}
	},
]};

var womitSplatD = { extend: womitSplatA, components: [
	{
		c: TransformComponent,
		d: {
			scaleX: 3,
			scaleY: 3,
		}
	},
	{
		c: DamageComponent,
		d: {
			amount: 0.5,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "projectiles",
			name: "womitSplatC",
			defaultAnimationName: "active",
			loop: false,
		}
	},
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "zombieHit",
		}
	},
]};

var womitSplasher = { components: [
	{
		c: TransformComponent,
		d: {
		}
	},
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["bulletHitPersonB"],
			//maxInWorld: 5,
			total: 1,
			//timeLeft: 0.01,
			//minInterval: 0.05,
			//maxInterval: 0.1,
		}
	},
]};

var womitBullet = { components: [
	{
		c: TransformComponent,
		d: {
			scaleX: 2,
			scaleY: 2,
		}
	},
	{
		c: DamageComponent,
		d: {
			amount: 1,
			type: DamageType.acid,
		}
	}, {
		c: ColliderComponent,
		d: {
			radius: 0.04,
			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
			],
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 20,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 1.05,
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 1,
			maxHealth: 1,
			spawnAsBody: {
				base: ["womitSplatD"],
			},
			dontCopyVelocitiesToBody: true,
		}
	},
	// always destroy on collision
	{
		c: CollisionDamageComponent,
		d: {
			amount: 2,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "projectiles",
			name: "womit",
			defaultAnimationName: "idle",
			loop: false,
		}
	},
], children: [
	{ components: [
		{
			c: TransformComponent,
			d: {
			}
		},
		{
			c: SpawnerComponent,
			d: {
				entityDefinitions: ["womitSplatA", "womitSplatB", "womitSplatC"],
				total: -1,
				minInterval: 0.1,
				maxInterval: 0.2,
			}
		},
	]},
]};


var womitGunWeapon = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxRange: 2.9,
			maxAngle: 5,
			randomAngle: 10,
			projectile: womitBullet,
			ejectedShell: womitSplatA,
			impulse: 20,
			interval: 2,
			// Make the police less sneaky sharpshooters and allow player some
			// time to react before firing
			minAimTime: 0.2,
			firingSoundClipName: "zombieWomit",

			cameraShakeDuration: 0.1,
			cameraShakeMagnitude: 0.02,

			ammoType: "pistolAmmo"
		}
	},
]};

var womitGunItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "Zombie intestines",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: false,
			equippedDefinition: "womitGunWeapon",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			equipByDefault: true,
			inventorySpriteName: "ui-base-icon-handgun",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getGun",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunA"
		}
	},
]};

var womitShort = { components: [
	{
		c: TransformComponent,
		d: {
			scaleX: 2,
			scaleY: 2,
		}
	},
	{
		c: DamageComponent,
		d: {
			amount: 1,
			type: DamageType.acid,
		}
	}, {
		c: ColliderComponent,
		d: {
			radius: 0.04,
			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
			],
		}
	},
	{
		c: RigidBodyComponent,
		d: {
			isBullet: true,
			density: 20,
		}
	},
	{
		c: DistanceDestroyerComponent,
		d: {
			distance: 1,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 0.5,
		}
	},
	{
		c: HealthComponent,
		d: {
			currentHealth: 1,
			maxHealth: 1,
			spawnAsBody: {
				base: ["womitSplatD"],
			},
			dontCopyVelocitiesToBody: true,
		}
	},
	// always destroy on collision
	{
		c: CollisionDamageComponent,
		d: {
			amount: 2,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "projectiles",
			name: "womit",
			defaultAnimationName: "idle",
			loop: false,
		}
	},
]};

var womitShortWeapon = { extend: gunBase, components: [
	{
		c: WeaponComponent,
		d: {
			maxRange: 0.9,
			maxAngle: 5,
			randomAngle: 10,
			projectile: womitShort,
			ejectedShell: womitSplatA,
			impulse: 5,
			interval: 1,
			minAimTime: 0.1,
			firingSoundClipName: "zombieWomit",

			cameraShakeDuration: 0.1,
			cameraShakeMagnitude: 0.02,

			ammoType: "pistolAmmo"
		}
	},
]};

var womitShortItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "Zombie intestines",
			type: "weapon",
			suspiciousness: 10.0,
			lootable: false,
			equippedDefinition: "womitShortWeapon",
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			//equipSpriteNamePostfix: "Gun",
			equipByDefault: true,
			inventorySpriteName: "ui-base-icon-handgun",
			stackable: false
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getGun",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHandgunA"
		}
	},
]};

var haxSpawner = { components: [
	/*
	#if debug
	{
		c: EntityStatsComponent,
	},
	#end
	*/
	{
		c: TransformComponent
	},
	{
		c: SpawnerComponent,
		d: {
			entityDefinitions: ["fistHit"],
			total: -1,
			maxInWorld: 10000,
			interval: 0.01,
		}
	}
]};
