Skip to content

Commit

Permalink
Update InfinitePlacement Sprite and made the UI methods static to fix…
Browse files Browse the repository at this point in the history
… a bug with the HotKey

Made the InfinitePlacement Accessory give the player the maxStack value instead of adding +1 since it is causing problems as a hotfix.
  • Loading branch information
Kirtle committed Jun 10, 2020
1 parent 281ca53 commit c86bc6b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 36 deletions.
6 changes: 5 additions & 1 deletion Buffs/InfinitePlacementBuff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<BuilderPlayer>().InfinitePlacement = true;
}
}
}
15 changes: 8 additions & 7 deletions BuilderPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class BuilderPlayer : ModPlayer
public List<Item> NormalVanityClothes;
public List<Item> BuildingVanityClothes;
public bool IsNormalAccessories;
public bool BuildingModeHotkeyPressed;
public bool InfinitePlacement;

public override void Initialize()
{
Expand All @@ -27,17 +27,18 @@ public override void Initialize()
NormalVanityClothes = new List<Item>(3);
BuildingVanityClothes = new List<Item>(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()
Expand Down
18 changes: 9 additions & 9 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 = 46;
item.height = 46;
item.width = 24;
item.height = 24;
item.value = Item.sellPrice(0, 10, 0, 0);
item.rare = ItemRarityID.Red;
}
Expand Down Expand Up @@ -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<BuilderPlayer>().IsNormalAccessories = false;
}

public override void AddRecipes()
Expand All @@ -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<BuilderPlayer>().InfinitePlacement)
{
item.stack = item.maxStack + 1;
}
}
}
Expand All @@ -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<BuilderPlayer>().InfinitePlacement)
{
item.stack += 1;
base.PlaceInWorld(i, j, type, item);
item.stack = item.maxStack + 1;
}
}
}
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.
Binary file modified Items/InfinitePlacement2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Items/InfinitePlacement3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Items/Sprite-0001.ase
Binary file not shown.
29 changes: 10 additions & 19 deletions UI/BasePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,36 +25,28 @@ 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()
public static void BuildingModeAccessoriesToggle()
{
modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
var modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
CleanAcessoriesList();
SaveCurrentAccessories();
modPlayer.IsNormalAccessories = !modPlayer.IsNormalAccessories;
LoadAccessories();
UpdateButtonImage();
}

public void CleanAcessoriesList()
public static void CleanAcessoriesList()
{
modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
var modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
//TODO: Mod config where the player can choose if he wishes to have "2nd" vanity slots too
if (modPlayer.IsNormalAccessories)
{
Expand All @@ -71,9 +62,9 @@ public void CleanAcessoriesList()
}
}

public void SaveCurrentAccessories()
public static void SaveCurrentAccessories()
{
modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
var modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
int maxAccessoryIndex = 5 + Main.LocalPlayer.extraAccessorySlots;
//Normal and Vanity Accessories
for (int i = 3; i < 3 + maxAccessoryIndex; i++)
Expand Down Expand Up @@ -103,9 +94,9 @@ public void SaveCurrentAccessories()
}
}

public void LoadAccessories()
public static void LoadAccessories()
{
modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
var modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();

if (modPlayer.IsNormalAccessories)
{
Expand Down Expand Up @@ -134,9 +125,9 @@ public void LoadAccessories()
}
}
}
public void UpdateButtonImage()
public static void UpdateButtonImage()
{
modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
var modPlayer = Main.LocalPlayer.GetModPlayer<BuilderPlayer>();
if (modPlayer.IsNormalAccessories)
button.SetImage(BuilderEssentials.BuildingModeOff);
else
Expand Down

0 comments on commit c86bc6b

Please sign in to comment.