<?xml version="1.0" encoding="utf-8" ?>
<Patch>
	<Operation Class="PatchOperationSequence">
		<success>Always</success>
		<operations>

			<li Class="CombatExtended.PatchOperationFindMod">
				<modName>[CP] DOOM</modName>
			</li>

			<li Class="PatchOperationAdd">
				<xpath>Defs</xpath>
				<value>

					<!-- There is only one type of UAC EMG Cell for CE, no subcategory for variants required -->

					<!-- ==================== AmmoSet ========================== -->

					<CombatExtended.AmmoSetDef>
						<defName>AmmoSet_Doom2016EmgMkVPistol</defName>
						<label>UAC EMG Cell</label>
						<ammoTypes>
							<Ammo_Doom2016EmgMkVPistol>Bullet_Doom2016EmgMkVPistol</Ammo_Doom2016EmgMkVPistol>
						</ammoTypes>
					</CombatExtended.AmmoSetDef>

					<!-- ==================== Ammo ========================== -->

					<ThingDef Class="CombatExtended.AmmoDef" ParentName="SpacerSmallAmmoBase">
						<defName>Ammo_Doom2016EmgMkVPistol</defName>
						<label>UAC EMG Cell</label>
						<description>Plasma containment power cell developed by the Union Aerospace Corporation for directed-energy sidearms, utilizing the compression of Argent energy into a kinetic slug</description>
						<statBases>
							<Mass>0.004</Mass>
							<Bulk>0.01</Bulk>
							<MarketValue>0.21</MarketValue>
						</statBases>
						<tradeTags>
							<li>CE_AutoEnableTrade</li>
							<li>CE_AutoEnableCrafting_TableMachining</li>
							<!-- Plasma ammo can't be handloaded, and the containment cell must be precision-machined anyway -->
						</tradeTags>
						<thingCategories>
							<li>AmmoAdvanced</li>
						</thingCategories>
						<graphicData>
							<texPath>Things/Ammo/Charged/Concentrated</texPath>
							<graphicClass>Graphic_StackCount</graphicClass>
						</graphicData>
						<ammoClass>Plasma</ammoClass>
						<comps>
							<!-- Arbitarily defined cookoff explosive stats; represents a plasma containment system failing -->
						  <li Class="CombatExtended.CompProperties_ExplosiveCE">
							<damageAmountBase>20</damageAmountBase>
							<explosiveDamageType>Bomb</explosiveDamageType>
							<explosiveRadius>0.5</explosiveRadius>
							<applyDamageToExplosionCellsNeighbors>true</applyDamageToExplosionCellsNeighbors>
						  </li>
						  <li Class="CombatExtended.CompProperties_Fragments">
							<fragments>
								<Fragment_Large>2</Fragment_Large>
								<Fragment_Small>10</Fragment_Small>
							</fragments>
						  </li>
						</comps>
					</ThingDef>

					<!-- ================== Projectiles ================== -->
					
					<!-- Workaround for conditionally-patched projectiles: use an existing abstract class from the generic ammo library (In this case, Base6x24mmChargedBullet) -->

					<ThingDef Class="CombatExtended.AmmoDef" ParentName="Base6x24mmChargedBullet">
						<defName>Bullet_Doom2016EmgMkVPistol</defName>
						<label>EMG Bolt</label>
						<graphicData>
							<texPath>Things/Projectile/EMGMarkV</texPath>
							<graphicClass>Graphic_Single</graphicClass>
						</graphicData>
						<projectile Class="CombatExtended.ProjectilePropertiesCE">
							<speed>140</speed>
							<damageDef>Bomb</damageDef>
							<damageAmountBase>3</damageAmountBase>
							<explosionRadius>0.5</explosionRadius>
							<applyDamageToExplosionCellsNeighbors>true</applyDamageToExplosionCellsNeighbors>
							<secondaryDamage>
								<li>
									<def>Flame_Secondary</def>
									<amount>12</amount>
								</li>
							</secondaryDamage>
						</projectile>
					</ThingDef>

					<!-- ==================== Recipes ========================== -->

					<RecipeDef ParentName="ChargeAmmoRecipeBase">
						<defName>MakeAmmo_Doom2016EmgMkVPistol</defName>
						<label>make UAC EMG Cells</label>
						<description>Craft 500 shots' worth of UAC EMG Cells.</description>
						<jobString>Making UAC EMG Cells.</jobString>
						<workAmount>2800</workAmount>
						<ingredients>
							<li>
								<filter>
									<thingDefs>
										<li>Steel</li>
									</thingDefs>
								</filter>
								<count>4</count>
							</li>
							<li>
								<filter>
									<thingDefs>
										<li>Plasteel</li>
									</thingDefs>
								</filter>
								<count>3</count>
							</li>
							<li>
								<filter>
									<thingDefs>
										<li>ComponentIndustrial</li>
									</thingDefs>
								</filter>
								<count>2</count>
							</li>
						</ingredients>
						<fixedIngredientFilter>
							<thingDefs>
								<li>Steel</li>
								<li>Plasteel</li>
								<li>ComponentIndustrial</li>
							</thingDefs>
						</fixedIngredientFilter>
						<products>
							<Ammo_Doom2016EmgMkVPistol>500</Ammo_Doom2016EmgMkVPistol>
						</products>
					</RecipeDef>

				</value>
			</li>

		</operations>
	</Operation>
</Patch>