Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using RimWorld;
- using UnityEngine;
- using Verse;
- using Verse.AI;
- using Verse.Sound;
- namespace modNamespace
- {
- public class MountainTemp : MapComponent
- {
- List<Room> RoomsInMountains = new List<Room>();
- /// <summary>
- /// Fetchs the mountain rooms.
- /// </summary>
- void FetchMountainRooms()
- {
- // Clear our list of mountain rooms
- RoomsInMountains = new List<Room>();
- // Get the list of rooms from the region grid
- List<Room> allRooms = Find.RegionGrid.allRooms;
- // No rooms to check, abort now
- if( ( allRooms == null )||
- ( allRooms.Count < 1 ) )
- return;
- // Itterate the rooms
- foreach( var room in allRooms ){
- // No open roof? This could be in a mountain...
- if( room.OpenRoofCount == 0 ){
- var roomCells = room.Cells.ToList();
- // Only rooms with cells
- if( ( roomCells != null )&&
- ( roomCells.Any() == true ) ){
- // Now make sure all cells have a thick roof
- if( roomCells.Exists(
- cell => cell.GetRoof().isThickRoof == false ) )
- continue;
- // Room has all tick roofs
- RoomsInMountains.Add( room );
- }
- }
- }
- }
- /// <summary>
- /// Map tick for component
- /// </summary>
- public override void MapComponentTick()
- {
- // Get the rooms in the mountain
- FetchMountainRooms();
- // No rooms, nothing to do
- if( RoomsInMountains.Count < 1 )
- return;
- // Now do something with them
- // Create a debug dump of the rooms :
- var debugDump = "Mountainous Rooms:\n";
- foreach( var room in RoomsInMountains ){
- debugDump += "RoomID: " + room.roomID + " Temp: " + room.Temperature + "\n";
- }
- Log.Message( debugDump );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement