﻿PART
{
	name = wbiS1WarpCore
	module = Part
	author = Angel-125

	MODEL
	{
		model = WildBlueIndustries/Blueshift/Parts/Engine/WarpTech/mk2WarpCore
		texture = mk2FuselageShort, Squad/Parts/FuelTank/mk2FuselageShort/mk2FuselageShort
	}

	rescaleFactor = 1

	node_stack_top = 0.0, 1.406, 0.0, 0.0, 1.0, 0.0, 1
	node_stack_bottom = 0.0, -1.406, 0.0, 0.0, -1.0, 0.0, 1
	node_attach = 0.625, 0.0, 0.0, 1.0, 0.0, 0.0, 1

	NODE
	{
		name = dock
		transform = dockingNode
		size = 1
	}

	TechRequired = wbiGravityWaveApplications

	category = Engine
	subcategory = 0
	entryCost = 475000
	cost = 142500

	title = Mk2 "Starflight" Warp Core
	manufacturer = <CLASSIFIED>
	description = The S-1 "Starflight 2" Warp Core is a miniaturized version of the original Mk2 Starfield. Some components were [REDACTED] from [REDACTED] and aren’t well understood, but they should work [REDACTED] to propel a vessel faster than light.
	attachRules = 1,1,1,1,1
	mass = 1.45
	dragModelType = none
	maximum_drag = 0.02
	minimum_drag = 0.02
	angularDrag = 0.2
	stackSymmetry = 1
	crashTolerance = 20
	thermalMassModifier = 8.0
	emissiveConstant = 0.95
	maxTemp = 2000
	explosionPotential = 0.1
	fuelCrossFeed = True
	breakingForce = 500000
	breakingTorque = 500000
	bulkheadProfiles = Size1
	tags = cck-Blueshift warp graviolium

Variants
Covers Off
Covers On
Radial Mounts & Covers
Radial Mounts
Vertical Core
Vertical Core No Covers

	MODULE
	{
		name = ModuleAnimateGeneric
		animationName = deploy
		actionGUIName = Toggle Docking Port
		startEventGUIName = Open Docking Shield
		endEventGUIName = Close Docking Shield
		allowAnimationWhileShielded = True
	}

	// Graviolium is normally not a tweakable resource, meaning you have to fill up your tanks while in flight.
	// Without Kerbal Flying Saucers, the only way to get the resource is to mine asteroids.
	// But this cheat lets you tweak the resource in the editor.
	MODULE
	{
		name = WBIResourceTweaker
		resourceName = Graviolium
		tweakEnabledName = CHEAT: Enable Graviolium tweak
		tweakDisabledName = CHEAT: Disable Graviolium tweak
	}

	MODULE
	{
		name = WBIAnimatedTexture
//		debugMode = true

		// ID of the module so we can distinguish between several animated textures in one part.
		// This animated texture is controlled by the warp engine.
		moduleID = mk2WarpCore

		// Name of transform whose texture we will animate
		textureTransformName = warpCorePlasma

		// The part module will look for <name>1, <name>2, etc. until it can't find images in numeric sequence.
		// Don't include the sequence number here.
		// You can animate both diffuse and emissive textures. You don't need them to have the same number of diffuse and emissive images.
//		animatedDiffuseTexture =

		animatedEmissiveTexture = WildBlueIndustries/Blueshift/Parts/Engine/WarpTech/WarpPlasma

		// Can be zero
		minFramesPerSecond = 15

		// Must be greater than zero. 
		// NOTE: 50 is the fastest that we can go due to how many updates per second we get. 50 is the default value.
		maxFramesPerSecond = 50

		// Emissive animation fades when animation throttle is at minimum.
		fadesAtMinThrottle = false

		// How many seconds until the emissive texture is fully visible/hidden
		emissiveFadeTime = 2
	}

	// Generators are just like the stock resource converter, except that this one can control animated textures and/or Effects.
	// This generator produces the GravityWaves that power warp coils by consuming Graviolium and FusionPellets.
	MODULE
	{
		name = WBIModuleGeneratorFX
//		debugMode = true

		// Setting this to the same value as WBIWarpEngine's warpPowerGeneratorID field lets the warp engine control the generator.
		moduleID = warpPower

		// This also replaces the name shown in the editor.
		ConverterName = Main Power

		// Short description of the module as displayed in the editor.
		moduleDescription = Provides power for the warp core.

		StartActionName = Activate Main Power
		StopActionName = Deactivate Main Power
		ToggleActionName = Toggle Main Power

		INPUT_RESOURCE
		{
			ResourceName = Graviolium
			Ratio = 0.002
			FlowMode = STAGE_PRIORITY_FLOW
		}
		INPUT_RESOURCE
		{
			ResourceName = FusionPellets
			Ratio = 0.00005
			FlowMode = STAGE_PRIORITY_FLOW
		}
		OUTPUT_RESOURCE
		{
			ResourceName = GravityWaves
			Ratio = 50
			DumpExcess = true
			FlowMode = ALL_VESSEL
		}
		OUTPUT_RESOURCE
		{
			ResourceName = wbiElectroPlasma
			Ratio = 1400
			DumpExcess = true
			FlowMode = ALL_VESSEL
		}
		OUTPUT_RESOURCE
		{
			ResourceName = ElectricCharge
			Ratio = 6
			DumpExcess = true
			FlowMode = ALL_VESSEL
		}
		OUTPUT_RESOURCE
		{
			ResourceName = StaticCharge
			Ratio = 0.002
			DumpExcess = false
			FlowMode = ALL_VESSEL
		}
		DRAINED_RESOURCE
		{
			ResourceName = GravityWaves
			Ratio = 5
			FlowMode = NO_FLOW
		}
		DRAINED_RESOURCE
		{
			ResourceName = wbiElectroPlasma
			Ratio = 140
		}
	}

	// Warp engines provide faster than light travel but require resources to do so.
	MODULE
	{
		name = WBIWarpEngine
		engineID = warpEngine
//		debugEnabled = true

		// Short description of the module as displayed in the editor.
		moduleDescription = Enables fater than light travel.

		EngineType = Generic
		exhaustDamage = False
		heatProduction = 0
		fxOffset = 0, 0, 0
		ignitionThreshold = 0.01
		minThrust = 0

		// Optional bow shock transform for the warp effects
		bowShockTransformName = bowShock

		// We need a non-significant value so that KSP won't flip out when the flight scene is loaded.
		maxThrust = 0.000001

		// Warp engines need a small amount of electric charge to operate.
		PROPELLANT
		{
			name = ElectricCharge
			resourceFlowMode = STAGE_PRIORITY_FLOW
			ratio = 1.8
			DrawGauge = True
			minResToLeave = 1.0
		}

		// Minimum planetary radii needed to go to warp.
		minPlanetaryRadius = 1.0

		// When the powerMultiplier drops below this value, the engine will flame out.
		warpIgnitionThreshold = 0.25

		// While in orbit around a planet or moon, limit top speed by this multiplier so that we don't blow past the celestial body.
		// Think of this as a speed limit while in the harbor.
		// Out in interplanetary space, we can really open up the throttle.
		// The first number represents how close to the SOI edge the vessel is (1 = right at the edge, 0.1 = 10% of the distance to the SOI edge)
		// The second number is the top speed multiplier.
		planetarySOISpeedCurve
		{
			key = 1 0.1
			key = 0.5 0.05
			key = 0.25 0.01
			key = 0.1 0.005
		}

		// In addition to any specified PROPELLANT resources, warp engines require warpCapacity. Only parts with
		// a WBIWarpCoil part module can generate warpCapacity.
		// The warp curve controls how much warpCapacity is neeeded to go light speed or faster.
		// The first number represents the available warpCapacity, while the second number gives multiples of C.
		// You can apply any kind of warp curve you want, but the baseline uses the Fibonacci sequence * 10.
		// It may seem steep, but in KSP's small scale, 1C is plenty fast.
		// This curve is modified by the engine's displacementImpulse and current vessel mass.
		// effectiveWarpCapacity = warpCapacity * (displacementImpulse / vessel mass)
		warpCurve
		{
			key = 1 0
			key = 10 1
			key = 30 2
			key = 50 3
			key = 80 4
			key = 130 5
			key = 210 6
			key = 340 7
			key = 550 10
			key = 890 12
			key = 1440 16
			key = 2330 21
			key = 3770 27
			key = 6100 35
			key = 9870 45
			key = 15970 58
			key = 28540 76
		}

		// ISP is important even for a warp engine since it affects propellant consumption. But we're unconcerned about atmosphere.
		atmosphereCurve
		{
			key = 0 100
			key = 1 100
		}

		// Engines can drive WBIModuleGeneratorFX that produce resources needed for warp travel.
		warpPowerGeneratorID = warpPower

		// Effects
		flameoutEffectName = flameout
		powerEffectName = power
		engageEffectName = engage
		disengageEffectName = disengage
		runningEffectName = running
		
		// An optional effect to play when the ship exceeds light speed.
		photonicBoomEffectName = photonicBoom

		// Also used as warp effects spool time.
		engineSpoolTime = 0.05

		// Engines can drive animated textures
		textureModuleID = mk2WarpCore
	}

	MODULE:NEEDS[Waterfall]
	{
		name = ModuleWaterfallFX
		engineID = warpEngine
		CONTROLLER
		{
			name = throttle
			linkedTo = throttle
			engineID = warpEngine
			responseRateUp = 0.03
			responseRateDown = 0.2
		}
		TEMPLATE
		{
			// This is the name of the template to use
			templateName = ftlWarpField
			overrideParentTransform = waterfallWarpEffects
			position = 0,0,0
			rotation = 0, 0, 0
			scale = 1, 1, 1
		}
		TEMPLATE
		{
			// This is the name of the template to use
			templateName = ftlWarpBowShock
			position = 0,0,0
			rotation = 0, 0, 0
			scale = 1, 1, 1
		}
	}

	MODULE
	{
		name = ModuleLiftingSurface
		useInternalDragModel = False
		deflectionLiftCoeff = 0.7
		dragAtMaxAoA = 0.15
		dragAtMinAoA = 0.1
	}

	RESOURCE
	{
		name = FusionPellets
		amount = 48
		maxAmount = 48
	}

	RESOURCE
	{
		name = Graviolium
		amount = 0
		maxAmount = 32
	}

	RESOURCE
	{
		name = GravityWaves
		amount = 0
		maxAmount = 500
	}

	RESOURCE
	{
		name = wbiElectroPlasma
		amount = 0
		maxAmount = 1400
	}

	RESOURCE
	{
		name = StaticCharge
		amount = 0
		maxAmount = 300
	}

	EFFECTS
	{	
		running
		{
			AUDIO
			{
				channel = Ship
				clip = WildBlueIndustries/Blueshift/FX/WarpEngineRunning2
				volume = 0.0 0.0
				volume = 1.0 2.5
				loop = true
			}
		}
		power
		{
			AUDIO
			{
				channel = Ship
				clip = WildBlueIndustries/Blueshift/FX/WarpEnginePower2
				volume = 0.0 0.0
				volume = 0.05 0.1
				volume = 0.1 0.25
				volume = 1.0 1.0
				pitch = 0.0 0.5
				pitch = 1.0 1.15
				loop = true
			}
		}
		engage
		{
			AUDIO
			{
				channel = Ship
				clip = WildBlueIndustries/Blueshift/FX/WarpEngineStart
				volume = 2.0
				pitch = 1.0
				loop = false
			}

		}
		disengage
		{
			AUDIO
			{
				channel = Ship
				clip = WildBlueIndustries/Blueshift/FX/WarpEngineStop
				volume = 2.0
				pitch = 1.0
				loop = false
			}

		}
		flameout
		{
			AUDIO
			{
				channel = Ship
				clip = sound_explosion_low
				volume = 1.0
				pitch = 2.0
				loop = false
			}
		}

		photonicBoom
		{
			AUDIO
			{
				channel = Ship
				clip = WildBlueIndustries/Blueshift/FX/PhotonicBoom
				volume = 2.0
				pitch = 1.0
				loop = false
			}
		}	
	}

	DRAG_CUBE
	{
		cube = Default, 5.603,0.5646,1.249, 5.603,0.5644,1.249, 2.494,0.9701,0.1549, 2.494,0.9701,0.1549, 9.338,0.9011,0.6933, 9.338,0.901,0.6933, 0,0,0, 2.5,3.75,1.5
	}
}