public override float ModifyDamage(float damage, DamageType type)
        {
            float modifiedDamage = damage;

            if (bActive)
            {
                if (parentEnergy == null)
                {
                    parentEnergy = GetComponentInParent <EnergyMixin>();
                }

                if (parentEnergy == null)
                {
                    // Error state
                    return(damage);
                }

                float damageReduction   = damage * (1 - multiplier);
                float energyConsumption = damageReduction * fDamageToEnergyRatio;
                if (parentEnergy.ConsumeEnergy(energyConsumption))
                {
                    Log.LogDebug($"Hoverbike received {damage} damage, reduced by {damageReduction} costing {energyConsumption} energy");
                    modifiedDamage -= damageReduction;
                }
            }

            return(modifiedDamage);
        }
        private PDAScanner.Result Scan()
        {
            if (stateCurrent != ScanState.None)
            {
                return(PDAScanner.Result.None);
            }
            if (idleTimer > 0f)
            {
                return(PDAScanner.Result.None);
            }

            PDAScanner.Result     result     = PDAScanner.Result.None;
            PDAScanner.ScanTarget scanTarget = PDAScanner.scanTarget;
            PDAScanner.UpdateTarget(scanDistance, false);

            if (scanTarget.isValid && energyMixin.charge > 0f)
            {
                result = PDAScanner.Scan();

                if (result == PDAScanner.Result.Scan)
                {
                    float amount = powerConsumption * Time.deltaTime;
                    energyMixin.ConsumeEnergy(amount);
                    stateCurrent = ScanState.Scan;
                    isScanning   = true;
                }
                else if (result == PDAScanner.Result.Done || result == PDAScanner.Result.Researched)
                {
                    idleTimer = 0.5f;
                    PDASounds.queue.PlayIfFree(completeSoundAsset);
                }
            }
            return(result);
        }
示例#3
0
 private void ShieldIteration()
 {
     if (!energyMixin.ConsumeEnergy(shieldPowerCost))
     {
         StopShield();
     }
 }
        private void ShieldIteration()
        {
            if (energyMixin.charge < energyMixin.capacity * 0.2f)
            {
                ErrorMessage.AddDebug("Warning!\nLow Power!\nEnergy Shield Disabled!");

                StopShield();

                thisSeamoth.SlotKeyDown(GetShieldSlot());
            }
            else if (!energyMixin.ConsumeEnergy(shieldPowerCost))
            {
                StopShield();
            }
        }
 public void LateUpdate()
 {
     if (laserCannonEnabled)
     {
         if (shoot && repeat)
         {
             beamPositions[0]           = seamoth.torpedoTubeLeft.transform.position;
             beamPositions[1]           = CalculateLaserBeam();
             beamPositions[2]           = seamoth.torpedoTubeRight.transform.position;
             lineRenderer.positionCount = beamPositions.Length;
             lineRenderer.SetPositions(beamPositions);
             lineRenderer.material.color = Color.Lerp(beamcolor, Color.clear, 0.1f);
             laserBeam.SetActive(true);
             loopingEmitter.Play();
             energyMixin.ConsumeEnergy(powerConsumption * Time.deltaTime);
         }
         else
         {
             loopingEmitter.Stop();
             laserBeam.SetActive(false);
         }
     }
 }
示例#6
0
        private PDAScanner.Result Scan()
        {
            if (stateCurrent != ScanState.None)
            {
                return(PDAScanner.Result.None);
            }
            if (idleTimer > 0f)
            {
                return(PDAScanner.Result.None);
            }

            PDAScanner.Result     result     = PDAScanner.Result.None;
            PDAScanner.ScanTarget scanTarget = PDAScanner.scanTarget;

            if (scanTarget.isValid && energyMixin.charge > 0f)
            {
                result = PDAScanner.Scan();

                if (result == PDAScanner.Result.Scan)
                {
                    float amount = powerConsumption * Time.deltaTime;
                    energyMixin.ConsumeEnergy(amount);
                    stateCurrent = ScanState.Scan;
                }
                else if (result == PDAScanner.Result.Done || result == PDAScanner.Result.Researched)
                {
                    idleTimer = 0.5f;
                    PDASounds.queue.PlayIfFree(completeSound);
                    if (fxControl != null)
                    {
                        fxControl.Play(0);
                    }
                }
            }
            return(result);
        }
        public void Update()
        {
            if (!isActive)
            {
                return;
            }

            else if (thisVehicle.liveMixin.health < thisVehicle.liveMixin.maxHealth && energyMixin.charge > energyMixin.capacity * 0.1f)
            {
                weldSound.Play();
                energyMixin.ConsumeEnergy(powerConsumption * Time.deltaTime);
                main.SetIcon(HandReticle.IconType.Progress, 1.5f);
                thisVehicle.liveMixin.health += Time.deltaTime * repairPerSec;
                main.SetInteractText("Repairing...", false, HandReticle.Hand.None);

                if (thisVehicle.liveMixin.health < thisVehicle.liveMixin.maxHealth * 0.5f)
                {
                    SetProgressColor(Color.red);
                    SetInteractColor(Color.red);
                }
                else if (thisVehicle.liveMixin.health < thisVehicle.liveMixin.maxHealth * 0.75f && thisVehicle.liveMixin.health > thisVehicle.liveMixin.maxHealth * 0.5f)
                {
                    SetProgressColor(Color.yellow);
                    SetInteractColor(Color.yellow);
                }
                else if (thisVehicle.liveMixin.health > thisVehicle.liveMixin.maxHealth * 0.75f)
                {
                    SetProgressColor(Color.green);
                    SetInteractColor(Color.green);
                }

                main.SetProgress(thisVehicle.liveMixin.health / thisVehicle.liveMixin.maxHealth);

                if (thisVehicle.liveMixin.health >= thisVehicle.liveMixin.maxHealth)
                {
                    thisVehicle.liveMixin.health = thisVehicle.liveMixin.maxHealth;
                    thisVehicle.SlotKeyDown(moduleSlotID);
                    return;
                }
            }
            else if (energyMixin.charge <= energyMixin.capacity * 0.1f)
            {
                if (idleTimer > 0f)
                {
                    weldSound.Stop();
                    idleTimer = Mathf.Max(0f, idleTimer - Time.deltaTime);
                    SetInteractColor(Color.red);
                    main.SetInteractText("Warning!\nLow Power!", "Repair Module Disabled!", false, false, HandReticle.Hand.None);
                }
                else
                {
                    idleTimer = 3f;
                    thisVehicle.SlotKeyDown(moduleSlotID);
                    return;
                }
            }
            else if (thisVehicle.liveMixin.health == thisVehicle.liveMixin.maxHealth)
            {
                thisVehicle.SlotKeyDown(moduleSlotID);
                return;
            }
        }
        [HarmonyPrefix]      // Harmony prefix
        public static bool Prefix(Vehicle __instance, ref float energyCost, ref bool __result)
        {
            float           enginePowerRating   = Traverse.Create(__instance).Field("enginePowerRating").GetValue <float>();
            EnergyInterface thisEnergyInterface = __instance.GetComponent <EnergyInterface>();
            EnergyMixin     thisEnergyMixing    = __instance.GetComponent <EnergyMixin>();
            float           realEnergyCost      = energyCost / enginePowerRating;

            if (Player.main.currentMountedVehicle != null && Player.main.currentMountedVehicle == __instance)
            {
                if (SeamothInfo.ModeGreenOn) // Only gears 1 to 5 are provided (note that the first number in the division bracket is the desired energy consumption)
                {
                    if (Config.SeamothGearValue == 1f)
                    {
                        realEnergyCost = energyCost * (10f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 2f)
                    {
                        realEnergyCost = energyCost * (20f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 3f)
                    {
                        realEnergyCost = energyCost * (40f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 4f)
                    {
                        realEnergyCost = energyCost / enginePowerRating; // Energy consumption is 80 (80f / 80f)
                    }
                    else if (Config.SeamothGearValue == 5f)
                    {
                        realEnergyCost = energyCost * (120f / 80f) / enginePowerRating;
                    }
                }
                else
                { // note that the first number in the division bracket is the desired energy consumption
                    if (Config.SeamothGearValue == 1f)
                    {
                        realEnergyCost = energyCost * (10f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 2f)
                    {
                        realEnergyCost = energyCost * (30f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 3f)
                    {
                        realEnergyCost = energyCost * (60f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 4f)
                    {
                        realEnergyCost = energyCost * (100f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 5f)
                    {
                        realEnergyCost = energyCost * (150f / 80f) / enginePowerRating;
                    }
                    else if (Config.SeamothGearValue == 6f)
                    {
                        realEnergyCost = energyCost * (300f / 80f) / enginePowerRating;
                    }
                } // end else
                int   num;
                float energyCanProvide = thisEnergyInterface.TotalCanProvide(out num);
                __result = thisEnergyMixing.ConsumeEnergy(Mathf.Min(realEnergyCost, energyCanProvide));
                return(false);
            } // end if (Player.main.currentMountedVehicle != null)
            return(true);
        }     // end public static bool Prefix(Vehicle __instance, ref float energyCost, ref bool __result)