public void GetUpdateString_ValidUpdateStringGenerated_ValidUpdateStringReturned() { BatteryCell bc = new BatteryCell(3) { Voltage = 3.2f }; Assert.AreEqual(String.Format("<BC;{0},{1}>", bc.CellID, bc.Voltage), bc.GetUpdateString()); }
public void UpdateFromString_InvalidUpdateString_ObjectUpdated() { BatteryCell bc = new BatteryCell(4) { Voltage = 3.5f }; string updateString; updateString = "<BC;4,3.6>"; bc.UpdateFromString(updateString); Assert.AreEqual(3.6f, bc.Voltage); }
private void HandleBatteryCellWarningVoltage(BatteryCell cell) { if (!this.Dispatcher.HasShutdownStarted && !this.Dispatcher.HasShutdownFinished) { this.Dispatcher.Invoke((Action)(() => { var cellBar = this.FindName("cellBar" + cell.CellID) as ProgressBar; cellBar.Foreground = Brushes.OrangeRed; var cellPanel = this.FindName("cellPanel" + cell.CellID) as StackPanel; cellPanel.ToolTip = "This battery cell is currently operating at a non-ideal voltage."; })); } }
private void HandleBatteryCellUnderVoltage(BatteryCell cell) { if (!this.Dispatcher.HasShutdownStarted && !this.Dispatcher.HasShutdownFinished) { this.Dispatcher.Invoke((Action)(() => { var cellBar = this.FindName("cellBar" + cell.CellID) as ProgressBar; cellBar.Foreground = Brushes.DarkRed; var cellPanel = this.FindName("cellPanel" + cell.CellID) as StackPanel; cellPanel.ToolTip = "This battery cell is currently experiencing under voltage."; })); } }
private void HandleBatteryCellNormalVoltage(BatteryCell cell) { if (!this.Dispatcher.HasShutdownStarted && !this.Dispatcher.HasShutdownFinished) { this.Dispatcher.Invoke((Action)(() => { var cellBar = this.FindName("cellBar" + cell.CellID) as ProgressBar; cellBar.Foreground = Brushes.Lime; var cellPanel = this.FindName("cellPanel" + cell.CellID) as StackPanel; cellPanel.ToolTip = null; })); } }
void SpawnCell(List <BatteryConfigInfo> infoList) { for (int i = 0; i < infoList.Count; i++) { GameObject go = Instantiate(BatteryCell); go.transform.SetParent(cellParent.transform); go.transform.localScale = Vector3.one; BatteryConfigInfo info = infoList[i]; BatteryCell batteryCell = go.GetComponent <BatteryCell>(); batteryCell.batteryInfo = info; GameObject okBtn = go.transform.GetChild(14).gameObject; EventTriggerListener.Get(okBtn, info).onClick = PlaceBattery; } }
public void UpdateFromString_InvalidUpdateString_ThrowException() { BatteryCell bc = new BatteryCell(2); string updateString; updateString = "<>"; Assert.Throws <InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); updateString = "<B;23,45.2>"; Assert.Throws <InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); updateString = "<B,1,4>"; Assert.Throws <InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); updateString = "<B;3,45.1235>"; Assert.Throws <InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); updateString = "<B;,12>"; Assert.Throws <InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); }
public void GetCellIDFromUpdateString_ValidUpdateString_CellIDReturned() { string updateString; updateString = "<BC;1,234.3>"; Assert.AreEqual(1, BatteryCell.GetCellIDFromUpdateString(updateString)); updateString = "<BC;2,234.3>"; Assert.AreEqual(2, BatteryCell.GetCellIDFromUpdateString(updateString)); updateString = "<BC;3,234.3>"; Assert.AreEqual(3, BatteryCell.GetCellIDFromUpdateString(updateString)); updateString = "<BC;4,234.3>"; Assert.AreEqual(4, BatteryCell.GetCellIDFromUpdateString(updateString)); updateString = "<BC;5,234.3>"; Assert.AreEqual(5, BatteryCell.GetCellIDFromUpdateString(updateString)); updateString = "<BC;6,234.3>"; Assert.AreEqual(6, BatteryCell.GetCellIDFromUpdateString(updateString)); updateString = "<BC;7,234.3>"; Assert.AreEqual(7, BatteryCell.GetCellIDFromUpdateString(updateString)); }
public void GetCellIDFromUpdateString_InvalidUpdateString_ExceptionThrown() { string updateString = "<BC;one,234.3>"; Assert.Throws <InvalidUpdateStringException>(() => BatteryCell.GetCellIDFromUpdateString(updateString)); }
private void UpdateBatteryCell(string updateString) { var bc = roverStatus.Battery.Cells.First(c => c.CellID == BatteryCell.GetCellIDFromUpdateString(updateString)); bc.UpdateFromString(updateString); }
private static bool Prefix(NetworkInstanceId parentId, ulong ownerSteamId, string prefabName) { DynamicThing dynamicThing = NetworkThing.Find(parentId) as DynamicThing; DynamicThing dynamicThing2 = (DynamicThing)Thing.FindPrefab(prefabName); bool flag = !dynamicThing2; if (!flag) { Vector3 vector = dynamicThing.RigidBody.worldCenterOfMass + dynamicThing.ThingTransform.forward * 1f; Quaternion rotation = Quaternion.AngleAxis(180f, dynamicThing.ThingTransform.up); DynamicThing dynamicThing3 = OnServer.Create(dynamicThing2, vector, rotation, ownerSteamId, null); Stackable stackable = dynamicThing3 as Stackable; bool flag2 = stackable; if (flag2) { stackable.NetworkQuantity = stackable.MaxQuantity; } BatteryCell batteryCell = dynamicThing3 as BatteryCell; bool flag3 = batteryCell; if (flag3) { batteryCell.PowerStored = batteryCell.PowerMaximum; } Ingot ingot = dynamicThing3 as Ingot; bool flag4 = ingot; if (flag4) { ingot.NetworkQuantity = ingot.MaxQuantity; } CreditCard creditCard = dynamicThing3 as CreditCard; bool flag5 = creditCard; if (flag5) { creditCard.Currency = 8000f; } DirtCanister dirtCanister = dynamicThing3 as DirtCanister; bool flag6 = dirtCanister; if (flag6) { dirtCanister.AddDirtCheat(8000f); } //Creative mode addition if (WorldManager.Instance.GameMode == GameMode.Creative) { int colorcan = -1; foreach (var chel in Human.AllHumans) //catch idea of search in lists from liz's AtomicBatteryPatch { if (chel.OwnerSteamId == dynamicThing3.OwnerSteamId) { Human parentHuman = null; parentHuman = chel; bool suitis = (parentHuman.Suit == null || parentHuman == null); if (!suitis) { //Debug.LogError("Builder catched"); colorcan = (int)(Math.Round(parentHuman.Suit.OutputSetting - 51f)); //pressure 50 = CustomColorIndex -1 default if (colorcan > 11) { colorcan = 11; } else if (colorcan < -1) { colorcan = -1; } } } } if (dynamicThing3.PaintableMaterial != null) { OnServer.SetCustomColor(dynamicThing3, colorcan); } } } return(false); }