Skip to content

Commit

Permalink
Added Dyes slots to the Mod Config
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirtle committed Jul 2, 2020
1 parent 3330043 commit 99ec489
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 7 deletions.
1 change: 1 addition & 0 deletions Buffs/BuildInPeaceBuff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public override void Update(Player player, ref int buffIndex)
Main.invasionType = 0;
Main.invasionDelay = 0;
Main.invasionSize = 0;
Main.dayTime = true;
Main.time = 27000; //mid day
Main.fastForwardTime = false;

Expand Down
11 changes: 10 additions & 1 deletion BuilderEssentialsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class BuilderEssentialsConfig : ModConfig
[ReloadRequired]
[DefaultValue(true)]
public bool miscEquips;
[Label("Different Dyes while on Building Mode")]
[ReloadRequired]
[DefaultValue(true)]
public bool dyes;

public override void OnChanged()
{
Expand All @@ -41,12 +45,17 @@ public override void OnChanged()
Tools.armor = armor;
Tools.vanityArmor = vanityArmor;
Tools.miscEquips = miscEquips;
Tools.dyes = dyes;
}

public override void OnLoaded()
{
Tools.accessories = accessories;
Tools.vanityAccessories = vanityAccessories;
Tools.armor = armor;
Tools.vanityArmor = vanityArmor;
Tools.miscEquips = miscEquips;
//Tools.LoadedConfig();
Tools.dyes = dyes;
}
}
}
36 changes: 34 additions & 2 deletions BuilderPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,25 @@ namespace BuilderEssentials
public class BuilderPlayer : ModPlayer
{
//Building Mode
public bool IsNormalAccessories;

public List<Item> NormalAccessories;
public List<Item> BuildingAccessories;

public List<Item> NormalVanityAccessories;
public List<Item> BuildingVanityAccessories;

public List<Item> NormalArmor;
public List<Item> BuildingArmor;

public List<Item> NormalVanityArmor;
public List<Item> BuildingVanityArmor;

public List<Item> NormalMiscEquips;
public List<Item> BuildingMiscEquips;
public bool IsNormalAccessories;

public List<Item> NormalDyes;
public List<Item> BuildingDyes;


//Creative Wheel Stuff
Expand Down Expand Up @@ -54,17 +62,25 @@ public enum CreativeWheelItem : int
public bool mirrorWandEffects;
public override void Initialize()
{
IsNormalAccessories = true;

NormalAccessories = new List<Item>(7);
BuildingAccessories = new List<Item>(7);

NormalVanityAccessories = new List<Item>(7);
BuildingVanityAccessories = new List<Item>(7);

NormalArmor = new List<Item>(3);
BuildingArmor = new List<Item>(3);

NormalVanityArmor = new List<Item>(3);
BuildingVanityArmor = new List<Item>(3);

NormalMiscEquips = new List<Item>(5);
BuildingMiscEquips = new List<Item>(5);
IsNormalAccessories = true;

NormalDyes = new List<Item>(15);
BuildingDyes = new List<Item>(15);


//Creative Wheel Stuff
Expand Down Expand Up @@ -122,18 +138,28 @@ public override TagCompound Save()
return new TagCompound
{
{ "IsNormalAccessories", IsNormalAccessories },

{ "NormalAccessories", NormalAccessories },
{ "BuildingAccessories", BuildingAccessories },

{"NormalVanityAccessories", NormalVanityAccessories },
{"BuildingVanityAccessories", BuildingVanityAccessories },

{"NormalArmor", NormalArmor },
{"BuildingArmor", BuildingArmor },

{"NormalVanityArmor", NormalVanityArmor },
{"BuildingVanityArmor", BuildingVanityArmor },

{"NormalMiscEquips", NormalMiscEquips },
{"BuildingMiscEquips", BuildingMiscEquips },

{"NormalDyes", NormalDyes },
{"BuildingDyes", BuildingDyes },

{"creativeWheelSelectedIndex", creativeWheelSelectedIndex},
{"autoHammerSelectedIndex", autoHammerSelectedIndex },

{"paintingColorSelectedIndex", paintingColorSelectedIndex},
{"paintingToolSelected", paintingToolSelected}
};
Expand Down Expand Up @@ -175,6 +201,12 @@ public override void Load(TagCompound tag)
if (tag.ContainsKey("BuildingMiscEquips"))
BuildingMiscEquips = tag.Get<List<Item>>("BuildingMiscEquips");

if (tag.ContainsKey("NormalDyes"))
NormalDyes = tag.Get<List<Item>>("NormalDyes");

if (tag.ContainsKey("BuildingDyes"))
BuildingDyes = tag.Get<List<Item>>("BuildingDyes");

//Creative Wheel
if (tag.ContainsKey("creativeWheelSelectedIndex"))
creativeWheelSelectedIndex = tag.Get<List<int>>("creativeWheelSelectedIndex");
Expand Down
59 changes: 55 additions & 4 deletions Utilities/BuildingMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static partial class Tools
public static bool armor;
public static bool vanityArmor;
public static bool miscEquips;
public static bool dyes;

public static void BuildingModeToggle()
{
Expand All @@ -44,6 +45,8 @@ public static void CleanAcessoriesList()
modPlayer.NormalVanityArmor.Clear();
if (miscEquips)
modPlayer.NormalMiscEquips.Clear();
if (dyes)
modPlayer.NormalDyes.Clear();
}
else
{
Expand All @@ -57,6 +60,8 @@ public static void CleanAcessoriesList()
modPlayer.BuildingVanityArmor.Clear();
if (miscEquips)
modPlayer.BuildingMiscEquips.Clear();
if (dyes)
modPlayer.BuildingDyes.Clear();
}
}

Expand Down Expand Up @@ -118,6 +123,29 @@ public static void SaveCurrentAccessories()
modPlayer.BuildingMiscEquips.Add(player.miscEquips[i]);
}
}


//Dyes
for (int i = 0; i < 15; i++)
{
if (dyes)
{
if (i < 10) //Armor + Accessories Dyes
{
if (modPlayer.IsNormalAccessories)
modPlayer.NormalDyes.Add(player.dye[i]);
else
modPlayer.BuildingDyes.Add(player.dye[i]);
}
else //Misc Equipement Dyes
{
if (modPlayer.IsNormalAccessories)
modPlayer.NormalDyes.Add(player.miscDyes[i - 10]);
else
modPlayer.BuildingDyes.Add(player.miscDyes[i - 10]);
}
}
}
}

public static void LoadAccessories()
Expand All @@ -131,16 +159,16 @@ public static void LoadAccessories()
if (modPlayer.IsNormalAccessories)
{
if (accessories)
player.armor[i] = modPlayer.NormalAccessories[i-3];
player.armor[i] = modPlayer.NormalAccessories[i - 3];
if (vanityAccessories)
player.armor[i + 10] = modPlayer.NormalVanityAccessories[i-3];
player.armor[i + 10] = modPlayer.NormalVanityAccessories[i - 3];
}
else
{
if (accessories)
player.armor[i] = modPlayer.BuildingAccessories[i-3];
player.armor[i] = modPlayer.BuildingAccessories[i - 3];
if (vanityAccessories)
player.armor[i + 10] = modPlayer.BuildingVanityAccessories[i-3];
player.armor[i + 10] = modPlayer.BuildingVanityAccessories[i - 3];
}
}

Expand Down Expand Up @@ -175,6 +203,29 @@ public static void LoadAccessories()
player.miscEquips[i] = modPlayer.BuildingMiscEquips[i];
}
}


//Dyes
for (int i = 0; i < 15; i++)
{
if (dyes)
{
if (i < 10)
{
if (modPlayer.IsNormalAccessories)
player.dye[i] = modPlayer.NormalDyes[i];
else
player.dye[i] = modPlayer.BuildingDyes[i];
}
else
{
if (modPlayer.IsNormalAccessories)
player.miscDyes[i - 10] = modPlayer.NormalDyes[i];
else
player.miscDyes[i - 10] = modPlayer.BuildingDyes[i];
}
}
}
}
public static void UpdateButtonImage()
{
Expand Down

0 comments on commit 99ec489

Please sign in to comment.