Complete recode of vanilla recipe edits to be modular. Uses functional programming.

This commit is contained in:
Ozzatron committed 2022-06-23 19:30:27 -04:00
1 parent cf3df1a5ce
commit bc2b25df6f
2 files changed
+278 -796

No files matched your search

File diff suppressed because it is too large. Load diff
+21 -17
View File
@@ -1,4 +1,7 @@
using CalamityMod.Items.Placeables.Banners;
using System;
using System.Collections.Generic;
using System.Linq;
using CalamityMod.Items.Placeables.Banners;
using CalamityMod.Items.Tools.ClimateChange;
using CalamityMod.NPCs.Abyss;
using CalamityMod.NPCs.AcidRain;
@@ -14,10 +17,6 @@ using CalamityMod.NPCs.SunkenSea;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Terraria;
using Terraria.Chat;
using Terraria.GameContent.Events;
@@ -43,6 +42,23 @@ namespace CalamityMod
ChatHelper.BroadcastChatMessage(NetworkText.FromKey(key), textColor.Value);
}
public static int IngredientIndex(this Recipe r, int itemID)
{
for (int i = 0; i < r.requiredItem.Count; ++i)
if (r.requiredItem[i].type == itemID)
return i;
return -1;
}
public static bool ChangeIngredientStack(this Recipe r, int itemID, int stack)
{
int idx = r.IngredientIndex(itemID);
if (idx == -1)
return false;
r.requiredItem[idx].stack = stack;
return true;
}
// Yes, this method has a use that Utils.Swap does not; You cannot use refs on array indices.
// The CLR will not allow that. As such, a custom method must be used to achieve this.
@@ -112,18 +128,6 @@ namespace CalamityMod
return colors2D;
}
public static string CombineStrings(params object[] args)
{
StringBuilder result = new StringBuilder(1024);
for (int i = 0; i < args.Length; ++i)
{
object o = args[i];
result.Append(o.ToString());
result.Append(' ');
}
return result.ToString();
}
/// <summary>
/// Determines if a list contains an entry of a specific type. Specifically intended to account for derived types.
/// </summary>