Terraria.Lighting.GetColor C# (CSharp) Method

GetColor() public static method

public static GetColor ( int x, int y ) : Color
x int
y int
return Color
        public static Color GetColor(int x, int y)
        {
            int index1 = x - Lighting.firstTileX + Lighting.offScreenTiles;
            int index2 = y - Lighting.firstTileY + Lighting.offScreenTiles;
            if (Main.gameMenu)
                return Color.White;
            if (index1 < 0 || index2 < 0 || (index1 >= Main.screenWidth / 16 + Lighting.offScreenTiles * 2 + 10 || index2 >= Main.screenHeight / 16 + Lighting.offScreenTiles * 2))
                return Color.Black;
            Lighting.LightingState lightingState = Lighting.states[index1][index2];
            int num1 = (int)((double)byte.MaxValue * (double)lightingState.r * (double)Lighting.brightness);
            int num2 = (int)((double)byte.MaxValue * (double)lightingState.g * (double)Lighting.brightness);
            int num3 = (int)((double)byte.MaxValue * (double)lightingState.b * (double)Lighting.brightness);
            if (num1 > (int)byte.MaxValue)
                num1 = (int)byte.MaxValue;
            if (num2 > (int)byte.MaxValue)
                num2 = (int)byte.MaxValue;
            if (num3 > (int)byte.MaxValue)
                num3 = (int)byte.MaxValue;
            return new Color((int)(byte)num1, (int)(byte)num2, (int)(byte)num3, (int)byte.MaxValue);
        }

Same methods

Lighting::GetColor ( int x, int y, Color oldColor ) : Color

Usage Example

Exemplo n.º 1
0
        // Token: 0x0600008F RID: 143 RVA: 0x0000BB70 File Offset: 0x00009D70
        public void DrawFreshAnimations(SpriteBatch spriteBatch)
        {
            for (int i = 0; i < this.data.Length; i++)
            {
                this.data[i].animationTimeElapsed++;
            }
            if (!Main.SettingsEnabled_MinersWobble)
            {
                return;
            }
            int     num  = 1;
            Vector2 zero = new Vector2((float)Main.offScreenRange);

            if (Main.drawToScreen)
            {
                zero = Vector2.Zero;
            }
            zero = Vector2.Zero;
            for (int j = 0; j < this.data.Length; j++)
            {
                if (this.data[j].type == num)
                {
                    int damage = this.data[j].damage;
                    if (damage >= 20)
                    {
                        int x = this.data[j].X;
                        int y = this.data[j].Y;
                        if (WorldGen.InWorld(x, y, 0))
                        {
                            bool flag = Main.tile[x, y] != null;
                            if (flag && num == 1)
                            {
                                flag = (flag && Main.tile[x, y].active() && Main.tileSolid[(int)Main.tile[x, y].type]);
                            }
                            if (flag && num == 2)
                            {
                                flag = (flag && Main.tile[x, y].wall > 0);
                            }
                            if (flag)
                            {
                                bool flag2 = false;
                                bool flag3 = false;
                                if (Main.tile[x, y].type == 10)
                                {
                                    flag2 = false;
                                }
                                else if (Main.tileSolid[(int)Main.tile[x, y].type] && !Main.tileSolidTop[(int)Main.tile[x, y].type])
                                {
                                    flag2 = true;
                                }
                                else if (Main.tile[x, y].type == 5)
                                {
                                    flag3 = true;
                                    int num2 = (int)(Main.tile[x, y].frameX / 22);
                                    int num3 = (int)(Main.tile[x, y].frameY / 22);
                                    if (num3 < 9)
                                    {
                                        flag2 = (((num2 != 1 && num2 != 2) || num3 < 6 || num3 > 8) && (num2 != 3 || num3 > 2) && (num2 != 4 || num3 < 3 || num3 > 5) && (num2 != 5 || num3 < 6 || num3 > 8));
                                    }
                                }
                                else if (Main.tile[x, y].type == 72)
                                {
                                    flag3 = true;
                                    if (Main.tile[x, y].frameX <= 34)
                                    {
                                        flag2 = true;
                                    }
                                }
                                if (flag2 && Main.tile[x, y].slope() == 0 && !Main.tile[x, y].halfBrick())
                                {
                                    int num4 = 0;
                                    if (damage >= 80)
                                    {
                                        num4 = 3;
                                    }
                                    else if (damage >= 60)
                                    {
                                        num4 = 2;
                                    }
                                    else if (damage >= 40)
                                    {
                                        num4 = 1;
                                    }
                                    else if (damage >= 20)
                                    {
                                        num4 = 0;
                                    }
                                    Rectangle value = new Rectangle(this.data[j].crackStyle * 18, num4 * 18, 16, 16);
                                    value.Inflate(-2, -2);
                                    if (flag3)
                                    {
                                        value.X = (4 + this.data[j].crackStyle / 2) * 18;
                                    }
                                    int animationTimeElapsed = this.data[j].animationTimeElapsed;
                                    if ((float)animationTimeElapsed < 10f)
                                    {
                                        float   arg_365_0 = (float)animationTimeElapsed / 10f;
                                        Color   color     = Lighting.GetColor(x, y);
                                        float   rotation  = 0f;
                                        Vector2 zero2     = Vector2.Zero;
                                        float   num5      = 0.5f;
                                        float   num6      = arg_365_0 % num5;
                                        num6 *= 1f / num5;
                                        if ((int)(arg_365_0 / num5) % 2 == 1)
                                        {
                                            num6 = 1f - num6;
                                        }
                                        Tile      tileSafely = Framing.GetTileSafely(x, y);
                                        Tile      tile       = tileSafely;
                                        Texture2D texture;
                                        if (Main.canDrawColorTile(tileSafely.type, (int)tileSafely.color()))
                                        {
                                            texture = Main.tileAltTexture[(int)tileSafely.type, (int)tileSafely.color()];
                                        }
                                        else
                                        {
                                            texture = Main.tileTexture[(int)tileSafely.type];
                                        }
                                        Vector2 vector    = new Vector2(8f);
                                        Vector2 value2    = new Vector2(1f);
                                        float   arg_427_0 = num6 * 0.2f + 1f;
                                        float   num7      = 1f - num6;
                                        num7   = 1f;
                                        color *= num7 * num7 * 0.8f;
                                        Vector2 scale    = arg_427_0 * value2;
                                        Vector2 position = (new Vector2((float)(x * 16 - (int)Main.screenPosition.X), (float)(y * 16 - (int)Main.screenPosition.Y)) + zero + vector + zero2).Floor();
                                        spriteBatch.Draw(texture, position, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, 16, 16)), color, rotation, vector, scale, SpriteEffects.None, 0f);
                                        color.A = 180;
                                        spriteBatch.Draw(Main.tileCrackTexture, position, new Rectangle?(value), color, rotation, vector, scale, SpriteEffects.None, 0f);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
All Usage Examples Of Terraria.Lighting::GetColor