diff --git a/BuilderEssentials.cs b/BuilderEssentials.cs index e6f5da6..f40fa60 100644 --- a/BuilderEssentials.cs +++ b/BuilderEssentials.cs @@ -16,6 +16,7 @@ public class BuilderEssentials : Mod public static bool UIOpen; internal static BasePanel BasePanel; internal static UserInterface UserInterface; + internal static ModHotKey ToggleBuildingMode; public void LoadTextures() { @@ -25,6 +26,8 @@ public void LoadTextures() public override void Load() { + ToggleBuildingMode = RegisterHotKey("Toggle Building Mode", "N"); + if (!Main.dedServ && Main.netMode != NetmodeID.Server) { LoadTextures(); @@ -39,6 +42,7 @@ public override void Load() public override void Unload() { BasePanel = null; + ToggleBuildingMode = null; } private GameTime _lastUpdateUiGameTime; diff --git a/BuilderPlayer.cs b/BuilderPlayer.cs index 208158f..67067cf 100644 --- a/BuilderPlayer.cs +++ b/BuilderPlayer.cs @@ -1,6 +1,7 @@ using BuilderEssentials.UI; using System.Collections.Generic; using Terraria; +using Terraria.GameInput; using Terraria.ModLoader; using Terraria.ModLoader.IO; @@ -15,6 +16,7 @@ public class BuilderPlayer : ModPlayer public List NormalVanityClothes; public List BuildingVanityClothes; public bool IsNormalAccessories; + public bool BuildingModeHotkeyPressed; public override void Initialize() { @@ -25,6 +27,17 @@ public override void Initialize() NormalVanityClothes = new List(3); BuildingVanityClothes = new List(3); IsNormalAccessories = true; + BuildingModeHotkeyPressed = false; + } + + public override void ProcessTriggers(TriggersSet triggersSet) + { + if (BuilderEssentials.ToggleBuildingMode.JustPressed) + { + BuildingModeHotkeyPressed = true; + + BasePanel.button.OnClick(); + } } public override TagCompound Save() diff --git a/Items/InfinitePlacement.cs b/Items/InfinitePlacement.cs index 6740fc2..3050fb1 100644 --- a/Items/InfinitePlacement.cs +++ b/Items/InfinitePlacement.cs @@ -19,8 +19,8 @@ public override void SetDefaults() { item.accessory = true; item.vanity = false; - item.width = 48; - item.height = 48; + item.width = 46; + item.height = 46; item.value = Item.sellPrice(0, 10, 0, 0); item.rare = ItemRarityID.Red; } diff --git a/Items/InfinitePlacement.png b/Items/InfinitePlacement.png index a18dbee..681ac24 100644 Binary files a/Items/InfinitePlacement.png and b/Items/InfinitePlacement.png differ diff --git a/Items/Placeable/MultiCraftingStation.cs b/Items/Placeable/MultiCraftingStation.cs new file mode 100644 index 0000000..77123b9 --- /dev/null +++ b/Items/Placeable/MultiCraftingStation.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace BuilderEssentials.Items.Placeable +{ + class MultiCraftingStation : ModItem + { + public override void SetStaticDefaults() + { + Tooltip.SetDefault("This is a modded workbench."); + } + + public override void SetDefaults() + { + item.width = 48; + item.height = 48; + item.maxStack = 99; + item.useTurn = true; + item.autoReuse = true; + item.useAnimation = 15; + item.useTime = 10; + item.useStyle = ItemUseStyleID.SwingThrow; + item.consumable = true; + item.value = 150; + item.createTile = TileType(); + } + + public override void AddRecipes() + { + ModRecipe recipe = new ModRecipe(mod); + recipe.AddIngredient(ItemID.WorkBench); + recipe.SetResult(this); + recipe.AddRecipe(); + } + } +} diff --git a/Items/Placeable/MultiCraftingStation.png b/Items/Placeable/MultiCraftingStation.png new file mode 100644 index 0000000..019edcd Binary files /dev/null and b/Items/Placeable/MultiCraftingStation.png differ diff --git a/Tiles/MultiCraftingStation.cs b/Tiles/MultiCraftingStation.cs new file mode 100644 index 0000000..95bab5e --- /dev/null +++ b/Tiles/MultiCraftingStation.cs @@ -0,0 +1,44 @@ +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.ObjectData; +using static Terraria.ModLoader.ModContent; + +namespace BuilderEssentials.Tiles +{ + class MultiCraftingStation : ModTile + { + public override void SetDefaults() + { + Main.tileSolidTop[Type] = false; + Main.tileFrameImportant[Type] = true; + Main.tileNoAttach[Type] = true; + Main.tileTable[Type] = true; + Main.tileLavaDeath[Type] = true; + TileObjectData.newTile.CopyFrom(TileObjectData.Style3x3); + TileObjectData.newTile.Origin = new Point16(1, 1); + TileObjectData.newTile.CoordinateHeights = new[] { 16, 16, 16 }; + TileObjectData.newTile.Height = 3; + TileObjectData.newTile.CoordinateWidth = 16; + TileObjectData.newTile.Width = 3; + TileObjectData.addTile(Type); + AddToArray(ref TileID.Sets.RoomNeeds.CountsAsTable); + disableSmartCursor = true; + adjTiles = new int[] { TileID.WorkBenches, TileID.Furnaces, TileID.Hellforge, TileID.Anvils, TileID.AlchemyTable, TileID.Sinks, + TileID.Sawmill, TileID.Loom, TileID.Chairs, TileID.Tables, TileID.Tables2, TileID.CookingPots, TileID.TinkerersWorkbench, + TileID.ImbuingStation, TileID.DyeVat, TileID.HeavyWorkBench, TileID.DemonAltar, TileID.MythrilAnvil, + TileID.AdamantiteForge, TileID.Bookcases, TileID.CrystalBall, TileID.Autohammer, TileID.LunarCraftingStation, + TileID.Kegs, TileID.Blendomatic, TileID.MeatGrinder, TileID.BoneWelder, TileID.GlassKiln, TileID.HoneyDispenser, + TileID.IceMachine, TileID.LivingLoom, TileID.SkyMill, TileID.Solidifier, TileID.FleshCloningVat, TileID.SteampunkBoiler, + TileID.LihzahrdFurnace, TileID.WaterDrip, TileID.Waterfall, TileID.LavaDrip, TileID.Lavafall, + TileID.HoneyDrip, TileID.Honeyfall, TileID.Campfire, TileID.Extractinator}; + } + + public override void KillMultiTile(int i, int j, int frameX, int frameY) + { + Item.NewItem(i * 16, j * 16, 32, 16, ItemType()); + } + } +} diff --git a/Tiles/MultiCraftingStation.png b/Tiles/MultiCraftingStation.png new file mode 100644 index 0000000..41f8b13 Binary files /dev/null and b/Tiles/MultiCraftingStation.png differ diff --git a/UI/BasePanel.cs b/UI/BasePanel.cs index ae893fc..1db4ebf 100644 --- a/UI/BasePanel.cs +++ b/UI/BasePanel.cs @@ -1,8 +1,10 @@ using Terraria; using Terraria.UI; +using Terraria.GameInput; using Terraria.GameContent.UI.Elements; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input; namespace BuilderEssentials.UI { @@ -24,11 +26,24 @@ public override void OnInitialize() public override void Update(GameTime gameTime) { + modPlayer = Main.LocalPlayer.GetModPlayer(); + if (button.IsMouseHovering) Main.LocalPlayer.mouseInterface = true; + + if (modPlayer.BuildingModeHotkeyPressed) + { + BuildingModeAccessoriesToggle(); + modPlayer.BuildingModeHotkeyPressed = false; + } } public void ChangeAccessories_OnClick(UIMouseEvent evt, UIElement listeningElement) + { + BuildingModeAccessoriesToggle(); + } + + public void BuildingModeAccessoriesToggle() { modPlayer = Main.LocalPlayer.GetModPlayer(); CleanAcessoriesList();