public void VolumeStorage_BasicChecks() { var cookies = SetupCookieTradeGood(); var cookiePile = new VolumeStorageDB(); cookiePile.TypeStores.Add(cookies.CargoTypeID, new TypeStore(100)); var added = cookiePile.AddCargoByUnit(cookies, 99); var storedCookies = cookiePile.GetUnitsStored(cookies); var storedCookieMass = cookiePile.GetMassStored(cookies); var storedCookieVolume = cookiePile.GetVolumeStored(cookies); Assert.AreEqual(99, added); Assert.AreEqual(99, storedCookies); Assert.AreEqual(99, storedCookieMass); Assert.AreEqual(99, storedCookieVolume); var addMore = cookiePile.AddCargoByUnit(cookies, 100); var storedCookies2 = cookiePile.GetUnitsStored(cookies); var storedCookieMass2 = cookiePile.GetMassStored(cookies); var storedCookieVolume2 = cookiePile.GetVolumeStored(cookies); Assert.AreEqual(1, addMore); Assert.AreEqual(100, storedCookies2); Assert.AreEqual(100, storedCookieMass2); Assert.AreEqual(100, storedCookieVolume2); }
public void Display() { ImGui.BeginChild(_entityState.Name, new System.Numerics.Vector2(260, 200), true); ImGui.Text(_entityState.Name); ImGui.Text("Transfer Rate: " + _volStorageDB.TransferRateInKgHr); ImGui.Text("At DeltaV < " + Stringify.Velocity(_volStorageDB.TransferRangeDv_mps)); foreach (var typeStore in _stores) { CargoTypeSD stype = _staticData.CargoTypes[typeStore.Key]; var freeVolume = typeStore.Value.FreeVolume; var maxVolume = typeStore.Value.MaxVolume; var storedVolume = maxVolume - freeVolume; string headerText = stype.Name + " " + Stringify.Volume(freeVolume) + " / " + Stringify.Volume(maxVolume) + " free"; ImGui.PushID(_entityState.Entity.Guid.ToString()); if (ImGui.CollapsingHeader(headerText, ImGuiTreeNodeFlags.CollapsingHeader)) { ImGui.Columns(3); ImGui.Text("Item"); ImGui.NextColumn(); ImGui.Text("Count"); ImGui.NextColumn(); ImGui.Text("Total Mass"); ImGui.NextColumn(); ImGui.Separator(); foreach (var cargoItemKvp in typeStore.Value.CurrentStoreInUnits.ToArray()) { ICargoable cargoItem = _stores[typeStore.Key].Cargoables[cargoItemKvp.Key]; if (cargoItem == null) { FactionInfoDB factionInfoDB; //factionInfoDB. } var cname = cargoItem.Name; var unitsStored = cargoItemKvp.Value; var volumePerItem = cargoItem.VolumePerUnit; var volumeStored = _volStorageDB.GetVolumeStored(cargoItem); var massStored = _volStorageDB.GetMassStored(cargoItem); bool isSelected = selectedCargo == cargoItem; if (ImGui.Selectable(cname, isSelected)) { selectedCargo = cargoItem; CargoItemSelectedEvent.Invoke(this); } ImGui.NextColumn(); ImGui.Text(Stringify.Number(unitsStored)); if (_cargoToMove.ContainsKey(cargoItem)) { var unitsMoving = _cargoToMove[cargoItem]; string text = Stringify.Number(unitsMoving); ImGui.SameLine(); float blue = 0f; if (_cargoToMoveDatablob.ContainsKey(cargoItem)) { if (_cargoToMoveDatablob[cargoItem] != 0) { blue = 0.25f; } } if (_cargoToMoveOrders.ContainsKey(cargoItem)) { if (_cargoToMoveOrders[cargoItem] != 0) { blue = 0.5f; } } if (_cargoToMoveUI.ContainsKey(cargoItem)) { if (_cargoToMoveUI[cargoItem] != 0) { blue = 0.75f; } } if (unitsMoving > 0) { ImGui.TextColored(new Vector4(0.5f, 1, blue, 1), text); } else { ImGui.TextColored(new Vector4(1f, 0.5f, blue, 1), text); } } ImGui.NextColumn(); ImGui.Text(Stringify.Mass(massStored)); ImGui.NextColumn(); } ImGui.Columns(1); } } ImGui.EndChild(); }