Exemplo n.º 1
0
 void Start()
 {
     pEmitter      = gameObject.GetComponent <KSPParticleEmitter>();
     pEmitter.emit = false;
     EffectBehaviour.AddParticleEmitter(pEmitter);
 }
Exemplo n.º 2
0
 void Awake()
 {
     pEmitter = gameObject.GetComponent <KSPParticleEmitter>();
     EffectBehaviour.AddParticleEmitter(pEmitter);
     gpe = gameObject.GetComponent <BDAGaplessParticleEmitter>();
 }
Exemplo n.º 3
0
        void OnEnable()
        {
            BDArmorySetup.numberOfParticleEmitters++;

            rb = gameObject.AddOrGetComponent <Rigidbody>();

            pEmitters = gameObject.GetComponentsInChildren <KSPParticleEmitter>();

            using (var pe = pEmitters.AsEnumerable().GetEnumerator())
                while (pe.MoveNext())
                {
                    if (pe.Current == null)
                    {
                        continue;
                    }
                    if (FlightGlobals.getStaticPressure(transform.position) == 0 && pe.Current.useWorldSpace)
                    {
                        pe.Current.emit = false;
                    }
                    else if (pe.Current.useWorldSpace)
                    {
                        BDAGaplessParticleEmitter gpe = pe.Current.gameObject.AddComponent <BDAGaplessParticleEmitter>();
                        gpe.rb   = rb;
                        gpe.emit = true;
                    }
                    else
                    {
                        pe.Current.emit = true;
                        EffectBehaviour.AddParticleEmitter(pe.Current);
                    }
                }

            prevPosition  = transform.position;
            currPosition  = transform.position;
            startPosition = transform.position;
            startTime     = Time.time;

            massScalar = 0.012f / rocketMass;

            rb.mass        = rocketMass;
            rb.isKinematic = true;
            rb.velocity    = Vector3.zero;
            if (!FlightGlobals.RefFrameIsRotating)
            {
                rb.useGravity = false;
            }

            rb.useGravity = false;

            randThrustSeed = UnityEngine.Random.Range(0f, 100f);
            thrustVector   = new Vector3(0, 0, thrust);

            SetupAudio();

            if (this.sourceVessel)
            {
                var aName = this.sourceVessel.GetName();
                if (BDACompetitionMode.Instance && BDACompetitionMode.Instance.Scores.ContainsKey(aName))
                {
                    ++BDACompetitionMode.Instance.Scores[aName].shotsFired;
                }
                sourceVesselName = sourceVessel.GetName(); // Set the source vessel name as the vessel might have changed its name or died by the time the bullet hits.
            }
            else
            {
                sourceVesselName = null;
            }
            if (tntMass <= 0)
            {
                explosive = false;
            }
        }
Exemplo n.º 4
0
        void OnEnable()
        {
            if (parentPart == null)
            {
                gameObject.SetActive(false);
                return;
            }
            hasFuel   = true;
            startTime = Time.time;
            engine    = parentPart.FindModuleImplementing <ModuleEngines>();
            var leak = parentPart.FindModuleImplementing <ModuleDrainFuel>();

            if (leak != null)
            {
                leak.drainDuration = 0;
            }
            foreach (var existingLeakFX in parentPart.GetComponentsInChildren <FuelLeakFX>())
            {
                existingLeakFX.lifeTime = 0; //kill leak FX
            }

            BDArmorySetup.numberOfParticleEmitters++;
            pEmitters = gameObject.GetComponentsInChildren <KSPParticleEmitter>();

            using (var pe = pEmitters.AsEnumerable().GetEnumerator())
                while (pe.MoveNext())
                {
                    if (pe.Current == null)
                    {
                        continue;
                    }
                    pe.Current.emit = true;
                    _highestEnergy  = pe.Current.maxEnergy;
                    EffectBehaviour.AddParticleEmitter(pe.Current);
                }

            Seat = null;
            if (parentPart.parent != null)
            {
                var kerbalSeats = parentPart.parent.Modules.OfType <KerbalSeat>();
                if (kerbalSeats.Count() > 0)
                {
                    Seat = kerbalSeats.First();
                }
            }
            if (parentPart.protoModuleCrew.Count > 0) //crew can extingusih fire
            {
                burnTime = 10;
            }
            if (parentPart.parent != null && parentPart.parent.protoModuleCrew.Count > 0 || (Seat != null && Seat.Occupant != null))
            {
                burnTime = 20; //though adjacent parts will take longer to get to and extingusih
            }
            if (!surfaceFire)
            {
                if (parentPart.GetComponent <ModuleSelfSealingTank>() != null)
                {
                    ModuleSelfSealingTank FBX;
                    FBX = parentPart.GetComponent <ModuleSelfSealingTank>();
                    if (FBX.FireBottles > 0)
                    {
                        FBX.FireBottles -= 1;
                        if (engine != null && engine.EngineIgnited && engine.allowRestart)
                        {
                            engine.Shutdown();
                            enginerestartTime = Time.time;
                        }
                        burnTime = 10;
                        Misc.Misc.RefreshAssociatedWindows(parentPart);
                        Debug.Log("[FireFX] firebottles remianing in " + parentPart.name + ": " + FBX.FireBottles);
                    }
                    else
                    {
                        if (engine != null && engine.EngineIgnited && engine.allowRestart)
                        {
                            if (parentPart.vessel.verticalSpeed < 30) //not diving/trying to climb. With the vessel registry, could also grab AI state to add a !evading check
                            {
                                engine.Shutdown();
                                enginerestartTime = Time.time + 10;
                                burnTime          = 20;
                            }
                            //though if it is diving, then there isn't a second call to cycle engines. Add an Ienumerator to check once every couple sec?
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        void OnEnable()
        {
            // OLD:
            //thermal = BDArmorySetup.FLARE_THERMAL*UnityEngine.Random.Range(0.45f, 1.25f);
            // NEW: generate flare within spectrum of emitting vessel's heat signature
            thermal      = BDATargetManager.GetVesselHeatSignature(sourceVessel) * UnityEngine.Random.Range(0.65f, 1.75f);
            startThermal = thermal;
            minThermal   = startThermal * 0.3f;

            if (gaplessEmitters == null || pEmitters == null)
            {
                gaplessEmitters = new List <BDAGaplessParticleEmitter>();

                pEmitters = new List <KSPParticleEmitter>();

                IEnumerator <KSPParticleEmitter> pe = gameObject.GetComponentsInChildren <KSPParticleEmitter>().Cast <KSPParticleEmitter>().GetEnumerator();
                while (pe.MoveNext())
                {
                    if (pe.Current == null)
                    {
                        continue;
                    }
                    if (pe.Current.useWorldSpace)
                    {
                        BDAGaplessParticleEmitter gpe = pe.Current.gameObject.AddComponent <BDAGaplessParticleEmitter>();
                        gaplessEmitters.Add(gpe);
                        gpe.emit = true;
                    }
                    else
                    {
                        EffectBehaviour.AddParticleEmitter(pe.Current);
                        pEmitters.Add(pe.Current);
                        pe.Current.emit = true;
                    }
                }
                pe.Dispose();
            }
            List <BDAGaplessParticleEmitter> .Enumerator gEmitter = gaplessEmitters.GetEnumerator();
            while (gEmitter.MoveNext())
            {
                if (gEmitter.Current == null)
                {
                    continue;
                }
                gEmitter.Current.emit = true;
            }
            gEmitter.Dispose();

            List <KSPParticleEmitter> .Enumerator pEmitter = pEmitters.GetEnumerator();
            while (pEmitter.MoveNext())
            {
                if (pEmitter.Current == null)
                {
                    continue;
                }
                pEmitter.Current.emit = true;
            }
            pEmitter.Dispose();

            BDArmorySetup.numberOfParticleEmitters++;


            if (lights == null)
            {
                lights = gameObject.GetComponentsInChildren <Light>();
            }

            IEnumerator <Light> lgt = lights.AsEnumerable().GetEnumerator();

            while (lgt.MoveNext())
            {
                if (lgt.Current == null)
                {
                    continue;
                }
                lgt.Current.enabled = true;
            }
            lgt.Dispose();
            startTime = Time.time;

            //ksp force applier
            //gameObject.AddComponent<KSPForceApplier>().drag = 0.4f;


            BDArmorySetup.Flares.Add(this);

            if (sourceVessel != null)
            {
                relativePos = transform.position - sourceVessel.transform.position;
            }

            upDirection = VectorUtils.GetUpDirection(transform.position);

            velocity = startVelocity;
        }
Exemplo n.º 6
0
        void OnEnable()
        {
            startThermal = thermal;
            minThermal   = startThermal * 0.3f;

            if (gaplessEmitters == null || pEmitters == null)
            {
                gaplessEmitters = new List <BDAGaplessParticleEmitter>();

                pEmitters = new List <KSPParticleEmitter>();

                IEnumerator <KSPParticleEmitter> pe = gameObject.GetComponentsInChildren <KSPParticleEmitter>().Cast <KSPParticleEmitter>().GetEnumerator();
                while (pe.MoveNext())
                {
                    if (pe.Current == null)
                    {
                        continue;
                    }
                    if (pe.Current.useWorldSpace)
                    {
                        BDAGaplessParticleEmitter gpe = pe.Current.gameObject.AddComponent <BDAGaplessParticleEmitter>();
                        gaplessEmitters.Add(gpe);
                        gpe.emit = true;
                    }
                    else
                    {
                        EffectBehaviour.AddParticleEmitter(pe.Current);
                        pEmitters.Add(pe.Current);
                        pe.Current.emit = true;
                    }
                }
                pe.Dispose();
            }
            List <BDAGaplessParticleEmitter> .Enumerator gEmitter = gaplessEmitters.GetEnumerator();
            while (gEmitter.MoveNext())
            {
                if (gEmitter.Current == null)
                {
                    continue;
                }
                gEmitter.Current.emit = true;
            }
            gEmitter.Dispose();

            List <KSPParticleEmitter> .Enumerator pEmitter = pEmitters.GetEnumerator();
            while (pEmitter.MoveNext())
            {
                if (pEmitter.Current == null)
                {
                    continue;
                }
                pEmitter.Current.emit = true;
            }
            pEmitter.Dispose();

            BDArmorySetup.numberOfParticleEmitters++;

            if (lights == null)
            {
                lights = gameObject.GetComponentsInChildren <Light>();
            }

            IEnumerator <Light> lgt = lights.AsEnumerable().GetEnumerator();

            while (lgt.MoveNext())
            {
                if (lgt.Current == null)
                {
                    continue;
                }
                lgt.Current.enabled = true;
            }
            lgt.Dispose();
            startTime = Time.time;

            //ksp force applier
            //gameObject.AddComponent<KSPForceApplier>().drag = 0.4f;

            BDArmorySetup.Flares.Add(this);

            upDirection = VectorUtils.GetUpDirection(transform.position);
        }