Exemplo n.º 1
0
        private void SetGlowGridFromDist(int index)
        {
            float    num  = (float)this.calcGrid[index].intDist / 100f;
            ColorInt colB = default(ColorInt);

            if (num <= this.glower.Props.glowRadius)
            {
                float b  = 1f / (num * num);
                float a  = 1f + this.attenLinearSlope * num;
                float b2 = Mathf.Lerp(a, b, 0.4f);
                colB = this.glower.Props.glowColor * b2;
            }
            if (colB.r > 0 || colB.g > 0 || colB.b > 0)
            {
                colB.ClampToNonNegative();
                ColorInt colA = this.glowGrid[index].AsColorInt();
                colA += colB;
                if (num < this.glower.Props.overlightRadius)
                {
                    colA.a = 1;
                }
                Color32 toColor = colA.ToColor32;
                this.glowGrid[index] = toColor;
            }
        }
Exemplo n.º 2
0
        private void SetGlowGridFromDist(int index)
        {
            float    num      = (float)calcGrid[index].intDist / 100f;
            ColorInt colorInt = default(ColorInt);

            if (num <= glower.Props.glowRadius)
            {
                float b  = 1f / (num * num);
                float b2 = Mathf.Lerp(1f + attenLinearSlope * num, b, 0.4f);
                colorInt   = glower.Props.glowColor * b2;
                colorInt.a = 0;
            }
            if (colorInt.r > 0 || colorInt.g > 0 || colorInt.b > 0)
            {
                colorInt.ClampToNonNegative();
                ColorInt colorInt2 = glowGrid[index].AsColorInt();
                colorInt2 += colorInt;
                if (num < glower.Props.overlightRadius)
                {
                    colorInt2.a = 1;
                }
                Color32 toColor = colorInt2.ToColor32;
                glowGrid[index] = toColor;
            }
        }
Exemplo n.º 3
0
        public RaceProperties()
        {
            ColorInt colorInt = new ColorInt(141, 56, 52);

            this.meatColor = colorInt.ToColor;
            this.soundCallIntervalRange = new IntRange(2000, 4000);
            base..ctor();
        }
        // Note: this type is marked as 'beforefieldinit'.
        static HediffComp_TendDuration()
        {
            ColorInt colorInt = new ColorInt(116, 101, 72);

            HediffComp_TendDuration.UntendedColor           = colorInt.ToColor;
            HediffComp_TendDuration.TendedIcon_Need_General = ContentFinder <Texture2D> .Get("UI/Icons/Medical/TendedNeed", true);

            HediffComp_TendDuration.TendedIcon_Well_General = ContentFinder <Texture2D> .Get("UI/Icons/Medical/TendedWell", true);

            HediffComp_TendDuration.TendedIcon_Well_Injury = ContentFinder <Texture2D> .Get("UI/Icons/Medical/BandageWell", true);
        }
Exemplo n.º 5
0
        static HediffComp_TendDuration()
        {
            // Note: this type is marked as 'beforefieldinit'.
            ColorInt colorInt = new ColorInt(116, 101, 72);

            HediffComp_TendDuration.UntendedColor           = colorInt.ToColor;
            HediffComp_TendDuration.TendedIcon_Need_General = ContentFinder <Texture2D> .Get("UI/Icons/Medical/TendedNeed", true);

            HediffComp_TendDuration.TendedIcon_Well_General = ContentFinder <Texture2D> .Get("UI/Icons/Medical/TendedWell", true);

            HediffComp_TendDuration.TendedIcon_Well_Injury = ContentFinder <Texture2D> .Get("UI/Icons/Medical/BandageWell", true);
        }
Exemplo n.º 6
0
        static TexUI()
        {
            // Note: this type is marked as 'beforefieldinit'.
            ColorInt colorInt = new ColorInt(51, 63, 51, 200);

            TexUI.GrayBg = SolidColorMaterials.NewSolidColorTexture(colorInt.ToColor);
            ColorInt colorInt2 = new ColorInt(32, 32, 32, 255);

            TexUI.AvailResearchColor = colorInt2.ToColor;
            ColorInt colorInt3 = new ColorInt(0, 64, 64, 255);

            TexUI.ActiveResearchColor = colorInt3.ToColor;
            ColorInt colorInt4 = new ColorInt(0, 64, 16, 255);

            TexUI.FinishedResearchColor = colorInt4.ToColor;
            ColorInt colorInt5 = new ColorInt(42, 42, 42, 255);

            TexUI.LockedResearchColor = colorInt5.ToColor;
            ColorInt colorInt6 = new ColorInt(0, 0, 0, 255);

            TexUI.RelatedResearchColor = colorInt6.ToColor;
            ColorInt colorInt7 = new ColorInt(30, 30, 30, 255);

            TexUI.HighlightBgResearchColor = colorInt7.ToColor;
            ColorInt colorInt8 = new ColorInt(160, 160, 160, 255);

            TexUI.HighlightBorderResearchColor = colorInt8.ToColor;
            ColorInt colorInt9 = new ColorInt(80, 80, 80, 255);

            TexUI.DefaultBorderResearchColor = colorInt9.ToColor;
            ColorInt colorInt10 = new ColorInt(60, 60, 60, 255);

            TexUI.DefaultLineResearchColor = colorInt10.ToColor;
            ColorInt colorInt11 = new ColorInt(51, 205, 217, 255);

            TexUI.HighlightLineResearchColor = colorInt11.ToColor;
            TexUI.FastFillTex   = Texture2D.whiteTexture;
            TexUI.FastFillStyle = new GUIStyle
            {
                normal = new GUIStyleState
                {
                    background = TexUI.FastFillTex
                }
            };
            TexUI.TextBGBlack = ContentFinder <Texture2D> .Get("UI/Widgets/TextBGBlack", true);

            TexUI.GrayTextBG = ContentFinder <Texture2D> .Get("UI/Overlays/GrayTextBG", true);

            TexUI.FloatMenuOptionBG = ContentFinder <Texture2D> .Get("UI/Widgets/FloatMenuOptionBG", true);

            TexUI.GrayscaleGUI = MatLoader.LoadMat("Misc/GrayscaleGUI", -1);
        }
        // Note: this type is marked as 'beforefieldinit'.
        static FloatMenuOption()
        {
            ColorInt colorInt = new ColorInt(21, 25, 29);

            FloatMenuOption.ColorBGActive = colorInt.ToColor;
            ColorInt colorInt2 = new ColorInt(29, 45, 50);

            FloatMenuOption.ColorBGActiveMouseover = colorInt2.ToColor;
            ColorInt colorInt3 = new ColorInt(40, 40, 40);

            FloatMenuOption.ColorBGDisabled   = colorInt3.ToColor;
            FloatMenuOption.ColorTextActive   = Color.white;
            FloatMenuOption.ColorTextDisabled = new Color(0.9f, 0.9f, 0.9f);
        }
Exemplo n.º 8
0
        static FloatMenuOption()
        {
            // Note: this type is marked as 'beforefieldinit'.
            ColorInt colorInt = new ColorInt(21, 25, 29);

            FloatMenuOption.ColorBGActive = colorInt.ToColor;
            ColorInt colorInt2 = new ColorInt(29, 45, 50);

            FloatMenuOption.ColorBGActiveMouseover = colorInt2.ToColor;
            ColorInt colorInt3 = new ColorInt(40, 40, 40);

            FloatMenuOption.ColorBGDisabled   = colorInt3.ToColor;
            FloatMenuOption.ColorTextActive   = Color.white;
            FloatMenuOption.ColorTextDisabled = new Color(0.9f, 0.9f, 0.9f);
        }
Exemplo n.º 9
0
        public RaceProperties()
        {
            ColorInt colorInt = new ColorInt(141, 56, 52);

            this.meatColor              = colorInt.ToColor;
            this.meatMarketValue        = 2f;
            this.useMeatFrom            = null;
            this.useLeatherFrom         = null;
            this.specialShadowData      = null;
            this.soundCallIntervalRange = new IntRange(2000, 4000);
            this.soundMeleeHitPawn      = null;
            this.soundMeleeHitBuilding  = null;
            this.soundMeleeMiss         = null;
            this.deathActionWorkerInt   = null;
            this.meatDef    = null;
            this.leatherDef = null;
            this.corpseDef  = null;
            base..ctor();
        }
Exemplo n.º 10
0
        public static ColorInt ParseColorInt(string str)
        {
            str = str.TrimStart(colorTrimStartParameters);
            str = str.TrimEnd(colorTrimEndParameters);
            string[] array  = str.Split(',');
            ColorInt result = new ColorInt(255, 255, 255, 255);

            result.r = ParseIntPermissive(array[0]);
            result.g = ParseIntPermissive(array[1]);
            result.b = ParseIntPermissive(array[2]);
            if (array.Length == 4)
            {
                result.a = ParseIntPermissive(array[3]);
            }
            else
            {
                result.a = 255;
            }
            return(result);
        }
Exemplo n.º 11
0
        public override void Regenerate()
        {
            LayerSubMesh subMesh = base.GetSubMesh(MatBases.LightOverlay);

            if (subMesh.verts.Count == 0)
            {
                this.MakeBaseGeometry(subMesh);
            }
            Color32[] array = new Color32[subMesh.verts.Count];
            int       maxX  = this.sectRect.maxX;
            int       maxZ  = this.sectRect.maxZ;

            bool[]      array2      = new bool[4];
            Thing[]     innerArray  = base.Map.edificeGrid.InnerArray;
            RoofGrid    roofGrid    = base.Map.roofGrid;
            CellIndices cellIndices = base.Map.cellIndices;

            for (int i = this.sectRect.minX; i <= maxX + 1; i++)
            {
                for (int j = this.sectRect.minZ; j <= maxZ + 1; j++)
                {
                    int num  = default(int);
                    int num2 = default(int);
                    int num3 = default(int);
                    int num4 = default(int);
                    int num5 = default(int);
                    this.CalculateVertexIndices(i, j, out num, out num2, out num3, out num4, out num5);
                    IntVec3 a    = new IntVec3(i, 0, j);
                    bool    flag = false;
                    for (int k = 0; k < 4; k++)
                    {
                        IntVec3 c = a + SectionLayer_LightingOverlay.CheckSquareOffsets[k];
                        if (!c.InBounds(base.Map))
                        {
                            array2[k] = true;
                        }
                        else
                        {
                            Thing   thing   = innerArray[cellIndices.CellToIndex(c)];
                            RoofDef roofDef = roofGrid.RoofAt(c.x, c.z);
                            if (roofDef != null && (roofDef.isThickRoof || thing == null || !thing.def.holdsRoof || thing.def.altitudeLayer == AltitudeLayer.DoorMoveable))
                            {
                                flag = true;
                            }
                            if (thing != null && thing.def.blockLight)
                            {
                                array2[k] = true;
                            }
                            else
                            {
                                array2[k] = false;
                            }
                        }
                    }
                    ColorInt colorInt = new ColorInt(0, 0, 0, 0);
                    int      num6     = 0;
                    if (!array2[0])
                    {
                        colorInt += this.glowGrid[cellIndices.CellToIndex(i, j - 1)].AsColorInt();
                        num6++;
                    }
                    if (!array2[1])
                    {
                        colorInt += this.glowGrid[cellIndices.CellToIndex(i - 1, j - 1)].AsColorInt();
                        num6++;
                    }
                    if (!array2[2])
                    {
                        colorInt += this.glowGrid[cellIndices.CellToIndex(i - 1, j)].AsColorInt();
                        num6++;
                    }
                    if (!array2[3])
                    {
                        colorInt += this.glowGrid[cellIndices.CellToIndex(i, j)].AsColorInt();
                        num6++;
                    }
                    if (num6 > 0)
                    {
                        colorInt  /= (float)num6;
                        array[num] = colorInt.ToColor32;
                    }
                    else
                    {
                        array[num] = new Color32(0, 0, 0, 0);
                    }
                    if (flag && array[num].a < 100)
                    {
                        array[num].a = 100;
                    }
                }
            }
            for (int l = this.sectRect.minX; l <= maxX; l++)
            {
                for (int m = this.sectRect.minZ; m <= maxZ; m++)
                {
                    int num7  = default(int);
                    int num8  = default(int);
                    int num9  = default(int);
                    int num10 = default(int);
                    int num11 = default(int);
                    this.CalculateVertexIndices(l, m, out num7, out num8, out num9, out num10, out num11);
                    ColorInt colA = default(ColorInt) + array[num7];
                    colA        += array[num8];
                    colA        += array[num9];
                    colA        += array[num10];
                    array[num11] = (colA / 4f).ToColor32;
                    Thing thing = innerArray[cellIndices.CellToIndex(l, m)];
                    if (roofGrid.Roofed(l, m) && (thing == null || !thing.def.holdsRoof) && array[num11].a < 100)
                    {
                        array[num11].a = 100;
                    }
                }
            }
            subMesh.mesh.colors32 = array;
        }
Exemplo n.º 12
0
 public static object FromString(string str, Type itemType)
 {
     try
     {
         itemType = (Nullable.GetUnderlyingType(itemType) ?? itemType);
         if (itemType == typeof(string))
         {
             str = str.Replace("\\n", "\n");
             return(str);
         }
         if (itemType == typeof(int))
         {
             return(ParseIntPermissive(str));
         }
         if (itemType == typeof(float))
         {
             return(float.Parse(str, CultureInfo.InvariantCulture));
         }
         if (itemType == typeof(bool))
         {
             return(bool.Parse(str));
         }
         if (itemType == typeof(long))
         {
             return(long.Parse(str, CultureInfo.InvariantCulture));
         }
         if (itemType == typeof(double))
         {
             return(double.Parse(str, CultureInfo.InvariantCulture));
         }
         if (itemType == typeof(sbyte))
         {
             return(sbyte.Parse(str, CultureInfo.InvariantCulture));
         }
         if (itemType.IsEnum)
         {
             try
             {
                 object obj = BackCompatibility.BackCompatibleEnum(itemType, str);
                 if (obj != null)
                 {
                     return(obj);
                 }
                 return(Enum.Parse(itemType, str));
             }
             catch (ArgumentException innerException)
             {
                 string str2 = "'" + str + "' is not a valid value for " + itemType + ". Valid values are: \n";
                 str2 += GenText.StringFromEnumerable(Enum.GetValues(itemType));
                 ArgumentException ex = new ArgumentException(str2, innerException);
                 throw ex;
             }
         }
         if (itemType == typeof(Type))
         {
             if (str == "null" || str == "Null")
             {
                 return(null);
             }
             Type typeInAnyAssembly = GenTypes.GetTypeInAnyAssembly(str);
             if (typeInAnyAssembly == null)
             {
                 Log.Error("Could not find a type named " + str);
             }
             return(typeInAnyAssembly);
         }
         if (itemType == typeof(Action))
         {
             string[] array      = str.Split('.');
             string   methodName = array[array.Length - 1];
             string   empty      = string.Empty;
             empty = ((array.Length != 3) ? array[0] : (array[0] + "." + array[1]));
             Type       typeInAnyAssembly2 = GenTypes.GetTypeInAnyAssembly(empty);
             MethodInfo method             = typeInAnyAssembly2.GetMethods().First((MethodInfo m) => m.Name == methodName);
             return((Action)Delegate.CreateDelegate(typeof(Action), method));
         }
         if (itemType == typeof(Vector3))
         {
             return(FromStringVector3(str));
         }
         if (itemType == typeof(Vector2))
         {
             return(FromStringVector2(str));
         }
         if (itemType == typeof(Rect))
         {
             return(FromStringRect(str));
         }
         if (itemType == typeof(Color))
         {
             str = str.TrimStart('(', 'R', 'G', 'B', 'A');
             str = str.TrimEnd(')');
             string[] array2 = str.Split(',');
             float    num    = (float)FromString(array2[0], typeof(float));
             float    num2   = (float)FromString(array2[1], typeof(float));
             float    num3   = (float)FromString(array2[2], typeof(float));
             bool     flag   = num > 1f || num3 > 1f || num2 > 1f;
             float    num4   = (float)((!flag) ? 1 : 255);
             if (array2.Length == 4)
             {
                 num4 = (float)FromString(array2[3], typeof(float));
             }
             Color color = default(Color);
             if (!flag)
             {
                 color.r = num;
                 color.g = num2;
                 color.b = num3;
                 color.a = num4;
             }
             else
             {
                 color = GenColor.FromBytes(Mathf.RoundToInt(num), Mathf.RoundToInt(num2), Mathf.RoundToInt(num3), Mathf.RoundToInt(num4));
             }
             return(color);
         }
         if (itemType == typeof(PublishedFileId_t))
         {
             return(new PublishedFileId_t(ulong.Parse(str)));
         }
         if (itemType == typeof(IntVec2))
         {
             return(IntVec2.FromString(str));
         }
         if (itemType == typeof(IntVec3))
         {
             return(IntVec3.FromString(str));
         }
         if (itemType == typeof(Rot4))
         {
             return(Rot4.FromString(str));
         }
         if (itemType == typeof(CellRect))
         {
             return(CellRect.FromString(str));
         }
         if (itemType != typeof(CurvePoint))
         {
             if (itemType == typeof(NameTriple))
             {
                 NameTriple nameTriple = NameTriple.FromString(str);
                 nameTriple.ResolveMissingPieces();
             }
             else
             {
                 if (itemType == typeof(FloatRange))
                 {
                     return(FloatRange.FromString(str));
                 }
                 if (itemType == typeof(IntRange))
                 {
                     return(IntRange.FromString(str));
                 }
                 if (itemType == typeof(QualityRange))
                 {
                     return(QualityRange.FromString(str));
                 }
                 if (itemType == typeof(ColorInt))
                 {
                     str = str.TrimStart('(', 'R', 'G', 'B', 'A');
                     str = str.TrimEnd(')');
                     string[] array3   = str.Split(',');
                     ColorInt colorInt = new ColorInt(255, 255, 255, 255);
                     colorInt.r = (int)FromString(array3[0], typeof(int));
                     colorInt.g = (int)FromString(array3[1], typeof(int));
                     colorInt.b = (int)FromString(array3[2], typeof(int));
                     if (array3.Length == 4)
                     {
                         colorInt.a = (int)FromString(array3[3], typeof(int));
                     }
                     else
                     {
                         colorInt.a = 255;
                     }
                     return(colorInt);
                 }
             }
             throw new ArgumentException("Trying to parse to unknown data type " + itemType.Name + ". Content is '" + str + "'.");
         }
         return(CurvePoint.FromString(str));
     }
     catch (Exception innerException2)
     {
         ArgumentException ex2 = new ArgumentException("Exception parsing " + itemType + " from \"" + str + "\"", innerException2);
         throw ex2;
     }
 }
Exemplo n.º 13
0
        public override void Regenerate()
        {
            LayerSubMesh subMesh = base.GetSubMesh(MatBases.LightOverlay);

            if (subMesh.verts.Count == 0)
            {
                this.MakeBaseGeometry(subMesh);
            }
            Color32[] array = new Color32[subMesh.verts.Count];
            int       maxX  = this.sectRect.maxX;
            int       maxZ  = this.sectRect.maxZ;
            int       width = this.sectRect.Width;
            Map       map   = base.Map;
            int       x     = map.Size.x;

            Thing[]     innerArray  = map.edificeGrid.InnerArray;
            int         num         = innerArray.Length;
            RoofGrid    roofGrid    = map.roofGrid;
            CellIndices cellIndices = map.cellIndices;
            int         num2;
            int         num3;
            int         num4;
            int         num5;
            int         num6;

            this.CalculateVertexIndices(this.sectRect.minX, this.sectRect.minZ, out num2, out num3, out num4, out num5, out num6);
            int num7 = cellIndices.CellToIndex(new IntVec3(this.sectRect.minX, 0, this.sectRect.minZ));

            int[] array2 = new int[4];
            array2[0] = -map.Size.x - 1;
            array2[1] = -map.Size.x;
            array2[2] = -1;
            int[] array3 = array2;
            int[] array4 = new int[4];
            array4[0] = -1;
            array4[1] = -1;
            int[] array5 = array4;
            for (int i = this.sectRect.minZ; i <= maxZ + 1; i++)
            {
                int num8 = num7 / x;
                int j    = this.sectRect.minX;
                while (j <= maxX + 1)
                {
                    ColorInt colorInt = new ColorInt(0, 0, 0, 0);
                    int      num9     = 0;
                    bool     flag     = false;
                    for (int k = 0; k < 4; k++)
                    {
                        int num10 = num7 + array3[k];
                        if (num10 >= 0 && num10 < num && num10 / x == num8 + array5[k])
                        {
                            Thing   thing   = innerArray[num10];
                            RoofDef roofDef = roofGrid.RoofAt(num10);
                            if (roofDef != null && (roofDef.isThickRoof || thing == null || !thing.def.holdsRoof || thing.def.altitudeLayer == AltitudeLayer.DoorMoveable))
                            {
                                flag = true;
                            }
                            if (thing == null || !thing.def.blockLight)
                            {
                                colorInt += this.glowGrid[num10];
                                num9++;
                            }
                        }
                    }
                    if (num9 > 0)
                    {
                        array[num2] = (colorInt / num9).ToColor32;
                    }
                    else
                    {
                        array[num2] = new Color32(0, 0, 0, 0);
                    }
                    if (flag && array[num2].a < 100)
                    {
                        array[num2].a = 100;
                    }
                    j++;
                    num2++;
                    num7++;
                }
                int num11 = maxX + 2 - this.sectRect.minX;
                num2 -= num11;
                num7 -= num11;
                num2 += width + 1;
                num7 += map.Size.x;
            }
            int num12;
            int num13;
            int num14;
            int num15;
            int num16;

            this.CalculateVertexIndices(this.sectRect.minX, this.sectRect.minZ, out num12, out num13, out num14, out num15, out num16);
            int num17 = cellIndices.CellToIndex(this.sectRect.minX, this.sectRect.minZ);

            for (int l = this.sectRect.minZ; l <= maxZ; l++)
            {
                int m = this.sectRect.minX;
                while (m <= maxX)
                {
                    ColorInt colA = default(ColorInt) + array[num12];
                    colA        += array[num12 + 1];
                    colA        += array[num12 + width + 1];
                    colA        += array[num12 + width + 2];
                    array[num16] = new Color32((byte)(colA.r / 4), (byte)(colA.g / 4), (byte)(colA.b / 4), (byte)(colA.a / 4));
                    if (array[num16].a < 100 && roofGrid.Roofed(num17))
                    {
                        Thing thing2 = innerArray[num17];
                        if (thing2 == null || !thing2.def.holdsRoof)
                        {
                            array[num16].a = 100;
                        }
                    }
                    m++;
                    num12++;
                    num16++;
                    num17++;
                }
                num12++;
                num17 -= width;
                num17 += map.Size.x;
            }
            subMesh.mesh.colors32 = array;
        }
Exemplo n.º 14
0
        public static object FromString(string str, Type itemType)
        {
            object result;

            try
            {
                itemType = (Nullable.GetUnderlyingType(itemType) ?? itemType);
                if (itemType == typeof(string))
                {
                    str    = str.Replace("\\n", "\n");
                    result = str;
                }
                else if (itemType == typeof(int))
                {
                    result = int.Parse(str, CultureInfo.InvariantCulture);
                }
                else if (itemType == typeof(float))
                {
                    result = float.Parse(str, CultureInfo.InvariantCulture);
                }
                else if (itemType == typeof(bool))
                {
                    result = bool.Parse(str);
                }
                else if (itemType == typeof(long))
                {
                    result = long.Parse(str, CultureInfo.InvariantCulture);
                }
                else if (itemType == typeof(double))
                {
                    result = double.Parse(str, CultureInfo.InvariantCulture);
                }
                else if (itemType == typeof(sbyte))
                {
                    result = sbyte.Parse(str, CultureInfo.InvariantCulture);
                }
                else
                {
                    if (itemType.IsEnum)
                    {
                        try
                        {
                            result = Enum.Parse(itemType, str);
                            return(result);
                        }
                        catch (ArgumentException innerException)
                        {
                            string text = string.Concat(new object[]
                            {
                                "'",
                                str,
                                "' is not a valid value for ",
                                itemType,
                                ". Valid values are: \n"
                            });
                            text += GenText.StringFromEnumerable(Enum.GetValues(itemType));
                            ArgumentException ex = new ArgumentException(text, innerException);
                            throw ex;
                        }
                    }
                    if (itemType == typeof(Type))
                    {
                        if (str == "null" || str == "Null")
                        {
                            result = null;
                        }
                        else
                        {
                            Type typeInAnyAssembly = GenTypes.GetTypeInAnyAssembly(str);
                            if (typeInAnyAssembly == null)
                            {
                                Log.Error("Could not find a type named " + str);
                            }
                            result = typeInAnyAssembly;
                        }
                    }
                    else if (itemType == typeof(Action))
                    {
                        string[] array = str.Split(new char[]
                        {
                            '.'
                        });
                        string methodName = array[array.Length - 1];
                        string typeName   = string.Empty;
                        if (array.Length == 3)
                        {
                            typeName = array[0] + "." + array[1];
                        }
                        else
                        {
                            typeName = array[0];
                        }
                        Type       typeInAnyAssembly2 = GenTypes.GetTypeInAnyAssembly(typeName);
                        MethodInfo method             = typeInAnyAssembly2.GetMethods().First((MethodInfo m) => m.Name == methodName);
                        result = (Action)Delegate.CreateDelegate(typeof(Action), method);
                    }
                    else if (itemType == typeof(Vector3))
                    {
                        result = ParseHelper.FromStringVector3(str);
                    }
                    else if (itemType == typeof(Vector2))
                    {
                        result = ParseHelper.FromStringVector2(str);
                    }
                    else if (itemType == typeof(Rect))
                    {
                        result = ParseHelper.FromStringRect(str);
                    }
                    else if (itemType == typeof(Color))
                    {
                        str = str.TrimStart(new char[]
                        {
                            '(',
                            'R',
                            'G',
                            'B',
                            'A'
                        });
                        str = str.TrimEnd(new char[]
                        {
                            ')'
                        });
                        string[] array2 = str.Split(new char[]
                        {
                            ','
                        });
                        float num  = (float)ParseHelper.FromString(array2[0], typeof(float));
                        float num2 = (float)ParseHelper.FromString(array2[1], typeof(float));
                        float num3 = (float)ParseHelper.FromString(array2[2], typeof(float));
                        bool  flag = num > 1f || num3 > 1f || num2 > 1f;
                        float num4 = (float)((!flag) ? 1 : 255);
                        if (array2.Length == 4)
                        {
                            num4 = (float)ParseHelper.FromString(array2[3], typeof(float));
                        }
                        Color color;
                        if (!flag)
                        {
                            color.r = num;
                            color.g = num2;
                            color.b = num3;
                            color.a = num4;
                        }
                        else
                        {
                            color = GenColor.FromBytes(Mathf.RoundToInt(num), Mathf.RoundToInt(num2), Mathf.RoundToInt(num3), Mathf.RoundToInt(num4));
                        }
                        result = color;
                    }
                    else if (itemType == typeof(PublishedFileId_t))
                    {
                        result = new PublishedFileId_t(ulong.Parse(str));
                    }
                    else if (itemType == typeof(IntVec2))
                    {
                        result = IntVec2.FromString(str);
                    }
                    else if (itemType == typeof(IntVec3))
                    {
                        result = IntVec3.FromString(str);
                    }
                    else if (itemType == typeof(Rot4))
                    {
                        result = Rot4.FromString(str);
                    }
                    else if (itemType == typeof(CellRect))
                    {
                        result = CellRect.FromString(str);
                    }
                    else
                    {
                        if (itemType != typeof(CurvePoint))
                        {
                            if (itemType == typeof(NameTriple))
                            {
                                NameTriple nameTriple = NameTriple.FromString(str);
                                nameTriple.ResolveMissingPieces(null);
                            }
                            else
                            {
                                if (itemType == typeof(FloatRange))
                                {
                                    result = FloatRange.FromString(str);
                                    return(result);
                                }
                                if (itemType == typeof(IntRange))
                                {
                                    result = IntRange.FromString(str);
                                    return(result);
                                }
                                if (itemType == typeof(QualityRange))
                                {
                                    result = QualityRange.FromString(str);
                                    return(result);
                                }
                                if (itemType == typeof(ColorInt))
                                {
                                    str = str.TrimStart(new char[]
                                    {
                                        '(',
                                        'R',
                                        'G',
                                        'B',
                                        'A'
                                    });
                                    str = str.TrimEnd(new char[]
                                    {
                                        ')'
                                    });
                                    string[] array3 = str.Split(new char[]
                                    {
                                        ','
                                    });
                                    ColorInt colorInt = new ColorInt(255, 255, 255, 255);
                                    colorInt.r = (int)ParseHelper.FromString(array3[0], typeof(int));
                                    colorInt.g = (int)ParseHelper.FromString(array3[1], typeof(int));
                                    colorInt.b = (int)ParseHelper.FromString(array3[2], typeof(int));
                                    if (array3.Length == 4)
                                    {
                                        colorInt.a = (int)ParseHelper.FromString(array3[3], typeof(int));
                                    }
                                    else
                                    {
                                        colorInt.a = 255;
                                    }
                                    result = colorInt;
                                    return(result);
                                }
                            }
                            throw new ArgumentException(string.Concat(new string[]
                            {
                                "Trying to parse to unknown data type ",
                                itemType.Name,
                                ". Content is '",
                                str,
                                "'."
                            }));
                        }
                        result = CurvePoint.FromString(str);
                    }
                }
            }
            catch (Exception innerException2)
            {
                ArgumentException ex2 = new ArgumentException(string.Concat(new object[]
                {
                    "Exception parsing ",
                    itemType,
                    " from \"",
                    str,
                    "\""
                }), innerException2);
                throw ex2;
            }
            return(result);
        }
Exemplo n.º 15
0
        public override void Regenerate()
        {
            LayerSubMesh subMesh = GetSubMesh(MatBases.LightOverlay);

            if (subMesh.verts.Count == 0)
            {
                MakeBaseGeometry(subMesh);
            }
            Color32[] array = new Color32[subMesh.verts.Count];
            int       maxX  = sectRect.maxX;
            int       maxZ  = sectRect.maxZ;
            int       width = sectRect.Width;
            Map       map   = base.Map;
            int       x     = map.Size.x;

            Thing[]     innerArray  = map.edificeGrid.InnerArray;
            Thing[]     array2      = innerArray;
            int         num         = array2.Length;
            RoofGrid    roofGrid    = map.roofGrid;
            CellIndices cellIndices = map.cellIndices;

            CalculateVertexIndices(sectRect.minX, sectRect.minZ, out int botLeft, out int _, out int _, out int _, out int _);
            int num2 = cellIndices.CellToIndex(new IntVec3(sectRect.minX, 0, sectRect.minZ));

            int[] array3 = new int[4]
            {
                -map.Size.x - 1,
                -map.Size.x,
                -1,
                0
            };
            int[] array4 = new int[4]
            {
                -1,
                -1,
                0,
                0
            };
            for (int i = sectRect.minZ; i <= maxZ + 1; i++)
            {
                int num3 = num2 / x;
                int num4 = sectRect.minX;
                while (num4 <= maxX + 1)
                {
                    ColorInt a    = new ColorInt(0, 0, 0, 0);
                    int      num5 = 0;
                    bool     flag = false;
                    for (int j = 0; j < 4; j++)
                    {
                        int num6 = num2 + array3[j];
                        if (num6 >= 0 && num6 < num && num6 / x == num3 + array4[j])
                        {
                            Thing   thing   = array2[num6];
                            RoofDef roofDef = roofGrid.RoofAt(num6);
                            if (roofDef != null && (roofDef.isThickRoof || thing == null || !thing.def.holdsRoof || thing.def.altitudeLayer == AltitudeLayer.DoorMoveable))
                            {
                                flag = true;
                            }
                            if (thing == null || !thing.def.blockLight)
                            {
                                a += glowGrid[num6];
                                num5++;
                            }
                        }
                    }
                    if (num5 > 0)
                    {
                        array[botLeft] = (a / num5).ToColor32;
                    }
                    else
                    {
                        array[botLeft] = new Color32(0, 0, 0, 0);
                    }
                    if (flag && array[botLeft].a < 100)
                    {
                        array[botLeft].a = 100;
                    }
                    num4++;
                    botLeft++;
                    num2++;
                }
                int num7 = maxX + 2 - sectRect.minX;
                botLeft -= num7;
                num2    -= num7;
                botLeft += width + 1;
                num2    += map.Size.x;
            }
            CalculateVertexIndices(sectRect.minX, sectRect.minZ, out int botLeft2, out int _, out int _, out int _, out int center2);
            int num8 = cellIndices.CellToIndex(sectRect.minX, sectRect.minZ);

            for (int k = sectRect.minZ; k <= maxZ; k++)
            {
                int num9 = sectRect.minX;
                while (num9 <= maxX)
                {
                    ColorInt colorInt = default(ColorInt) + array[botLeft2];
                    colorInt      += array[botLeft2 + 1];
                    colorInt      += array[botLeft2 + width + 1];
                    colorInt      += array[botLeft2 + width + 2];
                    array[center2] = new Color32((byte)(colorInt.r / 4), (byte)(colorInt.g / 4), (byte)(colorInt.b / 4), (byte)(colorInt.a / 4));
                    if (array[center2].a < 100 && roofGrid.Roofed(num8))
                    {
                        Thing thing2 = array2[num8];
                        if (thing2 == null || !thing2.def.holdsRoof)
                        {
                            array[center2].a = 100;
                        }
                    }
                    num9++;
                    botLeft2++;
                    center2++;
                    num8++;
                }
                botLeft2++;
                num8 -= width;
                num8 += map.Size.x;
            }
            subMesh.mesh.colors32 = array;
        }