var pickableItemBase = { extend: lightObstacleBase, components: [
	{
		c: LootableComponent,
		d: {
			// No indicator by default
			noIndicator: true,
			pickable: true,
			lootingTime: 0
		}
	},
	{
		c: ItemComponent,
		d: {
			lootable: true,
			stackable: false
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.2,
			collisionGroup: CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
			collidesWith: [
			//	CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
			],
			senses: [CollisionCategoryDefinitions.CC_CHARACTERS],
		}
	},
	{ // this is for fading in and out based on fog of war
		c: TweenerComponent,
		d: {
			duration: 0.5,
			component: "SpriteComponent",
			field: "alpha",
			firstValueFromTarget: true
		}
	},
	{
		c: FogOfWarTargetComponent,
		d: {
			componentParamsWhenVisible: {
				TweenerComponent: {
					values: [0.0, 1.0]
				}
			},
			componentParamsWhenInvisible: {
				TweenerComponent: {
					values:  [1.0, 0.0]
				}
			},
			componentParamsWhenInvisibleButNotHidden: {
				TweenerComponent: {
					values: [1.0, 0.25]
				}
			}
		}
	},
	// Cannot define "default" sprite here because otherwise Tiled tiles that use this EntityDefinition will not use their sprite
	/*
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "dynamiteStackBig",
		}
	},
	*/
]};

var keyItemPointerLight = { components: [
	{
		c: TransformComponent,
		d: {
			scaleX: 0.5,
			scaleY: 0.5,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_LIGHTING,
			sheet: "lights",
			name: "lightTestMedium",
			alpha: 0.2
		}
	},
]};


var keyItemPointer = { components: [
	{
		c: TransformComponent,
		d: {
			scaleX: 0.15,
			scaleY: 0.15,
			zIndex: -1,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_FLOOR_OBJECTS,
			sheet: "lights",
			name: "lightTestMedium",
			tint: 0xffec9f,
		}
	},
	{
		c: TweenerComponent,
		d: {
			component: "SpriteComponent",
			field: "alpha",
			duration: 1,
			values: [1, 0.5, 1],
			repeat: true
		}
	}
], children: [
	keyItemPointerLight,
]};


var userPickableItemBase = { extend: pickableItemBase, components: [
	{
		c: TransformComponent,
		d: {
			zIndex: -20
		}
	},
	{
		c: ActionableComponent,
		d: {
			// User pickable items are always actionable
			actionDefinitions: [ActionDefinitions.pickup],
		}
	},
	{
		c: LootableComponent,
		d: {
			// User pickable items always have an indicator
			noIndicator: false,
			indicatorDefinition: lootIndicatorBase,
		}
	},
	{
		c: IndicatorComponent,
		d: {
			iconDefinition: indicatorIconBase,
			aboveTextDefinition: indicatorAboveBase,
			belowTextDefinition: indicatorBelowBase,
		}
	},
], children: [
	keyItemPointer,
]};

var chaching = { components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			sheet: "fxUI",
			name: "fxChaching",
			defaultAnimationName: "big",
			fps: 30,
			loop: false,
			//tint: 0xffec9f,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 1
		}
	},
	{
		c: TransformComponent,
		d: {
			zIndex: 3,
		}
	},
	/*
	{
		c: TweenerComponent,
		d: {
			component: "SpriteComponent",
			field: "alpha",
			duration: 1,
			values: [1, 10],
			repeat: true
		}
	}
	*/
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "cash",
		}
	},
]};

var smallChaching = { components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "fxUI",
			name: "fxChaching",
			defaultAnimationName: "big",
			fps: 30,
			loop: false,
			//tint: 0xffec9f,
		}
	},
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 1
		}
	},
	{
		c: TransformComponent,
		d: {
			scaleX: 0.5,
			scaleY: 0.5,
		}
	},
	/*
	{
		c: TweenerComponent,
		d: {
			component: "SpriteComponent",
			field: "alpha",
			duration: 1,
			values: [1, 10],
			repeat: true
		}
	}
	*/
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "cash",
		}
	},
]};

var getGunIcon = { components: [
	{
		c: TransformComponent,
		d: {
			zIndex: 3,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_IN_GAME_UI,
			sheet: "ingame-ui",
			name: "ui-base-icon-handgun",
		//	defaultAnimationName: "big",
		//	fps: 30,
		//	loop: false,
			//tint: 0xffec9f,
		}
	},
	{
		c: TweenerComponent,
		d: {
			component: "SpriteComponent",
			field: "alpha",
			duration: 0.7,
			values: [1, 0],
			repeat: false,
			easing: EasingFunctions.linear
		}
	},
]};

var getUziIcon = { extend: getGunIcon, components: [
	{
		c: SpriteComponent,
		d: {
			name: "ui-base-icon-uzi",
		}
	},
]};

var getShotgunIcon = { extend: getGunIcon, components: [
	{
		c: SpriteComponent,
		d: {
			name: "ui-base-icon-shotgun",
		}
	},
]};

var getPythonIcon = { extend: getGunIcon, components: [
	{
		c: SpriteComponent,
		d: {
			name: "ui-base-icon-python",
		}
	},
]};

var getBase = { components: [
	{
		c: TimerDestroyerComponent,
		d: {
			lifetime: 1
		}
	},
	{
		c: TransformComponent,
		d: {
	//		scaleX: 0.5,
	//		scaleY: 0.5,
		}
	},
	{
		c: TweenerComponent,
		d: {
			component: "TransformComponent",
			field: "simpleLocalScale",
			duration: 0.7,
			values: [1, 3.0],
			easing: EasingFunctions.linear
		}
	},
]};

var getGun = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupGun",
		}
	},
], children: [
	getGunIcon,
]};

var getUzi = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupGun",
		}
	},
], children: [
	getUziIcon,
]};

var getShotgun = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupGun",
		}
	},
], children: [
	getShotgunIcon,
]};

var getPython = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupGun",
		}
	},
], children: [
	getPythonIcon,
]};

var getKeyIcon = { extend: getGunIcon, components: [
	{
		c: SpriteComponent,
		d: {
			name: "ui-base-icon-key",
		}
	},
]};

var getKey = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupGun",
		}
	},
], children: [
	getKeyIcon,
]};

var getCashIcon = { extend: getGunIcon, components: [
	{
		c: SpriteComponent,
		d: {
			name: "ui-base-icon-dollar",
		}
	},
]};

var getHealthIcon = { extend: getGunIcon, components: [
	{
		c: SpriteComponent,
		d: {
			name: "ui-base-icon-health",
		}
	},
]};

var getAmmoIcon = { extend: getGunIcon, components: [
	{
		c: SpriteComponent,
		d: {
			name: "ui-base-icon-ammo",
		}
	},
]};

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

var getPistolAmmoText = { extend: getShotgunAmmoText, components: [
	{
		c: PixelTextComponent,
		d: {
			text: "$pistolAmmo",
		}
	}
]};

var getUziAmmoText = { extend: getShotgunAmmoText, components: [
	{
		c: PixelTextComponent,
		d: {
			text: "$SMGAmmo",
		}
	}
]};

var getRevolverAmmoText = { extend: getShotgunAmmoText, components: [
	{
		c: PixelTextComponent,
		d: {
			text: "$revolverAmmo",
		}
	}
]};

var getTranqAmmoText = { extend: getShotgunAmmoText, components: [
	{
		c: PixelTextComponent,
		d: {
			text: "$darts",
		}
	}
]};

var getRifleAmmoText = { extend: getShotgunAmmoText, components: [
	{
		c: PixelTextComponent,
		d: {
			text: "$sniperAmmo",
		}
	}
]};

var getCash = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "cash",
		}
	},
], children: [
	getCashIcon,
]};

var getHealth = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupBox",
		}
	},
], children: [
	getHealthIcon,
]};

var getAmmo = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupAmmo",
		}
	},
], children: [
	getAmmoIcon,
]};

var getShotgunAmmo = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupAmmo",
		}
	},
], children: [
	getAmmoIcon,
	getShotgunAmmoText
]};

var getPistolAmmo = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupAmmo",
		}
	},
], children: [
	getAmmoIcon,
	getPistolAmmoText
]};

var getUziAmmo = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupAmmo",
		}
	},
], children: [
	getAmmoIcon,
	getUziAmmoText
]};

var getRevolverAmmo = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupAmmo",
		}
	},
], children: [
	getAmmoIcon,
	getRevolverAmmoText
]};

var getTranqAmmo = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupAmmo",
		}
	},
], children: [
	getAmmoIcon,
	getTranqAmmoText
]};

var getRifleAmmo = { extend: getBase, components: [
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "pickupAmmo",
		}
	},
], children: [
	getAmmoIcon,
	getRifleAmmoText
]};

var wireCutterItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "wireCutter",
			type: "cutter",
			lootable: true,
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			inventorySpriteName: "ui-base-icon-knife",
			stackable: true,
		},
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableLockpickBasic"
		}
	},
]};

var shittyLockpickItem = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "badLockpick",
			type: "lockpick",
			lootable: true,
			equippable: true,
			equipSlot: EquipmentSlot.rightHand,
			inventorySpriteName: "ui-base-icon-lockpick",
			stackable: true,
			amount: 1,
			maxStack: 3,
		},
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableLockpickBasic"
		}
	},
]};

var redKey = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "redKey",
			type: "key",
			lootable: true,
			equippable: false,
			inventorySpriteName: "ui-base-icon-key-red",
			removeAfterLevel: true,
			respawnable: true,
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getKey",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableKeyRed",
		}
	},
]};

var redKeyMinimart = { extend: redKey, components: [
	{
		c: ObjectiveComponent,
		d: {
			name: "minimartObjective1"
		}
	}
]};

var orangeKey = { extend: redKey, components: [
	{
		c: ItemComponent,
		d: {
			name: "orangeKey",
			inventorySpriteName: "ui-base-icon-key-orange",
		}
	},
	{
		c: SpriteComponent,
		d: {
			name: "itemUsableKeyOrange",
		}
	},
]};

var grayKey = { extend: redKey, components: [
	{
		c: ItemComponent,
		d: {
			name: "grayKey",
			inventorySpriteName: "ui-base-icon-key-gray",
		}
	},
	{
		c: SpriteComponent,
		d: {
			name: "itemUsableKeyGray",
		}
	},
]};

var blueKey = { extend: redKey, components: [
	{
		c: ItemComponent,
		d: {
			name: "blueKey",
			inventorySpriteName: "ui-base-icon-key-blue",
		}
	},
	{
		c: SpriteComponent,
		d: {
			name: "itemUsableKeyBlue",
		}
	},
]};

var redKeyPolice = { extend: userPickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "redKey",
			type: "key",
			lootable: false,
			equippable: false,
			inventorySpriteName: "ui-base-icon-key-red",
			removeAfterLevel: true,
			respawnable: true,
		}
	},
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getKey",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableKeyRed",
		}
	},
]};

var orangeKeyPolice = { extend: redKeyPolice, components: [
	{
		c: ItemComponent,
		d: {
			name: "orangeKey",
			inventorySpriteName: "ui-base-icon-key-orange",
		}
	},
	{
		c: SpriteComponent,
		d: {
			name: "itemUsableKeyOrange",
		}
	},
]};

var grayKeyPolice = { extend: redKeyPolice, components: [
	{
		c: ItemComponent,
		d: {
			name: "grayKey",
			inventorySpriteName: "ui-base-icon-key-gray",
		}
	},
	{
		c: SpriteComponent,
		d: {
			name: "itemUsableKeyGray",
		}
	},
]};

var vaultKey = { extend: redKey, components: [
	{
		c: ItemComponent,
		d: {
			name: "vaultKey",
			inventorySpriteName: "ui-base-icon-key-vault",
		}
	},
	{
		c: SpriteComponent,
		d: {
			name: "itemUsableKeySafe",
		}
	},
]};

var visioNIX2000 = { extend: redKey, components: [
	{
		c: ItemComponent,
		d: {
			name: "VisioNIX2000",
			inventorySpriteName: "ui-base-icon-key-vault",
		}
	},
	{
		c: SpriteComponent,
		d: {
			name: "itemNixVision",
		}
	},
]};

var knoxKeyCardA = { extend: redKey, components: [
	{
		c: ItemComponent,
		d: {
			name: "knoxKeyA",
			inventorySpriteName: "ui-base-icon-key-vault",
			removeAfterLevel: false,
			respawnable: false,
		}
	},
	{
		c: SpriteComponent,
		d: {
			name: "itemUsableKeycardA",
		}
	},
]};

var knoxKeyCardB = { extend: redKey, components: [
	{
		c: ItemComponent,
		d: {
			name: "knoxKeyB",
			inventorySpriteName: "ui-base-icon-key-vault",
			removeAfterLevel: false,
			respawnable: false,
		}
	},
	{
		c: SpriteComponent,
		d: {
			name: "itemUsableKeycardB",
		}
	},
]};

var healthPickupBase = { extend: userPickableItemBase, components: [
	{
		c: LootableComponent,
		d: {
			lootingTime: 0,
			spawnWhenLooted: "getHealth",
		}
	},
	{
		c: HealthGiverComponent,
		d: {
			amount: 0.5
		}
	},
	{
		c: ItemComponent,
		d: {
			inventorySpriteName: "ui-base-icon-health",
		}
	},
]};

var medkit = { extend: healthPickupBase, components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemUsableHealthPack",
		}
	},
	{
		c: HealthGiverComponent,
		d: {
			amount: 2
		}
	}
]};

var tapeDeckA = { components: [
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "tiles",
			name: "tapeDeckA",
			defaultAnimationName: "on",
		}
	},
	{
		c: AudioSourceComponent,
		d: {
			autoPlay: "musicSneak",
		}
	},
]};

var horseMask = { components: [
	{
		c: TransformComponent,
		d: {
		//	zIndex: -20
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "inventory",
			name: "itemMaskHorse",
		}
	},
]};

var hockeyMask = { components: [
	{
		c: TransformComponent,
		d: {
		//	zIndex: -20
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "inventory",
			name: "itemMaskHockey",
		}
	},
]};

var gasMask = { components: [
	{
		c: TransformComponent,
		d: {
		//	zIndex: -20
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "inventory",
			name: "itemMaskGas",
		}
	},
]};

var pumpkinMask = { components: [
	{
		c: TransformComponent,
		d: {
		//	zIndex: -20
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "inventory",
			name: "itemMaskPumpkin",
		}
	},
]};

var clownMask = { components: [
	{
		c: TransformComponent,
		d: {
		//	zIndex: -20
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OVERHEAD,
			sheet: "inventory",
			name: "itemMaskClown",
		}
	},
]};

var horseMaskItem = { extend: lightObstacleBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "horseMask",
			type: "mask",
			lootable: false,
			equippable: false,
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_FLOOR_OBJECTS,
			sheet: "inventory",
			name: "itemPickableMaskHorse",
		}
	},
	{
		c: ColliderComponent,
		d: {
			radius: 0.2,
			collisionGroup: CollisionCategoryDefinitions.CC_LIGHT_DYNAMIC_OBSTACLE,
			collidesWith: [
			//	CollisionCategoryDefinitions.CC_CHARACTERS,
				CollisionCategoryDefinitions.CC_WALLS,
				CollisionCategoryDefinitions.CC_DOORS,
			],
			senses: [CollisionCategoryDefinitions.CC_CHARACTERS],
		}
	},
]};

var cursedMaskItem = { extend: pickableItemBase, components: [
	{
		c: ItemComponent,
		d: {
			name: "cursedMask",
			type: "mask",
			lootable: true,
			equippable: false,
			inventorySpriteName: "ui-base-icon-key-red",
		}
	},
	{
		c: SpriteComponent,
		d: {
			layer: LayerDefinitions.LAYER_OBJECTS,
			sheet: "inventory",
			name: "itemPickableMaskHorse",
		}
	},
	{
		c: LootableComponent,
		d: {
			// User pickable items always have an indicator
			noIndicator: true,
			indicatorDefinition: lootIndicatorBase,
			pickable: true,
		}
	},
]};