Esempio n. 1
0
        public override bool TryGetItemGamepadOverrideInstructions(
            Item[] inv,
            int context,
            int slot,
            out string instruction)
        {
            instruction = "";
            Item newItem = inv[slot];

            if (newItem.IsAir || newItem.favorited)
            {
                return(false);
            }
            switch (context)
            {
            case 0:
                if (TEHatRack.FitsHatRack(newItem))
                {
                    instruction = Lang.misc[76].Value;
                    return(true);
                }
                break;

            case 26:
            case 27:
                if (Main.player[Main.myPlayer].ItemSpace(newItem).CanTakeItemToPersonalInventory)
                {
                    instruction = Lang.misc[68].Value;
                    return(true);
                }
                break;
            }
            return(false);
        }
Esempio n. 2
0
        public static bool IsBreakable(int clickX, int clickY)
        {
            int index1 = clickX;
            int index2 = clickY;
            int x      = index1 - (int)Main.tile[index1, index2].frameX % 54 / 18;
            int y      = index2 - (int)Main.tile[x, index2].frameY / 18;
            int index3 = TEHatRack.Find(x, y);

            return(index3 == -1 || !(TileEntity.ByID[index3] as TEHatRack).ContainsItems());
        }
Esempio n. 3
0
        public static int Place(int x, int y)
        {
            TEHatRack teHatRack = new TEHatRack();

            teHatRack.Position                        = new Point16(x, y);
            teHatRack.ID                              = TileEntity.AssignNewID();
            teHatRack.type                            = TEHatRack._myEntityID;
            TileEntity.ByID[teHatRack.ID]             = (TileEntity)teHatRack;
            TileEntity.ByPosition[teHatRack.Position] = (TileEntity)teHatRack;
            return(teHatRack.ID);
        }
Esempio n. 4
0
 public static int Hook_AfterPlacement(
     int x,
     int y,
     int type      = 475,
     int style     = 0,
     int direction = 1,
     int alternate = 0)
 {
     if (Main.netMode != 1)
     {
         return(TEHatRack.Place(x - 1, y - 3));
     }
     NetMessage.SendTileSquare(Main.myPlayer, x, y - 1, 5, TileChangeType.None);
     NetMessage.SendData(87, -1, -1, (NetworkText)null, x - 1, (float)(y - 3), (float)TEHatRack._myEntityID, 0.0f, 0, 0, 0);
     return(-1);
 }
Esempio n. 5
0
        public override bool OverrideItemSlotHover(Item[] inv, int context = 0, int slot = 0)
        {
            Item obj = inv[slot];

            if (!obj.IsAir && !inv[slot].favorited && (context == 0 && TEHatRack.FitsHatRack(obj)))
            {
                Main.cursorOverride = 9;
                return(true);
            }
            if (obj.IsAir || context != 26 && context != 27 || !Main.player[Main.myPlayer].ItemSpace(inv[slot]).CanTakeItemToPersonalInventory)
            {
                return(false);
            }
            Main.cursorOverride = 8;
            return(true);
        }
Esempio n. 6
0
        public static void Framing_CheckTile(int callX, int callY)
        {
            if (WorldGen.destroyObject)
            {
                return;
            }
            int  num1       = callX;
            int  num2       = callY;
            Tile tileSafely = Framing.GetTileSafely(callX, callY);
            int  num3       = num1 - (int)tileSafely.frameX / 18 % 3;
            int  y          = num2 - (int)tileSafely.frameY / 18 % 4;
            bool flag       = false;

            for (int index1 = num3; index1 < num3 + 3; ++index1)
            {
                for (int index2 = y; index2 < y + 4; ++index2)
                {
                    Tile tile = Main.tile[index1, index2];
                    if (!tile.active() || tile.type != (ushort)475)
                    {
                        flag = true;
                    }
                }
            }
            if (!WorldGen.SolidTileAllowBottomSlope(num3, y + 4) || !WorldGen.SolidTileAllowBottomSlope(num3 + 1, y + 4) || !WorldGen.SolidTileAllowBottomSlope(num3 + 2, y + 4))
            {
                flag = true;
            }
            if (!flag)
            {
                return;
            }
            TEHatRack.Kill(num3, y);
            Item.NewItem(num3 * 16, y * 16, 48, 64, 3977, 1, false, 0, false, false);
            WorldGen.destroyObject = true;
            for (int i = num3; i < num3 + 3; ++i)
            {
                for (int j = y; j < y + 4; ++j)
                {
                    if (Main.tile[i, j].active() && Main.tile[i, j].type == (ushort)475)
                    {
                        WorldGen.KillTile(i, j, false, false, false);
                    }
                }
            }
            WorldGen.destroyObject = false;
        }
Esempio n. 7
0
        public static void OnPlayerInteraction(Player player, int clickX, int clickY)
        {
            int index1 = clickX;
            int index2 = clickY;
            int x1     = index1 - (int)Main.tile[index1, index2].frameX % 54 / 18;
            int y1     = index2 - (int)Main.tile[x1, index2].frameY / 18;
            int id     = TEHatRack.Find(x1, y1);

            if (id == -1)
            {
                return;
            }
            int y2 = y1 + 1;
            int x2 = x1 + 1;

            TileEntity.BasicOpenCloseInteraction(player, x2, y2, id);
        }
Esempio n. 8
0
        private bool TryFitting(Item[] inv, int context = 0, int slot = 0, bool justCheck = false)
        {
            if (!TEHatRack.FitsHatRack(inv[slot]))
            {
                return(false);
            }
            if (justCheck)
            {
                return(true);
            }
            int index1 = TEHatRack.hatTargetSlot;

            ++TEHatRack.hatTargetSlot;
            for (int index2 = 0; index2 < 2; ++index2)
            {
                if (this._items[index2].IsAir)
                {
                    index1 = index2;
                    TEHatRack.hatTargetSlot = index2 + 1;
                    break;
                }
            }
            for (int index2 = 0; index2 < 2; ++index2)
            {
                if (inv[slot].type == this._items[index2].type)
                {
                    index1 = index2;
                }
            }
            if (TEHatRack.hatTargetSlot >= 2)
            {
                TEHatRack.hatTargetSlot = 0;
            }
            SoundEngine.PlaySound(7, -1, -1, 1, 1f, 0.0f);
            Utils.Swap <Item>(ref this._items[index1], ref inv[slot]);
            if (Main.netMode == 1)
            {
                NetMessage.SendData(124, -1, -1, (NetworkText)null, Main.myPlayer, (float)this.ID, (float)index1, 0.0f, 0, 0, 0);
            }
            return(true);
        }
Esempio n. 9
0
 public override void NetPlaceEntityAttempt(int x, int y)
 {
     NetMessage.SendData(86, -1, -1, (NetworkText)null, TEHatRack.Place(x, y), (float)x, (float)y, 0.0f, 0, 0, 0);
 }
Esempio n. 10
0
 public override bool OverrideItemSlotLeftClick(Item[] inv, int context = 0, int slot = 0)
 {
     if (!ItemSlot.ShiftInUse)
     {
         return(false);
     }
     if (Main.cursorOverride == 9 && context == 0)
     {
         Item obj = inv[slot];
         if (Main.cursorOverride == 9 && !obj.IsAir && (!obj.favorited && context == 0) && TEHatRack.FitsHatRack(obj))
         {
             return(this.TryFitting(inv, context, slot, false));
         }
     }
     if ((Main.cursorOverride != 8 || context != 23) && (context != 26 && context != 27))
     {
         return(false);
     }
     inv[slot] = Main.player[Main.myPlayer].GetItem(Main.myPlayer, inv[slot], GetItemSettings.InventoryEntityToPlayerInventorySettings);
     if (Main.netMode == 1)
     {
         NetMessage.SendData(124, -1, -1, (NetworkText)null, Main.myPlayer, (float)this.ID, (float)slot, 0.0f, 0, 0, 0);
     }
     return(true);
 }