Skip to content

Commit

Permalink
Fixed a few PlacementAnywhere bugs and edge cases
Browse files Browse the repository at this point in the history
Only doesn't work well with multi tiles tried to place mid air.
  • Loading branch information
Kirtle committed Jun 28, 2020
1 parent d1a4341 commit 65b4e31
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 27 deletions.
51 changes: 28 additions & 23 deletions Items/Accessories/CreativeWrench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public override void UpdateAccessory(Player player, bool hideVisual)
Player.tileRangeX = 65;
Player.tileRangeY = 55;

//Thanks direwolf420 for the monstrosity checks
//Right click timer
if (Main.mouseRight && UIUtilities.IsUIAvailable()
&& (!player.mouseInterface || CreativeWheelRework.CreativeWheelReworkPanel.IsMouseHovering)
Expand Down Expand Up @@ -81,12 +80,6 @@ public override void UpdateAccessory(Player player, bool hideVisual)
autoHammerAlert = true;
}
}

//PlacementAnywhere
if (modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.PlacementAnywhere))
{

}
}
}

Expand Down Expand Up @@ -121,14 +114,15 @@ public override bool CanPlace(int i, int j, int type)
if (!modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinitePlacement)
&& !modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinityUpgrade))
{
if (selectedItem.type == ItemID.BoneWand || selectedItem.type == ItemID.HiveWand ||
selectedItem.type == ItemID.LeafWand || selectedItem.type == ItemID.LivingMahoganyWand ||
selectedItem.type == ItemID.LivingMahoganyLeafWand || selectedItem.type == ItemID.LivingWoodWand ||
selectedItem.type == ItemID.StaffofRegrowth)
{
//I'm sorry but it's just easier this way
//Wands are infinite, might need to loop through the inventory and check if they have ammo to decrease their stack?
}
if (selectedItem.type == ItemID.LivingMahoganyWand || selectedItem.type == ItemID.LivingMahoganyLeafWand)
ReduceItemStack(ItemID.RichMahogany);
else if (selectedItem.type == ItemID.LivingWoodWand || selectedItem.type == ItemID.LeafWand)
ReduceItemStack(ItemID.Wood);
else if (selectedItem.type == ItemID.BoneWand)
ReduceItemStack(ItemID.Bone);
else if (selectedItem.type == ItemID.HiveWand)
ReduceItemStack(ItemID.Hive);
else if (selectedItem.type == ItemID.StaffofRegrowth) { } //Condition to make specific wands not removed
else //TODO: This is still reducing the stack by 1 when trying to place multi tiles in the air
{
selectedItem.stack--;
Expand Down Expand Up @@ -157,19 +151,30 @@ public override bool CanPlace(int i, int j, int type)
return base.CanPlace(i, j, type);
}

private void ReduceItemStack(int ammoItemType)
{
foreach (Item item in Main.LocalPlayer.inventory)
{
if (item.type == ammoItemType)
{
item.stack--;
break;
}
}
}

//Infinite Placement Stuff
public override void PlaceInWorld(int i, int j, Item item)
{
BuilderPlayer modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();

if (!modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinitePlacement)
&& !modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinityUpgrade))
if (!modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinitePlacement) &&
!modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinityUpgrade))
{
if (item.consumable == false)
item.consumable = true;

//Wands will decrease their stack either way, but at least won't be consumed.
//Perhaps make my own Multi Wand to compensate for that?
//Wands aren't consumable items
if (item.type == ItemID.BoneWand || item.type == ItemID.HiveWand || item.type == ItemID.LeafWand ||
item.type == ItemID.LivingMahoganyWand || item.type == ItemID.LivingMahoganyLeafWand ||
item.type == ItemID.LivingWoodWand || item.type == ItemID.StaffofRegrowth)
Expand All @@ -179,8 +184,8 @@ public override void PlaceInWorld(int i, int j, Item item)
if (modPlayer.mirrorWandEffects)
UIUtilities.MirrorWandPlacement(i, j, item, -1);

if (modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinitePlacement)
|| modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinityUpgrade))
if (modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinitePlacement) ||
modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinityUpgrade))
item.consumable = false;
else
base.PlaceInWorld(i, j, item);
Expand All @@ -192,8 +197,8 @@ public class InfinitePlacementWall : GlobalWall
public override void PlaceInWorld(int i, int j, int type, Item item)
{
BuilderPlayer modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
if (modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinityUpgrade)
|| modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinitePlacement))
if (modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinityUpgrade) ||
modPlayer.creativeWheelSelectedIndex.Contains((int)CreativeWheelItem.InfinitePlacement))
item.consumable = false;
else
item.consumable = true;
Expand Down
5 changes: 2 additions & 3 deletions Items/MirrorWand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public override void SetStaticDefaults()
}
public override void SetDefaults()
{
item.height = 20;
item.width = 18;
item.height = 32;
item.width = 32;
item.useTime = 1;
item.useAnimation = 10;
item.useStyle = ItemUseStyleID.HoldingOut;
Expand Down Expand Up @@ -109,7 +109,6 @@ public override void UpdateInventory(Player player)
{
BuilderPlayer modPlayer = player.GetModPlayer<BuilderPlayer>();
base.UpdateInventory(player);
//Main.NewText("Start: " + MirrorWand.mouseLeftStart + " End: " + MirrorWand.mouseLeftEnd);

if (OperationComplete && OperationCompleteLeft && TransparentSelection.validPlacement)
modPlayer.mirrorWandEffects = true;
Expand Down
2 changes: 1 addition & 1 deletion build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
displayName = Builder Essentials
author = Kirtle
version = 0.1.11.2
version = 0.1.11.3
buildIgnore = *.csproj, *.user, obj\*, bin\*, .vs\*
homepage = https://discord.gg/wQYMbQq

0 comments on commit 65b4e31

Please sign in to comment.