public static float getCurrentOxygenFill(Sandbox.ModAPI.Ingame.IMyGridTerminalSystem gridTerminalSystem) { List <IMyOxygenTank> oxygenTanks = new List <IMyOxygenTank>(); List <IMyTerminalBlock> gridBlocks = new List <IMyTerminalBlock>(); gridTerminalSystem.GetBlocksOfType <IMyOxygenTank>(gridBlocks); foreach (IMyTerminalBlock gridBlock in gridBlocks) { if (gridBlock as IMyOxygenTank != null) { oxygenTanks.Add(gridBlock as IMyOxygenTank); } } return(getCurrentOxygenFill(oxygenTanks[0])); }
public override void Init(MyObjectBuilder_EntityBase objectBuilder) { this.objectBuilder = objectBuilder; regulator = Entity as Sandbox.ModAPI.Ingame.IMyCubeBlock; Sandbox.ModAPI.Ingame.IMyGridTerminalSystem gts = Sandbox.ModAPI.MyAPIGateway.TerminalActionsHelper.GetTerminalSystemForGrid((Sandbox.ModAPI.IMyCubeGrid)regulator.CubeGrid); gts.GetBlocksOfType <Sandbox.ModAPI.Ingame.IMyThrust>(reactors); if (regulator != null && regulator.BlockDefinition.SubtypeId == "Regulator") // check the subtypeId { Entity.NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME; // to enable UpdateBeforeSimulation100() } else { } }