using System;
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;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using SideLoader;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BalanceTweaks;
[BepInPlugin("johbenji.balancetweaks", "Balance Tweaks", "0.8.0")]
public class BalanceTweaksPlugin : BaseUnityPlugin
{
public const string GUID = "johbenji.balancetweaks";
public const string NAME = "Balance Tweaks";
public const string VERSION = "0.8.0";
internal static ManualLogSource Log;
public static List<SEDependingScene> referenceCallOfElementsList;
public static float exaltedDeathReq = 0.25f;
public static float exaltedDeathTimer = 10f;
public static float exaltedApplicationTimerReference = -1f;
public static float exaltedRecessionTimerReference = -1f;
internal void Awake()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
ConfigElements.Init(((BaseUnityPlugin)this).Config);
SL.OnGameplayResumedAfterLoading += GameplayResumed;
SL.OnPacksLoaded += SL_OnPacksLoaded;
new Harmony("johbenji.balancetweaks").PatchAll();
}
internal void SL_OnPacksLoaded()
{
SL_OnPacksLoadedCallOfElements();
SL_OnPacksLoadedReverberation();
SL_OnPacksLoadedFlamethrower();
}
private void SL_OnPacksLoadedFlamethrower()
{
Log.LogMessage((object)"Adjusting Flamethrower skill effects.");
Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(8100090);
Skill val = (Skill)(object)((itemPrefab is Skill) ? itemPrefab : null);
if ((Object)(object)val != (Object)null)
{
ShootConeBlastChecker orAddComponent = UnityEngineExtensions.GetOrAddComponent<ShootConeBlastChecker>(((Component)val).transform);
}
else
{
Log.LogMessage((object)"Flamethrower skill NOT found.");
}
Log.LogMessage((object)"Flamethrower skill effects adjustment complete.");
}
private void SL_OnPacksLoadedCallOfElements()
{
Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(8200300);
AttackSkill val = (AttackSkill)(object)((itemPrefab is AttackSkill) ? itemPrefab : null);
if ((Object)(object)val != (Object)null)
{
AddStatusEffectDependingScene componentInChildren = ((Component)((Component)val).transform).GetComponentInChildren<AddStatusEffectDependingScene>();
if ((Object)(object)componentInChildren != (Object)null)
{
referenceCallOfElementsList = new List<SEDependingScene>(componentInChildren.SEDependingScene);
Log.LogMessage((object)$"Call to Elements found and reference list saved with {referenceCallOfElementsList.Count} entries.");
}
}
else
{
Log.LogMessage((object)"Call to Elements NOT found.");
}
}
private void SL_OnPacksLoadedReverberation()
{
Log.LogMessage((object)"Adjusting Reverberation skill effects.");
Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(8201070);
Skill val = (Skill)(object)((itemPrefab is Skill) ? itemPrefab : null);
if ((Object)(object)val != (Object)null)
{
Log.LogMessage((object)"Reverberation skill found.");
val.Cooldown = 40f;
List<GameObject> list = ChildFinder.FindChildrenByNameSubstring(((Component)val).gameObject, "NormalD");
List<GameObject> list2 = ChildFinder.FindChildrenByNameSubstring(((Component)val).gameObject, "NormalC");
Log.LogMessage((object)$"Found {list.Count} D effects and {list2.Count} C effects.");
foreach (GameObject item in list)
{
Log.LogMessage((object)"Adding ResetCooldown to Haunting Beat effect.");
ResetCooldown orAddComponent = UnityEngineExtensions.GetOrAddComponent<ResetCooldown>(item);
orAddComponent.skillID = 8201050;
}
foreach (GameObject item2 in list2)
{
Log.LogMessage((object)"Adding ResetCooldown to Welkin Ring effect.");
ResetCooldown orAddComponent2 = UnityEngineExtensions.GetOrAddComponent<ResetCooldown>(item2);
orAddComponent2.skillID = 8201051;
}
}
else
{
Log.LogMessage((object)"Reverberation skill NOT found.");
}
Log.LogMessage((object)"Reverberation skill effects adjustment complete.");
}
internal void GameplayResumed()
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
DictionaryExt<string, string> playerCharacters = CharacterManager.Instance.PlayerCharacters;
for (int i = 0; i < playerCharacters.Count; i++)
{
string text = playerCharacters.m_values[i];
Character character = CharacterManager.Instance.GetCharacter(text);
if (!((Object)(object)character != (Object)null) || !character.StatusEffectMngr.HasStatusEffect("Call of Elements") || referenceCallOfElementsList == null)
{
continue;
}
foreach (SEDependingScene referenceCallOfElements in referenceCallOfElementsList)
{
string activeSceneName = SceneManagerHelper.ActiveSceneName;
string sceneName = AreaManager.Instance.GetArea(referenceCallOfElements.Area).SceneName;
if (activeSceneName == sceneName)
{
StatusEffect sEAssociated = referenceCallOfElements.SEAssociated;
if (sEAssociated.StatusName.Contains("Discipline"))
{
character.StatusEffectMngr.AddStatusEffect("DisciplineIndicator");
break;
}
if (sEAssociated.StatusName.Contains("Rage"))
{
character.StatusEffectMngr.AddStatusEffect("RageIndicator");
break;
}
if (sEAssociated.StatusName.Contains("Mist"))
{
character.StatusEffectMngr.AddStatusEffect("MistIndicator");
break;
}
if (sEAssociated.StatusName.Contains("Bless"))
{
character.StatusEffectMngr.AddStatusEffect("BlessIndicator");
break;
}
if (sEAssociated.StatusName.Contains("Possess"))
{
character.StatusEffectMngr.AddStatusEffect("PossessIndicator");
break;
}
if (sEAssociated.StatusName.Contains("Cool"))
{
character.StatusEffectMngr.AddStatusEffect("CoolIndicator");
break;
}
if (sEAssociated.StatusName.Contains("Warm"))
{
character.StatusEffectMngr.AddStatusEffect("WarmIndicator");
break;
}
}
}
}
}
}
public static class ChildFinder
{
public static List<GameObject> FindChildrenByNameSubstring(GameObject parent, string substring)
{
List<GameObject> list = new List<GameObject>();
Transform[] componentsInChildren = parent.GetComponentsInChildren<Transform>(true);
foreach (Transform val in componentsInChildren)
{
if (((Object)val).name.Contains(substring))
{
list.Add(((Component)val).gameObject);
}
}
return list;
}
}
public static class ConfigElements
{
public static ConfigEntry<bool> toolDurabilityChange;
public static ConfigEntry<float> crueltyStatusEffectPenetration;
public static ConfigEntry<float> lanternFireDamage;
public static ConfigEntry<float> lanternFireImpact;
public static ConfigEntry<float> lanternFrostDamage;
public static ConfigEntry<float> lanternFrostImpact;
public static ConfigEntry<float> lanternLightningDamage;
public static ConfigEntry<float> lanternLightningImpact;
public static ConfigEntry<float> lanternEtherealDamage;
public static ConfigEntry<float> lanternEtherealImpact;
public static ConfigEntry<float> lanternDecayDamage;
public static ConfigEntry<float> lanternDecayImpact;
public static void Init(ConfigFile config)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Expected O, but got Unknown
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Expected O, but got Unknown
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected O, but got Unknown
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Expected O, but got Unknown
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Expected O, but got Unknown
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Expected O, but got Unknown
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Expected O, but got Unknown
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Expected O, but got Unknown
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Expected O, but got Unknown
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Expected O, but got Unknown
toolDurabilityChange = config.Bind<bool>("Compatibility", "Tool Durability Change", false, new ConfigDescription("Disabled = compatibility with the mod VheosModPack. Enabled = intended experience", (AcceptableValueBase)null, Array.Empty<object>()));
crueltyStatusEffectPenetration = config.Bind<float>("Values", "Cruelty, Status Effect Penetration", 0.5f, new ConfigDescription("The percentage of status effect buildup that passes through immunities when the player has cruelty passive", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0]));
lanternFireDamage = config.Bind<float>("Flamethrower", "Fire-based Lantern, Fire Damage", 2.75f, new ConfigDescription("The damage per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
lanternFireImpact = config.Bind<float>("Flamethrower", "Fire-based Lantern, Fire Impact", 2.65f, new ConfigDescription("The impact per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
lanternFrostDamage = config.Bind<float>("Flamethrower", "Frost-based Lantern, Frost Damage", 3.75f, new ConfigDescription("The damage per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
lanternFrostImpact = config.Bind<float>("Flamethrower", "Frost-based Lantern, Frost Impact", 3.65f, new ConfigDescription("The impact per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
lanternLightningDamage = config.Bind<float>("Flamethrower", "Lightning-based Lantern, Lightning Damage", 4.75f, new ConfigDescription("The damage per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
lanternLightningImpact = config.Bind<float>("Flamethrower", "Lightning-based Lantern, Lightning Impact", 5.65f, new ConfigDescription("The impact per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
lanternEtherealDamage = config.Bind<float>("Flamethrower", "Ethereal-based Lantern, Ethereal Damage", 3.75f, new ConfigDescription("The damage per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
lanternEtherealImpact = config.Bind<float>("Flamethrower", "Ethereal-based Lantern, Ethereal Impact", 3.65f, new ConfigDescription("The impact per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
lanternDecayDamage = config.Bind<float>("Flamethrower", "Decay-based Lantern, Decay Damage", 6.75f, new ConfigDescription("The damage per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
lanternDecayImpact = config.Bind<float>("Flamethrower", "Decay-based Lantern, Decay Impact", 3.65f, new ConfigDescription("The impact per hit dealt by the flamethrower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[0]));
}
}
public class EquipPatches
{
[HarmonyPatch(typeof(Equipment), "OnEquip")]
public class OnEquip_Patch
{
private static void Prefix(Equipment __instance)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Invalid comparison between Unknown and I4
Character ownerCharacter = ((EffectSynchronizer)__instance).OwnerCharacter;
if (!((Object)(object)ownerCharacter == (Object)null) && ownerCharacter.IsLocalPlayer && !((Object)(object)ownerCharacter.LeftHandEquipment == (Object)null) && (int)ownerCharacter.LeftHandEquipment.IKType == 1)
{
if (((Item)ownerCharacter.LeftHandEquipment).ItemID == 5100080 && !ownerCharacter.StatusEffectMngr.HasStatusEffect("Spirit Guard AoE"))
{
ownerCharacter.StatusEffectMngr.AddStatusEffect("Spirit Guard AoE");
}
if (((Item)ownerCharacter.LeftHandEquipment).ItemID == 5100110 && !ownerCharacter.StatusEffectMngr.HasStatusEffect("Status Guard AoE"))
{
ownerCharacter.StatusEffectMngr.AddStatusEffect("Status Guard AoE");
}
}
}
}
[HarmonyPatch(typeof(Equipment), "OnUnequip")]
public class OnUnequip_Patch
{
private static void Prefix(Equipment __instance)
{
bool flag = false;
bool flag2 = false;
Character ownerCharacter = ((EffectSynchronizer)__instance).OwnerCharacter;
if ((Object)(object)ownerCharacter == (Object)null || !ownerCharacter.IsLocalPlayer || (Object)(object)ownerCharacter.StatusEffectMngr == (Object)null)
{
return;
}
if ((Object)(object)ownerCharacter.LeftHandEquipment == (Object)null)
{
flag = true;
flag2 = true;
}
else
{
if (((Item)ownerCharacter.LeftHandEquipment).ItemID != 5100080)
{
flag = true;
}
if (((Item)ownerCharacter.LeftHandEquipment).ItemID != 5100110)
{
flag2 = true;
}
}
if (ownerCharacter.StatusEffectMngr.HasStatusEffect("Spirit Guard AoE") && flag)
{
ownerCharacter.StatusEffectMngr.RemoveStatusWithIdentifierName("Spirit Guard AoE");
}
if (ownerCharacter.StatusEffectMngr.HasStatusEffect("Status Guard AoE") && flag2)
{
ownerCharacter.StatusEffectMngr.RemoveStatusWithIdentifierName("Status Guard AoE");
}
}
}
}
public class ShootConeBlastChecker : MonoBehaviour
{
public string componentNameToCheck = "ShootConeBlast";
private void Start()
{
ShootConeBlast componentInChildren = ((Component)this).GetComponentInChildren<ShootConeBlast>();
if ((Object)(object)componentInChildren != (Object)null)
{
ReplaceOriginalFlamethrowerEffect(componentInChildren);
}
}
private void ReplaceOriginalFlamethrowerEffect(ShootConeBlast target)
{
if ((Object)(object)target != (Object)null)
{
Blast baseBlast = ((ShootBlast)target).BaseBlast;
if ((Object)(object)baseBlast != (Object)null)
{
if (baseBlast is LanternConeBlast)
{
Transform transform = ((Component)baseBlast).transform;
AddIfEffectGameObjects(transform);
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"Blast component in ShootConeBlast is NOT a LanternConeBlast.");
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"Blast component NOT found in ShootConeBlast.");
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"ShootConeBlast component NOT found in Flamethrower skill.");
}
}
private void AddIfEffectGameObjects(Transform parentTransform)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Expected O, but got Unknown
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Expected O, but got Unknown
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Expected O, but got Unknown
Transform val = parentTransform.Find("BalanceTweaksCheck");
if ((Object)(object)val != (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"BalanceTweaksCheck already exists. Skipping adding effects.");
return;
}
GameObject val2 = new GameObject("BalanceTweaksCheck");
Object.Instantiate<GameObject>(val2);
val2.transform.SetParent(parentTransform, false);
Transform gameObjectToHoldComp = parentTransform.Find("NormalFire");
changePunctualDamage(gameObjectToHoldComp, new List<DamageType>
{
new DamageType((Types)5, ConfigElements.lanternFireDamage.Value)
}.ToArray(), ConfigElements.lanternFireImpact.Value);
changeAddStatusEffectBuildup(gameObjectToHoldComp, "Burning", 15f);
Transform gameObjectToHoldComp2 = parentTransform.Find("NormalIce");
changePunctualDamage(gameObjectToHoldComp2, new List<DamageType>
{
new DamageType((Types)4, ConfigElements.lanternFrostDamage.Value)
}.ToArray(), ConfigElements.lanternFrostImpact.Value);
changeAddStatusEffectBuildup(gameObjectToHoldComp2, "Cripple", 15f);
Transform gameObjectToHoldComp3 = parentTransform.Find("NormalLightning");
changePunctualDamage(gameObjectToHoldComp3, new List<DamageType>
{
new DamageType((Types)3, ConfigElements.lanternLightningDamage.Value)
}.ToArray(), ConfigElements.lanternLightningImpact.Value);
changeAddStatusEffectBuildup(gameObjectToHoldComp3, "Doom", 15f);
Transform gameObjectToHoldComp4 = parentTransform.Find("NormalDecay");
changePunctualDamage(gameObjectToHoldComp4, new List<DamageType>
{
new DamageType((Types)2, ConfigElements.lanternDecayDamage.Value)
}.ToArray(), ConfigElements.lanternDecayImpact.Value);
changeAddStatusEffectBuildup(gameObjectToHoldComp4, "Bleeding", 15f);
Transform gameObjectToHoldComp5 = parentTransform.Find("NormalEthereal");
changePunctualDamage(gameObjectToHoldComp5, new List<DamageType>
{
new DamageType((Types)1, ConfigElements.lanternEtherealDamage.Value)
}.ToArray(), ConfigElements.lanternEtherealImpact.Value);
changeAddStatusEffectBuildup(gameObjectToHoldComp5, "Haunted", 15f);
BalanceTweaksPlugin.Log.LogMessage((object)"Flamethrower damage adjusted.");
}
private void changePunctualDamage(Transform gameObjectToHoldComp, DamageType[] damageTypes, float impact)
{
if ((Object)(object)gameObjectToHoldComp == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"GameObject to hold PunctualDamage component is null.");
return;
}
PunctualDamage component = ((Component)gameObjectToHoldComp).GetComponent<PunctualDamage>();
component.Damages = damageTypes;
}
private void changeAddStatusEffectBuildup(Transform gameObjectToHoldComp, string statusIdentifier, float buildUpValue)
{
if ((Object)(object)gameObjectToHoldComp == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"GameObject to hold AddStatusEffectBuildUp component is null.");
return;
}
AddStatusEffectBuildUp component = ((Component)gameObjectToHoldComp).GetComponent<AddStatusEffectBuildUp>();
component.Status = ResourcesPrefabManager.Instance.GetStatusEffectPrefab(statusIdentifier);
component.BuildUpValue = buildUpValue;
}
}
public class Patches
{
[HarmonyPatch(typeof(AddStatusEffectDependingScene), "ActivateLocally")]
public class AddVisibilityStatusEffectDependingScene_Patch
{
private static void Prefix(Character _affectedCharacter, AddStatusEffectDependingScene __instance)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
if (BalanceTweaksPlugin.referenceCallOfElementsList == null)
{
BalanceTweaksPlugin.Log.LogError((object)"BalanceTweaksPlugin.referenceCallOfElementsList is null.");
return;
}
SEDependingScene[] array = BalanceTweaksPlugin.referenceCallOfElementsList.ToArray();
List<SEDependingScene> list = new List<SEDependingScene>();
SEDependingScene[] array2 = array;
foreach (SEDependingScene val in array2)
{
AreaEnum area = val.Area;
StatusEffect sEAssociated = val.SEAssociated;
SEDependingScene val2 = new SEDependingScene();
val2.Area = area;
val2.SEAssociated = sEAssociated;
if ((Object)(object)_affectedCharacter.StatusEffectMngr != (Object)null && (_affectedCharacter.StatusEffectMngr.HasStatusEffect(sEAssociated.IdentifierName) || _affectedCharacter.StatusEffectMngr.HasStatusEffect(sEAssociated.AmplifiedStatus.IdentifierName) || _affectedCharacter.HasShamanicResonance) && (Object)(object)sEAssociated.AmplifiedStatus != (Object)null)
{
val2.SEAssociated = sEAssociated.AmplifiedStatus;
}
list.Add(val2);
}
__instance.SEDependingScene = list.ToArray();
_affectedCharacter.StatusEffectMngr.AddStatusEffect("Call of Elements");
}
}
[HarmonyPatch(typeof(Disease), "ProcessUpdate")]
public class OnLastLegsDisease_Patch
{
private static void Postfix(Disease __instance)
{
Character ownerCharacter = ((EffectSynchronizer)__instance).OwnerCharacter;
if (!((Object)(object)ownerCharacter != (Object)null) || !(((StatusEffect)__instance).IdentifierName == "Life Drain 3") || !((Object)(object)ownerCharacter.StatusEffectMngr != (Object)null))
{
return;
}
bool flag = IsCharacterLowHealth(ownerCharacter);
if (ownerCharacter.StatusEffectMngr.HasStatusEffect("OnYourLastLegReceding"))
{
return;
}
if (flag && !ownerCharacter.StatusEffectMngr.HasStatusEffect("OnYourLastLeg") && !ownerCharacter.StatusEffectMngr.HasStatusEffect("OnYourLastLegReceding"))
{
bool flag2 = BalanceTweaksPlugin.exaltedApplicationTimerReference != -1f && Time.time - BalanceTweaksPlugin.exaltedApplicationTimerReference < 1f;
Sprite statusIcon = GetStatusIcon("OnYourLastLeg");
if (!flag2)
{
if ((Object)(object)statusIcon != (Object)null)
{
ownerCharacter.CharacterUI.ShowInfoNotification("Disease: On Your Last Leg has been contracted.", statusIcon);
}
else
{
ownerCharacter.CharacterUI.ShowInfoNotification("Disease: On Your Last Leg has been contracted.");
}
}
ownerCharacter.StatusEffectMngr.AddStatusEffect("OnYourLastLeg");
BalanceTweaksPlugin.exaltedApplicationTimerReference = Time.time;
}
else
{
if (flag || !ownerCharacter.StatusEffectMngr.HasStatusEffect("OnYourLastLeg"))
{
return;
}
ownerCharacter.StatusEffectMngr.RemoveStatusWithIdentifierName("OnYourLastLeg");
if (ownerCharacter.StatusEffectMngr.HasStatusEffect("OnYourLastLegReceding"))
{
return;
}
if (BalanceTweaksPlugin.exaltedRecessionTimerReference == -1f || !(Time.time - BalanceTweaksPlugin.exaltedRecessionTimerReference < 1f))
{
Sprite statusIcon2 = GetStatusIcon("OnYourLastLeg");
if ((Object)(object)statusIcon2 != (Object)null)
{
ownerCharacter.CharacterUI.ShowInfoNotification("Disease: On Your Last Leg is now receding.", statusIcon2);
}
else
{
ownerCharacter.CharacterUI.ShowInfoNotification("Disease: On Your Last Leg is now receding.");
}
}
ownerCharacter.StatusEffectMngr.AddStatusEffect("OnYourLastLegReceding");
BalanceTweaksPlugin.exaltedRecessionTimerReference = Time.time;
}
}
private static Sprite GetStatusIcon(string statusEffectName)
{
StatusEffect statusEffectPrefab = ResourcesPrefabManager.Instance.GetStatusEffectPrefab(statusEffectName);
if ((Object)(object)statusEffectPrefab != (Object)null)
{
return statusEffectPrefab.StatusIcon;
}
return null;
}
private static bool IsCharacterLowHealth(Character character)
{
if ((Object)(object)character.m_characterStats != (Object)null)
{
float maxHealth = character.m_characterStats.MaxHealth;
float num = maxHealth - character.m_characterStats.ActiveMaxHealth;
float num2 = num / maxHealth;
return num2 >= BalanceTweaksPlugin.exaltedDeathReq;
}
return false;
}
}
[HarmonyPatch(typeof(GatherableInteraction), "CharSpellTakeItem")]
public class GatherableInteraction_BalancePatch
{
private static bool Prefix(Character _character, GatherableInteraction __instance)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
if (!ConfigElements.toolDurabilityChange.Value)
{
return true;
}
if (!Object.op_Implicit((Object)(object)_character))
{
return true;
}
GatherInstance value = null;
if (__instance.m_pendingAnims.TryGetValue(UID.op_Implicit(_character.UID), out value))
{
if (value != null && Object.op_Implicit((Object)(object)value.ItemVisual))
{
ItemManager.PutBackVisual(value.ItemVisual);
}
}
else
{
value = new GatherInstance();
value.Character = _character;
__instance.m_pendingAnims.Add(UID.op_Implicit(_character.UID), value);
}
value.ValidItem = __instance.GetValidItem(_character);
value.IsCurrentWeapon = Object.op_Implicit((Object)(object)value.ValidItem) && value.ValidItem.IsEquipped;
Transform equipmentVisualSlotTransform = _character.Inventory.GetEquipmentVisualSlotTransform((EquipmentSlotIDs)5);
if ((Object)(object)value.ValidItem != (Object)null)
{
if ((Object)(object)equipmentVisualSlotTransform != (Object)null)
{
if (value.ValidItem.HasVisualLoaded)
{
value.ItemVisual = value.ValidItem.LoadedVisual;
}
else
{
value.ItemVisual = ItemManager.GetVisuals(value.ValidItem.ItemID);
}
value.ItemVisual.SetTransformParent(equipmentVisualSlotTransform);
((Component)value.ItemVisual).transform.localPosition = value.ItemVisual.CastTakeOffset;
((Component)value.ItemVisual).transform.localRotation = Quaternion.Euler(value.ItemVisual.CastTakeRot);
Transform transform = ((Component)value.ItemVisual).transform;
transform.localScale *= value.ItemVisual.CastTakeScale;
value.ItemVisual.Show();
}
value.ValidItem.ReduceDurability(15f);
}
return false;
}
}
[HarmonyPatch(typeof(DefeatScenariosManager), "DelayedStartDefeat")]
public class exaltedCharacterLossAdjuster_Patch
{
private static bool Prefix(float _delay, DefeatScenariosManager __instance)
{
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.m_notRealDefeat)
{
bool flag = false;
if (Object.op_Implicit((Object)(object)CharacterManager.Instance.GetWorldHostCharacter()) && Object.op_Implicit((Object)(object)__instance.FatalStatus) && CharacterManager.Instance.GetWorldHostCharacter().StatusEffectMngr.HasStatusEffect(__instance.FatalStatus.IdentifierName) && (Object)(object)CharacterManager.Instance.GetWorldHostCharacter().m_characterStats != (Object)null && CharacterManager.Instance.GetWorldHostCharacter().StatusEffectMngr.GetStatusEffectOfName(__instance.FatalStatus.IdentifierName).Age > BalanceTweaksPlugin.exaltedDeathTimer)
{
flag = true;
}
if (Object.op_Implicit((Object)(object)CharacterManager.Instance.GetWorldHostCharacter()) && Object.op_Implicit((Object)(object)__instance.FatalStatus) && CharacterManager.Instance.GetWorldHostCharacter().StatusEffectMngr.HasStatusEffect("OnYourLastLegReceding") && (Object)(object)CharacterManager.Instance.GetWorldHostCharacter().m_characterStats != (Object)null)
{
if (CharacterManager.Instance.GetWorldHostCharacter().StatusEffectMngr.GetStatusEffectOfName("OnYourLastLegReceding").Age > BalanceTweaksPlugin.exaltedDeathTimer)
{
flag = true;
}
else
{
if (BalanceTweaksPlugin.exaltedApplicationTimerReference == -1f)
{
flag = true;
}
float num = Time.time - BalanceTweaksPlugin.exaltedApplicationTimerReference;
if (num > BalanceTweaksPlugin.exaltedDeathTimer)
{
flag = true;
}
}
}
if (flag)
{
Area area = AreaManager.Instance.GetArea(__instance.m_fatalScene);
__instance.DefeatLoadScene(area.SceneName, "319");
return false;
}
__instance.m_defeatCountSinceLastRest++;
if (!__instance.m_defeatCountPerSceneSinceLastRest.ContainsKey(SceneManagerHelper.ActiveSceneName))
{
__instance.m_defeatCountPerSceneSinceLastRest.Add(SceneManagerHelper.ActiveSceneName, 0);
}
__instance.m_defeatCountPerSceneSinceLastRest[SceneManagerHelper.ActiveSceneName]++;
}
if (__instance.Ready)
{
((MonoBehaviour)__instance).Invoke("StartDefeat", _delay);
return false;
}
((MonoBehaviour)__instance).Invoke("FailSafeDefeat", _delay);
return false;
}
}
[HarmonyPatch(typeof(DefeatScenariosManager), "LoadSaveData")]
public class exaltedFatalStatus_Patch
{
private static void Postfix(DefeatScenariosManager __instance)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
string text = "OnYourLastLeg";
StatusEffect statusEffectPrefab = ResourcesPrefabManager.Instance.GetStatusEffectPrefab(text);
if ((Object)(object)statusEffectPrefab == (Object)null)
{
BalanceTweaksPlugin.Log.LogError((object)("Failed to find Status Effect with identifier: " + text));
return;
}
Type typeFromHandle = typeof(DefeatScenariosManager);
FieldInfo field = typeFromHandle.GetField("m_fatalStatus", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(__instance, statusEffectPrefab);
StatusEffect val = (StatusEffect)field.GetValue(__instance);
BalanceTweaksPlugin.Log.LogMessage((object)("DefeatScenarioManager Fatal Status Effect set to: " + ((Object)val).name));
}
else
{
BalanceTweaksPlugin.Log.LogError((object)"Failed to find m_fatalStatus field in DefeatScenariosManager.");
}
}
}
[HarmonyPatch(typeof(StatusEffectManager), "AddStatusEffectBuildUp", new Type[]
{
typeof(StatusEffect),
typeof(float),
typeof(Character)
})]
public class crueltyBuildupCut_Patch
{
private static void Postfix(StatusEffectManager __instance, StatusEffect _statusEffect, ref float _buildUp, Character _dealerChar)
{
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Expected O, but got Unknown
if (!__instance.m_character.IsPhotonPlayerLocal || (Object)(object)_statusEffect == (Object)null || __instance.m_character.QuestStatusImmunity)
{
return;
}
float statusBuildUpModifier = __instance.m_character.Stats.GetStatusBuildUpModifier(_statusEffect.IdentifierName);
if (!__instance.m_character.Stats.HasStatusImmunity(_statusEffect.InheritedTags) || !HasCrueltyPassive(_dealerChar) || _statusEffect.IdentifierName == "Pain" || _statusEffect.IdentifierName == "Confusion")
{
return;
}
statusBuildUpModifier *= ConfigElements.crueltyStatusEffectPenetration.Value;
_buildUp *= statusBuildUpModifier;
if (_buildUp <= 0f)
{
return;
}
if (_statusEffect.IgnoreBuildUpIfApplied && (Object)(object)__instance.GetStatusEffectOfName(_statusEffect.IdentifierName) != (Object)null)
{
__instance.AddStatusEffect(_statusEffect, _dealerChar);
return;
}
if (!__instance.m_statusBuildUp.ContainsKey(_statusEffect.IdentifierName))
{
__instance.m_statusBuildUp.Add(_statusEffect.IdentifierName, new PairBuildUpTime());
}
PairBuildUpTime obj = __instance.m_statusBuildUp[_statusEffect.IdentifierName];
obj.BuildUp += _buildUp;
__instance.m_statusBuildUp[_statusEffect.IdentifierName].Time = Time.time;
if (__instance.m_statusBuildUp[_statusEffect.IdentifierName].BuildUp >= 100f && (!Object.op_Implicit((Object)(object)_statusEffect.RequiredStatus) || __instance.HasStatusEffect(_statusEffect.RequiredStatus.IdentifierName)))
{
if (!_statusEffect.IgnoreBuildUpIfApplied)
{
PairBuildUpTime obj2 = __instance.m_statusBuildUp[_statusEffect.IdentifierName];
obj2.BuildUp -= 100f;
}
else
{
__instance.m_statusBuildUp[_statusEffect.IdentifierName].BuildUp = 0f;
}
__instance.AddStatusEffect(_statusEffect, _dealerChar);
}
}
}
[HarmonyPatch(typeof(StatusEffectManager), "AddStatusEffect", new Type[]
{
typeof(StatusEffect),
typeof(Character),
typeof(string[])
})]
public class crueltyAdd_Patch
{
private static void Postfix(StatusEffectManager __instance, StatusEffect _statusEffect, Character _dealer, string[] _loadData, ref StatusEffect __result)
{
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Expected I4, but got Unknown
//IL_0483: Unknown result type (might be due to invalid IL or missing references)
//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0508: Unknown result type (might be due to invalid IL or missing references)
//IL_0515: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.m_character.IsPhotonPlayerLocal && _loadData == null)
{
__result = null;
}
else if ((Object)(object)_statusEffect == (Object)null)
{
__result = null;
}
else if ((!__instance.m_character.Alive || __instance.m_character.IsUndyingDead) && _statusEffect.Purgeable)
{
__result = null;
}
else if (_statusEffect.IdentifierName == "Petrification" && (Object)(object)__instance.m_character.OwnerPlayerSys == (Object)null)
{
__result = null;
}
else if (__instance.m_character.QuestStatusImmunity)
{
__result = null;
}
else
{
if (_statusEffect.IgnoreStatusResist || (!__instance.m_character.Stats.HasStatusImmunity(_statusEffect.InheritedTags) && __instance.m_character.Stats.GetStatusBuildUpModifier(_statusEffect.IdentifierName) != 0f))
{
return;
}
if (HasCrueltyPassive(_dealer) && !(_statusEffect.IdentifierName == "Pain") && !(_statusEffect.IdentifierName == "Confusion"))
{
if (__instance.m_character.HasShamanicResonance && (Object)(object)_statusEffect.AmplifiedStatus != (Object)null && _loadData == null)
{
_statusEffect = _statusEffect.AmplifiedStatus;
}
if (Object.op_Implicit((Object)(object)_statusEffect.RequiredStatus))
{
if (!__instance.HasStatusEffect(_statusEffect.RequiredStatus.IdentifierName))
{
__result = null;
return;
}
if (_statusEffect.RemoveRequiredStatus)
{
__instance.RemoveStatusWithIdentifierName(_statusEffect.RequiredStatus.IdentifierName);
}
}
Disease val = (Disease)(object)((_statusEffect is Disease) ? _statusEffect : null);
if ((Object)(object)val != (Object)null && val.HasStatusCure)
{
for (int i = 0; i < val.StatusCure.Length; i++)
{
if (__instance.HasStatus(val.StatusCure[i]))
{
__result = null;
return;
}
}
}
bool flag = true;
StatusEffect firstEffectOfFamily = __instance.GetFirstEffectOfFamily(StatusEffectFamily.op_Implicit(_statusEffect.EffectFamily));
if ((Object)(object)firstEffectOfFamily != (Object)null)
{
if (Object.op_Implicit((Object)(object)firstEffectOfFamily.ComplicationStatus))
{
firstEffectOfFamily.Stop();
__instance.RemoveStatus(UID.op_Implicit(firstEffectOfFamily.UID));
__instance.AddStatusEffect(firstEffectOfFamily.ComplicationStatus, _dealer);
__result = null;
return;
}
if (!(firstEffectOfFamily is LevelStatusEffect))
{
StackBehaviors stackBehavior = _statusEffect.StackBehavior;
StackBehaviors val2 = stackBehavior;
switch ((int)val2)
{
case 0:
flag = false;
break;
case 1:
flag = firstEffectOfFamily.Priority <= _statusEffect.Priority && __instance.OverrideStatusEffect(firstEffectOfFamily, _statusEffect);
break;
case 2:
case 3:
firstEffectOfFamily.AddStack(_statusEffect);
flag = false;
break;
case 4:
{
StatusEffect statusEffectOfName = __instance.GetStatusEffectOfName(_statusEffect.IdentifierName);
if (Object.op_Implicit((Object)(object)statusEffectOfName))
{
flag = __instance.OverrideStatusEffect(statusEffectOfName, _statusEffect);
}
break;
}
case 5:
{
int statusOfFamilyCount = __instance.GetStatusOfFamilyCount(StatusEffectFamily.op_Implicit(_statusEffect.EffectFamily));
if (firstEffectOfFamily.EffectFamily.MaxStackCount != -1 && statusOfFamilyCount == firstEffectOfFamily.EffectFamily.MaxStackCount)
{
firstEffectOfFamily.RemoveOldestStack();
}
break;
}
}
}
else
{
firstEffectOfFamily.AddStack(_statusEffect);
flag = false;
}
}
if (NetworkLevelLoader.Instance.IsOverallLoadingDone)
{
__instance.m_fastSync = true;
}
if (flag)
{
StatusEffect val3 = Object.Instantiate<StatusEffect>(_statusEffect);
val3.ParentManager = __instance;
if (!((Component)val3).gameObject.activeSelf)
{
((Component)val3).gameObject.SetActive(true);
}
((Component)val3).transform.SetParent(__instance.GetStatusHolder(_statusEffect.IdentifierName));
UnityEngineExtensions.ResetLocal(((Component)val3).transform, true);
bool flag2 = _loadData != null && !NetworkLevelLoader.Instance.IsOverallLoadingDone;
if (_loadData != null)
{
val3.LoadNetworkData(_loadData);
}
else
{
val3.SetSourceCharacter(_dealer);
}
((MonoBehaviour)Global.Instance).StartCoroutine(__instance.DelayedStatusActivation(0.1f, val3, flag2));
__instance.m_statuses.Add(val3.UID, val3);
if (!__instance.m_statusPerFamily.ContainsKey(StatusEffectFamily.op_Implicit(val3.EffectFamily)))
{
__instance.m_statusPerFamily.Add(StatusEffectFamily.op_Implicit(val3.EffectFamily), new List<UID>());
}
__instance.m_statusPerFamily[StatusEffectFamily.op_Implicit(val3.EffectFamily)].Add(val3.UID);
if (!AchievementManager.Instance.IsAchievementCompleted((Achievement)43) && val3.InheritedTags.Contains(TagSourceManager.Boon) && __instance.GetStatusOfTypeCountDistinct(TagSourceManager.Boon) >= AchievementManager.BoonAchievementStatusId.Length)
{
AchievementManager.Instance.SetAchievementAsCompleted((Achievement)43);
}
__result = val3;
}
else
{
firstEffectOfFamily.SetSourceCharacter(_dealer);
__result = firstEffectOfFamily;
}
}
else
{
__result = null;
}
}
}
}
private static bool HasCrueltyPassive(Character character)
{
int num = 8202003;
if ((Object)(object)character != (Object)null && (Object)(object)character.Inventory != (Object)null && (Object)(object)character.Inventory.SkillKnowledge != (Object)null)
{
Item itemFromItemID = ((CharacterKnowledge)character.Inventory.SkillKnowledge).GetItemFromItemID(num);
if ((Object)(object)itemFromItemID == (Object)null)
{
return false;
}
return true;
}
return false;
}
}
public class SL_ChangeArrowRadius : SL_Effect, ICustomModel
{
public float radius;
public Type SLTemplateModel => typeof(SL_ChangeArrowRadius);
public Type GameModel => typeof(ChangeArrowRadius);
public override void ApplyToComponent<T>(T component)
{
ChangeArrowRadius changeArrowRadius = component as ChangeArrowRadius;
changeArrowRadius.radius = radius;
}
public override void SerializeEffect<T>(T effect)
{
ChangeArrowRadius changeArrowRadius = effect as ChangeArrowRadius;
radius = changeArrowRadius.radius;
}
}
public class ChangeArrowRadius : Effect
{
public float radius;
public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
{
Item parentItem = ((Effect)this).ParentItem;
RangeAttackSkill val = (RangeAttackSkill)(object)((parentItem is RangeAttackSkill) ? parentItem : null);
if ((Object)(object)val == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"Bow Skill not found");
return;
}
ShootProjectileAmmoVisuals[] componentsInChildren = ((Component)((Component)val).transform).GetComponentsInChildren<ShootProjectileAmmoVisuals>();
if (componentsInChildren == null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"ShootProjectileAmmoVisuals[] is null");
return;
}
if (componentsInChildren.Length == 0)
{
BalanceTweaksPlugin.Log.LogMessage((object)"ShootProjectileAmmoVisuals[] does not have any shoot projectile ammo visuals");
return;
}
ShootProjectileAmmoVisuals[] array = componentsInChildren;
foreach (ShootProjectileAmmoVisuals val2 in array)
{
Projectile[] projectiles = ((ShootProjectile)val2).m_projectiles;
Projectile[] array2 = projectiles;
foreach (Projectile val3 in array2)
{
RaycastProjectile val4 = (RaycastProjectile)(object)((val3 is RaycastProjectile) ? val3 : null);
if ((Object)(object)val4 != (Object)null)
{
val4.Radius = radius;
}
}
}
}
}
public class SL_ReduceStatusDuration : SL_Effect, ICustomModel
{
public string statusIdentifier;
public float durationReduction;
public Type SLTemplateModel => typeof(SL_ReduceStatusDuration);
public Type GameModel => typeof(ReduceStatusDuration);
public override void ApplyToComponent<T>(T component)
{
ReduceStatusDuration reduceStatusDuration = component as ReduceStatusDuration;
reduceStatusDuration.statusIdentifier = statusIdentifier;
reduceStatusDuration.durationReduction = durationReduction;
}
public override void SerializeEffect<T>(T effect)
{
ReduceStatusDuration reduceStatusDuration = effect as ReduceStatusDuration;
statusIdentifier = reduceStatusDuration.statusIdentifier;
durationReduction = reduceStatusDuration.durationReduction;
}
}
public class ReduceStatusDuration : Effect
{
public string statusIdentifier;
public float durationReduction;
public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
{
StatusEffectManager statusEffectMngr = _affectedCharacter.StatusEffectMngr;
if ((Object)(object)statusEffectMngr != (Object)null)
{
StatusEffect statusEffectOfName = statusEffectMngr.GetStatusEffectOfName(statusIdentifier);
if ((Object)(object)statusEffectOfName != (Object)null)
{
if (statusEffectOfName.StartLifespan != -1f)
{
Type typeFromHandle = typeof(StatusEffect);
FieldInfo field = typeFromHandle.GetField("m_statusStack", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
List<StatusData> list = (List<StatusData>)field.GetValue(statusEffectOfName);
if (list.Count > 0)
{
for (int i = 0; i < list.Count; i++)
{
StatusData val = list[i];
val.UpdateLifespan(durationReduction);
}
}
else
{
BalanceTweaksPlugin.Log.LogError((object)"No status data found in the status stack.");
}
}
else
{
BalanceTweaksPlugin.Log.LogError((object)"SL_ReduceStatusDuration did not get the status stack field.");
}
FieldInfo field2 = typeFromHandle.GetField("m_remainingTime", BindingFlags.Instance | BindingFlags.NonPublic);
if (field2 != null)
{
float num = (float)field2.GetValue(statusEffectOfName) - durationReduction;
if (num < 0f)
{
statusEffectMngr.RemoveStatus("Rage");
}
else
{
field2.SetValue(statusEffectOfName, num);
}
}
else
{
BalanceTweaksPlugin.Log.LogError((object)"SL_ReduceStatusDuration did not get the remaining time field.");
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"SL_ReduceStatusDuration, status is infinite and cannot be reduced.");
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)("status Effect " + statusIdentifier + " not found"));
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"status Effect manager not found");
}
BalanceTweaksPlugin.Log.LogMessage((object)"Failed Reset Cooldown:");
}
private Transform FindChildWithNamePart(Transform parent, string namePart)
{
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
if (((Object)child).name.Contains(namePart))
{
return child;
}
}
return null;
}
}
public class SL_ResetCooldown : SL_Effect, ICustomModel
{
public int skillID;
public Type SLTemplateModel => typeof(SL_ResetCooldown);
public Type GameModel => typeof(ResetCooldown);
public override void ApplyToComponent<T>(T component)
{
ResetCooldown resetCooldown = component as ResetCooldown;
resetCooldown.skillID = skillID;
}
public override void SerializeEffect<T>(T effect)
{
ResetCooldown resetCooldown = effect as ResetCooldown;
skillID = resetCooldown.skillID;
}
}
public class ResetCooldown : Effect
{
public int skillID;
public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
{
CharacterInventory inventory = _affectedCharacter.Inventory;
if ((Object)(object)inventory != (Object)null)
{
CharacterSkillKnowledge skillKnowledge = inventory.SkillKnowledge;
if ((Object)(object)skillKnowledge != (Object)null)
{
Transform transform = ((Component)skillKnowledge).transform;
if ((Object)(object)transform != (Object)null)
{
Transform val = FindChildWithNamePart(transform, skillID.ToString());
if ((Object)(object)val != (Object)null)
{
Skill component = ((Component)val).GetComponent<Skill>();
if ((Object)(object)component != (Object)null)
{
component.ResetCoolDown();
return;
}
BalanceTweaksPlugin.Log.LogMessage((object)"Skill component not found");
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"Skill not found");
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"Character skill list transform is null");
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"Character skill knowledge is null");
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"Character inventory is null");
}
BalanceTweaksPlugin.Log.LogMessage((object)"Failed Reset Cooldown:");
}
private Transform FindChildWithNamePart(Transform parent, string namePart)
{
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
if (((Object)child).name.Contains(namePart))
{
return child;
}
}
return null;
}
}