using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using Jewelcrafting;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WarheimStuff")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WarheimStuff")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace WarheimStuff;
[HarmonyPatch(typeof(Skills), "Awake")]
[HarmonyAfter(new string[] { "org.bepinex.plugins.professions" })]
public static class ProfessionsKeepLevelsPatch
{
private static readonly HashSet<int> PatchedButtons = new HashSet<int>();
private static Type _professionsType;
private static Type _helperType;
private static Type _skillElementType;
private static FieldInfo _professionPanelElementsField;
private static FieldInfo _allowUnselectField;
private static FieldInfo _professionChangeCooldownField;
private static FieldInfo _serverTimeField;
private static MethodInfo _updateSelectPanelSelectionsMethod;
private static MethodInfo _fromProfessionMethod;
private static MethodInfo _getActiveProfessionsMethod;
private static MethodInfo _storeActiveProfessionsMethod;
private static MethodInfo _getInactiveProfessionsMethod;
private static MethodInfo _storeInactiveProfessionsMethod;
private static MethodInfo _getHumanFriendlyTimeMethod;
private static bool _reflectionReady;
private static void Postfix()
{
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Expected O, but got Unknown
try
{
if (!PrepareReflection() || !(_professionPanelElementsField?.GetValue(null) is IDictionary dictionary) || dictionary.Count == 0)
{
return;
}
foreach (DictionaryEntry item in dictionary)
{
object professionObj = item.Key;
object? value = item.Value;
GameObject val = (GameObject)((value is GameObject) ? value : null);
if ((Object)(object)val == (Object)null)
{
continue;
}
Component component = val.GetComponent(_skillElementType);
if ((Object)(object)component == (Object)null)
{
continue;
}
object? obj = AccessTools.Field(_skillElementType, "Select")?.GetValue(component);
Button val2 = (Button)((obj is Button) ? obj : null);
if (!((Object)(object)val2 == (Object)null) && PatchedButtons.Add(((Object)val2).GetInstanceID()))
{
((UnityEventBase)val2.onClick).RemoveAllListeners();
((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
{
OnProfessionButtonClicked(professionObj);
});
}
}
}
catch (Exception arg)
{
Debug.LogError((object)$"[WarheimStuff] Failed to rewire Professions buttons: {arg}");
}
}
private static bool PrepareReflection()
{
if (_reflectionReady)
{
return true;
}
_professionsType = AccessTools.TypeByName("Professions.Professions");
_helperType = AccessTools.TypeByName("Professions.Helper");
_skillElementType = AccessTools.TypeByName("Skill_Element");
if (_professionsType == null || _helperType == null || _skillElementType == null)
{
return false;
}
_professionPanelElementsField = AccessTools.Field(_professionsType, "professionPanelElements");
_allowUnselectField = AccessTools.Field(_professionsType, "allowUnselect");
_professionChangeCooldownField = AccessTools.Field(_professionsType, "professionChangeCooldown");
_serverTimeField = AccessTools.Field(_professionsType, "serverTime");
_updateSelectPanelSelectionsMethod = AccessTools.Method(_professionsType, "UpdateSelectPanelSelections", (Type[])null, (Type[])null);
_fromProfessionMethod = AccessTools.Method(_professionsType, "fromProfession", (Type[])null, (Type[])null);
_getActiveProfessionsMethod = AccessTools.Method(_helperType, "getActiveProfessions", (Type[])null, (Type[])null);
_storeActiveProfessionsMethod = AccessTools.Method(_helperType, "storeActiveProfessions", (Type[])null, (Type[])null);
_getInactiveProfessionsMethod = AccessTools.Method(_helperType, "getInactiveProfessions", (Type[])null, (Type[])null);
_storeInactiveProfessionsMethod = AccessTools.Method(_helperType, "storeInactiveProfessions", (Type[])null, (Type[])null);
_getHumanFriendlyTimeMethod = AccessTools.Method(_helperType, "getHumanFriendlyTime", (Type[])null, (Type[])null);
_reflectionReady = _professionPanelElementsField != null && _allowUnselectField != null && _professionChangeCooldownField != null && _serverTimeField != null && _updateSelectPanelSelectionsMethod != null && _fromProfessionMethod != null && _getActiveProfessionsMethod != null && _storeActiveProfessionsMethod != null && _getInactiveProfessionsMethod != null && _storeInactiveProfessionsMethod != null && _getHumanFriendlyTimeMethod != null;
return _reflectionReady;
}
private static void OnProfessionButtonClicked(object professionObj)
{
try
{
if (!PrepareReflection() || (Object)(object)Player.m_localPlayer == (Object)null)
{
return;
}
object obj = _getActiveProfessionsMethod.Invoke(null, null);
if (obj == null)
{
return;
}
Type type = obj.GetType();
MethodInfo method = type.GetMethod("Contains");
MethodInfo method2 = type.GetMethod("Add");
MethodInfo method3 = type.GetMethod("Remove");
if (method != null && (bool)method.Invoke(obj, new object[1] { professionObj }))
{
if (!CanUnselectNow())
{
return;
}
method3?.Invoke(obj, new object[1] { professionObj });
_storeActiveProfessionsMethod.Invoke(null, new object[1] { obj });
Player.m_localPlayer.m_customData["Professions LastProfessionChange"] = GetServerUnixTime().ToString();
}
else
{
RestoreOldInactiveLevelIfNeeded(professionObj);
method2?.Invoke(obj, new object[1] { professionObj });
_storeActiveProfessionsMethod.Invoke(null, new object[1] { obj });
}
_updateSelectPanelSelectionsMethod.Invoke(null, null);
}
catch (Exception arg)
{
Debug.LogError((object)$"[WarheimStuff] Error in profession click override: {arg}");
}
}
private static bool CanUnselectNow()
{
object value = _allowUnselectField.GetValue(null);
object value2 = _professionChangeCooldownField.GetValue(null);
object obj = value?.GetType().GetProperty("Value")?.GetValue(value);
object obj2 = value2?.GetType().GetProperty("Value")?.GetValue(value2);
bool flag = string.Equals(obj?.ToString(), "On", StringComparison.OrdinalIgnoreCase);
float num = ((obj2 != null) ? Convert.ToSingle(obj2) : 0f);
if (!flag)
{
return false;
}
if (num <= 0f)
{
return true;
}
if (!Player.m_localPlayer.m_customData.TryGetValue("Professions LastProfessionChange", out var value3))
{
return true;
}
if (!int.TryParse(value3, out var result))
{
return true;
}
int serverUnixTime = GetServerUnixTime();
int num2 = result + (int)(num * 3600f) - serverUnixTime;
if (num2 > 0)
{
string text = (string)_getHumanFriendlyTimeMethod.Invoke(null, new object[1] { num2 });
((Character)Player.m_localPlayer).Message((MessageType)2, "You can change your profession in " + text + ".", 0, (Sprite)null);
return false;
}
return true;
}
private static int GetServerUnixTime()
{
DateTime dateTime = (DateTime)_serverTimeField.GetValue(null);
return (int)((DateTimeOffset)dateTime).ToUnixTimeSeconds();
}
private static Skill GetOrCreateSkill(Player player, SkillType skillType)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)player == (Object)null)
{
return null;
}
object value = Traverse.Create((object)player).Field("m_skills").GetValue();
if (value == null)
{
return null;
}
object value2 = Traverse.Create(value).Method("GetSkill", new object[1] { skillType }).GetValue();
return (Skill)((value2 is Skill) ? value2 : null);
}
private static void RestoreOldInactiveLevelIfNeeded(object professionObj)
{
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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)
try
{
object obj = _getInactiveProfessionsMethod.Invoke(null, null);
if (!(obj is IDictionary dictionary) || !dictionary.Contains(professionObj))
{
return;
}
float num = 0f;
object obj2 = dictionary[professionObj];
if (obj2 != null)
{
num = Convert.ToSingle(obj2);
}
if (num <= 0f)
{
return;
}
object obj3 = _fromProfessionMethod.Invoke(null, new object[1] { professionObj });
if (obj3 != null)
{
SkillType skillType = (SkillType)obj3;
Skill orCreateSkill = GetOrCreateSkill(Player.m_localPlayer, skillType);
if (orCreateSkill != null)
{
orCreateSkill.m_level = Mathf.Max(orCreateSkill.m_level, num);
}
dictionary.Remove(professionObj);
_storeInactiveProfessionsMethod.Invoke(null, new object[1] { obj });
}
}
catch (Exception arg)
{
Debug.LogWarning((object)$"[WarheimStuff] Failed to restore old inactive profession level: {arg}");
}
}
}
[BepInPlugin("dzk.warheimstuff", "WarheimStuff", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class WarheimStuff : BaseUnityPlugin
{
private enum WarheimRingType
{
DPS,
Tank,
Archer,
Mage
}
public class SE_WarheimRingDPS : StatusEffect
{
public float m_staminaRegenMultiplier = 1f;
public float m_damageMultiplier = 1f;
public void SetStaminaRegenMultiplier(float value)
{
m_staminaRegenMultiplier = value;
}
public void SetDamageMultiplier(float value)
{
m_damageMultiplier = value;
}
public override void ModifyStaminaRegen(ref float staminaRegen)
{
staminaRegen *= m_staminaRegenMultiplier;
}
public override void ModifyAttack(SkillType skill, ref HitData hitData)
{
((DamageTypes)(ref hitData.m_damage)).Modify(m_damageMultiplier);
}
}
public class SE_WarheimRingTank : StatusEffect
{
public float m_healthPercentBonus;
public float m_healthRegenMultiplier = 1f;
public void SetHealthPercentBonus(float value)
{
m_healthPercentBonus = value;
}
public void SetHealthRegenMultiplier(float value)
{
m_healthRegenMultiplier = value;
}
public override void ModifyHealthRegen(ref float regenMultiplier)
{
regenMultiplier *= m_healthRegenMultiplier;
}
}
public class SE_WarheimRingArcher : StatusEffect
{
public float m_staminaPercentBonus;
public float m_moveSpeedMultiplier = 1f;
public void SetStaminaPercentBonus(float value)
{
m_staminaPercentBonus = value;
}
public void SetMoveSpeedMultiplier(float value)
{
m_moveSpeedMultiplier = value;
}
public override void ModifySpeed(float baseSpeed, ref float speed, Character character, Vector3 dir)
{
speed *= m_moveSpeedMultiplier;
}
}
public class SE_WarheimRingMage : StatusEffect
{
public float m_eitrPercentBonus;
public float m_eitrRegenMultiplier = 1f;
public void SetEitrPercentBonus(float value)
{
m_eitrPercentBonus = value;
}
public void SetEitrRegenMultiplier(float value)
{
m_eitrRegenMultiplier = value;
}
public override void ModifyEitrRegen(ref float regen)
{
regen *= m_eitrRegenMultiplier;
}
}
public class SE_CollierWarheimDPS : StatusEffect
{
public float m_damageMultiplier = 1f;
public float m_staminaRegenMultiplier = 1f;
public void SetDamageMultiplier(float value)
{
m_damageMultiplier = value;
}
public void SetStaminaRegenMultiplier(float value)
{
m_staminaRegenMultiplier = value;
}
public override void ModifyAttack(SkillType skill, ref HitData hitData)
{
((DamageTypes)(ref hitData.m_damage)).Modify(m_damageMultiplier);
}
public override void ModifyStaminaRegen(ref float staminaRegen)
{
staminaRegen *= m_staminaRegenMultiplier;
}
}
public class SE_CollierWarheimMage : StatusEffect
{
public float m_eitr;
public float m_skillup;
public float m_regenModifier;
public void SetEitr(float eitr)
{
m_eitr = eitr;
}
public void SetSkill(float skill)
{
m_skillup = skill;
}
public void SetRegenModifier(float regenModifier)
{
m_regenModifier = regenModifier;
}
public override void ModifyEitrRegen(ref float regen)
{
regen *= m_regenModifier;
}
public override void ModifySkillLevel(SkillType skill, ref float value)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Invalid comparison between Unknown and I4
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
if ((int)skill == 10 || (int)skill == 9)
{
value += m_skillup;
}
}
}
public class SE_CollierWarheimTank : StatusEffect
{
public float m_healthPercentBonus;
public float m_healthRegenMultiplier = 1f;
public void SetHealthPercentBonus(float value)
{
m_healthPercentBonus = value;
}
public void SetHealthRegenMultiplier(float value)
{
m_healthRegenMultiplier = value;
}
public override void ModifyHealthRegen(ref float regenMultiplier)
{
regenMultiplier *= m_healthRegenMultiplier;
}
}
[HarmonyPatch]
public static class Patch_IsNeckItem
{
private static MethodBase TargetMethod()
{
if (!Chainloader.PluginInfos.TryGetValue("org.bepinex.plugins.jewelcrafting", out var value))
{
return null;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
Type type = assembly.GetType("Jewelcrafting.Visual");
if (type == null)
{
return null;
}
return AccessTools.Method(type, "IsNeckItem", (Type[])null, (Type[])null);
}
private static void Postfix(ItemData item, ref bool __result)
{
if ((Object)(object)item?.m_dropPrefab != (Object)null && ((Object)item.m_dropPrefab).name.StartsWith("JC_Necklace_Warheim"))
{
__result = true;
}
}
}
[HarmonyPatch]
public static class Patch_IsFingerItem
{
private static MethodBase TargetMethod()
{
if (!Chainloader.PluginInfos.TryGetValue("org.bepinex.plugins.jewelcrafting", out var value))
{
return null;
}
Assembly assembly = ((object)value.Instance).GetType().Assembly;
Type type = assembly.GetType("Jewelcrafting.Visual");
if (type == null)
{
return null;
}
return AccessTools.Method(type, "IsFingerItem", (Type[])null, (Type[])null);
}
private static void Postfix(ItemData item, ref bool __result)
{
object obj;
if (item == null)
{
obj = null;
}
else
{
GameObject dropPrefab = item.m_dropPrefab;
obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null);
}
string text = (string)obj;
if (!string.IsNullOrEmpty(text) && text.StartsWith("JC_Ring_Warheim", StringComparison.Ordinal))
{
__result = true;
}
}
}
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
public static class FoodTotalsFromWarheimNecklacesPatch
{
[HarmonyPostfix]
private static void Postfix(Player __instance, ref float hp, ref float eitr)
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
SEMan value = Traverse.Create((object)__instance).Field("m_seman").GetValue<SEMan>();
if (value == null)
{
return;
}
List<StatusEffect> value2 = Traverse.Create((object)value).Field("m_statusEffects").GetValue<List<StatusEffect>>();
if (value2 == null)
{
return;
}
float num = 0f;
float num2 = 0f;
foreach (StatusEffect item in value2)
{
if (item is SE_CollierWarheimMage sE_CollierWarheimMage && sE_CollierWarheimMage.m_eitr != 0f)
{
num += sE_CollierWarheimMage.m_eitr;
}
if (item is SE_CollierWarheimTank sE_CollierWarheimTank && sE_CollierWarheimTank.m_healthPercentBonus != 0f)
{
num2 += sE_CollierWarheimTank.m_healthPercentBonus;
}
}
if (num != 0f)
{
eitr += num;
}
if (num2 != 0f)
{
hp *= 1f + num2;
}
}
}
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
public static class FoodTotalsFromWarheimRingsPatch
{
[HarmonyPostfix]
private static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr)
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
SEMan sEMan = ((Character)__instance).GetSEMan();
if (sEMan == null)
{
return;
}
float num = 0f;
float num2 = 0f;
float num3 = 0f;
foreach (StatusEffect statusEffect in sEMan.GetStatusEffects())
{
if (statusEffect is SE_WarheimRingTank sE_WarheimRingTank && sE_WarheimRingTank.m_healthPercentBonus != 0f)
{
num += sE_WarheimRingTank.m_healthPercentBonus;
}
if (statusEffect is SE_WarheimRingArcher sE_WarheimRingArcher && sE_WarheimRingArcher.m_staminaPercentBonus != 0f)
{
num2 += sE_WarheimRingArcher.m_staminaPercentBonus;
}
if (statusEffect is SE_WarheimRingMage sE_WarheimRingMage && sE_WarheimRingMage.m_eitrPercentBonus != 0f)
{
num3 += sE_WarheimRingMage.m_eitrPercentBonus;
}
}
if (num != 0f)
{
hp += hp * num;
}
if (num2 != 0f)
{
stamina += stamina * num2;
}
if (num3 != 0f)
{
eitr += eitr * num3;
}
}
}
public const string PluginGUID = "dzk.warheimstuff";
public const string PluginName = "WarheimStuff";
public const string PluginVersion = "1.0.0";
public static AssetBundle WarheimBundle;
private readonly float[] _tierSmall = new float[5] { 2f, 4f, 6f, 8f, 10f };
private readonly float[] _tierMedium = new float[5] { 1f, 2f, 3f, 4f, 5f };
private readonly float[] _tierLarge = new float[5] { 5f, 10f, 15f, 20f, 25f };
private void Awake()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
LoadAssets();
PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsReady;
PrefabManager.OnVanillaPrefabsAvailable += OnVanillaItemsReady;
PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailableForColliers;
new Harmony("dzk.warheimstuff").PatchAll();
}
private void OnVanillaPrefabsAvailableForColliers()
{
PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailableForColliers;
((MonoBehaviour)this).StartCoroutine(AddColliersWhenReady());
}
private IEnumerator AddColliersWhenReady()
{
while ((Object)(object)ObjectDB.instance == (Object)null || (Object)(object)ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("GP_Moder")) == (Object)null)
{
yield return null;
}
AddColliers();
}
private void LoadAssets()
{
WarheimBundle = AssetUtils.LoadAssetBundleFromResources("customcoins");
}
private void OnVanillaPrefabsReady()
{
AddWarheimCoin();
}
private void OnVanillaItemsReady()
{
PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsReady;
PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaItemsReady;
}
private void AddWarheimCoin()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
GameObject val = WarheimBundle.LoadAsset<GameObject>("assets/custombb/warheimcoin.prefab");
CustomItem val2 = new CustomItem(val, true);
ItemManager.Instance.AddItem(val2);
GameObject val3 = WarheimBundle.LoadAsset<GameObject>("assets/custombb/goldbar.prefab");
CustomItem val4 = new CustomItem(val3, true);
ItemManager.Instance.AddItem(val4);
}
private void AddColliers()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Expected O, but got Unknown
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Expected O, but got Unknown
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Expected O, but got Unknown
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Expected O, but got Unknown
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Expected O, but got Unknown
//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
//IL_04be: Expected O, but got Unknown
GameObject val = API.CreateNecklaceFromTemplate("Red", Color.red);
API.MarkJewelry(val);
((Object)val).name = "JC_Necklace_Warheim_Sailing";
ItemConfig val2 = new ItemConfig();
val2.Name = "Collier du Capitaine";
val2.Description = "Ce collier vous permettra de toujours avoir le vent dans le dos.";
Sprite icon1 = WarheimBundle.LoadAsset<Sprite>("colliersailing_icon.png");
val2.Icon = icon1;
val2.AddRequirement("WarheimCoin", 40, 20);
val2.CraftingStation = "piece_workbench";
val2.RepairStation = "piece_workbench";
SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
StatusEffect val3 = WarheimBundle.LoadAsset<StatusEffect>("SE_SailingWarheim");
CustomStatusEffect val4 = new CustomStatusEffect(val3, false);
ItemManager.Instance.AddStatusEffect(val4);
shared.m_equipStatusEffect = val4.StatusEffect;
CustomItem val5 = new CustomItem(val, false, val2);
ItemManager.Instance.AddItem(val5);
ItemManager.OnItemsRegistered += delegate
{
GameObject itemPrefab4 = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_Sailing");
ItemDrop val18 = ((itemPrefab4 != null) ? itemPrefab4.GetComponent<ItemDrop>() : null);
if ((Object)(object)val18 != (Object)null)
{
val18.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon1 };
}
};
GameObject val6 = API.CreateNecklaceFromTemplate("Red", Color.red);
API.MarkJewelry(val6);
((Object)val6).name = "JC_Necklace_Warheim_DPS";
ItemConfig val7 = new ItemConfig();
val7.Name = "Collier du Carnage";
val7.Description = "Ce collier augmente considérablement vos dégâts et votre régénération d'endurance.";
Sprite icon2 = WarheimBundle.LoadAsset<Sprite>("collierdps_icon.png");
val7.Icon = icon2;
val7.AddRequirement("WarheimCoin", 40, 20);
val7.CraftingStation = "piece_workbench";
val7.RepairStation = "piece_workbench";
SharedData shared2 = val6.GetComponent<ItemDrop>().m_itemData.m_shared;
shared2.m_icons = (Sprite[])(object)new Sprite[1] { icon2 };
SE_CollierWarheimDPS sE_CollierWarheimDPS = ScriptableObject.CreateInstance<SE_CollierWarheimDPS>();
((Object)sE_CollierWarheimDPS).name = "SE_CollierWarheim_DPS";
((StatusEffect)sE_CollierWarheimDPS).m_name = "Collier du Carnage";
((StatusEffect)sE_CollierWarheimDPS).m_icon = icon2;
((StatusEffect)sE_CollierWarheimDPS).m_tooltip = "+15% de dégâts totaux et +10% de régénération d'endurance.";
sE_CollierWarheimDPS.SetDamageMultiplier(1.15f);
sE_CollierWarheimDPS.SetStaminaRegenMultiplier(1.1f);
shared2.m_equipStatusEffect = (StatusEffect)(object)sE_CollierWarheimDPS;
CustomItem val8 = new CustomItem(val6, false, val7);
ItemManager.Instance.AddItem(val8);
ItemManager.OnItemsRegistered += delegate
{
GameObject itemPrefab3 = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_DPS");
ItemDrop val17 = ((itemPrefab3 != null) ? itemPrefab3.GetComponent<ItemDrop>() : null);
if ((Object)(object)val17 != (Object)null)
{
val17.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon2 };
}
};
GameObject val9 = API.CreateNecklaceFromTemplate("Red", Color.red);
API.MarkJewelry(val9);
((Object)val9).name = "JC_Necklace_Warheim_Mage";
ItemConfig val10 = new ItemConfig();
val10.Name = "Collier du Mage";
val10.Description = "Ce collier augmente vos capacités magiques.";
Sprite icon3 = WarheimBundle.LoadAsset<Sprite>("colliermage_icon.png");
val10.Icon = icon3;
val10.AddRequirement("WarheimCoin", 40, 20);
val10.CraftingStation = "piece_workbench";
val10.RepairStation = "piece_workbench";
SharedData shared3 = val9.GetComponent<ItemDrop>().m_itemData.m_shared;
shared3.m_icons = (Sprite[])(object)new Sprite[1] { icon3 };
SE_CollierWarheimMage sE_CollierWarheimMage = ScriptableObject.CreateInstance<SE_CollierWarheimMage>();
((Object)sE_CollierWarheimMage).name = "SE_CollierWarheim_Mage";
((StatusEffect)sE_CollierWarheimMage).m_name = "Collier du Mage";
((StatusEffect)sE_CollierWarheimMage).m_icon = icon3;
((StatusEffect)sE_CollierWarheimMage).m_tooltip = "+10% aux skills de magie, +30% de regen d'eitr, +50 d'eitr max.";
sE_CollierWarheimMage.SetEitr(50f);
sE_CollierWarheimMage.SetSkill(11f);
sE_CollierWarheimMage.SetRegenModifier(1.3f);
shared3.m_equipStatusEffect = (StatusEffect)(object)sE_CollierWarheimMage;
CustomItem val11 = new CustomItem(val9, false, val10);
ItemManager.Instance.AddItem(val11);
ItemManager.OnItemsRegistered += delegate
{
GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_Mage");
ItemDrop val16 = ((itemPrefab2 != null) ? itemPrefab2.GetComponent<ItemDrop>() : null);
if ((Object)(object)val16 != (Object)null)
{
val16.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon3 };
}
};
GameObject val12 = API.CreateNecklaceFromTemplate("Red", Color.red);
API.MarkJewelry(val12);
((Object)val12).name = "JC_Necklace_Warheim_Tank";
ItemConfig val13 = new ItemConfig();
val13.Name = "Collier du Gardien";
val13.Description = "Ce collier augmente vos capacités défensives.";
Sprite icon4 = WarheimBundle.LoadAsset<Sprite>("colliertank_icon.png");
val13.Icon = icon4;
val13.AddRequirement("WarheimCoin", 40, 20);
val13.CraftingStation = "piece_workbench";
val13.RepairStation = "piece_workbench";
SharedData shared4 = val12.GetComponent<ItemDrop>().m_itemData.m_shared;
shared4.m_icons = (Sprite[])(object)new Sprite[1] { icon4 };
SE_CollierWarheimTank sE_CollierWarheimTank = ScriptableObject.CreateInstance<SE_CollierWarheimTank>();
((Object)sE_CollierWarheimTank).name = "SE_CollierWarheim_Tank";
((StatusEffect)sE_CollierWarheimTank).m_name = "Collier du Gardien";
((StatusEffect)sE_CollierWarheimTank).m_icon = icon4;
((StatusEffect)sE_CollierWarheimTank).m_tooltip = "+10% de vie totale finale et +15% de régénération de vie.";
sE_CollierWarheimTank.SetHealthPercentBonus(0.1f);
sE_CollierWarheimTank.SetHealthRegenMultiplier(1.15f);
shared4.m_equipStatusEffect = (StatusEffect)(object)sE_CollierWarheimTank;
CustomItem val14 = new CustomItem(val12, false, val13);
ItemManager.Instance.AddItem(val14);
ItemManager.OnItemsRegistered += delegate
{
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("JC_Necklace_Warheim_Tank");
ItemDrop val15 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
if ((Object)(object)val15 != (Object)null)
{
val15.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon4 };
}
};
AddRings();
}
private void AddRings()
{
AddRingSeries(WarheimRingType.DPS);
AddRingSeries(WarheimRingType.Tank);
AddRingSeries(WarheimRingType.Archer);
AddRingSeries(WarheimRingType.Mage);
}
private void AddRingSeries(WarheimRingType type)
{
for (int i = 1; i <= 5; i++)
{
AddSingleRing(type, i);
}
}
private void AddSingleRing(WarheimRingType type, int tier)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Expected O, but got Unknown
GameObject val = API.CreateRingFromTemplate("Red", Color.red);
API.MarkJewelry(val);
string typeName = type.ToString().ToUpperInvariant();
string name = $"JC_Ring_Warheim_{typeName}_T{tier}";
((Object)val).name = name;
string ringDisplayName = GetRingDisplayName(type, tier);
string ringDescription = GetRingDescription(type, tier);
Sprite icon = GetRingIcon(type, tier);
ItemConfig val2 = new ItemConfig
{
Name = ringDisplayName,
Description = ringDescription,
Icon = icon,
CraftingStation = "piece_workbench",
RepairStation = "piece_workbench"
};
val2.AddRequirement("WarheimCoin", GetRingCost(tier), Math.Max(1, GetRingCost(tier) * 5));
SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared;
shared.m_icons = (Sprite[])(object)new Sprite[1] { icon };
StatusEffect equipStatusEffect = CreateRingStatusEffect(type, tier, icon);
shared.m_equipStatusEffect = equipStatusEffect;
CustomItem val3 = new CustomItem(val, false, val2);
ItemManager.Instance.AddItem(val3);
ItemManager.OnItemsRegistered += delegate
{
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab($"JC_Ring_Warheim_{typeName}_T{tier}");
ItemDrop val4 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
if ((Object)(object)val4 != (Object)null)
{
val4.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon };
}
};
}
private string GetRingDisplayName(WarheimRingType type, int tier)
{
if (1 == 0)
{
}
string result = type switch
{
WarheimRingType.DPS => $"Anneau du Carnage T{tier}",
WarheimRingType.Tank => $"Anneau du Gardien T{tier}",
WarheimRingType.Archer => $"Anneau du Traqueur T{tier}",
WarheimRingType.Mage => $"Anneau de l'Arcaniste T{tier}",
_ => $"Anneau Warheim T{tier}",
};
if (1 == 0)
{
}
return result;
}
private string GetRingDescription(WarheimRingType type, int tier)
{
int num = tier - 1;
if (1 == 0)
{
}
string result = type switch
{
WarheimRingType.DPS => "Cet anneau augmente vos capacités offensives en général.",
WarheimRingType.Tank => "Cet anneau augmente vos capacités défensives.",
WarheimRingType.Archer => "Cet anneau augmente vos capacités d'archer.",
WarheimRingType.Mage => "Cet anneau augmente vos capacités de mage.",
_ => "Anneau Warheim.",
};
if (1 == 0)
{
}
return result;
}
private int GetRingCost(int tier)
{
if (1 == 0)
{
}
int result = tier switch
{
1 => 5,
2 => 10,
3 => 15,
4 => 20,
5 => 25,
_ => 10,
};
if (1 == 0)
{
}
return result;
}
private Sprite GetRingIcon(WarheimRingType type, int tier)
{
string arg = type.ToString().ToLowerInvariant();
return WarheimBundle.LoadAsset<Sprite>($"ring_{arg}_t{tier}.png");
}
private StatusEffect CreateRingStatusEffect(WarheimRingType type, int tier, Sprite icon)
{
int num = tier - 1;
switch (type)
{
case WarheimRingType.DPS:
{
SE_WarheimRingDPS sE_WarheimRingDPS = ScriptableObject.CreateInstance<SE_WarheimRingDPS>();
((Object)sE_WarheimRingDPS).name = $"SE_WarheimRing_DPS_T{tier}";
((StatusEffect)sE_WarheimRingDPS).m_name = $"Anneau du Carnage T{tier}";
((StatusEffect)sE_WarheimRingDPS).m_icon = icon;
((StatusEffect)sE_WarheimRingDPS).m_tooltip = $"+{_tierSmall[num]}% regen stamina, +{_tierMedium[num]}% dégâts totaux.";
sE_WarheimRingDPS.SetStaminaRegenMultiplier(1f + _tierSmall[num] / 100f);
sE_WarheimRingDPS.SetDamageMultiplier(1f + _tierMedium[num] / 100f);
return (StatusEffect)(object)sE_WarheimRingDPS;
}
case WarheimRingType.Tank:
{
SE_WarheimRingTank sE_WarheimRingTank = ScriptableObject.CreateInstance<SE_WarheimRingTank>();
((Object)sE_WarheimRingTank).name = $"SE_WarheimRing_Tank_T{tier}";
((StatusEffect)sE_WarheimRingTank).m_name = $"Anneau du Gardien T{tier}";
((StatusEffect)sE_WarheimRingTank).m_icon = icon;
((StatusEffect)sE_WarheimRingTank).m_tooltip = $"+{_tierSmall[num]}% vie totale, +{_tierLarge[num]}% regen vie.";
sE_WarheimRingTank.SetHealthPercentBonus(_tierSmall[num] / 100f);
sE_WarheimRingTank.SetHealthRegenMultiplier(1f + _tierLarge[num] / 100f);
return (StatusEffect)(object)sE_WarheimRingTank;
}
case WarheimRingType.Archer:
{
SE_WarheimRingArcher sE_WarheimRingArcher = ScriptableObject.CreateInstance<SE_WarheimRingArcher>();
((Object)sE_WarheimRingArcher).name = $"SE_WarheimRing_Archer_T{tier}";
((StatusEffect)sE_WarheimRingArcher).m_name = $"Anneau du Traqueur T{tier}";
((StatusEffect)sE_WarheimRingArcher).m_icon = icon;
((StatusEffect)sE_WarheimRingArcher).m_tooltip = $"+{_tierSmall[num]}% stamina totale, +{_tierMedium[num]}% vitesse de déplacement.";
sE_WarheimRingArcher.SetStaminaPercentBonus(_tierSmall[num] / 100f);
sE_WarheimRingArcher.SetMoveSpeedMultiplier(1f + _tierMedium[num] / 100f);
return (StatusEffect)(object)sE_WarheimRingArcher;
}
case WarheimRingType.Mage:
{
SE_WarheimRingMage sE_WarheimRingMage = ScriptableObject.CreateInstance<SE_WarheimRingMage>();
((Object)sE_WarheimRingMage).name = $"SE_WarheimRing_Mage_T{tier}";
((StatusEffect)sE_WarheimRingMage).m_name = $"Anneau de l'Arcaniste T{tier}";
((StatusEffect)sE_WarheimRingMage).m_icon = icon;
((StatusEffect)sE_WarheimRingMage).m_tooltip = $"+{_tierSmall[num]}% eitr total, +{_tierLarge[num]}% regen d'eitr.";
sE_WarheimRingMage.SetEitrPercentBonus(_tierSmall[num] / 100f);
sE_WarheimRingMage.SetEitrRegenMultiplier(1f + _tierLarge[num] / 100f);
return (StatusEffect)(object)sE_WarheimRingMage;
}
default:
return null;
}
}
}