Terraria.Framing.GetTileSafely C# (CSharp) Method

GetTileSafely() public static method

public static GetTileSafely ( int i, int j ) : Tile
i int
j int
return Tile
        public static Tile GetTileSafely(int i, int j)
        {
            Tile tile = Main.tile[i, j];
            if (tile == null)
            {
                tile = new Tile();
                Main.tile[i, j] = tile;
            }
            return tile;
        }

Usage Example

Exemplo n.º 1
0
        public void DrawFreshAnimations(SpriteBatch spriteBatch)
        {
            for (int index = 0; index < this.data.Length; ++index)
            {
                ++this.data[index].animationTimeElapsed;
            }
            if (!Main.SettingsEnabled_MinersWobble)
            {
                return;
            }
            int     num1 = 1;
            Vector2 zero1;

            // ISSUE: explicit reference operation
            ((Vector2)@zero1).\u002Ector((float)Main.offScreenRange);
            if (Main.drawToScreen)
            {
                zero1 = Vector2.get_Zero();
            }
            zero1 = Vector2.get_Zero();
            for (int index = 0; index < this.data.Length; ++index)
            {
                if (this.data[index].type == num1)
                {
                    int damage = this.data[index].damage;
                    if (damage >= 20)
                    {
                        int x = this.data[index].X;
                        int y = this.data[index].Y;
                        if (WorldGen.InWorld(x, y, 0))
                        {
                            bool flag1 = Main.tile[x, y] != null;
                            if (flag1 && num1 == 1)
                            {
                                flag1 = flag1 && Main.tile[x, y].active() && Main.tileSolid[(int)Main.tile[x, y].type];
                            }
                            if (flag1 && num1 == 2)
                            {
                                flag1 = flag1 && (uint)Main.tile[x, y].wall > 0U;
                            }
                            if (flag1)
                            {
                                bool flag2 = false;
                                bool flag3 = false;
                                if ((int)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 ((int)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 ((int)Main.tile[x, y].type == 72)
                                {
                                    flag3 = true;
                                    if ((int)Main.tile[x, y].frameX <= 34)
                                    {
                                        flag2 = true;
                                    }
                                }
                                if (flag2 && (int)Main.tile[x, y].slope() == 0 && !Main.tile[x, y].halfBrick())
                                {
                                    int num2 = 0;
                                    if (damage >= 80)
                                    {
                                        num2 = 3;
                                    }
                                    else if (damage >= 60)
                                    {
                                        num2 = 2;
                                    }
                                    else if (damage >= 40)
                                    {
                                        num2 = 1;
                                    }
                                    else if (damage >= 20)
                                    {
                                        num2 = 0;
                                    }
                                    Rectangle rectangle;
                                    // ISSUE: explicit reference operation
                                    ((Rectangle)@rectangle).\u002Ector(this.data[index].crackStyle * 18, num2 * 18, 16, 16);
                                    // ISSUE: explicit reference operation
                                    ((Rectangle)@rectangle).Inflate(-2, -2);
                                    if (flag3)
                                    {
                                        rectangle.X = (__Null)((4 + this.data[index].crackStyle / 2) * 18);
                                    }
                                    int animationTimeElapsed = this.data[index].animationTimeElapsed;
                                    if ((double)animationTimeElapsed < 10.0)
                                    {
                                        double  num3   = (double)animationTimeElapsed / 10.0;
                                        Color   color1 = Lighting.GetColor(x, y);
                                        float   num4   = 0.0f;
                                        Vector2 zero2  = Vector2.get_Zero();
                                        float   num5   = 0.5f;
                                        double  num6   = (double)num5;
                                        float   num7   = (float)(num3 % num6) * (1f / num5);
                                        double  num8   = (double)num5;
                                        if ((int)(num3 / num8) % 2 == 1)
                                        {
                                            num7 = 1f - num7;
                                        }
                                        Tile      tileSafely = Framing.GetTileSafely(x, y);
                                        Tile      tile       = tileSafely;
                                        Texture2D texture2D  = !Main.canDrawColorTile(tileSafely.type, (int)tileSafely.color()) ? Main.tileTexture[(int)tileSafely.type] : (Texture2D)Main.tileAltTexture[(int)tileSafely.type, (int)tileSafely.color()];
                                        Vector2   vector2_1;
                                        // ISSUE: explicit reference operation
                                        ((Vector2)@vector2_1).\u002Ector(8f);
                                        Vector2 vector2_2;
                                        // ISSUE: explicit reference operation
                                        ((Vector2)@vector2_2).\u002Ector(1f);
                                        double  num9      = (double)num7 * 0.200000002980232 + 1.0;
                                        float   num10     = 1f - num7;
                                        float   num11     = 1f;
                                        Color   color2    = Color.op_Multiply(color1, (float)((double)num11 * (double)num11 * 0.800000011920929));
                                        Vector2 vector2_3 = vector2_2;
                                        Vector2 vector2_4 = Vector2.op_Multiply((float)num9, vector2_3);
                                        Vector2 vector2_5 = Vector2.op_Addition(Vector2.op_Addition(Vector2.op_Addition(new Vector2((float)(x * 16 - (int)Main.screenPosition.X), (float)(y * 16 - (int)Main.screenPosition.Y)), zero1), vector2_1), zero2).Floor();
                                        spriteBatch.Draw(texture2D, vector2_5, new Rectangle?(new Rectangle((int)tile.frameX, (int)tile.frameY, 16, 16)), color2, num4, vector2_1, vector2_4, (SpriteEffects)0, 0.0f);
                                        // ISSUE: explicit reference operation
                                        ((Color)@color2).set_A((byte)180);
                                        spriteBatch.Draw(Main.tileCrackTexture, vector2_5, new Rectangle?(rectangle), color2, num4, vector2_1, vector2_4, (SpriteEffects)0, 0.0f);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
All Usage Examples Of Terraria.Framing::GetTileSafely