﻿// This part effectively cancels the ship's inertial mass and modifies the engine exhaust stream's inertial mass by manipulating the Zero-Point Field (ZPF).
// This effectively increases an engine's thrust and Isp, resulting in a greater TWR and delta-v.
// What's cool is that this technology meshes with Blueshift's existing warp tech too. The ZPF, from which this concepts arises, is already tied to negative energy effects (like the Casimir effect)- the same physics often cited as a possible Alcubierre drive.
// Hence, the Zero-Point Inertial Dampener is a stepping-stone to warp tech.
// Though totally fictional and definitely inspired by Mass Effect, here are some real-world references
// that I researched while coming up with this plausibly deniable part module.

// Important notes
// These ideas are theoretical and unconfirmed by experiment.
// They lie at the fringe of mainstream physics, but remain internally consistent within classical and quantum electrodynamics.
// NASA’s Breakthrough Propulsion Physics Program explored related concepts but found no conclusive path to engineering.

// Background: Zero-Point Energy & Casimir Effect
// Source: https://en.wikipedia.org/wiki/Zero-point_energy
// Summary:
//    ZPE is the lowest energy possible in a quantum system.
//    The Casimir effect experimentally confirms the existence of vacuum fluctuations.
//    While ZPE is proven, harnessing it for inertia or propulsion remains unverified.

// "Inertia as a Zero-Point Field Lorentz Force"
// Authors: Bernard Haisch, Alfonso Rueda, Harold E. Puthoff
// Published: Physical Review A, 1994
// Link: https://www.researchgate.net/publication/13379419_Inertia_as_a_zero-point-field_Lorentz_force
// Summary:
//    Proposes that ZPF electromagnetic fluctuations exert a Lorentz-like force on accelerating matter.
//    Suggests that this interaction accounts for inertial mass.
//    Establishes a theoretical foundation tying ZPF to classical electrodynamics and relativity.

// "Advances in the Proposed Electromagnetic Zero-Point Field Theory of Inertia"
// Authors: Rueda, Haisch
// Published: arXiv Physics, 1998
// Link: https://arxiv.org/abs/physics/9807023
// Summary:
//    Expands on earlier work by modeling interactions at subatomic levels.
//    Argues that particle mass may arise from cumulative electromagnetic drag from the vacuum.
//    Connects the idea to quarks and electrons, proposing a universal mechanism.

// Let's face it, this is Space Magic, but at least it's internally consistent with Blueshift's other tech.

PART
{
	name = wbiS2InertialDampener
	module = Part
	author = Angel-125

	MODEL
	{
		model = WildBlueIndustries/Blueshift/Parts/Engine/WarpTech/s2ContragravityGenerator
	}

	rescaleFactor = 1

	node_stack_top = 0.0, 1.52, 0.0, 0.0, 1.0, 0.0, 2
	node_stack_bottom = 0.0, -1.52, 0.0, 0.0, -1.0, 0.0, 2
	node_attach = 0.0, -1.52, 0.0, 0.0, -1.0, 0.0, 2

	TechRequired = wbiGravityWaveApplications

	category = Engine
	subcategory = 0
	entryCost = 250000
	cost = 125000

	title = #LOC_BLUESHIFT_inertialDampenerTitle // S-2 Zero-Point Inertial Dampener
	manufacturer = <CLASSIFIED>
	description = #LOC_BLUESHIFT_inertialDampenerDesc // Powered by Graviolium, this device disturbs the quantum vacuum around your ship and its exhaust stream, reducing inertial resistance during engine burns. The result? More thrust, better ISP, and longer burns- all without changing your mass on paper. Where does the inertia go? <b>Don't ask.</b>
	attachRules = 1,1,1,1,0
	mass = 6
	dragModelType = none
	maximum_drag = 0.02
	minimum_drag = 0.02
	angularDrag = 0.2
	stackSymmetry = 2
	crashTolerance = 50
	thermalMassModifier = 8.0
	emissiveConstant = 0.95
	maxTemp = 2000
	explosionPotential = 0.1
	fuelCrossFeed = True
	breakingForce = 500000
	breakingTorque = 500000
	bulkheadProfiles = size2
	tags = cck-Blueshift warp contragravity graviolium

	// 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 = false

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

		// 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
	}

	MODULE
	{
		name = WBIInertialDampener

		// This part module enhances engine thrust and Isp. While the vessel's reported mass will remain unchanged, thrust, Isp, TWR, and delta-v values will be affected.

		// Amount of increase in Electric Charge that it costs to run the generator. Computed as a percentage of vessel mass. So, if this value is 0.05 (the default), and the vessel masses 100 tonnes, then the EC cost increases by 5.
		// This is a value between 0 and 1.
		ecMassPercentIncrease = 0.05

		groupName = #LOC_BLUESHIFT_dampenerGroup // Inertial Dampener

		// This also replaces the name shown in the editor.
		ConverterName = #LOC_BLUESHIFT_dampenerConverterTitle // Zero-Point Inertial Dampener

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

		// Short description of the module as displayed in the editor.
		moduleDescription = #LOC_BLUESHIFT_dampenerConverterDesc // Reduces inertial mass, effectively improving engine thrust and ISP.

		StartActionName = #LOC_BLUESHIFT_dampenerStartName // Activate zeroPoint Attenuator
		StopActionName = #LOC_BLUESHIFT_dampenerStopName // Deactivate zeroPoint Attenuator
		ToggleActionName = #LOC_BLUESHIFT_dampenerToggleName // Toggle zeroPoint Attenuator
		
		runningEffect = running

		// These input values are calibrated for a 1-tonne craft.
		// They will be scaled up depending on vessel mass.
		INPUT_RESOURCE
		{
			ResourceName = Graviolium
			Ratio = 0.001
			FlowMode = STAGE_PRIORITY_FLOW
		}

		// E.C. use remains constant unlike Graviolium and Static Charge.
		INPUT_RESOURCE
		{
			ResourceName = ElectricCharge
			Ratio = 100
			DumpExcess = true
			FlowMode = ALL_VESSEL
		}

		OUTPUT_RESOURCE
		{
			ResourceName = StaticCharge
			Ratio = 0.001
			DumpExcess = false
			FlowMode = ALL_VESSEL
		}
	}

	MODULE
	{
		name = ModulePartVariants
		baseVariant = NoExtension
		useProceduralDragCubes = true

		VARIANT
		{
			name = NoExtension
			displayName =  Without Extension
			primaryColor = #3a562a
			secondaryColor = #999999
			sizeGroup = GroupB
			GAMEOBJECTS
			{
				extensionMount = false
			}
		}
		VARIANT
		{
			name = WithExtension
			displayName =  With Extension
			primaryColor = #3a562a
			secondaryColor = #999999
			sizeGroup = GroupB
			GAMEOBJECTS
			{
				extensionMount = true
			}
		}
	}

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

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

	EFFECTS
	{	
		running
		{
			AUDIO
			{
				channel = Ship
				clip = WildBlueIndustries/Blueshift/FX/WarpEngineRunning2
				volume = 0.0 0.0
				volume = 1.0 2.5
				loop = true
			}
			MODEL_MULTI_PARTICLE
			{
				name = plasmaStationary
				modelName = WildBlueIndustries/Blueshift/FX/s2ContragravityRing
				transformName = particleEmitterTransform
				emission = 0.0 0.0
				emission = 1.0 1.0
				speed = 0.0 0.0
				speed = 1.0 1.0
			}
		}

	}
}