Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Commit

Permalink
clean up, finish Grindstone
Browse files Browse the repository at this point in the history
  • Loading branch information
Chasmical committed Sep 6, 2020
1 parent da3c4ab commit 9fccff5
Showing 1 changed file with 53 additions and 23 deletions.
76 changes: 53 additions & 23 deletions aTonOfItems/aToI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public void Awake()
RoguePatcher patcher = new RoguePatcher(this, GetType());

#region Quantum Fud
QuantumFudCooldowns = new Dictionary<InvItem, float>();

Sprite sprite1 = RogueUtilities.ConvertToSprite(Properties.Resources.QuantumFud);
CustomItem quantumFud = RogueLibs.CreateCustomItem("QuantumFud", sprite1, false,
new CustomNameInfo("Quantum Fud",
Expand Down Expand Up @@ -59,12 +61,22 @@ public void Awake()
agent.SayDialogue("HealthFullCantUseItem");
else
{
int heal = new ItemFunctions().DetermineHealthChange(item, agent);
agent.statusEffects.ChangeHealth(heal);
if (agent.statusEffects.hasTrait("HealthItemsGiveFollowersExtraHealth") || agent.statusEffects.hasTrait("HealthItemsGiveFollowersExtraHealth2"))
new ItemFunctions().GiveFollowersHealth(agent, heal);
item.gc.audioHandler.Play(agent, "UseFood");
new ItemFunctions().UseItemAnim(item, agent);
if (!QuantumFudCooldowns.TryGetValue(item, out float cd))
{
QuantumFudCooldowns.Add(item, 0f);
cd = 0f;
}
if (cd == 0f)
{
int heal = new ItemFunctions().DetermineHealthChange(item, agent);
agent.statusEffects.ChangeHealth(heal);
if (agent.statusEffects.hasTrait("HealthItemsGiveFollowersExtraHealth") || agent.statusEffects.hasTrait("HealthItemsGiveFollowersExtraHealth2"))
new ItemFunctions().GiveFollowersHealth(agent, heal);
item.gc.audioHandler.Play(agent, "UseFood");
new ItemFunctions().UseItemAnim(item, agent);

QuantumFudCooldowns[item] = 0.5f;
}
return;
}
item.gc.audioHandler.Play(agent, "CantDo");
Expand Down Expand Up @@ -643,20 +655,34 @@ public void Awake()
otherItem.contents.Add("Sharpened:3");
item.database.SubtractFromItemCount(item, 1);
new ItemFunctions().UseItemAnim(item, agent);

if (item.invItemCount < 1)
{
agent.mainGUI.invInterface.HideDraggedItem();
agent.mainGUI.invInterface.HideTarget();
}
};

RogueLibs.CreateCustomName("Sharpened:1", "Item",
new CustomNameInfo("Sharpened (1)",
null, null, null, null,
"Заточенный (1)",
null, null));
RogueLibs.CreateCustomName("Sharpened:2", "Item",
new CustomNameInfo("Sharpened (2)",
null, null, null, null,
"Заточенный (2)",
null, null));
RogueLibs.CreateCustomName("Sharpened:3", "Item",
new CustomNameInfo("Sharpened (3)",
null, null, null, null,
"Заточенный (3)",
null, null));
#endregion










}

public static bool PlayfieldObject_FindDamage(PlayfieldObject __instance, PlayfieldObject damagerObject, ref bool generic)
Expand Down Expand Up @@ -706,26 +732,23 @@ public static bool PlayfieldObject_FindDamage(PlayfieldObject __instance, Playfi
return true;
}

public void Update() => VoodooCheck();
public void FixedUpdate()
{
VoodooCheck();
QuantumFudCheck();
}

public static Dictionary<InvItem, Agent> VoodooUpdateList { get; set; }
public static Dictionary<InvItem, float> VoodooCooldowns { get; set; }
public void VoodooCheck()
{
List<InvItem> removal = new List<InvItem>();
Dictionary<InvItem, float> newDictionary = new Dictionary<InvItem, float>();

foreach (KeyValuePair<InvItem, float> pair in VoodooCooldowns)
newDictionary.Add(pair.Key, Mathf.Max(pair.Value - Time.fixedDeltaTime, 0f));
VoodooCooldowns = newDictionary;
VoodooCooldowns[pair.Key] = Mathf.Max(pair.Value - Time.fixedDeltaTime, 0f);

List<InvItem> removal = new List<InvItem>();
foreach (KeyValuePair<InvItem, Agent> pair in VoodooUpdateList)
{
InvItem item = pair.Key;
if (pair.Key == null || pair.Value == null)
{
removal.Add(item);
continue;
}
if (pair.Value.dead)
{
item.database.DestroyItem(item);
Expand All @@ -744,5 +767,12 @@ public void VoodooCheck()
VoodooCooldowns.Remove(item);
}
}

public static Dictionary<InvItem, float> QuantumFudCooldowns { get; set; }
public void QuantumFudCheck()
{
foreach (KeyValuePair<InvItem, float> pair in QuantumFudCooldowns)
QuantumFudCooldowns[pair.Key] = Mathf.Max(pair.Value - Time.fixedDeltaTime, 0f);
}
}
}

0 comments on commit 9fccff5

Please sign in to comment.