Skip to content

Commit

Permalink
KSP 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Palmer committed Oct 28, 2019
1 parent 4f302a3 commit 50dcea5
Show file tree
Hide file tree
Showing 9 changed files with 284 additions and 223 deletions.
Binary file modified .vs/Firespitter/v15/Server/sqlite3/storage.ide
Binary file not shown.
42 changes: 41 additions & 1 deletion Firespitter/Firespitter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Firespitter</RootNamespace>
<AssemblyName>Firespitter</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
Expand Down Expand Up @@ -53,10 +53,50 @@
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.AnimationModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.AnimationModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.AudioModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.AudioModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.IMGUIModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.IMGUIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.InputModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.InputModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.PhysicsModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UI">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.UI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.UIModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.UIModule.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.VehiclesModule">
<HintPath>..\..\..\KSP_DEV\KSP_x64_Data\Managed\UnityEngine.VehiclesModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="aero\FSbladeLiftSurface.cs" />
Expand Down
132 changes: 70 additions & 62 deletions Firespitter/engine/FSgroundParticles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ public class FSgroundParticles : PartModule
private MeshFilter meshFilter;

// a class which contains mesh emitter, animator and renderer, assigned to a GameObject
private FSparticleFX particleFX;
private Texture2D particleTexture;
//KSP 1.8
//private FSparticleFX particleFX;
//private Texture2D particleTexture;
//KSP 1.8

void Start()
{
Expand All @@ -70,44 +72,46 @@ void Start()
meshFilter = washDisc.AddComponent<MeshFilter>();
meshFilter.mesh = MeshCreator.createDisc(emissionDiscSize, 100);


//KSP 1.8
// fetch the particle texture from KSP's Game Database
particleTexture = GameDatabase.Instance.GetTexture(particleTextureName, false);
//particleTexture = GameDatabase.Instance.GetTexture(particleTextureName, false);

if (particleTexture == null)
{
Debug.Log("FSgroundParticles: particle texture loading error");
// it should use the default particle in this case, or just some pink crap maybe
}
else
{
//Setting the values for the particle system. the animator is never doing anything exciting, all particle motion is handled in the late update code
particleFX = new FSparticleFX(washDisc, particleTexture);
//if (particleTexture == null)
//{
// Debug.Log("FSgroundParticles: particle texture loading error");
// // it should use the default particle in this case, or just some pink crap maybe
//}
//else
//{
// //Setting the values for the particle system. the animator is never doing anything exciting, all particle motion is handled in the late update code
// particleFX = new FSparticleFX(washDisc, particleTexture);

// particles change color and alpha over time.
particleFX.AnimatorColor0 = getColorFromV4(particleColor0);
particleFX.AnimatorColor1 = getColorFromV4(particleColor1);
particleFX.AnimatorColor2 = getColorFromV4(particleColor2);
particleFX.AnimatorColor3 = getColorFromV4(particleColor3);
particleFX.AnimatorColor4 = getColorFromV4(particleColor4);

particleFX.EmitterMinSize = particleSize.x;
particleFX.EmitterMaxSize = particleSize.y;
particleFX.EmitterMinEnergy = particleEnergy.x;
particleFX.EmitterMaxEnergy = particleEnergy.y;
particleFX.EmitterMinEmission = 0f;
particleFX.EmitterMaxEmission = 0f;
particleFX.AnimatorSizeGrow = particleSizeGrow;

particleFX.EmitterLocalVelocity = new Vector3(0f, 0f, 0f);
particleFX.EmitterRndVelocity = new Vector3(0f, 0f, 0f);
// creates the emitters etc and assigns the above values
particleFX.setupFXValues();

//particleFX.pEmitter.rndRotation = true;

// Can't turn on Interpolate Triangles on the emitter, casue it's not exposed to code. REALLY?!? WHY?
}

// // particles change color and alpha over time.
// particleFX.AnimatorColor0 = getColorFromV4(particleColor0);
// particleFX.AnimatorColor1 = getColorFromV4(particleColor1);
// particleFX.AnimatorColor2 = getColorFromV4(particleColor2);
// particleFX.AnimatorColor3 = getColorFromV4(particleColor3);
// particleFX.AnimatorColor4 = getColorFromV4(particleColor4);

// particleFX.EmitterMinSize = particleSize.x;
// particleFX.EmitterMaxSize = particleSize.y;
// particleFX.EmitterMinEnergy = particleEnergy.x;
// particleFX.EmitterMaxEnergy = particleEnergy.y;
// particleFX.EmitterMinEmission = 0f;
// particleFX.EmitterMaxEmission = 0f;
// particleFX.AnimatorSizeGrow = particleSizeGrow;

// particleFX.EmitterLocalVelocity = new Vector3(0f, 0f, 0f);
// particleFX.EmitterRndVelocity = new Vector3(0f, 0f, 0f);
// // creates the emitters etc and assigns the above values
// particleFX.setupFXValues();

// //particleFX.pEmitter.rndRotation = true;

// // Can't turn on Interpolate Triangles on the emitter, casue it's not exposed to code. REALLY?!? WHY?
//}
//KSP 1.8
thrustTransform = part.FindModelTransform(thrustTransformName);
}

Expand Down Expand Up @@ -168,35 +172,39 @@ void Update()
}
currentEmission = Mathf.Clamp(currentEmission, 0f, emission);

particleFX.pEmitter.minEmission = currentEmission;
particleFX.pEmitter.maxEmission = currentEmission;
//KSP 1.8
//particleFX.pEmitter.minEmission = currentEmission;
//particleFX.pEmitter.maxEmission = currentEmission;
//KSP 1.8
}

void LateUpdate()
void LateUpdate()
{
if (!HighLogic.LoadedSceneIsFlight) return;

// to change particles you first have to get the array, modify it, then feed the whole thing back to the emitter
Particle[] particles = particleFX.pEmitter.particles;

for (int i = 0; i < particles.Length; i++)
{
// Oh hey, you can't access Interpolate Triangles on mesh emitters, so I have to this junk! Fuck you, whoever made the old Unity particle system.
// if a new particle has a very high energy, it means it's a newly created one. Move it!
if (particles[i].energy > particles[i].startEnergy - (Time.deltaTime * 1.1f))
{
//particles spawn on the outer points of the disc. move it a random amount towrds the center to distribute the spawning. a high number of outer points makes it look OK without exra sideways randomness.
particles[i].position = Vector3.Lerp(particles[i].position, washDisc.transform.position, UnityEngine.Random.value);
}

// The position of the current particle relative to the disc center
Vector3 offset = washDisc.transform.position - particles[i].position;
// Repel the particles. The closer a particle is to the disc center, the faster it moves away from it.
particles[i].position -= offset.normalized * 0.01f * Mathf.Clamp((maxDistance - currentDistance) - offset.magnitude, 1f, 15f);
//KSP 1.8
// // to change particles you first have to get the array, modify it, then feed the whole thing back to the emitter
// Particle[] particles = particleFX.pEmitter.particles;

// for (int i = 0; i < particles.Length; i++)
// {
// // Oh hey, you can't access Interpolate Triangles on mesh emitters, so I have to this junk! Fuck you, whoever made the old Unity particle system.
// // if a new particle has a very high energy, it means it's a newly created one. Move it!
// if (particles[i].energy > particles[i].startEnergy - (Time.deltaTime * 1.1f))
// {
// //particles spawn on the outer points of the disc. move it a random amount towrds the center to distribute the spawning. a high number of outer points makes it look OK without exra sideways randomness.
// particles[i].position = Vector3.Lerp(particles[i].position, washDisc.transform.position, UnityEngine.Random.value);
// }

// // The position of the current particle relative to the disc center
// Vector3 offset = washDisc.transform.position - particles[i].position;
// // Repel the particles. The closer a particle is to the disc center, the faster it moves away from it.
// particles[i].position -= offset.normalized * 0.01f * Mathf.Clamp((maxDistance - currentDistance) - offset.magnitude, 1f, 15f);
// }

// // assign the array back to the emitter
// particleFX.pEmitter.particles = particles;
//KSP 1.8
}

// assign the array back to the emitter
particleFX.pEmitter.particles = particles;
}
}
}
}
Loading

0 comments on commit 50dcea5

Please sign in to comment.