Ejemplo n.º 1
0
 private void Update()
 {
     if (health == null)
     {
         health = GetComponent <TurbineHealth>();
     }
     if (constructable == null)
     {
         constructable = gameObject.GetComponent <Constructable>();
     }
     if (constructable.constructed && Time.time > timeEastereggEnd && !NeedsMaintenance)
     {
         if (!loopSource.isPlaying)
         {
             loopSource.Play();
         }
         float amount = this.GetRechargeScalar() * DayNightCycle.main.deltaTime * 40f * WindyMultiplier(new Vector2(transform.position.x, transform.position.z));
         this.relay.ModifyPower(amount / 4f, out float num);
         if (QPatch.config.TurbineTakesDamage && health.health - num > 0f)
         {
             health.TakeDamage(num / 15f);
         }
         this.spin.spinSpeed    = amount * 10f;
         this.loopSource.volume = Mathf.Clamp(amount, 0.6f, 1f);
     }
     if (NeedsMaintenance)
     {
         this.spin.spinSpeed = 0f;
         loopSource.Stop();
     }
 }
Ejemplo n.º 2
0
        private void Update()
        {
            if (health == null)
            {
                health = GetComponent <TurbineHealth>();
            }
            if (constructable == null)
            {
                constructable = gameObject.GetComponent <Constructable>();
            }

            if (NeedsMaintenance)
            {
                this.spin.spinSpeed = 0f;
                if (loopSource != null)
                {
                    loopSource.Stop();
                }
            }
            else if (constructable.constructed && Time.time > timeEastereggEnd)
            {
                float deltaTime = Time.deltaTime;
                if (!loopSource.isPlaying)
                {
                    loopSource.Play();
                }
                float amount   = this.GetRechargeScalar() * DayNightCycle.main.deltaTime * 40f * WindyMultiplier(new Vector2(transform.position.x, transform.position.z));
                float powerGen = QPatch.config.PowerProductionScale * amount / 4f;
                this.profileEnergy += powerGen;
                this.profileTime   += deltaTime;
                if (profileTime >= 1)
                {
                    this.generationRate = this.profileEnergy / this.profileTime;
                    this.profileEnergy  = 0f;
                    this.profileTime    = 0;
                }
                this.relay.ModifyPower(powerGen, out float num);
                float damage = 200f / QPatch.config.SecondsUntilNeedMaintenance * deltaTime;
                if (QPatch.config.TurbineTakesDamage && health.health - damage > 0f)
                {
                    health.TakeDamage(num / 15f);
                }
                this.spin.spinSpeed    = amount * 10f;
                this.loopSource.volume = Mathf.Clamp(amount, 0.6f, 1f);
            }
        }