Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using RimWorld;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using UnityEngine;
- using Verse;
- using Verse.AI;
- using Verse.Sound;
- namespace RealMountainTemps
- {
- 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
- foreach (var room in RoomsInMountains)
- room.Temperature = 15;
- {
- var heaters = room.AllContainedThings.Where(t =>
- (t.def.thingClass == Building_TempControl) ||
- (t.def.thingClass == Building_WorkTable_HeatPush) ||
- ((t.TryGetComp<CompAttachBase>() != null) &&
- (t.TryGetComp<CompAttachBase>().HasAttachment(ThingDefOf.Fire))) ||
- (t.TryGetComp<CompHeatPusher>() != null) ||
- (t.TryGetComp<CompHeatPusherPowered>() != null)).ToList();
- if ((heaters != null) &&
- (heaters.Count > 0)) ;
- }
- {
- // do something
- }
- // 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