示例#1
0
 public unsafe static void AddWater(int x, int y)
 {
     if (x >= 5 && y >= 5 && x < Main.maxTilesX - 5 && y < Main.maxTilesY - 5)
     {
         fixed(Tile *ptr = &Main.tile[x, y])
         {
             if (ptr->liquid != 0 && ptr->checkingLiquid == 0)
             {
                 if (numLiquid >= 4095)
                 {
                     LiquidBuffer.AddBuffer(x, y);
                 }
                 else
                 {
                     ptr->checkingLiquid = 64;
                     Main.liquid[numLiquid].Init(x, y);
                     ptr->skipLiquid = 0;
                     numLiquid++;
                     if (Main.netMode == 2 && numLiquid < 1365)
                     {
                         NetMessage.sendWater(x, y);
                     }
                     if (ptr->active != 0)
                     {
                         int type = ptr->type;
                         if ((type != 4 || ptr->frameY != 176) && (Main.tileWaterDeath[type] || (ptr->lava != 0 && Main.tileLavaDeath[type])))
                         {
                             if (WorldGen.gen)
                             {
                                 ptr->active = 0;
                             }
                             else if (WorldGen.KillTile(x, y) && Main.netMode == 2)
                             {
                                 NetMessage.CreateMessage5(17, 0, x, y, 0);
                                 NetMessage.SendMessage();
                             }
                         }
                     }
                 }
             }
         }
     }
 }
示例#2
0
        public unsafe static int HurtTiles(ref Vector2 Position, ref Vector2 Velocity, int Width, int Height, bool fireImmune = false)
        {
            int num  = ((int)Position.X >> 4) - 1;
            int num2 = ((int)Position.X + Width >> 4) + 1;
            int num3 = ((int)Position.Y >> 4) - 1;
            int num4 = ((int)Position.Y + Height >> 4) + 1;

            if (num < 0)
            {
                num = 0;
            }
            if (num2 > Main.maxTilesX)
            {
                num2 = Main.maxTilesX;
            }
            if (num3 < 0)
            {
                num3 = 0;
            }
            if (num4 > Main.maxTilesY)
            {
                num4 = Main.maxTilesY;
            }

            fixed(Tile *ptr = Main.tile)
            {
                for (int i = num; i < num2; i++)
                {
                    Tile *ptr2 = ptr + (i * 1440 + num3);
                    int   num5 = num3;
                    while (num5 < num4)
                    {
                        if (ptr2->active != 0)
                        {
                            int type = ptr2->type;
                            if (type == 32 || type == 37 || type == 48 || type == 53 || type == 57 || type == 58 || type == 69 || type == 76 || type == 112 || type == 116 || type == 123)
                            {
                                double num6   = i << 4;
                                double num7   = num5 << 4;
                                int    result = 0;
                                switch (type)
                                {
                                case 32:
                                case 69:
                                case 80:
                                    if ((double)(Position.X + (float)Width) > num6 && (double)Position.X < num6 + 16.0 && (double)(Position.Y + (float)Height) > num7 && (double)Position.Y < num7 + 16.01)
                                    {
                                        result = 10;
                                        switch (type)
                                        {
                                        case 69:
                                            result = 17;
                                            break;

                                        case 80:
                                            result = 6;
                                            break;
                                        }
                                        if ((type == 32 || type == 69) && WorldGen.KillTile(i, num5))
                                        {
                                            NetMessage.CreateMessage5(17, 4, i, num5, 0);
                                            NetMessage.SendMessage();
                                        }
                                        return(result);
                                    }
                                    break;

                                case 53:
                                case 112:
                                case 116:
                                case 123:
                                    if ((double)(Position.X + (float)Width - 2f) >= num6 && (double)(Position.X + 2f) <= num6 + 16.0 && (double)(Position.Y + (float)Height - 2f) >= num7 && (double)(Position.Y + 2f) <= num7 + 16.0)
                                    {
                                        return(20);
                                    }
                                    break;

                                default:
                                    if ((double)(Position.X + (float)Width) >= num6 && (double)Position.X <= num6 + 16.0 && (double)(Position.Y + (float)Height) >= num7 && (double)Position.Y <= num7 + 16.01)
                                    {
                                        if (type == 48)
                                        {
                                            result = 40;
                                        }
                                        else if (!fireImmune && (type == 37 || type == 58 || type == 76))
                                        {
                                            result = 20;
                                        }
                                        return(result);
                                    }
                                    break;
                                }
                            }
                        }
                        num5++;
                        ptr2++;
                    }
                }
            }

            return(0);
        }