Example #1
0
        public static Color deepColor    = Color.green * 0.25f;      //based on convoluted DebugMatsSpectrum coloring

        //public Color GetCellExtraColor(int index)
        //This has to be a prefix since base code expects a thingdef at the index
        public static bool Prefix(DeepResourceGrid __instance, int index, ref Color __result, Map ___map)
        {
            if (DebugSettings.godMode)
            {
                return(true);
            }

            if (!___map.GetComponent <MapCompTerrainMineralScanned>()[index])
            {
                __result = unknownColor;
                return(false);
            }

            if (___map.edificeGrid[index]?.def.building?.isResourceRock ?? false)
            {
                IntVec3 c           = ___map.cellIndices.IndexToCell(index);
                int     count       = __instance.CountAt(c);
                bool    deepMineral = count > 0;
                if (deepMineral)
                {
                    ThingDef thingDef = __instance.ThingDefAt(c);
                    float    ratio    = (float)count / (float)thingDef.deepCountPerCell / 2f;

                    __result = Color.Lerp(groundColor, deepColor, ratio);
                }
                else
                {
                    __result = groundColor;
                }
                return(false);
            }
            return(true);
        }
Example #2
0
 public static CellBoolDrawer Drawer(this DeepResourceGrid deepResourceGrid) =>
 (CellBoolDrawer)drawerInfo.GetValue(deepResourceGrid);