public override void UpdateBeforeSimulation() { if (Reactor == null) { NeedsUpdate = MyEntityUpdateEnum.NONE; return; } if (Reactor.IsFunctional == true) { if (Reactor.GetInventory().Empty() == true) { var fuelId = new MyDefinitionId(typeof(MyObjectBuilder_Ingot), "UraniumB"); var content = (MyObjectBuilder_PhysicalObject)MyObjectBuilderSerializer.CreateNewObject(fuelId); var fuelItem = new MyObjectBuilder_InventoryItem { Amount = 1, Content = content }; if (Reactor.GetInventory().CanItemsBeAdded(100, fuelId) == true && MyAPIGateway.Multiplayer.IsServer == true) { Reactor.GetInventory().AddItems(100, fuelItem.Content); } } } NeedsUpdate = MyEntityUpdateEnum.NONE; }
/// <summary> /// Status generatoru /// </summary> /// <returns></returns> public List <string> GetReactorStatus() { // definice List <string> status = new List <string>(); //prochazeni bloku foreach (KeyValuePair <string, IMyReactor> block in Instance.GetByType <IMyReactor>()) { //hodnoty IMyReactor reactor = block.Value as IMyReactor; float actual = reactor.CurrentOutput; float maximum = reactor.MaxOutput; float uranium = 0; //overeni funkcnosti if (reactor.IsFunctional && reactor.IsWorking) { //overeni mnozstvi uranu if (UraniumReference > 0) { // polozky inventare List <MyInventoryItem> items = new List <MyInventoryItem>(); reactor.GetInventory(0).GetItems(items); // vypocet mnozstvi uranu if (items.Count > 0) { for (int j = 0; j < items.Count; j++) { if (items[j].Type.SubtypeId == "Uranium") { uranium += (float)items[j].Amount; } } } // doplneni statusu do vystupu status.Add(Formater.BarsWithPercent(Block.GetStatus(block.Value, uranium <= UraniumReference ? Status.UraniumIsLow : Status.Working), actual, maximum)); } else { status.Add(Formater.BarsWithPercent(Block.GetStatus(block.Value, Status.UraniumIsEmpty), 0, maximum)); } } else { status.Add(Formater.BarsWithPercent(Block.GetStatus(block.Value, Status.NotWorking), 0, maximum)); } } // vraceni return(status); }
void updateReactorData() { System.Text.RegularExpressions.Match match = reactorPowerRegex.Match(reactor.DetailedInfo); double parsedDouble = 0.0f; if (match.Success) { if (Double.TryParse(match.Groups[1].Value, out parsedDouble)) maxOutput = parsedDouble * Math.Pow(1000.0, POWER_MULTIPLIERS.IndexOf(match.Groups[2].Value)); if (Double.TryParse(match.Groups[3].Value, out parsedDouble)) currentOutput = parsedDouble * Math.Pow(1000.0, POWER_MULTIPLIERS.IndexOf(match.Groups[4].Value)); } IMyInventory inv = reactor.GetInventory(); maxUranContained = (double)inv.MaxVolume * uraniumDensity; IMyInventoryItem uranium = inv.GetItems()[0]; uranLeft = (double)uranium.Amount; double outputRatio = currentOutput / maxOutput; currentConsumption = maxUranPerSec * outputRatio; }
public static float GetReactorFuelLevel(IMyReactor reactor) { IMyInventory inventory = reactor.GetInventory(0); return((float)inventory.CurrentVolume / (float)inventory.MaxVolume); }
public override void UpdateOnceBeforeFrame() { Inventory = ModBlock.GetInventory(0); }
public float GetUraniumAmount() { return(GetItemAmountInInventory(m_oBlock.GetInventory(0), "Ingot", "Uranium")); }