private void SMSViewerForm_Load(object sender, EventArgs e) { MobileFactory factory = MobileFactory.Instance(); _output = new WindowsFormOutput(messagesListView, systemOutputTextBox); _mobile = factory.GetMobile(_model, _output); _mobile.SetChargeLevelChangedHandler(ChargeLevelChangedHandler); FormatUtils.formatOptions.ForEach(value => formatOptionsComboBox.Items.Add(value)); formatOptionsComboBox.SelectedIndex = 0; _charger = BatteryChargerFactory.Instance().GetBatteryCharger(BatteryChargerType.THREAD, 3); _charger.Start(); var chargerTypes = Enum.GetValues(typeof(BatteryChargerType)); foreach (var chargerType in chargerTypes) { chargerTypeComboBox.Items.Add(chargerType); } chargerTypeComboBox.SelectedIndex = 0; var providerTypes = Enum.GetValues(typeof(SMSProviderType)); foreach (var providerType in providerTypes) { providerTypeComboBox.Items.Add(providerType); } providerTypeComboBox.SelectedIndex = 0; }
[HarmonyPrefix] // This will run just before the code in the chosen method public static void Prefix(ref BatteryCharger __instance) { HashSet <TechType> compatibleTech = BatteryCharger.compatibleTech; // Make sure the Deep Battery is allowed in the battery charger if (!compatibleTech.Contains(DeepBatteryCellBase.BatteryID)) { compatibleTech.Add(DeepBatteryCellBase.BatteryID); } }
public static void Prefix(ref BatteryCharger __instance) { HashSet <TechType> compatibleTech = BatteryCharger.compatibleTech; // Make sure the Acid Battery is NOT allowed in the battery charger if (compatibleTech.Contains(AcidBatteryCellBase.BatteryID)) { compatibleTech.Remove(AcidBatteryCellBase.BatteryID); } }
public static void Prefix(ref BatteryCharger __instance) { FieldInfo compatTechField = typeof(BatteryCharger).GetField("compatibleTech", BindingFlags.Static | BindingFlags.NonPublic); var compatTech = (HashSet <TechType>)compatTechField.GetValue(null); if (!compatTech.Contains(EnzymeBatteryCore.BattID)) { compatTech.Add(EnzymeBatteryCore.BattID); } }
void OnTriggerEnter(Collider collider) { if (collider.tag == "Charger") { if (!isPowered) { connectedChargerObject = collider.transform.parent.gameObject; connectedCharger = connectedChargerObject.GetComponent <BatteryCharger> (); connectedCharger.SetConnectedInteractable(gameObject); } } }
static void Main(string[] args) { IBattery battery = new Battery(5000); IBattery fastBattery = new FastChargingBattery(12000); var batteryCharger = new BatteryCharger(4000); batteryCharger.ChargeBattery(battery); batteryCharger.ChargeBattery(fastBattery); Console.ReadLine(); }
public void DisconnectCharger(BatteryCharger charger) { if (Battery.IsCharging) { Battery.IsCharging = false; charger.Charge -= Battery.IncreaseChargeLevel; Output.WriteLine($"Charger has successfully disconnected."); } else { Output.WriteLine($"Charger is not connected."); } }
public void ConnectCharger(BatteryCharger charger) { if (!Battery.IsCharging) { Battery.IsCharging = true; charger.Charge += Battery.IncreaseChargeLevel; Output.WriteLine($"Charging started..."); } else { Output.WriteLine($"Charger has already connected."); } }
[HarmonyPrefix] // This will run just before the code in the chosen method public static void Prefix(ref BatteryCharger __instance) { // The HashSet of compatible batteries is a private static field FieldInfo compatibleTechFieldInfo = typeof(BatteryCharger).GetField("compatibleTech", BindingFlags.Static | BindingFlags.NonPublic); var compatibleTech = (HashSet <TechType>)compatibleTechFieldInfo.GetValue(null); // Make sure the Deep Battery is allowed in the battery charger if (!compatibleTech.Contains(DeepBatteryCellBase.BatteryID)) { compatibleTech.Add(DeepBatteryCellBase.BatteryID); } }
private void chargerTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { var chargerTypeString = chargerTypeComboBox.SelectedItem.ToString(); var chargerType = (BatteryChargerType)Enum.Parse(typeof(BatteryChargerType), chargerTypeString); if (_mobile.IsCharging()) { _mobile.DisconnectCharger(_charger); } _charger.Stop(); _charger = BatteryChargerFactory.Instance().GetBatteryCharger(chargerType, 3); _charger.Start(); _output.WriteLine($"{chargerType.ToString()} selected for charging."); }
public static bool Prefix(BatteryCharger __instance) { var BCColor = __instance.GetComponentsInChildren <SkinnedMeshRenderer>(); foreach (var Bccolor in BCColor) { if (Bccolor.name.Contains("battery_charging_station_")) { Bccolor.material.color = new Color32(Convert.ToByte(Config.fabricatorValue), Convert.ToByte(Config.fabricatorgValue), Convert.ToByte(Config.fabricatorbValue), 1); } } return(true); }
private void TestThatBatteryChargeLevelIncreasedWhenChargerIsConnected(BatteryChargerType type) { int value = _battery.ChargeLevel; _discharger.Start(); BatteryCharger charger = BatteryChargerFactory.Instance().GetBatteryCharger(type, CHARGE_VALUE); charger.Charge += _battery.IncreaseChargeLevel; charger.Start(); Thread.Sleep(Convert.ToInt32(Math.Max(_discharger.DischargePeriod * 1.1, charger.ChargePeriod * 1.1))); if (Math.Abs(DISCHARGE_VALUE) / _discharger.DischargePeriod >= CHARGE_VALUE / charger.ChargePeriod) { Assert.True(value >= _battery.ChargeLevel); } else { Assert.True(value < _battery.ChargeLevel); } }
void ChargerDisabled() { connectedCharger = null; }
private void ButtonStopChargeClick(object sender, EventArgs e) { BatteryCharger.StopCharge(); NotifyOnLower10Charge = true; }
private void ButtonChargeClick(object sender, EventArgs e) { BatteryCharger.StartCharge(); NotifyOnLower10Charge = false; UnLockOnZeroChargeLevel(); }
public void ChargeBattery() { BatteryCharger.ChargeBattery(this); }