<?xml version="1.0" encoding="utf-8"?>
<Patch>

	<!-- Replace all ship turrets with the new turret classes -->
	<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[@Name='BaseShipTurretBuilding']/thingClass</xpath>
		<value>
			<thingClass>CombatExtended.Compatibility.SOS2Compat.Building_ShipTurretCE</thingClass>
		</value>
	</Operation>
	<!-- Spinals don't need to use any CE logic as they are only in space so give them the right class (Torpedos already include their own special class tag) -->
	<Operation Class="PatchOperationAdd"> 
		<xpath>/Defs/ThingDef[@Name='ShipSpinalTurretBuilding']</xpath>
		<value>
			<thingClass>SaveOurShip2.Building_ShipTurret</thingClass>
		</value>
	</Operation>
	
	<!-- 
		NOTE: Do not use CombatExtended.PatchOperationMakeGunCECompatible for changing the verb properties, it will not remove the default SOS2 custom verb
		Instead you need to replace the verb with one which has values for the ship combat as well as for CE ground defense/inspect panel
		The class of the properties needs to be CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE and the verbClass should be CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE
	 -->
	<!-- Kinetic Weapons -->
	<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[defName='ShipTurret_KineticTop']/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE">
					<recoilAmount>0.35</recoilAmount>
					<ai_AvoidFriendlyFireRadius>2</ai_AvoidFriendlyFireRadius>
					<muzzleFlashScale>9</muzzleFlashScale>
					<label>shoot slug</label>
					<verbClass>CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<range>1500</range>
					<minRange>31.9</minRange>
					<warmupTime>0.5</warmupTime>
					<forcedMissRadius>1</forcedMissRadius>
					<noiseRadius>4</noiseRadius>
					<ai_IsBuildingDestroyer>true</ai_IsBuildingDestroyer>
					<soundCast>ShipCombatKinetic</soundCast>
					<requireLineOfSight>false</requireLineOfSight>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<defaultProjectileGround>Bullet_SOS2_Kinetic_CE</defaultProjectileGround> <!-- New Property that should be set to ground projectile -->
					<defaultProjectile>Proj_ShipTurretKinetic</defaultProjectile>
					<spawnDef>Bullet_Fake_Kinetic</spawnDef>
					<rangedFireRulepack>Combat_RangedFire_Thrown</rangedFireRulepack>
				</li>
			</verbs>
		</value>
	</Operation>
	<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[defName='ShipTurret_KineticTop_Large']/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE">
					<recoilAmount>0.35</recoilAmount>
					<ai_AvoidFriendlyFireRadius>2</ai_AvoidFriendlyFireRadius>
					<muzzleFlashScale>9</muzzleFlashScale>
					<label>shoot slug</label>
					<verbClass>CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<range>2500</range>
					<warmupTime>0.5</warmupTime>
					<forcedMissRadius>1</forcedMissRadius>
					<noiseRadius>4</noiseRadius>
					<ai_IsBuildingDestroyer>true</ai_IsBuildingDestroyer>
					<soundCast>ShipCombatKineticLarge</soundCast>
					<requireLineOfSight>false</requireLineOfSight>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<defaultProjectileGround>Bullet_SOS2_Kinetic_CE</defaultProjectileGround> <!-- New Property that should be set to ground projectile -->
					<defaultProjectile>Proj_ShipTurretKinetic_Large</defaultProjectile>
					<spawnDef>Bullet_Fake_Kinetic_Large</spawnDef>
					<rangedFireRulepack>Combat_RangedFire_Thrown</rangedFireRulepack>
				</li>
			</verbs>
		</value>
	</Operation>
	<!-- Plasma Weapons -->
	<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[defName='ShipTurret_PlasmaTop']/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE">
					<recoilAmount>0.35</recoilAmount>
					<ai_AvoidFriendlyFireRadius>2</ai_AvoidFriendlyFireRadius>
					<muzzleFlashScale>9</muzzleFlashScale>
					<label>fire plasma</label>
					<verbClass>CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<range>1000</range>
					<minRange>31.9</minRange>
					<warmupTime>1.5</warmupTime>
					<forcedMissRadius>1</forcedMissRadius>
					<noiseRadius>4</noiseRadius>
					<ai_IsBuildingDestroyer>true</ai_IsBuildingDestroyer>
					<soundCast>ShipCombatPlasma</soundCast>
					<requireLineOfSight>false</requireLineOfSight>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<defaultProjectileGround>Bullet_SOS2_Plasma_CE</defaultProjectileGround> <!-- New Property that should be set to ground projectile -->
					<defaultProjectile>Proj_ShipTurretPlasma</defaultProjectile>
					<spawnDef>Bullet_Fake_Plasma</spawnDef>
					<rangedFireRulepack>Combat_RangedFire_Thrown</rangedFireRulepack>
				</li>
			</verbs>
		</value>
	</Operation>
	<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[defName='ShipTurret_PlasmaTop_Large']/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE">
					<recoilAmount>0.35</recoilAmount>
					<ai_AvoidFriendlyFireRadius>2</ai_AvoidFriendlyFireRadius>
					<muzzleFlashScale>9</muzzleFlashScale>
					<label>fire plasma</label>
					<verbClass>CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<range>1500</range>
					<warmupTime>1.5</warmupTime>
					<forcedMissRadius>1</forcedMissRadius>
					<noiseRadius>4</noiseRadius>
					<ai_IsBuildingDestroyer>true</ai_IsBuildingDestroyer>
					<soundCast>ShipCombatPlasmaLarge</soundCast>
					<requireLineOfSight>false</requireLineOfSight>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<defaultProjectileGround>Bullet_SOS2_Plasma_CE</defaultProjectileGround> <!-- New Property that should be set to ground projectile -->
					<defaultProjectile>Proj_ShipTurretPlasma_Large</defaultProjectile>
					<spawnDef>Bullet_Fake_Plasma_Large</spawnDef>
					<rangedFireRulepack>Combat_RangedFire_Thrown</rangedFireRulepack>
				</li>
			</verbs>
		</value>
	</Operation>

	<!-- Laser Weapons -->
	<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[defName='ShipTurret_LaserTop']/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE">
					<recoilAmount>0.35</recoilAmount>
					<ai_AvoidFriendlyFireRadius>2</ai_AvoidFriendlyFireRadius>
					<burstShotCount>6</burstShotCount>
					<muzzleFlashScale>9</muzzleFlashScale>
					<label>shoot laser</label>
					<verbClass>CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<range>500</range>
					<minRange>31.9</minRange>
					<warmupTime>0.5</warmupTime>
					<forcedMissRadius>1</forcedMissRadius>
					<noiseRadius>4</noiseRadius>
					<ai_IsBuildingDestroyer>true</ai_IsBuildingDestroyer>
					<soundCast>ShipCombatLaser</soundCast>
					<requireLineOfSight>false</requireLineOfSight>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<defaultProjectileGround>Bullet_SOS2_Laser_CE</defaultProjectileGround> <!-- New Property that should be set to ground projectile -->
					<defaultProjectile>Proj_ShipTurretLaser</defaultProjectile>
					<spawnDef>Bullet_Fake_Laser</spawnDef>
					<rangedFireRulepack>Combat_RangedFire_Thrown</rangedFireRulepack>
				</li>
			</verbs>
		</value>
	</Operation>
	<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[defName='ShipTurret_LaserTop_Large']/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE">
					<recoilAmount>0.35</recoilAmount>
					<ai_AvoidFriendlyFireRadius>2</ai_AvoidFriendlyFireRadius>
					<burstShotCount>12</burstShotCount>
					<muzzleFlashScale>9</muzzleFlashScale>
					<label>shoot laser</label>
					<verbClass>CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<range>1000</range>
					<minRange>31.9</minRange>
					<warmupTime>1.5</warmupTime>
					<forcedMissRadius>1</forcedMissRadius>
					<noiseRadius>4</noiseRadius>
					<ai_IsBuildingDestroyer>true</ai_IsBuildingDestroyer>
					<soundCast>ShipCombatLaser</soundCast>
					<requireLineOfSight>false</requireLineOfSight>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<defaultProjectileGround>Bullet_SOS2_Laser_CE</defaultProjectileGround> <!-- New Property that should be set to ground projectile -->
					<defaultProjectile>Proj_ShipTurretLaserTwo</defaultProjectile>
					<spawnDef>Bullet_Fake_Laser</spawnDef>
					<rangedFireRulepack>Combat_RangedFire_Thrown</rangedFireRulepack>
				</li>
			</verbs>
		</value>
	</Operation>

	<!-- Cannons -->
	<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[defName='ShipTurret_ACITop']/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE">
					<recoilAmount>0.35</recoilAmount>
					<ai_AvoidFriendlyFireRadius>2</ai_AvoidFriendlyFireRadius>
					<burstShotCount>8</burstShotCount>
					<muzzleFlashScale>9</muzzleFlashScale>
					<label>shoot slug</label>
					<verbClass>CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<range>500</range>
					<minRange>31.9</minRange>
					<warmupTime>0.5</warmupTime>
					<forcedMissRadius>1</forcedMissRadius>
					<noiseRadius>8</noiseRadius>
					<ai_IsBuildingDestroyer>true</ai_IsBuildingDestroyer>
					<soundCast>ShipCombatACI</soundCast>
					<requireLineOfSight>false</requireLineOfSight>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<defaultProjectileGround>Bullet_SOS2_ACI_CE</defaultProjectileGround> <!-- New Property that should be set to ground projectile -->
					<defaultProjectile>Proj_ShipTurretACI</defaultProjectile>
					<spawnDef>Bullet_Fake_ACI</spawnDef>
					<rangedFireRulepack>Combat_RangedFire_Thrown</rangedFireRulepack>
				</li>
			</verbs>
		</value>
	</Operation>
		<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[defName='ShipTurret_ACIITop']/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE">
					<recoilAmount>0.35</recoilAmount>
					<ai_AvoidFriendlyFireRadius>2</ai_AvoidFriendlyFireRadius>
					<burstShotCount>8</burstShotCount>
					<muzzleFlashScale>9</muzzleFlashScale>
					<label>shoot slug</label>
					<verbClass>CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<range>1000</range>
					<warmupTime>0.5</warmupTime>
					<forcedMissRadius>1</forcedMissRadius>
					<noiseRadius>10</noiseRadius>
					<ai_IsBuildingDestroyer>true</ai_IsBuildingDestroyer>
					<soundCast>ShipCombatACII</soundCast>
					<requireLineOfSight>false</requireLineOfSight>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<defaultProjectileGround>Bullet_SOS2_ACI_CE</defaultProjectileGround> <!-- New Property that should be set to ground projectile -->
					<defaultProjectile>Proj_ShipTurretACII</defaultProjectile>
					<spawnDef>Bullet_Fake_ACII</spawnDef>
					<rangedFireRulepack>Combat_RangedFire_Thrown</rangedFireRulepack>
				</li>
			</verbs>
		</value>
	</Operation>
	<Operation Class="PatchOperationReplace">
		<xpath>/Defs/ThingDef[defName='ShipTurret_ACIIITop']/verbs</xpath>
		<value>
			<verbs>
				<li Class="CombatExtended.Compatibility.SOS2Compat.VerbPropertiesShipWeaponCE">
					<recoilAmount>0.35</recoilAmount>
					<ai_AvoidFriendlyFireRadius>2</ai_AvoidFriendlyFireRadius>
					<burstShotCount>10</burstShotCount>
					<muzzleFlashScale>9</muzzleFlashScale>
					<label>shoot slug</label>
					<verbClass>CombatExtended.Compatibility.SOS2Compat.Verb_ShootShipCE</verbClass>
					<hasStandardCommand>true</hasStandardCommand>
					<range>1000</range>
					<warmupTime>0.5</warmupTime>
					<forcedMissRadius>1</forcedMissRadius>
					<noiseRadius>10</noiseRadius>
					<ai_IsBuildingDestroyer>true</ai_IsBuildingDestroyer>
					<soundCast>ShipCombatACIII</soundCast>
					<requireLineOfSight>false</requireLineOfSight>
					<targetParams>
						<canTargetLocations>true</canTargetLocations>
					</targetParams>
					<defaultProjectileGround>Bullet_SOS2_ACI_CE</defaultProjectileGround> <!-- New Property that should be set to ground projectile -->
					<defaultProjectile>Proj_ShipTurretACIII</defaultProjectile>
					<spawnDef>Bullet_Fake_ACIII</spawnDef>
					<rangedFireRulepack>Combat_RangedFire_Thrown</rangedFireRulepack>
				</li>
			</verbs>
		</value>
	</Operation>
</Patch>