public override bool CanUseItem(Player player) { if (player.whoAmI != Main.myPlayer) { return(false); } if ((!canPaint && UIStateLogic1.paintWheel.toolIndex != 2) || !HelperMethods.ToolHasRange(toolRange)) { return(false); } BEPlayer mp = player.GetModPlayer <BEPlayer>(); PaintWheel panel = UIStateLogic1.paintWheel; byte selectedColor = (byte)(panel.colorIndex + 1); bool infPaintBucket = mp.infinitePaintBucketEquipped; switch (panel.toolIndex) { case 0: HelperMethods.PaintTileOrWall(selectedColor, panel.toolIndex, infPaintBucket); break; case 1: HelperMethods.PaintTileOrWall(selectedColor, panel.toolIndex, infPaintBucket); break; case 2: HelperMethods.ScrapPaint(); break; } return(true); }
internal static void PaintTileOrWall(byte color, int selectedTool, bool infinitePaint = false) { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); if (color < 0 || color > 30 || selectedTool == 2) { return; } bool needsSync = false; if (selectedTool == 0 && mp.PointedTile.active() && mp.PointedTile.color() != color) { if (infinitePaint || CanReduceItemStack(ColorByteToPaintItemType(color), reduceStack: true)) { mp.PointedTile.color(color); needsSync = true; } } else if (selectedTool == 1 && mp.PointedTile.wall != 0 && mp.PointedTile.wallColor() != color) { if (infinitePaint || CanReduceItemStack(ColorByteToPaintItemType(color), reduceStack: true)) { mp.PointedTile.wallColor(color); needsSync = true; } } if (needsSync && Main.netMode == NetmodeID.MultiplayerClient) { NetMessage.SendTileSquare(-1, Player.tileTargetX, Player.tileTargetY, 1); } }
internal static bool ValidTilePlacement(int i, int j) { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); if (mp.PlacementAnywhere) { return(true); } int[] treeTypes = { //[TAG 1.4] Implements new trees TileID.Trees, TileID.PalmTree, TileID.PineTree, TileID.MushroomTrees, TileID.ChristmasTree, }; Tile middle = Framing.GetTileSafely(i, j); Tile top = Framing.GetTileSafely(i, j - 1); Tile right = Framing.GetTileSafely(i + 1, j); Tile bottom = Framing.GetTileSafely(i, j + 1); Tile left = Framing.GetTileSafely(i - 1, j); return((!middle.active() || !Main.tileSolid[middle.type]) && !treeTypes.Contains(middle.type) && ( (top.active() && Main.tileSolid[top.type]) || (right.active() && Main.tileSolid[right.type]) || (bottom.active() && Main.tileSolid[bottom.type]) || (left.active() && Main.tileSolid[left.type]) || middle.wall != 0 )); }
public override void PlaceInWorld(int i, int j, Item item) { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); HelperMethods.MirrorPlacement(i, j, item.type); if (!mp.PlacementAnywhere) { return; } //I'm hardcoding this since vanilla also hardcodes their shitty frameX changes int[] directionFraming = new int[] { TileID.Chairs, TileID.Bathtubs, TileID.Beds, TileID.Mannequin, TileID.Womannequin //+ any other tile that mirrors with player direction }; Tile tile = Framing.GetTileSafely(i, j); TileObjectData data = TileObjectData.GetTileData(tile); if (directionFraming.Contains(item.createTile)) { HelperMethods.ChangeTileFraming(i, j, Main.LocalPlayer.direction == 1); } }
private void UpdateCrossesOnColors() { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); EvaluateAvailableColorsInInventory(); for (int i = 0; i < noPaintOverlay.Length; i++) { if (!colorAvailable[i] && !mp.infinitePaintBucketEquipped) { //Append(noPaintOverlay[i]); noPaintOverlay[i].Show(); if (colorIndex == i) { colorElements[colorIndex].SetVisibility(1f, 0.85f); colorOverlay.Hide(); colorIndex = -1; } } else if (colorAvailable[i] || mp.infinitePaintBucketEquipped) { colorAvailable[i] = true; noPaintOverlay[i].Hide(); } } }
private void ColorSelected(int index) { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); if (!colorAvailable[index] && !mp.infinitePaintBucketEquipped) { return; } for (int i = 0; i < colorElements.Length; i++) { colorElements[i].SetVisibility(1f, 0.85f); } colorOverlay.Hide(); if (colorIndex != index) { colorElements[index].SetVisibility(1f, 1f); colorOverlay.Left = colorElements[index].Left; colorOverlay.Top = colorElements[index].Top; colorOverlay.Show(); colorIndex = index; } else { colorIndex = -1; } }
public override void HoldItem(Player player) { if (player.whoAmI != Main.myPlayer) { return; } if (!UIStateLogic1.fillWandSelection.Visible) { UIStateLogic1.fillWandSelection.Show(); } BEPlayer mp = player.GetModPlayer <BEPlayer>(); player.showItemIcon = true; //Middle Mouse if (Main.mouseMiddle && HelperMethods.IsUIAvailable(notShowingMouseIcon: false)) { TileObjectData data = TileObjectData.GetTileData(mp.PointedTile); multiTileSelected = data != null; if (!multiTileSelected) { selectedTileItemType = HelperMethods.PickItem(mp.PointedTile, false); } else if (!oneTimeMessage) { Main.NewText("Fill Wand does not support multi tiles!", Color.Red); oneTimeMessage = true; } } if (selectedTileItemType != -1) { player.showItemIcon2 = selectedTileItemType; } //Right Mouse if (Main.mouseRight && player.HeldItem == item && selectedTileItemType != -1 && HelperMethods.IsUIAvailable(notShowingMouseIcon: false) && ++mouseRightTimer == 9) { int posX = Player.tileTargetX; int posY = Player.tileTargetY - (fillSelectionSize - 1); HelperMethods.RemoveTilesInArea(posX, posY, posX + fillSelectionSize, posY + fillSelectionSize, itemToDrop: selectedTileItemType); } if (Main.mouseRightRelease || mouseRightTimer == 9) { mouseRightTimer = 0; } }
public void UpdateUpgrades(Player player, ref List <bool> upgrades, ref List <bool> unlockedUpgrades) { BEPlayer mp = player.GetModPlayer <BEPlayer>(); if (upgrades[0]) //Fast placement { mp.FastPlacement = true; } if (upgrades[1]) //Inf Placement Range { mp.InfinitePlacementRange = true; } if (upgrades[2]) //Inf Player Range { mp.InfinitePlayerRange = true; } if (upgrades[3]) //Placement Anywhere { mp.PlacementAnywhere = true; } if (upgrades[4]) //Inf Placement { mp.InfinitePlacement = true; } if (upgrades[5]) //Inf Pickup Range { mp.InfinitePickupRange = true; } //Updating UI upgrade values through the wrench for (int i = 0; i < upgrades.Count; i++) { //Runs once before the wrench calls the Show() method if (Visible) { continue; } //Updating UI behaviour and leaving unlocked upgrades toggled elements[i].SetToggleable(unlockedUpgrades[i]); elements[i].SetOpacity(upgrades[i] ? 1f : .45f); elements[i].SetToggled(upgrades[i]); } //Setting upgrade values through the UI for (int i = 0; i < upgrades.Count; i++) { if (Visible && unlockedUpgrades[i]) { upgrades[i] = elements[i].Toggled; } } }
public override void UpdateInventory(Item item, Player player) { if (player.whoAmI != Main.myPlayer) { return; } BEPlayer mp = player.GetModPlayer <BEPlayer>(); //Just stop updating the whole Interface Layer? if (player.HeldItem.type != ItemType <MultiWand>() && multiWandWheel.Visible) { multiWandWheel.Hide(); } if (player.HeldItem.type != ItemType <AutoHammer>() && autoHammerWheel.Visible) { autoHammerWheel.Hide(); } if ((player.HeldItem.type != ItemType <SpectrePaintingTool>() && player.HeldItem.type != ItemType <PaintingTool>()) && paintWheel.Visible) { paintWheel.Hide(); } if (player.HeldItem.type != ItemType <FillWand>() && fillWandSelection.Visible) { fillWandSelection.Hide(); } if (player.HeldItem.type != ItemType <ShapesDrawer>()) { arrowPanel.Hide(); menuPanel.Hide(); } else if (player.HeldItem.type == ItemType <ShapesDrawer>() && !arrowPanel.Visible && !menuPanel.Visible) { arrowPanel.Show(); } // if (player.HeldItem.type == ItemType<ShapesDrawer>() && mirrorWandSelection.Visible) // { // mirrorWandSelection.Hide(); // //ShapesDrawer.Show(); // } // // if (player.HeldItem.type == ItemType<MirrorWand>()) /*&& shapesDrawerSelection.Visible)*/ // { // //shapesDrawerSelection.Hide(); // mirrorWandSelection.Show(); // } }
public override bool CanPlace(int i, int j, int type) { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); Item heldItem = mp.player.HeldItem; if ((mp.PlacementAnywhere || mp.InfinitePlacement) && HelperMethods.ValidTilePlacement(i, j)) { HelperMethods.PlaceTile(i, j, heldItem.type, true); PlaceInWorld(i, j, heldItem); return(false); } return(base.CanPlace(i, j, type)); }
internal static bool ToolHasRange(Point range) { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); if (mp.InfinitePlacementRange || mp.InfinitePlayerRange) { return(true); } Point playerCenter = Main.LocalPlayer.Center.ToTileCoordinates(); //range = new Point(Main.screenWidth / 16, Main.screenHeight / 16); return(Math.Abs(playerCenter.X - mp.PointedTileCoord.X) <= range.X && Math.Abs(playerCenter.Y - mp.PointedTileCoord.Y) <= range.Y); }
public override void HoldItem(Player player) { if (player.whoAmI != Main.myPlayer) { return; } BEPlayer mp = player.GetModPlayer <BEPlayer>(); if (Main.netMode != NetmodeID.Server && mp.ValidCursorPos) { canHammerTiles = HelperMethods.ToolHasRange(toolRange) && HelperMethods.IsUIAvailable(playerNotWieldingItem: false); player.showItemIcon = canHammerTiles && !UIStateLogic1.autoHammerWheel.IsMouseHovering; player.showItemIcon2 = item.type; } }
internal static bool CanReduceItemStack(int itemType, int amount = 1, bool reduceStack = true) { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); if (mp.InfinitePlacement) { return(true); } bool reducingWand = MultiWand.wandTypes.Contains(itemType); int materialType = reducingWand ? MultiWand.wandMaterials[Array.IndexOf(MultiWand.wandTypes, itemType)] : 0; //Checking heldItem first before looping through the inventory if (!reducingWand && Main.LocalPlayer.HeldItem.type == itemType && Main.LocalPlayer.HeldItem.stack >= amount) { if (reduceStack) { Main.LocalPlayer.HeldItem.stack -= amount; } return(true); } foreach (Item item in Main.LocalPlayer.inventory) { if ((!reducingWand && item.type == itemType && item.stack >= amount) || (reducingWand && item.type == materialType && item.stack >= amount)) { if (reduceStack) { item.stack -= amount; } return(true); } } return(false); }
public override void HoldItem(Player player) { BEPlayer mp = player.GetModPlayer <BEPlayer>(); if (player.whoAmI != Main.myPlayer || Main.netMode == NetmodeID.Server || !mp.ValidCursorPos) { return; } PaintWheel panel = UIStateLogic1.paintWheel; canPaint = HelperMethods.ToolHasRange(toolRange) && (panel.colorIndex != -1 || panel.toolIndex == 2) && HelperMethods.IsUIAvailable(playerNotWieldingItem: false); player.showItemIcon = canPaint && !panel.IsMouseHovering; switch (panel.toolIndex) { case 0: //Paint tiles if (mp.PointedTile.type >= 0 && mp.PointedTile.active()) { player.showItemIcon2 = ItemID.SpectrePaintbrush; } break; case 1: //Paint walls if (mp.PointedTile.type >= 0 && mp.PointedTile.wall > 0) { player.showItemIcon2 = ItemID.SpectrePaintRoller; } break; case 2: //Scrap paint if (mp.PointedTile.color() != 0 || mp.PointedTile.wallColor() != 0) { player.showItemIcon2 = ItemID.SpectrePaintScraper; } break; } }
internal static void ScrapPaint() { BEPlayer mp = Main.LocalPlayer.GetModPlayer <BEPlayer>(); bool needsSync = false; if (mp.PointedTile.color() != 0) { mp.PointedTile.color(0); needsSync = true; } if (mp.PointedTile.wallColor() != 0) { mp.PointedTile.wallColor(0); needsSync = true; } if (needsSync && Main.netMode == NetmodeID.MultiplayerClient) { NetMessage.SendData(MessageID.PaintTile, number: Player.tileTargetX, number2: Player.tileTargetY); NetMessage.SendData(MessageID.PaintWall, number: Player.tileTargetX, number2: Player.tileTargetY); } }
public override void HoldItem(Player player) { if (player.whoAmI != Main.myPlayer) { return; } //Had to create this static variable since I couldn't use player.mouseInterface in the draw method LMBDown = Main.mouseLeft && !player.mouseInterface; BEPlayer mp = player.GetModPlayer <BEPlayer>(); //Middle Mouse if (Main.mouseMiddle && !player.mouseInterface) { selectedItemType = HelperMethods.PickItem(mp.PointedTile, false); } if (selectedItemType != -1) { player.showItemIcon = true; player.showItemIcon2 = selectedItemType; } }