Skip to content

Commit

Permalink
Added a Crafting Station that allows all recipes in the game and a ho…
Browse files Browse the repository at this point in the history
…tkey to toggle Building Mode

Also updated the InfinitePlacement Sprite
  • Loading branch information
Kirtle committed Jun 10, 2020
1 parent 720ac41 commit 281ca53
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 2 deletions.
4 changes: 4 additions & 0 deletions BuilderEssentials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand All @@ -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();
Expand All @@ -39,6 +42,7 @@ public override void Load()
public override void Unload()
{
BasePanel = null;
ToggleBuildingMode = null;
}

private GameTime _lastUpdateUiGameTime;
Expand Down
13 changes: 13 additions & 0 deletions BuilderPlayer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BuilderEssentials.UI;
using System.Collections.Generic;
using Terraria;
using Terraria.GameInput;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;

Expand All @@ -15,6 +16,7 @@ public class BuilderPlayer : ModPlayer
public List<Item> NormalVanityClothes;
public List<Item> BuildingVanityClothes;
public bool IsNormalAccessories;
public bool BuildingModeHotkeyPressed;

public override void Initialize()
{
Expand All @@ -25,6 +27,17 @@ public override void Initialize()
NormalVanityClothes = new List<Item>(3);
BuildingVanityClothes = new List<Item>(3);
IsNormalAccessories = true;
BuildingModeHotkeyPressed = false;
}

public override void ProcessTriggers(TriggersSet triggersSet)
{
if (BuilderEssentials.ToggleBuildingMode.JustPressed)
{
BuildingModeHotkeyPressed = true;

BasePanel.button.OnClick();
}
}

public override TagCompound Save()
Expand Down
4 changes: 2 additions & 2 deletions Items/InfinitePlacement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Binary file modified Items/InfinitePlacement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions Items/Placeable/MultiCraftingStation.cs
Original file line number Diff line number Diff line change
@@ -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<Tiles.MultiCraftingStation>();
}

public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.WorkBench);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Binary file added Items/Placeable/MultiCraftingStation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions Tiles/MultiCraftingStation.cs
Original file line number Diff line number Diff line change
@@ -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<Items.Placeable.MultiCraftingStation>());
}
}
}
Binary file added Tiles/MultiCraftingStation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions UI/BasePanel.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -24,11 +26,24 @@ public override void OnInitialize()

public override void Update(GameTime gameTime)
{
modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();

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<BuilderPlayer>();
CleanAcessoriesList();
Expand Down

0 comments on commit 281ca53

Please sign in to comment.