// Turn the 'Boar' from RS+ into the 3.75m 'Mammoth II' from KSP2!
// Gives it a bunch of thrust, but weighs and costs more too.
// Also supplies WaterFall configs while I'm at it
// (unfinished)

+PART[restock-engine-boar]:NEEDS[RestockPlus]
{
	@name = Size3EngineMammothII
	@rescaleFactor = 1.5

	!node_attach = DELETE
	!node_stack_top = DELETE
	!node_stack_bottom = DELETE

	%node_stack_top = 0.0, 0.9, 0.0, 0, 1, 0, 3
	%node_stack_bottom = 0.0, -1.75, 0.0, 0, -1, 0, 3

	@entryCost = 122500
	@cost = 41500
	@title = S3 KX-100 'Mammoth-II' Liquid Fuel Engine
	@description = Kerbodyne's 'Mammoth-II' is a next-generation liquid fuel engine that combines massive power with massive size. Nothing about this engine is small.

	@attachRules = 1,0,1,0,1
	@bulkheadProfiles = size3
	@mass = 15

	@MODULE[ModuleEnginesFX]
	{
		@maxThrust = 4250
		!atmosphereCurve {}
		atmosphereCurve
		{
			key = 0 310
 			key = 1 270
			key = 12 0.001
		}
	}
	@MODULE[ModuleAlternator]
	{
		@RESOURCE[ElectricCharge]
		{
			@rate = 10.0
		}
	}
	VABORGANIZER:NEEDS[VABOrganizer]
	{
		organizerSubcategory = lfoEngines
	}
}

@PART[restock-engine-boar]:NEEDS[RestockPlus]
{
	%TechHidden = true
	@category = none
}

@PART[Size3EngineMammothII]:NEEDS[ReStockPlus,WaterfallRestock]
{
	// Remove any existing effects
	!EFFECTS {}
	!MODULE[EngineLightEffect] {}

	// Set sound and visual effects
	EFFECTS
	{
		engage
		{
			AUDIO
			{
				channel = Ship
				clip = sound_vent_medium
				volume = 1.0
				pitch = 2.0
				loop = false
			}
		}
		disengage
		{
			AUDIO
			{
				channel = Ship
				clip = sound_vent_soft
				volume = 1.0
				pitch = 2.0
				loop = false
			}
		}
		flameout
		{
			PREFAB_PARTICLE
			{
				prefabName = fx_exhaustSparks_flameout_2
				transformName = smokePoint
				oneShot = true
			}
			AUDIO
			{
				channel = Ship
				clip = sound_explosion_low
				volume = 1.0
				pitch = 2.0
				loop = false
			}
		}
		fx-boar-running
		{
			AUDIO
			{
				channel = Ship
				clip = Waterfall/Sounds/KatSounds/kero_loop_hard
				volume = 0.0 0.0
				volume = 0.05 0.6
				volume = 1.0 1.5
				pitch = 0.0 0.7
				pitch = 1.0 1.0
				loop = true
			}
			//PREFAB_PARTICLE
			//{
			//	prefabName = fx_smokeTrail_veryLarge
			//	transformName = smokePoint
			//	emission = 0.0 0.0
			//	emission = 0.05 0.0
			//	emission = 0.075 0.25
			//	emission = 1.0 1.25
			//	speed = 0.0 0.25
			//	speed = 1.0 1.0
			//	localOffset = 0, 0, 1
			//}
			MODEL_MULTI_PARTICLE
			{
				name = turbo
				modelName = ReStock/FX/restock-fx-boar-turbo-1
				transformName = fxTransformTurbo
				emission = 0.0 0.0
				emission = 0.01 0.1
				emission = 0.075 0.25
				emission = 1.0 1.0
				speed = 0.0 0.35
				speed = 1.0 1.0
			}
		}
	}
	// Add custom Waterfall controller, for main engine exhaust effects
	MODULE
	{
		name = ModuleWaterfallFX
		// This is a custom name
		moduleID = twinBoarFX
		// This links the effects to a given ModuleEngines
		engineID = basicEngine

		// List out all controllers we want available
		// This controller scales with atmosphere depth
		CONTROLLER
		{
			name = atmosphereDepth
			linkedTo = atmosphere_density
		}
		// This controller scales with effective throttle
		CONTROLLER
		{
			name = throttle
			linkedTo = throttle
		}
		// This controller generates a random value in the range specified
		CONTROLLER
		{
			name = random
			linkedTo = random
			range = -1,1
		}
		// -----------------------------------------------------
		// Past here should be generated with the ingame editor!
		// -----------------------------------------------------
		TEMPLATE
		{
			// This is the name of the template to use
			templateName = waterfall-kerolox-lower-5
			// This field allows you to override the parentTransform name in the EFFECTS contained in the template
			overrideParentTransform = thrustTransform
			position = 0.0, 0.0, -0.002
			rotation = 0, 0, 0
			scale = 2.6, 2.6, 1.0
		}
	}
	// Add custom Waterfall controller, for exaust dump efeccts
	MODULE
	{
		name = ModuleWaterfallFX
		// This is a custom name
		moduleID = twinBoarTurboFX
		// This links the effects to a given ModuleEngines
		engineID = basicEngine

		// List out all controllers we want available
		// This controller scales with atmosphere depth
		CONTROLLER
		{
			name = atmosphereDepth
			linkedTo = atmosphere_density
		}
		// This controller scales with effective throttle
		CONTROLLER
		{
			name = throttle
			linkedTo = throttle
		}
		// This controller generates a random value in the range specified
		CONTROLLER
		{
			name = random
			linkedTo = random
			range = -1,1
		}
		// -----------------------------------------------------
		// Past here should be generated with the ingame editor!
		// -----------------------------------------------------
		TEMPLATE
		{
			// This is the name of the template to use
			templateName = waterfall-kerolox-exhaust-1
			// This field allows you to override the parentTransform name in the EFFECTS contained in the template
			overrideParentTransform = fxTransformTurbo
			position = 0.0, 0.05, 0.0
			rotation = 0, 0, 0
			scale = 1.0, 1.0, 1.0
		}
	}
}