From 9fccff5296e6c4c1801a4b3bee21798b95bf5a12 Mon Sep 17 00:00:00 2001 From: Abbysssal <55982389+Abbysssal@users.noreply.github.com> Date: Sun, 6 Sep 2020 14:23:24 +0700 Subject: [PATCH] clean up, finish Grindstone --- aTonOfItems/aToI.cs | 76 +++++++++++++++++++++++++++++++-------------- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/aTonOfItems/aToI.cs b/aTonOfItems/aToI.cs index efc8e60..1e27dce 100644 --- a/aTonOfItems/aToI.cs +++ b/aTonOfItems/aToI.cs @@ -19,6 +19,8 @@ public void Awake() RoguePatcher patcher = new RoguePatcher(this, GetType()); #region Quantum Fud + QuantumFudCooldowns = new Dictionary(); + Sprite sprite1 = RogueUtilities.ConvertToSprite(Properties.Resources.QuantumFud); CustomItem quantumFud = RogueLibs.CreateCustomItem("QuantumFud", sprite1, false, new CustomNameInfo("Quantum Fud", @@ -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"); @@ -643,13 +655,23 @@ 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 @@ -657,6 +679,10 @@ public void Awake() + + + + } public static bool PlayfieldObject_FindDamage(PlayfieldObject __instance, PlayfieldObject damagerObject, ref bool generic) @@ -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 VoodooUpdateList { get; set; } public static Dictionary VoodooCooldowns { get; set; } public void VoodooCheck() { - List removal = new List(); - Dictionary newDictionary = new Dictionary(); - foreach (KeyValuePair 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 removal = new List(); foreach (KeyValuePair 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); @@ -744,5 +767,12 @@ public void VoodooCheck() VoodooCooldowns.Remove(item); } } + + public static Dictionary QuantumFudCooldowns { get; set; } + public void QuantumFudCheck() + { + foreach (KeyValuePair pair in QuantumFudCooldowns) + QuantumFudCooldowns[pair.Key] = Mathf.Max(pair.Value - Time.fixedDeltaTime, 0f); + } } }