Exemple #1
0
        private void MapUpdateHandler(object sender, MapUpdateWatcher.MapUpdateInfo info)
        {
            var  cell    = info.center;
            bool removed = info.removed;
            bool roof    = sender is RoofGrid;

            if (isFacingSet && roof && cell.IsInterior(this) && !GenAdj.CellsAdjacentCardinal(this).Contains(cell))
            {
                return;
            }
            bool unsureFace = false;

            for (int i = 0; i < scanLines.Count(); i++)
            {
                if (scanLines[i].Affected(cell))
                {
                    IntVec3 motivator = roof ? IntVec3.Zero : cell;
                    var     line      = scanLines[i];
                    bool    before    = line.facingSet;
                    line.FindObstruction(motivator, removed, info.map);
                    unsureFace |= line.facingSet != before;
                    needsUpdate = true;
                }
            }
            if (unsureFace)
            {
                isFacingSet = false;
            }
        }
Exemple #2
0
 private void ReactSkylights(MapUpdateWatcher.MapUpdateInfo info, IEnumerable <IntVec3> tiles)
 {
     if (info.removed)
     {
         ExcludeTileRange(tiles);
         WindowUtility.ResetWindowsAround(map, info.center);
     }
     else
     {
         IncludeTileRange(tiles);
     }
 }
Exemple #3
0
 public static void Postfix(Thing t, IntVec3 c)
 {
     if ((t is Building && t.def.passability == Traversability.Impassable) || (HarmonyPatcher.DubsSkylights && t.GetType() == HarmonyPatcher.Building_Skylight))
     {
         var info = new MapUpdateWatcher.MapUpdateInfo()
         {
             center  = c,
             removed = false,
             map     = t.Map
         };
         MapUpdateWatcher.OnMapUpdate(t, info);
     }
 }
Exemple #4
0
 public void MapUpdated(object sender, MapUpdateWatcher.MapUpdateInfo info)
 {
     if (DubsSkylights && sender.GetType() == Building_Skylight)
     {
         Thing thing = sender as Thing;
         var   tiles = thing.OccupiedRect().ExpandedBy(1).Cells;
         ReactSkylights(info, tiles);
     }
     if (TransparentRoofs && sender is RoofGrid && info.roofDef != null && TransparentRoofsList.Contains(info.roofDef))
     {
         ReactTransparentRoof(info);
     }
 }
Exemple #5
0
 private void ReactTransparentRoof(MapUpdateWatcher.MapUpdateInfo info)
 {
     if (TransparentRoofsList.Contains(info.roofDef))
     {
         if (info.removed)
         {
             ExcludeTile(info.center, true);
             WindowUtility.ResetWindowsAround(map, info.center);
         }
         else
         {
             IncludeTile(info.center);
         }
     }
 }
        public static void Postfix(RoofGrid __instance, IntVec3 c, RoofDef def, RoofDef __state)
        {
            if (Scribe.mode == LoadSaveMode.LoadingVars)
            {
                return;
            }
            bool    removing  = def == null;
            RoofDef defToPass = HarmonyPatcher.TransparentRoofs ? (removing ? __state : def) : def;
            var     info      = new MapUpdateWatcher.MapUpdateInfo()
            {
                center  = c,
                removed = removing,
                roofDef = defToPass,
                map     = (Map)MapInfo.GetValue(__instance)
            };

            MapUpdateWatcher.OnMapUpdate(__instance, info);
        }