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;
public class AddStatusEffectBuildupWhenEnchantment : Effect
{
public StatusEffect Status;
public float BuildUpValue = 33f;
public bool AffectController = false;
public int enchantmentID;
public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
{
if (AffectController)
{
_affectedCharacter = ((Effect)this).OwnerCharacter;
}
if ((Object)(object)Status != (Object)null && (Object)(object)_affectedCharacter != (Object)null && (Object)(object)_affectedCharacter.StatusEffectMngr != (Object)null && _affectedCharacter.Alive)
{
if ((Object)(object)((Effect)this).SourceCharacter == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"Source character is null. Cannot check for enchantments or apply status effect buildup.");
}
else if (checkForEnchantment(((Effect)this).SourceCharacter, enchantmentID))
{
_affectedCharacter.StatusEffectMngr.AddStatusEffectBuildUp(Status, BuildUpValue, ((Effect)this).SourceCharacter);
}
}
}
private bool checkForEnchantment(Character character, int enchantmentID)
{
if ((Object)(object)character == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"Character is null in checkForEnchantment.");
return false;
}
if ((Object)(object)character.Inventory == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"Character inventory is null in checkForEnchantment.");
return false;
}
CharacterEquipment equipment = character.Inventory.Equipment;
if ((Object)(object)equipment == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"Character equipment is null in checkForEnchantment.");
return false;
}
for (int i = 0; i < equipment.EquipmentSlots.Length; i++)
{
EquipmentSlot val = equipment.EquipmentSlots[i];
if (!((Object)(object)val != (Object)null) || !((Object)(object)val.EquippedItem != (Object)null))
{
continue;
}
Equipment equippedItem = val.EquippedItem;
if ((Object)(object)equippedItem == (Object)null || equippedItem.ActiveEnchantmentIDs == null || equippedItem.ActiveEnchantmentIDs.Count == 0)
{
continue;
}
for (int j = 0; j < equippedItem.ActiveEnchantmentIDs.Count; j++)
{
int num = equippedItem.ActiveEnchantmentIDs[j];
if (num == enchantmentID)
{
return true;
}
}
}
return false;
}
}
[BepInPlugin("johbenji.balancetweaks", "Balance Tweaks", "0.9.0")]
public class BalanceTweaksPlugin : BaseUnityPlugin
{
public const string GUID = "johbenji.balancetweaks";
public const string NAME = "Balance Tweaks";
public const string VERSION = "0.9.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();
SL_OnPacksLoadedSimeonsGambit();
SL_OnPacksLoadedVirginLantern();
SL_OnPacksLoadedForbiddenKnowledge();
}
private void SL_OnPacksLoadedSimeonsGambit()
{
Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(8100340);
Skill val = (Skill)(object)((itemPrefab is Skill) ? itemPrefab : null);
if ((Object)(object)val != (Object)null)
{
val.Cooldown = ConfigElements.cooldownSimeon.Value;
GameObject gameObject = ((Component)((Component)val).transform.Find("HitEffectsCounter")).gameObject;
if (Object.op_Implicit((Object)(object)gameObject))
{
AddStatusEffectBuildUp val2 = gameObject.gameObject.AddComponent<AddStatusEffectBuildUp>();
StatusEffect statusEffectPrefab = ResourcesPrefabManager.Instance.GetStatusEffectPrefab("Pain");
val2.Status = statusEffectPrefab;
val2.BuildUpValue = 100f;
}
else
{
Log.LogMessage((object)"Simeon's Gambit success condition object NOT found.");
}
}
else
{
Log.LogMessage((object)"Flamethrower skill NOT found.");
}
}
private void SL_OnPacksLoadedFlamethrower()
{
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);
}
}
else
{
Log.LogMessage((object)"Call to Elements NOT found.");
}
}
private void SL_OnPacksLoadedReverberation()
{
Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(8201070);
Skill val = (Skill)(object)((itemPrefab is Skill) ? itemPrefab : null);
if ((Object)(object)val != (Object)null)
{
val.Cooldown = 40f;
List<GameObject> list = ChildFinder.FindChildrenByNameSubstring(((Component)val).gameObject, "NormalD");
List<GameObject> list2 = ChildFinder.FindChildrenByNameSubstring(((Component)val).gameObject, "NormalC");
foreach (GameObject item in list)
{
ResetCooldown orAddComponent = UnityEngineExtensions.GetOrAddComponent<ResetCooldown>(item);
orAddComponent.skillID = 8201050;
}
{
foreach (GameObject item2 in list2)
{
ResetCooldown orAddComponent2 = UnityEngineExtensions.GetOrAddComponent<ResetCooldown>(item2);
orAddComponent2.skillID = 8201051;
}
return;
}
}
Log.LogMessage((object)"Reverberation skill NOT found.");
}
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;
}
}
}
}
}
private void SL_OnPacksLoadedVirginLantern()
{
GiveEnchantmentBonusDamage(18, (Types)2, 10f);
GiveEnchantmentBonusDamage(19, (Types)2, 10f);
GiveEnchantmentBonusDamage(20, (Types)3, 10f);
GiveEnchantmentBonusDamage(21, (Types)4, 10f);
}
private void GiveEnchantmentBonusDamage(int EnchantmentID, Types Type, float DamageBonus)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
Enchantment enchantmentPrefab = ResourcesPrefabManager.Instance.GetEnchantmentPrefab(EnchantmentID);
if ((Object)(object)enchantmentPrefab == (Object)null)
{
Log.LogMessage((object)$"Enchantment {EnchantmentID} NOT found.");
return;
}
Enchantment val = Object.Instantiate<Enchantment>(enchantmentPrefab);
Object.DontDestroyOnLoad((Object)(object)((Component)val).gameObject);
if (DamageBonus != 0f)
{
DamageList val2 = new DamageList();
DamageType val3 = new DamageType(Type, DamageBonus);
DamageType val4 = new DamageType((Types)5, -5f);
val2.Add(val3);
val2.Add(val4);
val.DamageModifier = val2;
}
References.ENCHANTMENT_PREFABS[EnchantmentID] = val;
}
private void SL_OnPacksLoadedForbiddenKnowledge()
{
Item itemPrefab = ResourcesPrefabManager.Instance.GetItemPrefab(8000001);
Item itemPrefab2 = ResourcesPrefabManager.Instance.GetItemPrefab(8000002);
AdjustTrap(itemPrefab, ConfigElements.RunicTrap.Value);
AdjustTrap(itemPrefab2, ConfigElements.RunicTrap.Value);
Item itemPrefab3 = ResourcesPrefabManager.Instance.GetItemPrefab(8100220);
Skill skill = (Skill)(object)((itemPrefab3 is Skill) ? itemPrefab3 : null);
AdjustDetonation(skill, ConfigElements.RunicDetonation.Value);
}
private void AdjustTrap(Item trap, float buildup)
{
if ((Object)(object)trap == (Object)null)
{
Log.LogMessage((object)"Trap NOT found.");
return;
}
if (!(trap is DeployableTrap))
{
Log.LogMessage((object)"Trap is not a deployable trap.");
return;
}
if ((Object)(object)((Component)trap).gameObject == (Object)null || (Object)(object)((Component)trap).transform == (Object)null)
{
Log.LogMessage((object)"Trap game object is null.");
return;
}
GameObject val = GameObjectExtensions.FindChildByName(((Component)trap).gameObject, "Effects");
if ((Object)(object)val == (Object)null)
{
Log.LogMessage((object)"Effects object not found.");
return;
}
AddStatusEffectBuildupWhenEnchantment addStatusEffectBuildupWhenEnchantment = val.AddComponent<AddStatusEffectBuildupWhenEnchantment>();
StatusEffect statusEffectPrefab = ResourcesPrefabManager.Instance.GetStatusEffectPrefab("Curse");
addStatusEffectBuildupWhenEnchantment.Status = statusEffectPrefab;
addStatusEffectBuildupWhenEnchantment.BuildUpValue = buildup;
addStatusEffectBuildupWhenEnchantment.enchantmentID = 17;
}
private void AdjustDetonation(Skill skill, float buildup)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
if ((Object)(object)skill == (Object)null)
{
Log.LogMessage((object)"Detonation skill NOT found.");
return;
}
Transform transform = ((Component)skill).transform;
GameObject val = GameObjectExtensions.FindChildByName(((Component)transform).gameObject, "RunicBlast");
if ((Object)(object)val == (Object)null)
{
Log.LogMessage((object)"Runic Blast object not found.");
return;
}
foreach (Transform item in val.transform)
{
Transform val2 = item;
ShootBlast component = ((Component)val2).GetComponent<ShootBlast>();
if ((Object)(object)component == (Object)null)
{
Log.LogMessage((object)"ShootBlast component not found in Runic Blast.");
continue;
}
Blast baseBlast = component.BaseBlast;
if ((Object)(object)baseBlast == (Object)null)
{
Log.LogMessage((object)"Blast component not found in ShootBlast.");
continue;
}
GameObject val3 = GameObjectExtensions.FindChildByName(((Component)baseBlast).gameObject, "Effects");
if ((Object)(object)val3 == (Object)null)
{
Log.LogMessage((object)"Effects object not found in Blast.");
continue;
}
AddStatusEffectBuildupWhenEnchantment addStatusEffectBuildupWhenEnchantment = val3.gameObject.AddComponent<AddStatusEffectBuildupWhenEnchantment>();
StatusEffect statusEffectPrefab = ResourcesPrefabManager.Instance.GetStatusEffectPrefab("Curse");
addStatusEffectBuildupWhenEnchantment.Status = statusEffectPrefab;
addStatusEffectBuildupWhenEnchantment.BuildUpValue = buildup;
addStatusEffectBuildupWhenEnchantment.enchantmentID = 17;
}
}
}
public class BTLanternConeBlast : ConeBlast
{
public ParticleSystem FXFire;
public ParticleSystem FXLightning;
public ParticleSystem FXEthereal;
public ParticleSystem FXIce;
public ParticleSystem FXDecay;
public ParticleSystem FXCopper;
public ParticleSystem m_fxToPlay;
public List<string> m_fireTier1Effects = new List<string>();
public List<string> m_fireTier2Effects = new List<string>();
public List<string> m_fireTier3Effects = new List<string>();
public List<string> m_iceTier1Effects = new List<string>();
public List<string> m_iceTier2Effects = new List<string>();
public List<string> m_lightningAEffects = new List<string>();
public List<string> m_lightningBEffects = new List<string>();
public List<string> m_etherealEffects = new List<string>();
public List<string> m_djinnEffects = new List<string>();
public List<string> m_decayEffects = new List<string>();
public List<string> m_copperEffects = new List<string>();
public List<string> m_effects;
public override void BaseShoot(float _lifespan)
{
Equipment leftHandEquipment = ((EffectSynchronizer)this).OwnerCharacter.LeftHandEquipment;
if (!((Object)(object)leftHandEquipment != (Object)null))
{
return;
}
int itemID = ((Item)((EffectSynchronizer)this).OwnerCharacter.LeftHandEquipment).ItemID;
if (itemID == 5100060 || itemID == 5100010)
{
m_fxToPlay = FXFire;
m_effects = m_fireTier1Effects;
}
else
{
switch (itemID)
{
case 5100000:
m_fxToPlay = FXFire;
m_effects = m_fireTier2Effects;
break;
case 5100070:
m_fxToPlay = FXIce;
m_effects = m_iceTier1Effects;
break;
case 5100090:
m_fxToPlay = FXLightning;
m_effects = m_lightningAEffects;
break;
default:
if (((Item)((EffectSynchronizer)this).OwnerCharacter.LeftHandEquipment).ItemID == 5100080)
{
m_fxToPlay = FXEthereal;
m_effects = m_etherealEffects;
}
else if (((EffectSynchronizer)this).OwnerCharacter.LeftHandEquipment.ActiveEnchantmentIDs.Contains(21))
{
m_fxToPlay = FXIce;
m_effects = m_iceTier2Effects;
}
else if (((EffectSynchronizer)this).OwnerCharacter.LeftHandEquipment.ActiveEnchantmentIDs.Contains(18))
{
m_fxToPlay = FXDecay;
m_effects = m_decayEffects;
}
else if (((EffectSynchronizer)this).OwnerCharacter.LeftHandEquipment.ActiveEnchantmentIDs.Contains(19))
{
m_fxToPlay = FXCopper;
m_effects = m_copperEffects;
}
else if (itemID == 5100110)
{
m_fxToPlay = FXLightning;
m_effects = m_djinnEffects;
}
else
{
m_fxToPlay = FXFire;
m_effects = m_fireTier3Effects;
}
break;
}
}
((Blast)this).BaseShoot(_lifespan);
m_fxToPlay.Play();
}
public override void AddEffect(int _categoryID, string _sourceID, EffectReference _effectRef)
{
((EffectSynchronizer)this).AddEffect(_categoryID, _sourceID, _effectRef);
string name = ((Object)((Component)_effectRef.Effect).transform).name;
if (name != null)
{
switch (name)
{
case "BT_fireTier1Effects":
m_fireTier1Effects.Add(_sourceID);
break;
case "BT_fireTier2Effects":
m_fireTier2Effects.Add(_sourceID);
break;
case "BT_fireTier3Effects":
m_fireTier3Effects.Add(_sourceID);
break;
case "BT_iceTier1Effects":
m_iceTier1Effects.Add(_sourceID);
break;
case "BT_iceTier2Effects":
m_iceTier2Effects.Add(_sourceID);
break;
case "BT_lightningAEffects":
m_lightningAEffects.Add(_sourceID);
break;
case "BT_lightningBEffects":
m_lightningBEffects.Add(_sourceID);
break;
case "BT_etherealEffects":
m_etherealEffects.Add(_sourceID);
break;
case "BT_djinnEffects":
m_djinnEffects.Add(_sourceID);
break;
case "BT_decayEffects":
m_decayEffects.Add(_sourceID);
break;
case "BT_copperEffects":
m_copperEffects.Add(_sourceID);
break;
}
}
}
public override void SynchronizeEffects(EffectCategories _category, Character _affectedCharacter, Vector3 _pos, Vector3 _dir)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
((EffectSynchronizer)this).SynchronizeEffects(_affectedCharacter, (IList<string>)m_effects, _pos, _dir);
}
}
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 ConfigEntry<float> cooldownSimeon;
public static ConfigEntry<float> RunicTrap;
public static ConfigEntry<float> RunicDetonation;
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
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_02ce: Expected O, but got Unknown
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Expected O, but got Unknown
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: 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]));
cooldownSimeon = config.Bind<float>("Misc", "Cooldown (Simeons Gambit)", 60f, new ConfigDescription("Cooldown of the skill Simeons Gambit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 120f), new object[0]));
RunicTrap = config.Bind<float>("Misc", "Forbidden Knowledge Runic Trap", 35f, new ConfigDescription("Runic Trap curse buildup with Forbidden Knowledge enchantment.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), new object[0]));
RunicDetonation = config.Bind<float>("Misc", "Forbidden Knowledge, Runic Detonation", 100f, new ConfigDescription("Runic Detonation curse buildup with Forbidden Knowledge enchantment.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), 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);
}
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 static class GameObjectExtensions
{
public static GameObject FindChildByName(GameObject parent, string childName)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
if ((Object)(object)parent == (Object)null || string.IsNullOrEmpty(childName))
{
return null;
}
foreach (Transform item in parent.transform)
{
Transform val = item;
if (((Object)val).name == childName)
{
return ((Component)val).gameObject;
}
GameObject val2 = FindChildByName(((Component)val).gameObject, childName);
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
}
return null;
}
public static GameObject AddChild(GameObject parent, string childName)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)parent == (Object)null || string.IsNullOrEmpty(childName))
{
return null;
}
GameObject val = new GameObject(childName);
val.transform.SetParent(parent.transform);
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
val.transform.localScale = Vector3.one;
return val;
}
}
public class Patches
{
[HarmonyPatch(typeof(Weapon), "AddImbueEffect")]
public class boostImbueEffectAddImbueEffect_Patch
{
private static void Postfix(Weapon __instance)
{
RefreshBoostImbueEffectCall(__instance);
}
}
[HarmonyPatch(typeof(Weapon), "RemoveAllImbueEffects")]
public class boostImbueEffectRemoveAllImbueEffects_Patch
{
private static void Postfix(Weapon __instance)
{
RefreshBoostImbueEffectCall(__instance);
}
}
[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;
}
}
}
}
public static void RefreshBoostImbueEffectCall(Weapon weapon)
{
IList<int> activeEnchantmentIDs = ((Equipment)weapon).ActiveEnchantmentIDs;
if (activeEnchantmentIDs == null || activeEnchantmentIDs.Count <= 0 || activeEnchantmentIDs[0] != 16)
{
return;
}
Enchantment val = ((Equipment)weapon).ActiveEnchantments[0];
if ((Object)(object)val != (Object)null)
{
BoostImbueDamage componentInChildren = ((Component)((Component)val).transform).GetComponentInChildren<BoostImbueDamage>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.updatePunctualDamageComponent();
}
}
}
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_AddStatusBuildupStability : SL_Effect, ICustomModel
{
public string StatusEffect = "";
public float Buildup;
public float BuildUpMultiplier = 1f;
public bool BypassCounter;
public bool AffectController;
public float stability;
public NumericCompare conditionType;
public Type SLTemplateModel => typeof(SL_AddStatusBuildupStability);
public Type GameModel => typeof(AddStatusBuildupStability);
public override void ApplyToComponent<T>(T component)
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
StatusEffect statusEffectPrefab = ResourcesPrefabManager.Instance.GetStatusEffectPrefab(StatusEffect);
if (!Object.op_Implicit((Object)(object)statusEffectPrefab))
{
SL.LogWarning(((object)this).GetType().Name + ": Could not find any effect with the identifier '" + StatusEffect + "'");
return;
}
AddStatusBuildupStability addStatusBuildupStability = component as AddStatusBuildupStability;
addStatusBuildupStability.Status = statusEffectPrefab;
addStatusBuildupStability.BuildUpValue = Buildup;
addStatusBuildupStability.BypassCounter = BypassCounter;
addStatusBuildupStability.BuildUpMultiplier = BuildUpMultiplier;
addStatusBuildupStability.AffectController = AffectController;
addStatusBuildupStability.stability = stability;
addStatusBuildupStability.conditionType = conditionType;
}
public override void SerializeEffect<T>(T effect)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
AddStatusBuildupStability addStatusBuildupStability = effect as AddStatusBuildupStability;
if (Object.op_Implicit((Object)(object)addStatusBuildupStability.Status))
{
StatusEffect = addStatusBuildupStability.Status.IdentifierName;
Buildup = addStatusBuildupStability.BuildUpValue;
BuildUpMultiplier = addStatusBuildupStability.BuildUpMultiplier;
BypassCounter = addStatusBuildupStability.BypassCounter;
AffectController = addStatusBuildupStability.AffectController;
stability = addStatusBuildupStability.stability;
conditionType = addStatusBuildupStability.conditionType;
}
}
}
public class AddStatusBuildupStability : Effect
{
public StatusEffect Status;
public float BuildUpValue;
public float BuildUpMultiplier;
public bool NoDealer;
public bool AffectController;
public bool BypassCounter;
public float stability;
public NumericCompare conditionType;
private bool success;
public override void ActivateLocally(Character _affectedCharacter, object[] _infos)
{
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Invalid comparison between Unknown and I4
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Invalid comparison between Unknown and I4
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Invalid comparison between Unknown and I4
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Invalid comparison between Unknown and I4
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Invalid comparison between Unknown and I4
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Invalid comparison between Unknown and I4
if (AffectController)
{
_affectedCharacter = ((Effect)this).OwnerCharacter;
}
BalanceTweaksPlugin.Log.LogMessage((object)$"Attempting to apply {Status.IdentifierName} buildup to {((Object)_affectedCharacter).name} with stability condition {((object)(NumericCompare)(ref conditionType)).ToString()} {stability}");
if (!((Object)(object)Status != (Object)null) || !((Object)(object)_affectedCharacter != (Object)null) || !((Object)(object)_affectedCharacter.StatusEffectMngr != (Object)null) || (_affectedCharacter.Countering && !BypassCounter) || !_affectedCharacter.Alive)
{
return;
}
success = false;
if ((int)conditionType == 2)
{
if (_affectedCharacter.Stability <= stability)
{
success = true;
}
}
else if ((int)conditionType == 3)
{
if (_affectedCharacter.Stability >= stability)
{
success = true;
}
}
else if ((int)conditionType == 4)
{
if (_affectedCharacter.Stability == stability)
{
success = true;
}
}
else if ((int)conditionType == 5)
{
if (_affectedCharacter.Stability != stability)
{
success = true;
}
}
else if ((int)conditionType == 0)
{
if (_affectedCharacter.Stability < stability)
{
success = true;
}
}
else if ((int)conditionType == 1)
{
if (_affectedCharacter.Stability > stability)
{
success = true;
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)$"Failed applying {Status.IdentifierName} status to {((Object)_affectedCharacter).name} who has a stability of {_affectedCharacter.Stability}.");
}
if (success)
{
_affectedCharacter.StatusEffectMngr.AddStatusEffectBuildUp(Status, BuildUpValue * BuildUpMultiplier, (!NoDealer) ? ((Effect)this).SourceCharacter : null);
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)$"Condition not satisfied. Character Stability = {_affectedCharacter.Stability}. Threshold Stability = {stability}. Condition Type = {((object)(NumericCompare)(ref conditionType)).ToString()}");
}
}
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_BoostImbueDamage : SL_Effect, ICustomModel
{
public bool lefthand;
public float bonusdamage;
public Type SLTemplateModel => typeof(SL_BoostImbueDamage);
public Type GameModel => typeof(BoostImbueDamage);
public override void ApplyToComponent<T>(T component)
{
BoostImbueDamage boostImbueDamage = component as BoostImbueDamage;
boostImbueDamage.lefthand = lefthand;
boostImbueDamage.bonusdamage = bonusdamage;
}
public override void SerializeEffect<T>(T effect)
{
BoostImbueDamage boostImbueDamage = effect as BoostImbueDamage;
lefthand = boostImbueDamage.lefthand;
bonusdamage = boostImbueDamage.bonusdamage;
}
}
public class BoostImbueDamage : Effect
{
public bool lefthand;
public float bonusdamage;
public void updatePunctualDamageComponent()
{
activate();
}
public override void ActivateLocally(Character _targetCharacter, object[] _infos)
{
activate();
}
private void activate()
{
Character sourceCharacter = ((Effect)this).SourceCharacter;
if ((Object)(object)sourceCharacter == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"Source character is null, cannot apply imbue damage boost.");
return;
}
Weapon val = fetchWeapon(sourceCharacter);
if ((Object)(object)val == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"Weapon is null, cannot apply imbue damage boost.");
return;
}
Dictionary<Types, bool> imbueElements = getImbueElements(val);
if (imbueElements == null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"Damage list is null, cannot apply imbue damage boost.");
return;
}
PunctualDamage component = ((Component)((Component)this).transform).GetComponent<PunctualDamage>();
if ((Object)(object)component == (Object)null)
{
BalanceTweaksPlugin.Log.LogMessage((object)"PunctualDamage component is null, cannot apply imbue damage boost.");
return;
}
List<DamageType> list = toDamageList(imbueElements);
component.Damages = list.ToArray();
}
private Weapon fetchWeapon(Character character)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
CharacterInventory inventory = character.Inventory;
if ((Object)(object)inventory != (Object)null)
{
CharacterEquipment equipment = inventory.Equipment;
if ((Object)(object)equipment != (Object)null)
{
Equipment val = null;
if (lefthand)
{
LeftHandEquipmentSlot val2 = (LeftHandEquipmentSlot)equipment.EquipmentSlots[6];
if ((Object)(object)val2 != (Object)null)
{
val = ((EquipmentSlot)val2).EquippedItem;
}
}
else
{
EquipmentSlot val3 = equipment.EquipmentSlots[5];
if ((Object)(object)val3 != (Object)null)
{
val = val3.EquippedItem;
}
}
if (val is Weapon)
{
return (Weapon)(object)((val is Weapon) ? val : null);
}
BalanceTweaksPlugin.Log.LogMessage((object)"Equipment is found, but is not a weapon.");
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"Character equipment is null");
}
}
else
{
BalanceTweaksPlugin.Log.LogMessage((object)"Character inventory is null");
}
return null;
}
private Dictionary<Types, bool> getImbueElements(Weapon weapon)
{
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Invalid comparison between Unknown and I4
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Invalid comparison between Unknown and I4
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: 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)
Dictionary<Types, bool> dictionary = new Dictionary<Types, bool>
{
{
(Types)0,
false
},
{
(Types)1,
false
},
{
(Types)2,
false
},
{
(Types)3,
false
},
{
(Types)4,
false
},
{
(Types)5,
false
},
{
(Types)6,
false
},
{
(Types)7,
false
},
{
(Types)8,
false
},
{
(Types)9,
false
}
};
ImbueStack firstImbue = weapon.FirstImbue;
if (firstImbue != null)
{
for (int i = 0; i < firstImbue.ImbuedEffects.Length; i++)
{
Effect val = firstImbue.ImbuedEffects[i];
if (val is WeaponDamage)
{
WeaponDamage val2 = (WeaponDamage)(object)((val is WeaponDamage) ? val : null);
DamageType[] damages = ((PunctualDamage)val2).Damages;
foreach (DamageType val3 in damages)
{
if (val3.Damage > 0f && (int)val3.Type != 9)
{
dictionary[val3.Type] = true;
}
}
if (val2.WeaponDamageMult > 1f && (int)val2.OverrideDType != 9)
{
dictionary[val2.OverrideDType] = true;
}
}
else
{
if (!(val is PunctualDamage))
{
continue;
}
PunctualDamage val4 = (PunctualDamage)(object)((val is PunctualDamage) ? val : null);
DamageType[] damages2 = val4.Damages;
foreach (DamageType val5 in damages2)
{
if (val5.Damage > 0f)
{
dictionary[val5.Type] = true;
}
}
}
}
}
return dictionary;
}
private List<DamageType> toDamageList(Dictionary<Types, bool> damageDictionary)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
List<DamageType> list = new List<DamageType>();
foreach (KeyValuePair<Types, bool> item in damageDictionary)
{
if (item.Value)
{
DamageType val = new DamageType();
val.Type = item.Key;
val.Damage = bonusdamage;
list.Add(val);
}
}
return list;
}
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_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;
}
}