using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HolyCrapForkIsBack.Items;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.ExpansionManagement;
using UnityEngine;
using UnityEngine.AddressableAssets;
using VoidItemAPI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("HolyCrapForkIsBack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HolyCrapForkIsBack")]
[assembly: AssemblyTitle("HolyCrapForkIsBack")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace HolyCrapForkIsBack
{
public static class Assets
{
internal static AssetBundle mainAssetBundle;
private const string assetbundleName = "hcfbasset";
private static string[] assetNames = new string[0];
public static void Init()
{
if ((Object)(object)mainAssetBundle == (Object)null)
{
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("HolyCrapForkIsBack.hcfbasset");
mainAssetBundle = AssetBundle.LoadFromStream(stream);
}
assetNames = mainAssetBundle.GetAllAssetNames();
Log.LogInfo(assetNames.ToString());
}
}
public static class HopooShaderToMaterial
{
public class Properties
{
public Dictionary<string, float> floats = new Dictionary<string, float>();
public Dictionary<string, Color> colors = new Dictionary<string, Color>();
public Dictionary<string, Texture> textures = new Dictionary<string, Texture>();
public Dictionary<string, Vector2> textureOffsets = new Dictionary<string, Vector2>();
public Dictionary<string, Vector2> textureScales = new Dictionary<string, Vector2>();
}
public class Standard
{
public static Shader shader = LegacyShaderAPI.Find("Hopoo Games/Deferred/Standard");
public static void Apply(Material mat, Properties properties = null)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
if (properties == null)
{
properties = new Properties();
}
if (mat.HasProperty("_BumpScale"))
{
properties.floats.Add("_NormalStrength", mat.GetFloat("_BumpScale"));
}
if (mat.HasProperty("_BumpMap"))
{
properties.textures.Add("_NormalTex", mat.GetTexture("_BumpMap"));
properties.textureOffsets.Add("_NormalTex", mat.GetTextureOffset("_BumpMap"));
properties.textureScales.Add("_NormalTex", mat.GetTextureScale("_BumpMap"));
}
if (mat.HasProperty("_EmTex"))
{
properties.textures.Add("_EmTex", mat.GetTexture("_EmissionMap"));
properties.textureOffsets.Add("_EmTex", mat.GetTextureOffset("_EmissionMap"));
properties.textureScales.Add("_EmTex", mat.GetTextureScale("_EmissionMap"));
}
HopooShaderToMaterial.Apply(mat, shader, properties);
}
public static void DisableEverything(Material mat)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
mat.DisableKeyword("DITHER");
mat.SetFloat("_DitherOn", 0f);
mat.DisableKeyword("FORCE_SPEC");
mat.SetFloat("_SpecularHighlights", 0f);
mat.SetFloat("_SpecularStrength", 0f);
mat.DisableKeyword("_EMISSION");
mat.SetFloat("_EmPower", 0f);
mat.SetColor("_EmColor", new Color(0f, 0f, 0f, 1f));
mat.DisableKeyword("FRESNEL_EMISSION");
mat.SetFloat("_FresnelBoost", 0f);
}
public static void Dither(Material mat)
{
mat.EnableKeyword("DITHER");
mat.SetFloat("_DitherOn", 1f);
}
public static void Gloss(Material mat, float glossiness = 1f, float specularExponent = 10f, Color? color = null)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
mat.EnableKeyword("FORCE_SPEC");
mat.SetFloat("_SpecularHighlights", 1f);
mat.SetFloat("_SpecularExponent", specularExponent);
mat.SetFloat("_SpecularStrength", glossiness);
mat.SetColor("_SpecularTint", (Color)(((??)color) ?? Color.white));
}
public static void Emission(Material mat, float power = 1f, Color? color = null)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
mat.EnableKeyword("_EMISSION");
mat.EnableKeyword("FRESNEL_EMISSION");
mat.SetFloat("_EmPower", power);
mat.SetColor("_EmColor", (Color)(((??)color) ?? Color.white));
if (power == 0f)
{
mat.DisableKeyword("_EMISSION");
mat.DisableKeyword("FRESNEL_EMISSION");
}
}
}
public class CloudRemap
{
public static Shader shader = LegacyShaderAPI.Find("Hopoo Games/FX/Cloud Remap");
public static void Apply(Material mat, Properties properties = null)
{
if (properties == null)
{
properties = new Properties();
}
HopooShaderToMaterial.Apply(mat, shader, properties);
mat.SetFloat("_AlphaBias", 0f);
mat.SetFloat("_AlphaBoost", 1f);
mat.SetFloat("_Cull", 0f);
mat.SetFloat("_DepthOffset", 0f);
mat.SetFloat("_Fade", 1f);
mat.SetFloat("_FadeCloseDistance", 0.5f);
mat.SetFloat("_FadeCloseOn", 0f);
mat.SetFloat("_InvFade", 2f);
mat.SetFloat("_ZTest", 4f);
mat.SetFloat("_ZWrite", 1f);
}
public static void Apply(Material mat, Texture remapTexture = null, Texture cloud1Texture = null, Texture cloud2Texture = null, Properties properties = null)
{
Apply(mat, properties);
mat.SetTexture("_Cloud1Tex", cloud1Texture);
mat.SetTexture("_Cloud2Tex", cloud2Texture);
mat.SetTexture("_RemapTex", remapTexture);
}
public static void Boost(Material mat, float power = 1f)
{
mat.SetFloat("_Boost", power);
}
}
public static void Apply(Material mat, Shader shader, Properties properties = null)
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
mat.shader = shader;
if (properties == null)
{
properties = new Properties();
}
foreach (KeyValuePair<string, float> @float in properties.floats)
{
mat.SetFloat(@float.Key, @float.Value);
}
foreach (KeyValuePair<string, Color> color in properties.colors)
{
mat.SetColor(color.Key, color.Value);
}
foreach (KeyValuePair<string, Texture> texture in properties.textures)
{
mat.SetTexture(texture.Key, texture.Value);
}
foreach (KeyValuePair<string, Vector2> textureOffset in properties.textureOffsets)
{
mat.SetTextureOffset(textureOffset.Key, textureOffset.Value);
}
foreach (KeyValuePair<string, Vector2> textureScale in properties.textureScales)
{
mat.SetTextureScale(textureScale.Key, textureScale.Value);
}
}
}
internal static class Log
{
internal static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void LogDebug(object data)
{
_logSource.LogDebug(data);
}
internal static void LogError(object data)
{
_logSource.LogError(data);
}
internal static void LogFatal(object data)
{
_logSource.LogFatal(data);
}
internal static void LogInfo(object data)
{
_logSource.LogInfo(data);
}
internal static void LogMessage(object data)
{
_logSource.LogMessage(data);
}
internal static void LogWarning(object data)
{
_logSource.LogWarning(data);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Ner0ls.HolyCrapForkIsBack", "HolyCrapForkIsBack", "1.0.5")]
[R2APISubmoduleDependency(new string[] { "ItemAPI", "LanguageAPI", "RecalculateStatsAPI" })]
public class Main : BaseUnityPlugin
{
public const string PluginGUID = "com.Ner0ls.HolyCrapForkIsBack";
public const string PluginAuthor = "Ner0ls";
public const string PluginName = "HolyCrapForkIsBack";
public const string PluginVersion = "1.0.5";
public List<ItemBase> Items = new List<ItemBase>();
public static PluginInfo PInfo { get; private set; }
public void Awake()
{
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
PInfo = ((BaseUnityPlugin)this).Info;
Log.Init(((BaseUnityPlugin)this).Logger);
Assets.Init();
Log.LogInfo("Trying to initialize items.");
foreach (Type item in from type in Assembly.GetExecutingAssembly().GetTypes()
where !type.IsAbstract && type.IsSubclassOf(typeof(ItemBase))
select type)
{
ItemBase itemBase = (ItemBase)Activator.CreateInstance(item);
if (!itemBase.forceEnable && !ValidateItem(itemBase, Items))
{
continue;
}
Log.LogInfo("Initializing item: " + itemBase.name);
itemBase.Init(((BaseUnityPlugin)this).Config);
if (itemBase.dlcRequired)
{
itemBase.itemDef.requiredExpansion = ((IEnumerable<ExpansionDef>)(object)ExpansionCatalog.expansionDefs).FirstOrDefault((Func<ExpansionDef, bool>)((ExpansionDef x) => x.nameToken == "DLC1_NAME"));
}
}
Log.LogInfo("Awake done.");
}
public bool ValidateItem(ItemBase item, List<ItemBase> itemList)
{
bool value = ((BaseUnityPlugin)this).Config.Bind<bool>("Item: " + item.nameDefault, "Enable Item?", true, "Should this item appear in runs?").Value;
bool value2 = ((BaseUnityPlugin)this).Config.Bind<bool>("Item: " + item.nameDefault, "Blacklist Item from AI Use?", false, "Should the AI not be able to obtain this item?").Value;
if (value)
{
itemList.Add(item);
if (value2)
{
item.AIBlacklisted = true;
}
}
return value;
}
}
}
namespace HolyCrapForkIsBack.Items
{
public class BrokenChopsticks : ItemBase<BrokenChopsticks>
{
public static ItemDef brokenChopsticksItemDef;
public override bool forceEnable => true;
public override string name => ItemBase.prefix + "BROKEN_CHOPSTICKS";
public override ItemTag[] itemTags => (ItemTag[])(object)new ItemTag[0];
public override bool canRemove => false;
public override bool hidden => false;
public override bool dlcRequired => false;
public override string nameToken => ItemBase.prefix + "BROKEN_CHOPSTICKS_NAME";
public override string pickupToken => ItemBase.prefix + "BROKEN_CHOPSTICKS_PICKUP";
public override string descToken => ItemBase.prefix + "BROKEN_CHOPSTICKS_DESC";
public override string loreToken => ItemBase.prefix + "BROKEN_CHOPSTICKS_LORE";
public override string nameDefault => "Broken Chopsticks";
public override string pickupDefault => "I told you it was a bad idea...";
public override string descDefault => "I told you it was a bad idea...";
public override string loreDefault => "";
public override void Init(ConfigFile config)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
brokenChopsticksItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
brokenChopsticksItemDef.deprecatedTier = (ItemTier)5;
brokenChopsticksItemDef.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Items/icons/broken_sharp_chopsticks.png");
brokenChopsticksItemDef.pickupModelPrefab = Resources.Load<GameObject>("Prefabs/PickupModels/PickupMystery");
SetupLanguageTokens();
ItemAPI.Add(new CustomItem(brokenChopsticksItemDef, displayRules));
}
}
public class BulwarkSpoon : ItemBase<BulwarkSpoon>
{
public static ItemDef gSpoonItemDef;
protected float barrierOnKill = 30f;
protected float damageBonus = 0.2f;
protected float armorBonus = 30f;
protected float cdrBonus = 0.2f;
protected float cdrPerStack = 0.1f;
public override string name => ItemBase.prefix + "BULWARK_SPOON";
public override ItemTag[] itemTags => (ItemTag[])(object)new ItemTag[2]
{
(ItemTag)6,
(ItemTag)3
};
public override bool canRemove => true;
public override bool hidden => false;
public override bool dlcRequired => false;
public override string nameToken => ItemBase.prefix + "BULWARK_SPOON_NAME";
public override string pickupToken => ItemBase.prefix + "BULWARK_SPOON_PICKUP";
public override string descToken => ItemBase.prefix + "BULWARK_SPOON_DESC";
public override string loreToken => ItemBase.prefix + "BULWARK_SPOON_LORE";
public override string nameDefault => "Bulwark Spoon";
public override string pickupDefault => "Gain barrier on kill.\nIncreases your stats in relation of your current barrier value.";
public override string descDefault => $"Gain {barrierOnKill} barrier on kill.\n" + $"Progressively increases your <style=cIsDamage>Base Damage</style> up to {damageBonus * 100f}% <style=cStack>(+{damageBonus * 100f}% per stack)</style>, your <style=cSub>Armor</style> up to {armorBonus} <style=cStack>(+{armorBonus} per stack)</style> " + $"and <style=cIsUtility>Cooldown Reduction</style> up to {cdrBonus * 100f}% <style=cStack>(+{cdrPerStack * 100f}% per stack)</style> in relation of the current percent of barrier you have over your combined health.";
public override string loreDefault => "For all my followers.\n\nThis is a piece of myself.\n\nThis is the way to show your devotion.\n\nThis is our bond, our connection.\n\nThis is our emblem, our identity.\n\nThis is my will.\n\nThis… is… the reminder.\n";
public override void Init(ConfigFile config)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
gSpoonItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
gSpoonItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
gSpoonItemDef.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Items/icons/bul_spoon.png");
gSpoonItemDef.pickupModelPrefab = Assets.mainAssetBundle.LoadAsset<GameObject>("Assets/Import/Items/models/bul_spoon/BulSpoon.prefab");
HopooShaderToMaterial.Standard.Apply(gSpoonItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial);
HopooShaderToMaterial.Standard.Gloss(gSpoonItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial, 0.1f, 1f, Color.white);
SetupLanguageTokens();
SetupHooks();
ItemAPI.Add(new CustomItem(gSpoonItemDef, displayRules));
}
protected override void SetupHooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
GlobalEventManager.OnCharacterDeath += new hook_OnCharacterDeath(GlobalEventManager_OnCharacterDeath);
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
}
private void GlobalEventManager_OnCharacterDeath(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)damageReport.attacker) && Object.op_Implicit((Object)(object)damageReport.attackerBody))
{
CharacterBody attackerBody = damageReport.attackerBody;
if (Object.op_Implicit((Object)(object)attackerBody.inventory) && attackerBody.inventory.GetItemCount(gSpoonItemDef.itemIndex) > 0)
{
attackerBody.healthComponent.AddBarrier(barrierOnKill);
}
orig.Invoke(self, damageReport);
}
}
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody characterBody, StatHookEventArgs args)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)characterBody.inventory))
{
int itemCount = characterBody.inventory.GetItemCount(gSpoonItemDef.itemIndex);
if (itemCount > 0)
{
float maxBarrier = characterBody.maxBarrier;
float num = characterBody.healthComponent.barrier / maxBarrier;
float num2 = cdrBonus + cdrPerStack * (float)itemCount;
args.damageMultAdd += damageBonus * num * (float)itemCount;
args.armorAdd += armorBonus * num * (float)itemCount;
args.cooldownMultAdd -= num2 * num;
}
}
}
}
public class Chopsticks : ItemBase<Chopsticks>
{
public static ItemDef chopsticksItemDef;
public float critChanceBonus = 20f;
public float critDamageBonus = 0.3f;
public override string name => ItemBase.prefix + "CHOPSTICKS";
public override ItemTag[] itemTags => (ItemTag[])(object)new ItemTag[2]
{
(ItemTag)1,
(ItemTag)16
};
public override bool canRemove => true;
public override bool hidden => false;
public BuffDef recentBreak { get; private set; }
public override bool dlcRequired => false;
public override string nameToken => ItemBase.prefix + "CHOPSTICKS_NAME";
public override string pickupToken => ItemBase.prefix + "CHOPSTICKS_PICKUP";
public override string descToken => ItemBase.prefix + "CHOPSTICKS_DESC";
public override string loreToken => ItemBase.prefix + "CHOPSTICKS_LORE";
public override string nameDefault => "Sharpened Chopsticks";
public override string pickupDefault => "Boosts Critical Chance and Critical Damage, breaks at low health.";
public override string descDefault => $"Gain +{critChanceBonus}% <style=cIsDamage>Critical Chance</style> <style=cStack>(+{critChanceBonus}% per stack)</style> and {critDamageBonus * 100f}% <style=cIsDamage>Critical Damage</style> <style=cStack>(+{critDamageBonus * 100f}% per stack)</style>. Taking damage to below <style=cIsHealth>25% health</style> <style=cIsUtility>breaks</style> this item.";
public override string loreDefault => "\"So... How would we use this again?\" I asked my partner.\n\n\"Look, I know you think it’s just a pair of chopsticks, but if you turn them this way...\"\n He held the chopsticks between his fingers.\n\"Why would you throw that? It’s not even sharp...\" I replied.\n\n\"Not yet.\" He insisted, while throwing the chopsticks on his backpack\n\n\"Why do I bother to debate...\" I said, as I continued foraging the place.\n\n\"It also looks cool!\" He yelled from the distance.";
public override void Init(ConfigFile config)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
chopsticksItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
chopsticksItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
chopsticksItemDef.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Items/icons/sharp_chopsticks.png");
chopsticksItemDef.pickupModelPrefab = Assets.mainAssetBundle.LoadAsset<GameObject>("Assets/Import/Items/models/chopsticks/Chopsticks.prefab");
HopooShaderToMaterial.Standard.Apply(chopsticksItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial);
SetupLanguageTokens();
SetupHooks();
ItemAPI.Add(new CustomItem(chopsticksItemDef, displayRules));
}
protected override void SetupHooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
HealthComponent.UpdateLastHitTime += new hook_UpdateLastHitTime(HealthComponent_UpdateLastHitTime);
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
}
private void HealthComponent_UpdateLastHitTime(orig_UpdateLastHitTime orig, HealthComponent self, float damageValue, Vector3 damagePosition, bool damageIsSilent, GameObject attacker)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, damageValue, damagePosition, damageIsSilent, attacker);
CharacterBody body = self.body;
if (Object.op_Implicit((Object)(object)body.inventory) && self.alive && self.isHealthLow)
{
int itemCount = body.inventory.GetItemCount(chopsticksItemDef.itemIndex);
if (itemCount > 0)
{
CharacterMasterNotificationQueue.PushItemTransformNotification(body.master, chopsticksItemDef.itemIndex, ItemBase<BrokenChopsticks>.instance.itemDef.itemIndex, (TransformationType)0);
body.inventory.RemoveItem(chopsticksItemDef, itemCount);
body.inventory.GiveItem(ItemBase<BrokenChopsticks>.instance.itemDef, itemCount);
}
}
}
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody characterBody, StatHookEventArgs args)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)characterBody.inventory))
{
int itemCount = characterBody.inventory.GetItemCount(chopsticksItemDef.itemIndex);
if (itemCount > 0)
{
args.critAdd += critChanceBonus * (float)itemCount;
args.critDamageMultAdd += critDamageBonus * (float)itemCount;
}
}
}
}
public class Fork : ItemBase<Fork>
{
public static ItemDef forkItemDef;
public float damageBonus = 3f;
public float damageBonusPerStack = 3f;
public override string name => ItemBase.prefix + "FORK";
public override ItemTag[] itemTags => (ItemTag[])(object)new ItemTag[1] { (ItemTag)1 };
public override bool canRemove => true;
public override bool hidden => false;
public override bool dlcRequired => false;
public override string nameToken => ItemBase.prefix + "FORK_NAME";
public override string pickupToken => ItemBase.prefix + "FORK_PICKUP";
public override string descToken => ItemBase.prefix + "FORK_DESC";
public override string loreToken => ItemBase.prefix + "FORK_LORE";
public override string nameDefault => "Fork";
public override string pickupDefault => "Do more damage.";
public override string descDefault => $"Gain +{damageBonus} <style=cIsDamage>Base Damage</style> <style=cStack>(+{damageBonusPerStack} per stack)</style>.";
public override string loreDefault => "\"You can't be serious... Look, I know we said we need everything we can get to survive, but you have to realize I wasn't literal about it!\"\n\nHe held up the silver instrument, a questioning look on his face. \"What do you mean? What if we need to fight off a monster?\"\n\nA brief silence.\n\n\"Please, we've both seen the creatures on this planet. Don't tell me you think that'd be enough to fight off anything here.\"\n\nHe shrugged. \"You never know\", he replied, as he slid the fork into his pocket.\n";
public override void Init(ConfigFile config)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
forkItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
forkItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
forkItemDef.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Items/icons/fork.png");
forkItemDef.pickupModelPrefab = Assets.mainAssetBundle.LoadAsset<GameObject>("Assets/Import/Items/models/fork/Fork.prefab");
HopooShaderToMaterial.Standard.Apply(forkItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial);
HopooShaderToMaterial.Standard.Gloss(forkItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial, 0.1f, 10f, Color.white);
SetupLanguageTokens();
SetupHooks();
ItemAPI.Add(new CustomItem(forkItemDef, displayRules));
}
protected override void SetupHooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
}
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody characterBody, StatHookEventArgs args)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)characterBody.inventory))
{
int itemCount = characterBody.inventory.GetItemCount(forkItemDef.itemIndex);
if (itemCount > 0)
{
args.baseDamageAdd += damageBonus + damageBonusPerStack * (float)itemCount;
}
}
}
}
public abstract class ItemBase<T> : ItemBase where T : ItemBase<T>
{
public static T instance { get; private set; }
public ItemBase()
{
if (instance != null)
{
throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting ItemBase was instantiated twice");
}
instance = this as T;
}
}
public abstract class ItemBase
{
public static string prefix = "HCFB_ITEM_";
public ItemDisplayRuleDict displayRules;
public ConfigEntry<bool> enabled;
public ConfigEntry<bool> aiBlacklist;
public ItemDef itemDef;
public static List<ItemBase> items = new List<ItemBase>();
public virtual bool forceEnable { get; }
public abstract string name { get; }
public abstract ItemTag[] itemTags { get; }
public abstract bool canRemove { get; }
public abstract bool hidden { get; }
public virtual bool AIBlacklisted { get; set; }
public abstract bool dlcRequired { get; }
public abstract string nameToken { get; }
public abstract string pickupToken { get; }
public abstract string descToken { get; }
public abstract string loreToken { get; }
public abstract string nameDefault { get; }
public abstract string pickupDefault { get; }
public abstract string descDefault { get; }
public abstract string loreDefault { get; }
public abstract void Init(ConfigFile config);
protected virtual void SetupLanguageTokens()
{
LanguageAPI.Add(nameToken, nameDefault);
LanguageAPI.Add(pickupToken, pickupDefault);
LanguageAPI.Add(descToken, descDefault);
LanguageAPI.Add(loreToken, loreDefault);
}
protected virtual ItemDef InitializeItemDef()
{
itemDef = ScriptableObject.CreateInstance<ItemDef>();
((Object)itemDef).name = name;
itemDef.nameToken = nameToken;
itemDef.pickupToken = pickupToken;
itemDef.descriptionToken = descToken;
itemDef.loreToken = loreToken;
itemDef.tags = itemTags;
itemDef.canRemove = canRemove;
itemDef.hidden = hidden;
itemDef.pickupIconSprite = Resources.Load<Sprite>("Textures/MiscIcons/texMysteryIcon");
itemDef.pickupModelPrefab = Resources.Load<GameObject>("Prefabs/PickupModels/PickupMystery");
return itemDef;
}
protected virtual void SetupHooks()
{
}
}
public class Knife : ItemBase<Knife>
{
public static ItemDef knifeItemDef;
protected float critChanceBonus = 5f;
protected float critDamageBonus = 0.05f;
public override string name => ItemBase.prefix + "KNIFE";
public override ItemTag[] itemTags => (ItemTag[])(object)new ItemTag[1] { (ItemTag)1 };
public override bool canRemove => true;
public override bool hidden => false;
public override bool dlcRequired => false;
public override string nameToken => ItemBase.prefix + "KNIFE_NAME";
public override string pickupToken => ItemBase.prefix + "KNIFE_PICKUP";
public override string descToken => ItemBase.prefix + "KNIFE_DESC";
public override string loreToken => ItemBase.prefix + "KNIFE_LORE";
public override string nameDefault => "Knife";
public override string pickupDefault => "Slightly boosts Critical Damage and Critical Chance.";
public override string descDefault => $"Gain {critDamageBonus * 100f}% <style=cIsDamage>Critical Damage</style> <style=cStack>(+{critDamageBonus * 100f}% per stack)</style> and {critChanceBonus}% <style=cIsDamage>Critical Chance</style> <style=cStack>(+{critChanceBonus}% per stack)</style>.";
public override string loreDefault => "I was being attacked, dissarmed, we were both at our physical limits. I looked for the closest thing to me, a kitchen knife was laying on the floor...\n\n\"Hmph, who would've imagined that I would use cutlery in a situation like this.\"\n I thought as I slowly crawled to grab it.\nThe attacker was relentless, he wanted to see my face while he stealed my last breath, in a flash, I stabbed him, right through his heart.\n\nHe collapsed to the ground as he looked me dead in the eyes. I knew the face, but not the being...\n\n\"That's what you get, you sneaky bastard, you took one precious life already, so I took yours.\" I exclaimed, exhausted.\n\nHe was done for. A small little creature crawled from the dead body and escaped, really fast.\n\n\"How long it will take...\" I thought, as I sitted on the ground.\n\n\"I knew we wouldn't...\" I passed out.";
public override void Init(ConfigFile config)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
knifeItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
knifeItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
knifeItemDef.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Items/icons/knife.png");
knifeItemDef.pickupModelPrefab = Assets.mainAssetBundle.LoadAsset<GameObject>("Assets/Import/Items/models/knife/Knife.prefab");
HopooShaderToMaterial.Standard.Apply(knifeItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial);
HopooShaderToMaterial.Standard.Gloss(knifeItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial, 0.05f, 10f, Color.white);
SetupLanguageTokens();
SetupHooks();
ItemAPI.Add(new CustomItem(knifeItemDef, displayRules));
}
protected override void SetupHooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
}
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody characterBody, StatHookEventArgs args)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)characterBody.inventory))
{
int itemCount = characterBody.inventory.GetItemCount(knifeItemDef.itemIndex);
if (itemCount > 0)
{
args.critAdd += critChanceBonus * (float)itemCount;
args.critDamageMultAdd += critDamageBonus * (float)itemCount;
}
}
}
}
public class MoltenFork : ItemBase<MoltenFork>
{
public static ItemDef gForkItemDef;
protected float damageBonus = 2f;
protected float igniteChance = 5f;
public override string name => ItemBase.prefix + "MOLTEN_FORK";
public override ItemTag[] itemTags => (ItemTag[])(object)new ItemTag[1] { (ItemTag)1 };
public override bool canRemove => true;
public override bool hidden => false;
public override bool dlcRequired => false;
public override string nameToken => ItemBase.prefix + "MOLTEN_FORK_NAME";
public override string pickupToken => ItemBase.prefix + "MOLTEN_FORK_PICKUP";
public override string descToken => ItemBase.prefix + "MOLTEN_FORK_DESC";
public override string loreToken => ItemBase.prefix + "MOLTEN_FORK_LORE";
public override string nameDefault => "Molten Fork";
public override string pickupDefault => "Boosts damage against ignited enemies, chance to ignite on hit.";
public override string descDefault => $"Multiply your <style=cIsDamage>Damage</style> by {damageBonus} <style=cStack>(+1 to multiplier per stack)</style> against <style=cIsDamage>Ignited</style> enemies, {igniteChance}% of <style=cIsDamage>Igniting</style> enemies <style=cIsDamage>on hit</style>.";
public override string loreDefault => "\"I present to you an ancient relic of the gods!\" I saw my partner as he held a shiny little thing on his hand\n\n\"That just looks like a regular fork with a rare color\". I said as I tried to manipulate the object.\n\n\"It feels really warm though, maybe we could use it as a heat source.\" I added, the instrument slipped from my hand, landing on the floor and creating a bright spark of fire.\n\"THAT IS COOL AS HECK! We should keep it!\" He exclaimed full of excitement.\n\n\"How did that even work? Is it reactive to friction?\" I wondered.\n\"I don’t know man, but if we don’t take this incredible device someone else will do it.\" He added, as he tried to recover the instrument from the floor.\n\n\"Alright, just make sure you don’t end up on fire.\" I told him, as I chuckled a little\n\n\"Deal.\" He replied.";
public override void Init(ConfigFile config)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
gForkItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
gForkItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
gForkItemDef.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Items/icons/molt_fork.png");
gForkItemDef.pickupModelPrefab = Assets.mainAssetBundle.LoadAsset<GameObject>("Assets/Import/Items/models/molt_fork/MoltFork.prefab");
SetupLanguageTokens();
SetupHooks();
ItemAPI.Add(new CustomItem(gForkItemDef, displayRules));
}
protected override void SetupHooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage);
GlobalEventManager.OnHitEnemy += new hook_OnHitEnemy(GlobalEventManager_OnHitEnemy);
}
private void GlobalEventManager_OnHitEnemy(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)damageInfo.attacker))
{
orig.Invoke(self, damageInfo, victim);
return;
}
CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory) && component.inventory.GetItemCount(gForkItemDef) > 0 && Util.CheckRoll(igniteChance, component.master))
{
InflictDotInfo val = default(InflictDotInfo);
val.attackerObject = damageInfo.attacker;
val.victimObject = victim;
val.totalDamage = damageInfo.damage;
val.damageMultiplier = 1f;
val.dotIndex = (DotIndex)1;
InflictDotInfo val2 = val;
StrengthenBurnUtils.CheckDotForUpgrade(component.inventory, ref val2);
DotController.InflictDot(ref val2);
}
orig.Invoke(self, damageInfo, victim);
}
private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)damageInfo.attacker))
{
orig.Invoke(self, damageInfo);
return;
}
CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
if ((Object)(object)component != (Object)null && Object.op_Implicit((Object)(object)component.inventory))
{
int itemCount = component.inventory.GetItemCount(gForkItemDef);
if (itemCount > 0)
{
CharacterBody body = self.body;
BuffDef val = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/Common/bdOnFire.asset").WaitForCompletion();
BuffDef val2 = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/DLC1/StrengthenBurn/bdStrongerBurn.asset").WaitForCompletion();
if (body.HasBuff(val) || body.HasBuff(val2))
{
damageInfo.damage *= damageBonus * (float)itemCount;
}
}
}
orig.Invoke(self, damageInfo);
}
}
public class ObsidianKnife : ItemBase<ObsidianKnife>
{
public static ItemDef gKnifeItemDef;
protected float critDamageBonus = 0.5f;
protected float hemoDotChance = 10f;
public override string name => ItemBase.prefix + "OBSIDIAN_KNIFE";
public override ItemTag[] itemTags => (ItemTag[])(object)new ItemTag[1] { (ItemTag)1 };
public override bool canRemove => true;
public override bool hidden => false;
public override bool dlcRequired => false;
public override string nameToken => ItemBase.prefix + "OBSIDIAN_KNIFE_NAME";
public override string pickupToken => ItemBase.prefix + "OBSIDIAN_KNIFE_PICKUP";
public override string descToken => ItemBase.prefix + "OBSIDIAN_KNIFE_DESC";
public override string loreToken => ItemBase.prefix + "OBSIDIAN_KNIFE_LORE";
public override string nameDefault => "Obsidian Knife";
public override string pickupDefault => "Increases critical damage, critical hits have a chance to apply hemorrhage.";
public override string descDefault => $"Gain {critDamageBonus * 100f}% <style=cIsDamage>Critical Damage</style> <style=cStack>(+{critDamageBonus * 100f}% per stack)</style>, <style=cIsDamage>Critical Strikes</style> have a {hemoDotChance}% chance <style=cStack>(+{hemoDotChance}% per stack)</style> to apply <style=cDeath>Hemorrhage</style>.";
public override string loreDefault => "\"Here it is, your excellence, the sharpest tool of this world.\"\n\n\"A knife, forged in the hardest material, capable of cutting flesh like air.\"\n\n\"I present this to you, as my gift, as a way to honor you.\"\n\n“Perfect. Bring the offerings, we shall celebrate this gift in her name.”\n\n\"As you wish my lord.\"";
public override void Init(ConfigFile config)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Expected O, but got Unknown
gKnifeItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
gKnifeItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
gKnifeItemDef.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Items/icons/obs_knife.png");
gKnifeItemDef.pickupModelPrefab = Assets.mainAssetBundle.LoadAsset<GameObject>("Assets/Import/Items/models/obs_knife/ObsKnife.prefab");
HopooShaderToMaterial.Standard.Apply(gKnifeItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial);
HopooShaderToMaterial.Standard.Emission(gKnifeItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial, 0.001f, Color.white);
HopooShaderToMaterial.Standard.Gloss(gKnifeItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial, 0.2f, 5f, Color.white);
SetupLanguageTokens();
SetupHooks();
ItemAPI.Add(new CustomItem(gKnifeItemDef, displayRules));
}
protected override void SetupHooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
GlobalEventManager.OnHitEnemy += new hook_OnHitEnemy(GlobalEventManager_OnHitEnemy);
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
}
private void GlobalEventManager_OnHitEnemy(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)damageInfo.attacker))
{
orig.Invoke(self, damageInfo, victim);
return;
}
CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
if ((Object)(object)component != (Object)null && Object.op_Implicit((Object)(object)component.inventory) && damageInfo.crit)
{
int itemCount = component.inventory.GetItemCount(gKnifeItemDef.itemIndex);
if (itemCount > 0 && Util.CheckRoll(hemoDotChance * (float)itemCount, component.master))
{
damageInfo.damageType = (DamageType)134217728;
}
}
orig.Invoke(self, damageInfo, victim);
}
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody characterBody, StatHookEventArgs args)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)characterBody.inventory))
{
int itemCount = characterBody.inventory.GetItemCount(gKnifeItemDef.itemIndex);
if (itemCount > 0)
{
args.critDamageMultAdd += critDamageBonus * (float)itemCount;
}
}
}
}
public class Spoon : ItemBase<Spoon>
{
public static ItemDef spoonItemDef;
public float constantDamageBonus = 2f;
public float damageBonusPerKill = 0.02f;
public float damageBonusCap = 1f;
public override string name => ItemBase.prefix + "SPOON";
public override ItemTag[] itemTags => (ItemTag[])(object)new ItemTag[2]
{
(ItemTag)1,
(ItemTag)6
};
public override bool canRemove => true;
public override bool hidden => false;
public override bool dlcRequired => false;
public BuffDef stackBuff { get; set; }
public override string nameToken => ItemBase.prefix + "SPOON_NAME";
public override string pickupToken => ItemBase.prefix + "SPOON_PICKUP";
public override string descToken => ItemBase.prefix + "SPOON_DESC";
public override string loreToken => ItemBase.prefix + "SPOON_LORE";
public override string nameDefault => "Spoon";
public override string pickupDefault => "Do more damage, stack more damage each time you kill an enemy.";
public override string descDefault => $"Gain +{constantDamageBonus} base damage <style=cStack>(does not scale in any way)</style> and +{damageBonusPerKill} base damage <style=cStack>(scales 25% with player level)</style> each time you <style=cIsDamage>kill an enemy</style> with a max cap of {damageBonusCap} <style=cStack>(+{damageBonusCap} per stack)</style>.";
public override string loreDefault => "\"Well, if you said that could be useful, why can't I try with this?\" I exclaimed.\n\n...\n\n\"After all... What if we need to dig a hole as a shelter? Or pop some monster eyes out?\" I insisted.\n\n\"Dig a hole with a spoon...?\" He said in disbelief.\n\n\"Yeah.\"\n\n...\n\n\"We are gonna die, aren't we?\" I said, breaking his silence.\n\n\"Probably...\"";
public override void Init(ConfigFile config)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
spoonItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
spoonItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
spoonItemDef.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Items/icons/spoon.png");
spoonItemDef.pickupModelPrefab = Assets.mainAssetBundle.LoadAsset<GameObject>("Assets/Import/Items/models/spoon/Spoon.prefab");
HopooShaderToMaterial.Standard.Apply(spoonItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial);
HopooShaderToMaterial.Standard.Gloss(spoonItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial, 0.1f, 10f, Color.white);
CreateBuff();
SetupLanguageTokens();
SetupHooks();
ItemAPI.Add(new CustomItem(spoonItemDef, displayRules));
}
protected override void SetupHooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
GlobalEventManager.OnCharacterDeath += new hook_OnCharacterDeath(GlobalEventManager_OnCharacterDeath);
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
CharacterBody.onBodyStartGlobal += CharacterBody_onBodyStartGlobal;
}
private void GlobalEventManager_OnCharacterDeath(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport report)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)report.attacker) || !Object.op_Implicit((Object)(object)report.attackerBody))
{
return;
}
CharacterBody attackerBody = report.attackerBody;
if (Object.op_Implicit((Object)(object)attackerBody.inventory))
{
int itemCount = attackerBody.inventory.GetItemCount(spoonItemDef.itemIndex);
if (itemCount > 0)
{
int itemCount2 = attackerBody.inventory.GetItemCount(SpoonStack.spoonStackItemDef.itemIndex);
float num = damageBonusCap / damageBonusPerKill * (float)itemCount;
if ((float)itemCount2 < num)
{
attackerBody.inventory.GiveItem(SpoonStack.spoonStackItemDef, 1);
attackerBody.AddBuff(stackBuff);
}
}
}
orig.Invoke(self, report);
}
private void CharacterBody_onBodyStartGlobal(CharacterBody characterBody)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)characterBody.inventory) || characterBody.inventory.GetItemCount(spoonItemDef.itemIndex) <= 0)
{
return;
}
int itemCount = characterBody.inventory.GetItemCount(SpoonStack.spoonStackItemDef.itemIndex);
if (itemCount > 0)
{
for (int i = 0; i < itemCount; i++)
{
characterBody.AddBuff(stackBuff);
}
}
}
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody characterBody, StatHookEventArgs args)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)characterBody.inventory) || !characterBody.isPlayerControlled)
{
return;
}
if (characterBody.inventory.GetItemCount(spoonItemDef.itemIndex) > 0)
{
args.baseDamageAdd += constantDamageBonus;
return;
}
int itemCount = characterBody.inventory.GetItemCount(SpoonStack.spoonStackItemDef);
if (characterBody.GetBuffCount(stackBuff) > 0)
{
for (int i = 0; i < characterBody.GetBuffCount(stackBuff); i++)
{
characterBody.RemoveBuff(stackBuff);
}
characterBody.inventory.RemoveItem(SpoonStack.spoonStackItemDef, itemCount);
}
}
private void CreateBuff()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
stackBuff = ScriptableObject.CreateInstance<BuffDef>();
((Object)stackBuff).name = ItemBase.prefix + "SPOON_STACK_BUFF";
stackBuff.buffColor = Color.white;
stackBuff.canStack = true;
stackBuff.isDebuff = false;
stackBuff.eliteDef = null;
stackBuff.iconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Buffs/spoonStack.png");
ContentAddition.AddBuffDef(stackBuff);
}
}
public class SpoonStack : ItemBase<SpoonStack>
{
public static ItemDef spoonStackItemDef;
public float damageBonusPerKill = 0.02f;
public float levelScalingF = 0.25f;
public override bool forceEnable => true;
public override string name => ItemBase.prefix + "SPOON_STACK";
public override ItemTag[] itemTags => (ItemTag[])(object)new ItemTag[2]
{
(ItemTag)1,
(ItemTag)13
};
public override bool canRemove => false;
public override bool hidden => true;
public override bool dlcRequired => false;
public override string nameToken => ItemBase.prefix + "SPOON_STACK_NAME";
public override string pickupToken => ItemBase.prefix + "SPOON_STACK_PICKUP";
public override string descToken => ItemBase.prefix + "SPOON_STACK_DESC";
public override string loreToken => ItemBase.prefix + "SPOON_STACK_LORE";
public override string nameDefault => "Spoon Stack";
public override string pickupDefault => "What are you doing with this?";
public override string descDefault => "";
public override string loreDefault => "";
public override void Init(ConfigFile config)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
spoonStackItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
spoonStackItemDef.deprecatedTier = (ItemTier)5;
SetupLanguageTokens();
SetupHooks();
ItemAPI.Add(new CustomItem(spoonStackItemDef, displayRules));
}
protected override void SetupHooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
}
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody characterBody, StatHookEventArgs args)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)characterBody.inventory))
{
int itemCount = characterBody.inventory.GetItemCount(spoonStackItemDef.itemIndex);
if (itemCount > 0)
{
args.baseDamageAdd += damageBonusPerKill * (float)itemCount * (1f + levelScalingF * characterBody.level);
}
}
}
}
public class Spork : ItemBase<Spork>
{
public static ItemDef sporkItemDef;
public float cooldownBonusPerKill = 0.001f;
public float maxStacks = 50f;
public float cooldownBonusCap;
public override string name => ItemBase.prefix + "SPORK";
public override ItemTag[] itemTags
{
get
{
ItemTag[] array = new ItemTag[4];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
return (ItemTag[])(object)array;
}
}
public override bool canRemove => false;
public override bool hidden => false;
public override bool dlcRequired => true;
public BuffDef stackBuff { get; private set; }
public override string nameToken => ItemBase.prefix + "SPORK_NAME";
public override string pickupToken => ItemBase.prefix + "SPORK_PICKUP";
public override string descToken => ItemBase.prefix + "SPORK_DESC";
public override string loreToken => ItemBase.prefix + "SPORK_LORE";
public override string nameDefault => "Spork";
public override string pickupDefault => "Gain cooldown reduction per kill, resets every stage or if you die. <style=cIsVoid>Corrupts all Spoons</style>";
public override string descDefault => $"Gain +{cooldownBonusPerKill * 100f}% <style=cIsUtility>Cooldown Reduction</style> <style=cStack>(+{cooldownBonusPerKill * 100f}% per stack)</style> each time you <style=cIsDamage>kill an enemy</style> with a max cap of {cooldownBonusCap * 100f}% <style=cStack>(+{cooldownBonusCap * 100f}% per stack)</style>, caps at {maxStacks} stacks, resets every <style=cEvent>Stage</style> or if you <style=cDeath>Die</style>. <style=cIsVoid>Corrupts all Spoons</style>";
public override string loreDefault => "\"Oh wow this one looks freaky\" He said.\n\n\"What is that? Don’t touch it!\" I shouted from the distance.\n\n\"Too late...\" He told me as I saw him holding an strange object with a purple shine.\n\n\"Hm, it did nothing.\" He added\n\n\"You sure? What if it is radioactive or some stuff?\"\n\n\"You're overthinking it.\" He said, as he packed the mysterious object in his bag.\n\nA sudden chill went right down my spine as we continued our journey...";
public override void Init(ConfigFile config)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
cooldownBonusCap = maxStacks * cooldownBonusPerKill;
sporkItemDef = InitializeItemDef();
displayRules = new ItemDisplayRuleDict((ItemDisplayRule[])null);
sporkItemDef.deprecatedTier = (ItemTier)6;
sporkItemDef.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Items/icons/spork.png");
sporkItemDef.pickupModelPrefab = Assets.mainAssetBundle.LoadAsset<GameObject>("Assets/Import/Items/models/spork/Spork.prefab");
HopooShaderToMaterial.Standard.Apply(sporkItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial);
HopooShaderToMaterial.Standard.Gloss(sporkItemDef.pickupModelPrefab.GetComponentInChildren<Renderer>().sharedMaterial, 0.2f, 5f, Color.white);
CreateBuff();
SetupLanguageTokens();
SetupHooks();
ItemAPI.Add(new CustomItem(sporkItemDef, displayRules));
VoidTransformation.CreateTransformation(sporkItemDef, ItemBase<Spoon>.instance.itemDef);
}
public void CreateBuff()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
stackBuff = ScriptableObject.CreateInstance<BuffDef>();
stackBuff.buffColor = Color.magenta;
stackBuff.canStack = true;
stackBuff.isDebuff = false;
stackBuff.isHidden = false;
((Object)stackBuff).name = ItemBase.prefix + "SPORK_STACK_BUFF";
stackBuff.iconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("Assets/Import/Buffs/sporkStack.png");
ContentAddition.AddBuffDef(stackBuff);
}
protected override void SetupHooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
GlobalEventManager.OnCharacterDeath += new hook_OnCharacterDeath(GlobalEventManager_OnCharacterDeath);
RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
}
private void GlobalEventManager_OnCharacterDeath(orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport report)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)report.attacker) && Object.op_Implicit((Object)(object)report.attackerBody))
{
CharacterBody attackerBody = report.attackerBody;
if (Object.op_Implicit((Object)(object)attackerBody.inventory) && attackerBody.inventory.GetItemCount(sporkItemDef.itemIndex) > 0 && (float)attackerBody.GetBuffCount(stackBuff) < maxStacks)
{
attackerBody.AddBuff(stackBuff);
}
orig.Invoke(self, report);
}
}
private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody characterBody, StatHookEventArgs args)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)characterBody.inventory) || !characterBody.isPlayerControlled)
{
return;
}
int itemCount = characterBody.inventory.GetItemCount(sporkItemDef.itemIndex);
int buffCount = characterBody.GetBuffCount(stackBuff);
if (itemCount > 0)
{
args.cooldownMultAdd -= cooldownBonusPerKill * (float)buffCount * (float)itemCount;
return;
}
int buffCount2 = characterBody.GetBuffCount(stackBuff);
if (buffCount2 > 0)
{
for (int i = 0; i < buffCount2; i++)
{
characterBody.RemoveBuff(stackBuff);
}
}
}
}
}