Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. private List<IMyCargoContainer> containers = new List<IMyCargoContainer>();
  2. private List<IMyGyro> gyros = new List<IMyGyro>();
  3.  
  4.  
  5. private float volumeCurrent = 0;
  6. private float volumeMax = 0;
  7. private float currentRatio = 0f;
  8.  
  9. public Program()
  10. {
  11. Runtime.UpdateFrequency = UpdateFrequency.Update100;
  12. GridTerminalSystem.GetBlocksOfType(containers);
  13. GridTerminalSystem.GetBlocksOfType(gyros);
  14.  
  15. foreach (IMyCargoContainer cargo in containers)
  16. {
  17. volumeMax += cargo.GetInventory(0).MaxVolume.RawValue;
  18. }
  19. }
  20.  
  21. public void Main(string argument, UpdateType updateType)
  22. {
  23. UpdateCurrentStorage();
  24. SetGyroPower();
  25. }
  26.  
  27. private void UpdateCurrentStorage()
  28. {
  29. volumeCurrent = 0;
  30.  
  31. foreach (IMyCargoContainer cargo in containers)
  32. {
  33. volumeCurrent += cargo.GetInventory(0).CurrentVolume.RawValue;
  34. }
  35.  
  36. currentRatio = volumeCurrent / volumeMax;
  37. }
  38.  
  39. private void SetGyroPower()
  40. {
  41. foreach (IMyGyro gyro in gyros)
  42. {
  43. gyro.GyroPower = Math.Max(currentRatio, .25f);
  44. }
  45. }
  46.  
  47. private IMyTextSurface GetLCDPanel(string panelName)
  48. {
  49. return GridTerminalSystem.GetBlockWithName(panelName) as IMyTextSurface;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement