public void OnDisable() { weldSound.Stop(); isActive = false; toggle = false; currentMode = RepairMode.Disabled; Modules.SetInteractColor(Modules.Colors.White); Modules.SetProgressColor(Modules.Colors.White); }
public void Update() { if (isActive) { if (thisVehicle.liveMixin.health < thisVehicle.liveMixin.maxHealth && energyMixin.charge > energyMixin.capacity * 0.1f) { currentMode = RepairMode.Repair; 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) { Modules.SetProgressColor(Modules.Colors.Red); Modules.SetInteractColor(Modules.Colors.Red); } else if (thisVehicle.liveMixin.health < thisVehicle.liveMixin.maxHealth * 0.75f && thisVehicle.liveMixin.health > thisVehicle.liveMixin.maxHealth * 0.5f) { Modules.SetProgressColor(Modules.Colors.Yellow); Modules.SetInteractColor(Modules.Colors.Yellow); } else if (thisVehicle.liveMixin.health > thisVehicle.liveMixin.maxHealth * 0.75f) { Modules.SetProgressColor(Modules.Colors.Green); Modules.SetInteractColor(Modules.Colors.Green); } main.SetProgress(thisVehicle.liveMixin.health / thisVehicle.liveMixin.maxHealth); if (thisVehicle.liveMixin.health >= thisVehicle.liveMixin.maxHealth) { thisVehicle.liveMixin.health = thisVehicle.liveMixin.maxHealth; currentMode = RepairMode.None; thisVehicle.SlotKeyDown(moduleSlotID); return; } } else if (energyMixin.charge <= energyMixin.capacity * 0.1f) { if (idleTimer > 0f) { weldSound.Stop(); idleTimer = Mathf.Max(0f, idleTimer - Time.deltaTime); Modules.SetInteractColor(Modules.Colors.Red); main.SetInteractText("Warning!\nLow Power!", "Repair Module Disabled!", false, false, HandReticle.Hand.None); } else { idleTimer = 3f; thisVehicle.SlotKeyDown(moduleSlotID); return; } } if (currentMode == RepairMode.None || currentMode == RepairMode.Disabled && thisVehicle.liveMixin.health == thisVehicle.liveMixin.maxHealth) { thisVehicle.SlotKeyDown(moduleSlotID); return; } } else if (currentMode == RepairMode.Repair) { thisVehicle.SlotKeyDown(moduleSlotID); } }
/// <summary> /// Returns the capacity for repair available to this ship in the RepairMode provided. /// UOM is hitPts per day. IMPROVE Acquire value from data fields. /// </summary> /// <param name="mode">The RepairMode.</param> /// <returns></returns> public float GetRepairCapacity(RepairMode mode) { switch (mode) { case RepairMode.Self: return 2F; // HACK case RepairMode.PlanetHighOrbit: return 4F; // HACK case RepairMode.PlanetCloseOrbit: return 6F; // HACK case RepairMode.AlliedPlanetHighOrbit: return 8F; // HACK case RepairMode.AlliedPlanetCloseOrbit: return 10F; // HACK case RepairMode.BaseHighOrbit: case RepairMode.BaseCloseOrbit: case RepairMode.AlliedBaseHighOrbit: case RepairMode.AlliedBaseCloseOrbit: case RepairMode.None: default: throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(mode)); } }