public bool ModifyPower(float amount, out float modified) { modified = 0f; bool result; if (amount >= 0f) { result = (amount <= _capacity - _charge); modified = Mathf.Min(amount, _capacity - _charge); _charge += Mathf.Round(modified); } else { result = (_charge >= -amount); if (GameModeUtils.RequiresPower()) { modified = -Mathf.Min(-amount, _charge); _charge += Mathf.Round(modified); } else { modified = amount; } } return(result); }
public bool ModifyPower(float amount, out float modified) { bool result = false; modified = 0f; if (_powerState != FCSPowerStates.Unpowered && _chargeMode == PowerToggleStates.TrickleMode) { if (amount >= 0f) { result = (amount <= LoadData.BatteryConfiguration.Capacity - _charge); modified = Mathf.Min(amount, LoadData.BatteryConfiguration.Capacity - _charge); ChargeBatteries(modified); } else { result = (_charge >= -amount); if (GameModeUtils.RequiresPower()) { if (_chargeMode == PowerToggleStates.TrickleMode) { modified = -Mathf.Min(-amount, _charge); ConsumePower(modified); } } else { modified = amount; } } } return(result); }
public override void UpdateText() { if (GameModeUtils.RequiresPower() && base.Cyclops.powerRelay.GetPower() < Zapper.EnergyRequiredToZap) { base.UpperText.FontSize = 20; base.MiddleText.FontSize = 20; base.LowerText.FontSize = 20; base.UpperText.TextString = "CYCLOPS"; base.MiddleText.TextString = "POWER"; base.LowerText.TextString = "LOW"; base.UpperText.TextColor = Color.red; base.MiddleText.TextColor = Color.red; base.LowerText.TextColor = Color.red; } else { base.UpperText.FontSize = 12; base.LowerText.FontSize = 12; if (zapper.IsOnCooldown) { base.LowerText.TextString = "Defense System\n[Cooldown]"; base.LowerText.TextColor = Color.yellow; } else { base.LowerText.TextString = "Defense System\n[Charged]"; base.LowerText.TextColor = Color.white; } } }
public bool ModifyPower(float amount, out float modified) { modified = 0f; bool result; if (amount >= 0f) { result = (amount <= AIJetStreamT242Buildable.JetStreamT242Config.MaxCapacity - _charge); modified = Mathf.Min(amount, AIJetStreamT242Buildable.JetStreamT242Config.MaxCapacity - _charge); _charge += Mathf.Round(modified); } else { result = (_charge >= -amount); if (GameModeUtils.RequiresPower()) { modified = -Mathf.Min(-amount, _charge); _charge += Mathf.Round(modified); } else { modified = amount; } } return(result); }
public void PulseShield() { if (!this.HasUpgrade) { return; } if (!this.HasShieldModule) { return; } if (this.IsOnCooldown) { return; } UpdateCooldown(); float originalCost = Cyclops.shieldPowerCost; Cyclops.shieldPowerCost = originalCost * ShieldCostModifier; this.ShieldButton?.StartShield(); if (GameModeUtils.RequiresPower()) { Cyclops.powerRelay.ConsumeEnergy(Cyclops.shieldPowerCost, out float amountConsumed); } this.ShieldButton?.StopShield(); Cyclops.shieldPowerCost = originalCost; }
public virtual void Update() { if (_connectedRelay == null) { return; } //_energyToConsume = EnergyConsumptionPerSecond * DayNightCycle.main.deltaTime; bool requiresEnergy = GameModeUtils.RequiresPower(); bool hasPowerToConsume = !requiresEnergy || (this.AvailablePower >= EnergyConsumptionPerSecond); if (hasPowerToConsume && _prevPowerState != FCSPowerStates.Powered) { OnPowerResume?.Invoke(); _prevPowerState = FCSPowerStates.Powered; } else if (!hasPowerToConsume && _prevPowerState != FCSPowerStates.Unpowered) { OnPowerOutage?.Invoke(); _prevPowerState = FCSPowerStates.Unpowered; } //if (this.NotAllowToOperate) // return; //if (!hasPowerToConsume) // return; //if (requiresEnergy) // _connectedRelay.ConsumeEnergy(_energyToConsume, out float amountConsumed); }
public void ConsumePower(float amount) { if (GameModeUtils.RequiresPower()) { float totalPower = TotalCanProvide(out int sourceCount); if (sourceCount > 0) { amount = (amount > totalPower) ? totalPower : amount; amount = amount / sourceCount; BZLogger.Debug($"consume power: amount: {amount}, sources: {sourceCount}"); foreach (KeyValuePair <string, IBattery> kvp in batteries) { if (kvp.Value != null && kvp.Value.charge > 0f) { kvp.Value.charge += -Mathf.Min(amount, kvp.Value.charge); if (slots.TryGetValue(kvp.Key, out SlotDefinition definition)) { UpdateVisuals(definition, kvp.Value.charge / kvp.Value.capacity, equipment.GetItemInSlot(kvp.Key).item.GetTechType()); } } } } } }
public override void UpdateText() { if (GameModeUtils.RequiresPower() && base.Cyclops.powerRelay.GetPower() < Zapper.EnergyRequiredToZap) { base.MiddleText.FontSize = 20; base.MiddleText.TextString = DisplayTexts.Main.CyclopsPowerLow; base.MiddleText.TextColor = Color.red; base.UpperText.TextString = string.Empty; base.LowerText.TextString = string.Empty; } else { base.UpperText.FontSize = 12; base.LowerText.FontSize = 12; if (zapper.IsOnCooldown) { base.LowerText.TextString = DisplayTexts.Main.DefenseCooldown; base.LowerText.TextColor = Color.yellow; } else { base.LowerText.TextString = DisplayTexts.Main.DefenseCharged; base.LowerText.TextColor = Color.white; } } }
internal void ConsumePower() { bool requiresEnergy = GameModeUtils.RequiresPower(); if (requiresEnergy) { this.ConnectedRelay.ConsumeEnergy(_energyToConsume, out float amountConsumed); } }
/// <summary> /// Recharges the cyclops' power cells using all charging modules across all upgrade consoles. /// </summary> /// <returns><c>True</c> if the original code for the vanilla Cyclops Thermal Reactor Module is required; Otherwise <c>false</c>.</returns> public bool RechargeCyclops() { if (!initialized) { InitializeChargers(); } if (Time.timeScale == 0f) // Is the game paused? { return(false); } if (totalChargers < 0) { return(true); } // When in Creative mode or using the NoPower cheat, inform the chargers that there is no power deficit. // This is so that each charger can decide what to do individually rather than skip the entire charging cycle all together. powerDeficit = GameModeUtils.RequiresPower() ? Cyclops.powerRelay.GetMaxPower() - Cyclops.powerRelay.GetPower() : 0f; producedPower = 0f; // First, get renewable energy first for (int i = 0; i < this.Chargers.Length; i++) { producedPower += this.Chargers[i].Generate(powerDeficit); } if (powerDeficit > config.EmergencyEnergyDeficit || // Did the renewable energy sources not produce any power? (powerDeficit > config.MinimumEnergyDeficit && producedPower < MinimalPowerValue)) // Is the power deficit over the threshhold to start consuming non-renewable energy? { // Second, get non-renewable energy if there isn't enough renewable energy for (int i = 0; i < this.Chargers.Length; i++) { producedPower += this.Chargers[i].Drain(powerDeficit); } } if (producedPower > 0f) { Cyclops.powerRelay.ModifyPower(producedPower * this.RechargePenalty, out float amountStored); } // Last, inform the chargers to update their display status for (int i = 0; i < this.Chargers.Length; i++) { this.Chargers[i].UpdateStatus(); } return(requiresVanillaCharging); }
public override void UpdateText() { if (GameModeUtils.RequiresPower() && base.Cyclops.powerRelay.GetPower() < Zapper.EnergyRequiredToZap) { base.UpperText.FontSize = 20; base.MiddleText.FontSize = 20; base.LowerText.FontSize = 20; base.UpperText.TextString = "CYCLOPS"; base.MiddleText.TextString = "POWER"; base.LowerText.TextString = "LOW"; base.UpperText.TextColor = Color.red; base.MiddleText.TextColor = Color.red; base.LowerText.TextColor = Color.red; } else { base.UpperText.FontSize = 12; base.LowerText.FontSize = 12; if (zapper.SeamothInBay) { base.UpperText.TextString = "Seamoth\n[Connected]"; base.UpperText.TextColor = Color.green; if (zapper.HasSeamothWithElectricalDefense) { if (zapper.IsOnCooldown) { base.LowerText.TextString = "Defense System\n[Cooldown]"; base.LowerText.TextColor = Color.yellow; } else { base.LowerText.TextString = "Defense System\n[Charged]"; base.LowerText.TextColor = Color.white; } } else { base.LowerText.TextString = "Defense System\n[Missing]"; base.LowerText.TextColor = Color.red; } } else { base.UpperText.TextString = "Seamoth\n[Not Connected]"; base.UpperText.TextColor = Color.red; base.MiddleText.TextString = string.Empty; base.LowerText.TextString = string.Empty; } } }
private void StartShield() { sfx.Play(); if (GameModeUtils.RequiresPower()) { InvokeRepeating("ShieldIteration", 0f, shieldRunningIteration); } StartSeamothShielded(); }
private void UpdateLightEnergy() { if (lightIsActive) { float energyCost = DayNightCycle.main.deltaTime * ExosuitSettings.lightEnergyConsumption; float consumedEnergy = energyInterface.ConsumeEnergy(energyCost); if (consumedEnergy == 0 && energyCost != 0 && GameModeUtils.RequiresPower()) { SetLightsActive(false); } } }
public override void Process(PowerLevelChanged packet) { GameObject gameObject = GuidHelper.RequireObjectFrom(packet.Guid); if (packet.PowerType == PowerType.ENERGY_INTERFACE) { EnergyInterface energyInterface = gameObject.RequireComponent <EnergyInterface>(); float amount = packet.Amount; float num = 0f; if (GameModeUtils.RequiresPower()) { int num2 = 0; if (packet.Amount > 0f) { float num3 = energyInterface.TotalCanConsume(out num2); if (num3 > 0f) { float amount2 = amount / (float)num2; for (int i = 0; i < energyInterface.sources.Length; i++) { EnergyMixin energyMixin = energyInterface.sources[i]; if (energyMixin != null && energyMixin.charge < energyMixin.capacity) { num += energyMixin.ModifyCharge(amount2); } } } } else { float num4 = energyInterface.TotalCanProvide(out num2); if (num2 > 0) { amount = ((-amount <= num4) ? amount : (-num4)); for (int j = 0; j < energyInterface.sources.Length; j++) { EnergyMixin energyMixin2 = energyInterface.sources[j]; if (energyMixin2 != null && energyMixin2.charge > 0f) { float num5 = energyMixin2.charge / num4; num += energyMixin2.ModifyCharge(amount * num5); } } } } } } else { Log.Error("Unsupported packet power type: " + packet.PowerType); } }
public override void UpdateText() { if (GameModeUtils.RequiresPower() && base.Cyclops.powerRelay.GetPower() < Zapper.EnergyRequiredToZap) { base.MiddleText.FontSize = 20; base.MiddleText.TextString = DisplayTexts.Main.CyclopsPowerLow; base.MiddleText.TextColor = Color.red; base.UpperText.TextString = string.Empty; base.LowerText.TextString = string.Empty; } else { base.UpperText.FontSize = 12; base.LowerText.FontSize = 12; if (zapper.SeamothInBay) { base.UpperText.TextString = DisplayTexts.Main.SeamothConnected; base.UpperText.TextColor = Color.green; if (zapper.HasSeamothWithElectricalDefense) { if (zapper.IsOnCooldown) { base.LowerText.TextString = DisplayTexts.Main.DefenseCooldown; base.LowerText.TextColor = Color.yellow; } else { base.LowerText.TextString = DisplayTexts.Main.DefenseCharged; base.LowerText.TextColor = Color.white; } } else { base.LowerText.TextString = DisplayTexts.Main.DefenseMissing; base.LowerText.TextColor = Color.red; } } else { base.UpperText.TextString = DisplayTexts.Main.SeamothNotConnected; base.UpperText.TextColor = Color.red; base.MiddleText.TextString = string.Empty; base.LowerText.TextString = string.Empty; } } }
private void ZapRadius() { GameObject gameObject = Utils.SpawnZeroedAt(this.ElectricalDefensePrefab, Cyclops.transform, false); ElectricalDefense defenseComponent = gameObject.GetComponent <ElectricalDefense>(); defenseComponent.charge = ZapPower; defenseComponent.chargeScalar = ZapPower; defenseComponent.radius *= ZapPower; defenseComponent.chargeRadius *= ZapPower; if (GameModeUtils.RequiresPower()) { Cyclops.powerRelay.ConsumeEnergy(EnergyCostPerRadiusZap, out float amountConsumed); } }
public void Update() { chargeScale.localScale = new Vector3(shark.boostCharge, 1f, 1f); heatScale.localScale = new Vector3(shark.boostHeat, 1f, 1f); shark.energyInterface.GetValues(out float charge, out float capacity); if (GameModeUtils.RequiresPower()) { powerScale.localScale = new Vector3(charge / capacity, 1f, 1f); } else { powerScale.localScale = Vector3.one; } duraScale.localScale = new Vector3(shark.liveMixin.health / shark.liveMixin.maxHealth, 1f, 1f); }
/// <summary> /// Recharges the cyclops' power cells using all charging modules across all upgrade consoles. /// </summary> /// <returns><c>True</c> if the original code for the vanilla Cyclops Thermal Reactor Module is required; Otherwise <c>false</c>.</returns> public void RechargeCyclops() { if (!initialized) { InitializeChargers(); } if (Time.timeScale == 0f) // Is the game paused? { return; } // When in Creative mode or using the NoPower cheat, inform the chargers that there is no power deficit. // This is so that each charger can decide what to do individually rather than skip the entire charging cycle all together. powerDeficit = Cyclops.powerRelay.GetMaxPower() - Cyclops.powerRelay.GetPower(); producedPower = 0f; // First, get renewable energy first for (int i = 0; i < this.Chargers.Length; i++) { producedPower += this.Chargers[i].Generate(powerDeficit); } if (GameModeUtils.RequiresPower() && powerDeficit > producedPower) { // Second, get non-renewable energy if there isn't enough renewable energy for (int i = 0; i < this.Chargers.Length; i++) { producedPower += this.Chargers[i].Drain(powerDeficit); } } if (producedPower > 0f) { Cyclops.powerRelay.ModifyPower(producedPower * this.RechargePenalty, out float amountStored); } // Last, inform the chargers to update their display status for (int i = 0; i < this.Chargers.Length; i++) { this.Chargers[i].UpdateStatus(); } }
protected virtual bool AbleToZap() { if (!this.HasUpgrade) { return(false); } if (this.IsOnCooldown) { return(false); } if (GameModeUtils.RequiresPower() && Cyclops.powerRelay.GetPower() < EnergyRequiredToZap) { return(false); } return(true); }
internal bool HasEnoughPower(QTTeleportTypes type) { bool requiresEnergy = GameModeUtils.RequiresPower(); if (!requiresEnergy) { return(true); } switch (type) { case QTTeleportTypes.Global: return(ConnectedRelay != null && ConnectedRelay.GetPower() >= _interPowerUsage); case QTTeleportTypes.Intra: return(ConnectedRelay != null && ConnectedRelay.GetPower() >= _intraPowerUsage); } return(false); }
public void PulseShield() { if (!this.HasUpgrade) { return; } if (!this.HasShieldModule) { return; } if (this.IsOnCooldown) { return; } UpdateCooldown(); if (GameModeUtils.RequiresPower()) { float originalCost = Cyclops.shieldPowerCost; Cyclops.shieldPowerCost = originalCost * ShieldCostModifier; Cyclops.powerRelay.ConsumeEnergy(Cyclops.shieldPowerCost, out float amountConsumed); Cyclops.shieldPowerCost = originalCost; } LavaLarva[] leaches = Cyclops.gameObject.GetComponentsInChildren <LavaLarva>(); if (leaches == null) { QuickLogger.Warning("GetComponentsInChildren<LavaLarva>() returned null"); return; } for (int i = 0; i < leaches.Length; i++) { leaches[i].GetComponent <LiveMixin>().TakeDamage(1f, default(Vector3), DamageType.Electrical, null); } }
public void Update() { if (rateLimiter.Update(8.0f)) { float charge = GetCharge(); if (Mathf.Abs(lastCharge - charge) >= 5.0f) { lastCharge = charge; if (GameModeUtils.RequiresPower()) { var res = new ClientPowerChange(); res.targetGuid = GuidHelper.Get(gameObject); res.total = charge; res.force = false; Multiplayer.main.Send(res); } } } }
public void Update() { if (GameModeUtils.RequiresPower()) { bool flag = CheckMainPowerLevel(); if (isMainPowered != flag) { isMainPowered = flag; onPowerLevelChanged?.Invoke(isCabinPowered, isMainPowered); } } else if (!isMainPowered) { isMainPowered = true; isCabinPowered = powerRelay.IsPowered(); onPowerLevelChanged?.Invoke(isCabinPowered, isMainPowered); } }
public bool ModifyPower(float amount, out float modified) { modified = 0f; bool result = false; foreach (PowercellData powercellData in _powercellTracker) { if (powercellData.Battery.charge >= Mathf.Abs(amount)) { QuickLogger.Debug($"{powercellData.Battery.charge} || {amount}"); var battery = powercellData.Battery; if (amount >= 0f) { result = (amount <= battery.capacity - battery.charge); modified = Mathf.Min(amount, battery.capacity - battery.charge); battery.charge += modified; } else { result = (battery.charge >= -amount); if (GameModeUtils.RequiresPower()) { modified = -Mathf.Min(-amount, battery.charge); battery.charge += modified; } else { modified = amount; } } break; } } UpdateCharge(); return(result); }
public void AttemptBlink(Shark shark) { if (!shark.energyInterface.hasCharge && GameModeUtils.RequiresPower()) { return; } Vector3 targetPos = Vector3.zero; if (GameInput.GetMoveDirection().magnitude > 0f) { targetPos = shark.transform.position + shark.useRigidbody.velocity.normalized * 25f; } else { targetPos = shark.transform.position + shark.transform.forward * 25f; } targetPos.y = Mathf.Clamp(targetPos.y, Ocean.main.GetOceanLevel() - 3000f, Ocean.main.GetOceanLevel()); var hits = Physics.RaycastAll(shark.transform.position, shark.useRigidbody.velocity.normalized, 30f); foreach (RaycastHit hit in hits) { if (hit.transform.GetComponentInParent <Shark>()) { continue; } targetPos = hit.point + hit.normal.normalized * 5f; break; } shark.transform.position = targetPos; shark.fxControl.blinkFX.Play(true); Utils.PlayFMODAsset(blinkSound, transform); }
public void PulseShield() { if (!this.HasUpgrade) { return; } if (!this.HasShieldModule) { return; } if (this.IsOnCooldown) { return; } UpdateCooldown(); float originalCost = Cyclops.shieldPowerCost; Cyclops.shieldPowerCost = originalCost * ShieldCostModifier; if (GameModeUtils.RequiresPower()) { Cyclops.powerRelay.ConsumeEnergy(Cyclops.shieldPowerCost, out float amountConsumed); } Cyclops.shieldPowerCost = originalCost; LavaLarva[] componentsInChildren = Cyclops.gameObject.GetComponentsInChildren <LavaLarva>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].GetComponent <LiveMixin>().TakeDamage(1f, default(Vector3), DamageType.Electrical, null); } }
/// <summary> /// Handles the code for scaling up and down targets when using Scale Mode. /// </summary> private void ResizeMode() { try { if (Targeting.GetTarget(Player.main.gameObject, Main.Config.TargetingRange, out var go, out _)) { var entityRoot = Utils.GetEntityRoot(go) ?? go; // Handles the Target display on the top of the gun. var techType = CraftData.GetTechType(entityRoot); var techTypeString = techType != TechType.None ? techType.AsString() : ""; var translatedName = techTypeString != "" ? Language.main.GetOrFallback(techTypeString, techTypeString) + " size" : ""; var scale = translatedName != "" ? System.Math.Round(entityRoot.transform.localScale.x, 2) .ToString() : ""; textName.text = translatedName; textHealth.text = scale; if (GameInput.GetButtonDown(GameInput.Button.Deconstruct)) { entityRoot.transform.localScale = Vector3.one; } else if (GameInput.GetButtonHeld(GameInput.Button.RightHand) && ScaleBig && (energyMixin.ConsumeEnergy(1f * Main.Config.ScaleUpspeed) || !GameModeUtils.RequiresPower())) { par[5].gameObject.transform.Rotate(Vector3.forward * 5f); var changeSpeed = Main.Config.ScaleUpspeed; var oldScale = entityRoot.transform.localScale; var newScale = new Vector3(oldScale.x + changeSpeed, oldScale.y + changeSpeed, oldScale.z + changeSpeed); entityRoot.transform.localScale = newScale; if (!Main.Config.LethalResizing || (!(newScale.x >= Main.Config.ScaleKillSize) && !(newScale.y >= Main.Config.ScaleKillSize) && !(newScale.z >= Main.Config.ScaleKillSize))) { return; } entityRoot.GetComponentInChildren <LiveMixin>()?.Kill(); entityRoot.GetComponentInChildren <BreakableResource>()?.HitResource(); var drillable = entityRoot.GetComponent <Drillable>(); if (drillable is null) { return; } while (drillable.health.Sum() > 0) { drillable.OnDrill(entityRoot.transform.position, null, out var _); } } else if (GameInput.GetButtonHeld(GameInput.Button.RightHand) && ScaleSmall && (energyMixin.ConsumeEnergy(1f * Main.Config.ScaleDownspeed) || !GameModeUtils.RequiresPower())) { par[6].gameObject.transform.Rotate(-Vector3.forward * 5f); var changeSpeed = Main.Config.ScaleDownspeed; var oldScale = entityRoot.transform.localScale; var newScale = new Vector3(oldScale.x - changeSpeed, oldScale.y - changeSpeed, oldScale.z - changeSpeed); entityRoot.transform.localScale = newScale.x > changeSpeed ? newScale : new Vector3(0.01f, 0.01f, 0.01f); } } else { textName.text = ""; textHealth.text = ""; } }
void Update() { bool isAboveWater = transform.position.y > Ocean.main.GetOceanLevel() || shark.precursorOutOfWater; if (isAboveWater != shark.wasAboveWater) { sound.DoSplash(); shark.wasAboveWater = isAboveWater; } if (transform.parent) { transform.parent = null; } bool freecamEnabled = MainCameraControl.main.GetComponent <FreecamController>().GetActive(); cam.shouldLook = shark.GetPilotingMode() && Time.timeScale > 0f && !freecamEnabled; // Process Controls if (shark.GetPilotingMode() && !DevConsole.instance.selected && !freecamEnabled) { if (shark.energyInterface.hasCharge || !GameModeUtils.RequiresPower()) { if (GameInput.GetButtonDown(GameInput.Button.AltTool)) { shark.ToggleLights(!shark.lights.GetLightsActive()); } if (GameInput.GetButtonHeld(GameInput.Button.RightHand)) { shark.weapons.AttemptShoot(); } if (GameInput.GetButtonDown(GameInput.Button.Exit)) { ExitVehicle(); } if (shark.boostHeat == 1f) { shark.boostCharge = 0f; shark.overheated = true; } if (shark.boostHeat == 0f) { shark.overheated = false; } float preBoost = shark.boostCharge; if (GameInput.GetButtonHeld(GameInput.Button.Sprint) && !shark.overheated) { shark.boostCharge += Time.deltaTime * 2f; } else { shark.boostCharge = 0f; } shark.boostCharge = Mathf.Clamp01(shark.boostCharge); float postBoost = shark.boostCharge; shark.isBoosting = shark.boostCharge == 1f; if (isAboveWater) { shark.isBoosting = false; } shark.boostHeat += shark.isBoosting ? Time.deltaTime / 5f : -Time.deltaTime / 5f; shark.boostHeat = Mathf.Clamp01(shark.boostHeat); shark.boostChargeDelta = postBoost - preBoost; // Look rotation lookForce = GameInput.GetLookDelta(); } else { shark.ToggleLights(false); } } }
internal bool HasPowerToConsume() { bool requiresEnergy = GameModeUtils.RequiresPower(); return(!requiresEnergy || (this.AvailablePower >= _energyToConsume)); }
private void Update() { if (this.NotAllowToOperate) { return; } _energyToConsume = EnergyConsumptionPerSecond * DayNightCycle.main.deltaTime; var batteryChargePull = DayNightCycle.main.deltaTime * chargeSpeed * _powercellData.GetCapacity(); bool requiresEnergy = GameModeUtils.RequiresPower(); bool hasPowerToConsume = !requiresEnergy || (this.AvailablePower >= _energyToConsume); if (hasPowerToConsume && !_prevPowerState) { OnPowerResume?.Invoke(); _prevPowerState = true; } else if (!hasPowerToConsume && _prevPowerState) { OnPowerOutage?.Invoke(); _prevPowerState = false; } if (!hasPowerToConsume) { return; } if (requiresEnergy) { if (_connectedRelay.GetPower() <= _energyToConsume) { _powercellData.RemoveCharge(_energyToConsume); return; } if (!GetHasBreakerTripped()) { _connectedRelay.ConsumeEnergy(_energyToConsume, out float amountConsumed); } if (!_powercellData.IsFull()) { if (_connectedRelay.GetPower() >= batteryChargePull) { _chargeTimer -= Time.deltaTime; if (_chargeTimer < 0) { _connectedRelay.ConsumeEnergy(batteryChargePull, out float amountPConsumed); _powercellData.AddCharge(amountPConsumed); QuickLogger.Debug($"Charging Battery: {amountPConsumed} units", true); _chargeTimer = 5f; } } } //QuickLogger.Debug($"Power Consumed: {amountConsumed}"); _mono.DisplayManager.UpdateVisuals(_powercellData); } }