public static void SetRoof_postfix(RoofGrid __instance, IntVec3 c, RoofDef def)
        {
            FieldInfo       mapInfo = AccessTools.Field(typeof(RoofGrid), "map");
            Map             map     = (Map)mapInfo.GetValue(__instance);
            MapComp_Windows mapComp = map.GetComponent <MapComp_Windows>();

            if (mapComp != null && mapComp.WindowScanGrid[map.cellIndices.CellToIndex(c)] > 0)
            {
                mapComp.roofUpdateRequest = true;
            }
        }
 public static void RegisterInCell_postfix(Thing t, IntVec3 c)
 {
     if (t is Building && t.def.passability == Traversability.Impassable)
     {
         MapComp_Windows mapComp = t.Map.GetComponent <MapComp_Windows>();
         if (mapComp != null && mapComp.WindowScanGrid[t.Map.cellIndices.CellToIndex(c)] > 0)
         {
             mapComp.updateRequest = true;
         }
     }
 }
        //[HarmonyAfter(new string[] { "Dubwise.Dubs_Skylights" })]
        public static void Regenerate_Prefix()
        {
            Map             map          = Find.CurrentMap;
            MapComp_Windows component    = map.GetComponent <MapComp_Windows>();
            FieldInfo       roofGridInfo = AccessTools.Field(typeof(RoofGrid), "roofGrid");

            RoofDef[] roofGrid = (RoofDef[])roofGridInfo.GetValue(map.roofGrid);
            roofGridCopy = new List <RoofDef>(roofGrid).ToArray();
            foreach (int i in (from t in component.WindowGrid.Select((s, i) => new { s, i })
                               where t.s is true
                               select t.i).ToList())
            {
                roofGrid[i] = null;
            }
        }
예제 #4
0
 public static void Prefix()
 {
     changedRoofs = new Dictionary <IntVec3, RoofDef>();
     if (stateDirty || map != Find.CurrentMap)
     {
         map             = Find.CurrentMap;                                // cache map
         roofRef         = (RoofDef[])roofGridInfo.GetValue(map.roofGrid); // cache roofgrid
         windowComponent = map.GetComponent <MapComp_Windows>();           // cache windowcomponent
         // we are clean
         stateDirty = false;
     }
     foreach (IntVec3 cell in windowComponent.WindowCells)
     {
         var index = map.cellIndices.CellToIndex(cell);
         changedRoofs.Add(cell, roofRef[index]);
         roofRef[index] = null;
     }
 }
        public static void Postfix(IntVec3 c, ref float __result)
        {
            // more caching, this method is called A LOT !
            Map             map  = LightingOverlay_Regenerate.map;
            MapComp_Windows comp = LightingOverlay_Regenerate.windowComponent;

            try
            {
                if (__result < 1f && comp.WindowCells.Contains(c))
                {
                    float x = Mathf.Max(0f, map.skyManager.CurSkyGlow * OpenTheWindowsSettings.LightTransmission);
                    __result = Mathf.Max(__result, x);
                }
            }
            catch (Exception e) // if you are catching err's you might as well explain them.
            {
                Log.Warning("Error at GlowGrid_GameGlowAt: " + e.Message);
            }
        }
예제 #6
0
        public static void Postfix(IntVec3 c, ref float __result)
        {
            Map             map  = LightingOverlay_Regenerate.map;
            MapComp_Windows comp = LightingOverlay_Regenerate.windowComponent;

            if (!comp.WindowCells.Contains(c))
            {
                return;
            }
            try
            {
                float fromSky = map.skyManager.CurSkyGlow * OpenTheWindowsSettings.LightTransmission;
                if (HarmonyPatcher.RaiseTheRoof && c.Roofed(map) && c.IsTransparentRoof(map))
                {
                    __result *= OpenTheWindowsSettings.LightTransmission;
                }
                __result = Mathf.Max(__result, fromSky);
            }
            catch (Exception e) // if you are catching err's you might as well explain them.
            {
                Log.Warning("Error at GlowGrid_GameGlowAt: " + e.Message);
            }
        }
 public NaturalLightOverlay(MapComp_Windows parent)
 {
     Parent      = parent;
     lastSeenMap = parent.map;
     drawer      = new CellBoolDrawer(this, parent.map.Size.x, parent.map.Size.z);
 }