diff --git a/Buffs/InfinitePlacementBuff.cs b/Buffs/InfinitePlacementBuff.cs index 85e864b..74eca4a 100644 --- a/Buffs/InfinitePlacementBuff.cs +++ b/Buffs/InfinitePlacementBuff.cs @@ -12,8 +12,12 @@ public override void SetDefaults() Main.debuff[Type] = true; Main.buffNoSave[Type] = true; Main.buffNoTimeDisplay[Type] = true; - Main.buffAlpha[Type] = 0; canBeCleared = false; } + + public override void Update(Player player, ref int buffIndex) + { + player.GetModPlayer().InfinitePlacement = true; + } } } diff --git a/BuilderPlayer.cs b/BuilderPlayer.cs index 67067cf..54f3f3b 100644 --- a/BuilderPlayer.cs +++ b/BuilderPlayer.cs @@ -16,7 +16,7 @@ public class BuilderPlayer : ModPlayer public List NormalVanityClothes; public List BuildingVanityClothes; public bool IsNormalAccessories; - public bool BuildingModeHotkeyPressed; + public bool InfinitePlacement; public override void Initialize() { @@ -27,17 +27,18 @@ public override void Initialize() NormalVanityClothes = new List(3); BuildingVanityClothes = new List(3); IsNormalAccessories = true; - BuildingModeHotkeyPressed = false; + InfinitePlacement = false; + } + + public override void ResetEffects() + { + InfinitePlacement = false; } public override void ProcessTriggers(TriggersSet triggersSet) { if (BuilderEssentials.ToggleBuildingMode.JustPressed) - { - BuildingModeHotkeyPressed = true; - - BasePanel.button.OnClick(); - } + BasePanel.BuildingModeAccessoriesToggle(); } public override TagCompound Save() diff --git a/Items/InfinitePlacement.cs b/Items/InfinitePlacement.cs index 3050fb1..433f289 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 = 46; - item.height = 46; + item.width = 24; + item.height = 24; item.value = Item.sellPrice(0, 10, 0, 0); item.rare = ItemRarityID.Red; } @@ -79,7 +79,8 @@ public override void RightClick(Player player) public override void UpdateAccessory(Player player, bool hideVisual) { - player.AddBuff(mod.BuffType("InfinitePlacementBuff"), 1); + player.AddBuff(mod.BuffType("InfinitePlacementBuff"), 90); + player.GetModPlayer().IsNormalAccessories = false; } public override void AddRecipes() @@ -101,9 +102,9 @@ public partial class InfinitePlacementTile : GlobalTile { public override void PlaceInWorld(int i, int j, Item item) { - if (Main.LocalPlayer.HasBuff(mod.BuffType("InfinitePlacementBuff"))) { - item.stack += 1; - base.PlaceInWorld(i, j, item); + if (Main.LocalPlayer.GetModPlayer().InfinitePlacement) + { + item.stack = item.maxStack + 1; } } } @@ -112,10 +113,9 @@ public partial class InfinitePlacementWall : GlobalWall { public override void PlaceInWorld(int i, int j, int type, Item item) { - if (Main.LocalPlayer.HasBuff(mod.BuffType("InfinitePlacementBuff"))) + if (Main.LocalPlayer.GetModPlayer().InfinitePlacement) { - item.stack += 1; - base.PlaceInWorld(i, j, type, item); + item.stack = item.maxStack + 1; } } } diff --git a/Items/InfinitePlacement.png b/Items/InfinitePlacement.png index 681ac24..4a13345 100644 Binary files a/Items/InfinitePlacement.png and b/Items/InfinitePlacement.png differ diff --git a/Items/InfinitePlacement2.png b/Items/InfinitePlacement2.png index a48ca26..c934eed 100644 Binary files a/Items/InfinitePlacement2.png and b/Items/InfinitePlacement2.png differ diff --git a/Items/InfinitePlacement3.png b/Items/InfinitePlacement3.png new file mode 100644 index 0000000..a48ca26 Binary files /dev/null and b/Items/InfinitePlacement3.png differ diff --git a/Items/Sprite-0001.ase b/Items/Sprite-0001.ase new file mode 100644 index 0000000..789583f Binary files /dev/null and b/Items/Sprite-0001.ase differ diff --git a/UI/BasePanel.cs b/UI/BasePanel.cs index 1db4ebf..6b5f664 100644 --- a/UI/BasePanel.cs +++ b/UI/BasePanel.cs @@ -12,7 +12,6 @@ public class BasePanel : UIState { public static UIImageButton button; public static Texture2D buttonTexture; - public BuilderPlayer modPlayer; public override void OnInitialize() { buttonTexture = BuilderEssentials.BuildingModeOff; @@ -26,16 +25,8 @@ 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) @@ -43,9 +34,9 @@ public void ChangeAccessories_OnClick(UIMouseEvent evt, UIElement listeningEleme BuildingModeAccessoriesToggle(); } - public void BuildingModeAccessoriesToggle() + public static void BuildingModeAccessoriesToggle() { - modPlayer = Main.LocalPlayer.GetModPlayer(); + var modPlayer = Main.LocalPlayer.GetModPlayer(); CleanAcessoriesList(); SaveCurrentAccessories(); modPlayer.IsNormalAccessories = !modPlayer.IsNormalAccessories; @@ -53,9 +44,9 @@ public void BuildingModeAccessoriesToggle() UpdateButtonImage(); } - public void CleanAcessoriesList() + public static void CleanAcessoriesList() { - modPlayer = Main.LocalPlayer.GetModPlayer(); + var modPlayer = Main.LocalPlayer.GetModPlayer(); //TODO: Mod config where the player can choose if he wishes to have "2nd" vanity slots too if (modPlayer.IsNormalAccessories) { @@ -71,9 +62,9 @@ public void CleanAcessoriesList() } } - public void SaveCurrentAccessories() + public static void SaveCurrentAccessories() { - modPlayer = Main.LocalPlayer.GetModPlayer(); + var modPlayer = Main.LocalPlayer.GetModPlayer(); int maxAccessoryIndex = 5 + Main.LocalPlayer.extraAccessorySlots; //Normal and Vanity Accessories for (int i = 3; i < 3 + maxAccessoryIndex; i++) @@ -103,9 +94,9 @@ public void SaveCurrentAccessories() } } - public void LoadAccessories() + public static void LoadAccessories() { - modPlayer = Main.LocalPlayer.GetModPlayer(); + var modPlayer = Main.LocalPlayer.GetModPlayer(); if (modPlayer.IsNormalAccessories) { @@ -134,9 +125,9 @@ public void LoadAccessories() } } } - public void UpdateButtonImage() + public static void UpdateButtonImage() { - modPlayer = Main.LocalPlayer.GetModPlayer(); + var modPlayer = Main.LocalPlayer.GetModPlayer(); if (modPlayer.IsNormalAccessories) button.SetImage(BuilderEssentials.BuildingModeOff); else