snjo / Firespitter

Plane and helicopter modules
firespitter.snjo.net
54 stars 49 forks source link

Firespitter conflicting with Mechjeb #217

Open merket opened 5 years ago

merket commented 5 years ago

Hello, Many people are reporting that firespitter in KSP 1.8 is conflicting with Mechjeb. Is there anything can be done on this part?

RushHour2k5 commented 5 years ago

I second this issue. When MechJeb and Firespitter are installed in unison it'll freeze on "Verifying expansion: Breaking Ground SquadExpansion/Serenity". Remove MechJeb or Firespitter and leave the other behind it works without issue.

enbock commented 5 years ago

A small workaround for it 😉

Clone the project, change the Firespitter to .net 4.0 and add missing libs in assemble. Then apply this patch to remove the FX:

Index: Firespitter/engine/FSgroundParticles.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- Firespitter/engine/FSgroundParticles.cs (revision 991774f0a6c2aacebfbdebb5e1e73be79de87ce2)
+++ Firespitter/engine/FSgroundParticles.cs (date 1572104271363)
@@ -168,35 +168,12 @@
             }
             currentEmission = Mathf.Clamp(currentEmission, 0f, emission);

-            particleFX.pEmitter.minEmission = currentEmission;
-            particleFX.pEmitter.maxEmission = currentEmission;
         }

         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);
-            }
-
-            // assign the array back to the emitter
-            particleFX.pEmitter.particles = particles;
         }
     }
 }
\ No newline at end of file
Index: Firespitter/engine/FSvelocityController.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- Firespitter/engine/FSvelocityController.cs  (revision 991774f0a6c2aacebfbdebb5e1e73be79de87ce2)
+++ Firespitter/engine/FSvelocityController.cs  (date 1572104320825)
@@ -60,26 +60,8 @@

             if (this.enabled && particleTextureName != string.Empty)
             {
-                // set up fx ---- TODO, assign each transform its own FX
-                particleTexture = GameDatabase.Instance.GetTexture(particleTextureName, false);
-                if (particleTexture != null)
-                {
-                    for (int i = 0; i < particleFX.Length; i++)
-                    {
-                        particleFX[i] = new Firespitter.FSparticleFX(transformArray[i].gameObject, particleTexture);
-                        particleFX[i].EmitterLocalVelocity = EmitterLocalVelocity;
-                        //Debug.Log("KTvelocityController: particle texture found: " + particleTextureName);
-                        particleFX[i].setupFXValues();
-                        particleFX[i].pEmitter.minEmission = 0f;
-                        particleFX[i].pEmitter.maxEmission = 0f;
-                        particleFX[i].pEmitter.useWorldSpace = false;
-                    }
-                }
-                else
-                {
                     useFX = false;
                     Debug.Log("KTvelocityController: particle texture not found, disabling fx");
-                }
             }
         }

@@ -111,11 +93,7 @@
                         thrustUsed = 0f;
                     if (thrustUsed > 0f)
                         part.gameObject.GetComponent<Rigidbody>().AddForceAtPosition(finalThrust, t.transform.position);
-                    if (useFX)
-                    {
-                        particleFX[i].pEmitter.minEmission = defaultEmitterMinEmission * thrustUsed;
-                        particleFX[i].pEmitter.maxEmission = defaultEmitterMaxEmission * thrustUsed;
-                    }
+                    
                     i++;
                 }
             }
Index: Firespitter/engine/FSparticleFX.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- Firespitter/engine/FSparticleFX.cs  (revision 991774f0a6c2aacebfbdebb5e1e73be79de87ce2)
+++ Firespitter/engine/FSparticleFX.cs  (date 1572104226075)
@@ -10,9 +10,6 @@
         public Texture particleTexture;
         public bool useLocalSpaceVelocityHack = false;

-        public ParticleEmitter pEmitter;
-        public ParticleRenderer pRenderer;
-        public ParticleAnimator pAnimator;

         private bool componentsAdded = false;

@@ -51,57 +48,14 @@

         private void addComponents()
         {
-            pEmitter =  gameObject.AddComponent<MeshParticleEmitter>();
-            pRenderer = gameObject.AddComponent<ParticleRenderer>();
-            pAnimator = gameObject.AddComponent<ParticleAnimator>();
         }

         public void setupFXValues()
-        {
-            if (!componentsAdded)
-            {
-                addComponents();
-                componentsAdded = true;
-            }            
-            pRenderer.materials = new Material[1];
-            pRenderer.materials[0].shader = Shader.Find(RendererShader);
-            pRenderer.materials[0].mainTexture = particleTexture;
-
-            pEmitter.minSize = EmitterMinSize;
-            pEmitter.maxSize = EmitterMaxSize;
-            pEmitter.minEnergy = EmitterMinEnergy;
-            pEmitter.maxEnergy = EmitterMaxEnergy;
-            pEmitter.minEmission = EmitterMinEmission;
-            pEmitter.maxEmission = EmitterMaxEmission;
-            pEmitter.localVelocity = EmitterLocalVelocity;
-            pEmitter.rndVelocity = EmitterRndVelocity;
-            pEmitter.useWorldSpace = EmitterUseWorldSpace;
-
-            pAnimator.doesAnimateColor = AnimatorDoesAnimateColor;
-
-            Color[] colorAnimation = pAnimator.colorAnimation;
-            colorAnimation[0] = AnimatorColor0;
-            colorAnimation[1] = AnimatorColor1;
-            colorAnimation[2] = AnimatorColor2;
-            colorAnimation[3] = AnimatorColor3;
-            colorAnimation[4] = AnimatorColor4;
-            pAnimator.colorAnimation = colorAnimation;
-
-            pAnimator.sizeGrow = AnimatorSizeGrow;            
+        {           
         }

         public void updateFX()
-        {
-            
-            if (useLocalSpaceVelocityHack)
-            {
-                //float velMagnitude = parentObject.GetComponent<Rigidbody>().velocity.magnitude;
-                float fxSpeed = Vector3.Dot(gameObject.transform.forward, parentObject.GetComponent<Rigidbody>().velocity);
-                if (fxSpeed > 0f)
-                    fxSpeed = 0;
-                pEmitter.localVelocity = new Vector3(0f, 0f, 1f + (-fxSpeed * 0.1f));
-                //pEmitter.maxEmission = pEmitter.minEmission + (velMagnitude * 3);
-            }            
+        {    
         }

     }
Index: Firespitter/wheel/FSwheel.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- Firespitter/wheel/FSwheel.cs    (revision 991774f0a6c2aacebfbdebb5e1e73be79de87ce2)
+++ Firespitter/wheel/FSwheel.cs    (date 1572104358386)
@@ -1068,35 +1068,11 @@
             // emit particles
             if (wheelList.wheels[wheelNumber].wheelCollider.isGrounded)
             {
-                if (useCustomParticleFX)
-                {
-                    wheelList.wheels[wheelNumber].smokeFX.pEmitter.minEmission = particleEmissionRate * fxLevel;
-                    wheelList.wheels[wheelNumber].smokeFX.pEmitter.maxEmission = particleEmissionRate * fxLevel;
-                }
-                else
-                {
                     part.Effect("tireSmoke", fxLevel);
-                }
             }
-            else
-            {
-                if (useCustomParticleFX)
-                {
-                    wheelList.wheels[wheelNumber].smokeFX.pEmitter.minEmission = 0f;
-                    wheelList.wheels[wheelNumber].smokeFX.pEmitter.maxEmission = 0f;
-                }
-            }
             //smokeFX
             wheelList.wheels[wheelNumber].screechCountdown -= TimeWarp.deltaTime;
         }
-        else
-        {
-            if (useCustomParticleFX)
-            {
-                wheelList.wheels[wheelNumber].smokeFX.pEmitter.minEmission = 0f;
-                wheelList.wheels[wheelNumber].smokeFX.pEmitter.maxEmission = 0f;
-            }
-        }
     }

     public void OnGUI()

Now compile it and copy dll into game data.

Finally you can play 1.8 inclusive mechjeb, usi mks/oks, usi-ls, etc.😉

RushHour2k5 commented 5 years ago

@enbock, for those who are either new to coding or have not yet compiled mods for KSP, could you please complete this for us and make a pull request or upload the DLL?

MikeLyno commented 5 years ago

Wow enbock, that is way too tough for me to even think about trying to do. Wonder why the two dudes involved in the making of this mod aren't fixing it. They gotta know about it by now.

merket commented 5 years ago

I see that the firespitter is updated to v7.14 but unfortunately it seems it still conflicts with mechjeb

merket commented 5 years ago

A small workaround for it 😉

Clone the project, change the Firespitter to .net 4.0 and add missing libs in assemble. Then apply this patch to remove the FX:

  • // 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. Now compile it and copy dll into game data.

Finally you can play 1.8 inclusive mechjeb, usi mks/oks, usi-ls, etc.😉

Dear @enbock Sir, Thank you so much for your contribution but I'm one of those users on GitHub, who has no idea of how to compile DLL's and no coding knowledge. I only have this account to report issues.

As @pilot76103 and @MikeLyno already mentioned, this fix is beyond our capabilities so if you'd be kind enough to share these files for us to download, we would appreciate it so much...

And thank you once again for your reply and solution.

enbock commented 5 years ago

In between is a new release out(https://github.com/snjo/Firespitter/releases/tag/v7.14) and works fine. Thanks to all contributors 😄

/edit: @merket ... I extracted the ZIP file of Firespitter after all other packages.... to be sure to have the real last version active and not overwritten by some other packages ;)

MikeLyno commented 5 years ago

Yup , 7.14 fixed it. I can friggin load the game now! Alright dudes.

Monniasza commented 4 years ago

Firespitter 7.15.0 won't work for me. KSP.log