Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. using RimWorld;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using UnityEngine;
  7. using Verse;
  8. using Verse.AI;
  9. using Verse.Sound;
  10.  
  11. namespace RealMountainTemps
  12. {
  13.  
  14. public class MountainTemp : MapComponent
  15. {
  16. List<Room> RoomsInMountains = new List<Room>();
  17.  
  18.  
  19. /// <summary>
  20. /// Fetchs the mountain rooms.
  21. /// </summary>
  22. void FetchMountainRooms()
  23. {
  24. // Clear our list of mountain rooms
  25. RoomsInMountains = new List<Room>();
  26.  
  27. // Get the list of rooms from the region grid
  28. List<Room> allRooms = Find.RegionGrid.allRooms;
  29.  
  30. // No rooms to check, abort now
  31. if ((allRooms == null) ||
  32. (allRooms.Count < 1))
  33. return;
  34.  
  35. // Itterate the rooms
  36. foreach (var room in allRooms)
  37. {
  38.  
  39. // No open roof? This could be in a mountain...
  40. if (room.OpenRoofCount == 0)
  41. {
  42.  
  43. var roomCells = room.Cells.ToList();
  44.  
  45. // Only rooms with cells
  46. if ((roomCells != null) &&
  47. (roomCells.Any() == true))
  48. {
  49.  
  50. // Now make sure all cells have a thick roof
  51. if (roomCells.Exists(
  52. cell => cell.GetRoof().isThickRoof == false))
  53. continue;
  54.  
  55. // Room has all tick roofs
  56. RoomsInMountains.Add(room);
  57.  
  58. }
  59. }
  60. }
  61. }
  62.  
  63. /// <summary>
  64. /// Map tick for component
  65. /// </summary>
  66. public override void MapComponentTick()
  67.  
  68. {
  69.  
  70. // Get the rooms in the mountain
  71. FetchMountainRooms();
  72.  
  73. // No rooms, nothing to do
  74. if (RoomsInMountains.Count < 1)
  75. return;
  76.  
  77. // Now do something with them
  78.  
  79. foreach (var room in RoomsInMountains)
  80. room.Temperature = 15;
  81. {
  82. var heaters = room.AllContainedThings.Where(t =>
  83. (t.def.thingClass == Building_TempControl) ||
  84. (t.def.thingClass == Building_WorkTable_HeatPush) ||
  85. ((t.TryGetComp<CompAttachBase>() != null) &&
  86. (t.TryGetComp<CompAttachBase>().HasAttachment(ThingDefOf.Fire))) ||
  87. (t.TryGetComp<CompHeatPusher>() != null) ||
  88. (t.TryGetComp<CompHeatPusherPowered>() != null)).ToList();
  89. if ((heaters != null) &&
  90. (heaters.Count > 0)) ;
  91.  
  92. }
  93.  
  94. {
  95. // do something
  96. }
  97.  
  98. // Create a debug dump of the rooms :
  99. var debugDump = "Mountainous Rooms:\n";
  100. foreach (var room in RoomsInMountains)
  101. {
  102. debugDump += "RoomID: " + room.roomID + " Temp: " + room.Temperature + "\n";
  103. }
  104. Log.Message(debugDump);
  105. }
  106. }
  107.  
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement