using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 HarmonyLib;
using HarmonyLib.Tools;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.U2D;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Pacifist")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Pacifist")]
[assembly: AssemblyCopyright("Copyright © oathorse 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ea282da8-693d-4cf1-bf7a-8ecac0827eaa")]
[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 TrophyHuntMod;
[BepInPlugin("com.oathorse.Pacifist", "Pacifist", "0.1.0")]
public class TrophyHuntMod : BaseUnityPlugin
{
public class GandrArrowData
{
public string m_arrowName = "";
public string m_ingredient = "";
public string m_name = "";
public string m_description = "";
public Type m_statusEffectType;
public GandrTypeIndex m_spriteIndex;
public GandrArrowData(string arrowName, string ingredient, string name, string description, Type statusEffectType, GandrTypeIndex spriteIndex)
{
m_arrowName = arrowName;
m_ingredient = ingredient;
m_name = name;
m_description = description;
m_statusEffectType = statusEffectType;
m_spriteIndex = spriteIndex;
}
}
[HarmonyPatch(typeof(Character), "GetJogSpeedFactor")]
public static class Character_GetJogSpeedFactor_Patch
{
public static void Postfix(Character __instance, ref float __result)
{
if (IsPacifist())
{
Guid cGUID = GetGUIDFromCharacter(__instance);
CharmedCharacter charmedCharacter = __m_allCharmedCharacters.Find((CharmedCharacter c) => c.m_charmGUID == cGUID);
if (charmedCharacter != null)
{
__result = 3f;
}
}
}
}
[HarmonyPatch(typeof(Character), "GetRunSpeedFactor")]
public static class Character_GetRunSpeedFactor_Patch
{
public static void Postfix(Character __instance, ref float __result)
{
if (IsPacifist())
{
Guid cGUID = GetGUIDFromCharacter(__instance);
CharmedCharacter charmedCharacter = __m_allCharmedCharacters.Find((CharmedCharacter c) => c.m_charmGUID == cGUID);
if (charmedCharacter != null)
{
__result = 3f;
}
}
}
}
[HarmonyPatch(typeof(MonsterAI), "UpdateAI")]
public static class MonsterAI_UpdateAI_Patch
{
public static void Postfix(MonsterAI __instance, float dt)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
if (IsPacifist() && !((Object)(object)__instance == (Object)null) && !((Object)(object)((BaseAI)__instance).m_character == (Object)null) && IsCharmed(((BaseAI)__instance).m_character) && !((Object)(object)((BaseAI)__instance).m_character == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null))
{
float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)((BaseAI)__instance).m_character).transform.position);
Character targetCreature = ((BaseAI)__instance).GetTargetCreature();
if (Object.op_Implicit((Object)(object)targetCreature))
{
float num2 = Vector3.Distance(((Component)targetCreature).transform.position, ((Component)((BaseAI)__instance).m_character).transform.position);
__instance.SetFollowTarget(((Component)Player.m_localPlayer).gameObject);
}
}
}
}
[HarmonyPatch(typeof(BaseAI), "Follow")]
public static class BaseAI_Follow_Patch
{
public static bool Prefix(BaseAI __instance, GameObject go, float dt)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
float num = 0f;
float num2 = Vector3.Distance(go.transform.position, ((Component)__instance.m_character).transform.position);
bool flag = num2 > 10f;
if (num2 < 3f + __instance.m_character.GetRadius() * 2f - num)
{
__instance.StopMoving();
}
else
{
__instance.MoveTo(dt, go.transform.position, 0f, flag);
}
return false;
}
}
[HarmonyPatch(typeof(BaseAI), "FindEnemy")]
public static class BaseAI_FindEnemy_Patch
{
public static bool Prefix(BaseAI __instance, ref Character __result)
{
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
if (!IsPacifist())
{
return true;
}
if (!IsCharmed(__instance.m_character))
{
return true;
}
Character localPlayer = (Character)(object)Player.m_localPlayer;
if ((Object)(object)localPlayer == (Object)null)
{
return true;
}
List<Character> allCharacters = Character.GetAllCharacters();
Character val = null;
float num = 99999f;
float hearRange = __instance.m_hearRange;
float viewRange = __instance.m_viewRange;
__instance.m_hearRange *= 1.25f;
__instance.m_viewRange *= 1.25f;
foreach (Character item in allCharacters)
{
if (!BaseAI.IsEnemy(__instance.m_character, item) || item.IsDead() || item.m_aiSkipTarget)
{
continue;
}
BaseAI baseAI = item.GetBaseAI();
if (((Object)(object)baseAI == (Object)null || !baseAI.IsSleeping()) && __instance.CanSenseTarget(item))
{
float num2 = Vector3.Distance(((Component)item).transform.position, ((Component)localPlayer).transform.position);
if (num2 < num || (Object)(object)val == (Object)null)
{
val = item;
num = num2;
}
}
}
__instance.m_hearRange = hearRange;
__instance.m_viewRange = viewRange;
if ((Object)(object)val == (Object)null && __instance.HuntPlayer())
{
Player closestPlayer = Player.GetClosestPlayer(((Component)__instance).transform.position, 200f);
if ((Object)(object)closestPlayer != (Object)null && (closestPlayer.InDebugFlyMode() || ((Character)closestPlayer).InGhostMode()))
{
__result = null;
return false;
}
__result = (Character)(object)closestPlayer;
return false;
}
if (num > 50f)
{
MonsterAI val2 = (MonsterAI)(object)((__instance is MonsterAI) ? __instance : null);
if (Object.op_Implicit((Object)(object)val2))
{
val2.m_timeSinceSensedTargetCreature = 0f;
val2.m_targetCreature = null;
val2.m_targetStatic = null;
((BaseAI)val2).SetTargetInfo(ZDOID.None);
}
__result = null;
return false;
}
if ((Object)(object)val == (Object)null)
{
MonsterAI val3 = (MonsterAI)(object)((__instance is MonsterAI) ? __instance : null);
if (Object.op_Implicit((Object)(object)val3))
{
val3.m_targetStatic = ((BaseAI)val3).FindClosestStaticPriorityTarget();
if ((Object)(object)val3.m_targetStatic == (Object)null)
{
val3.m_targetStatic = ((BaseAI)val3).FindRandomStaticTarget(50f);
}
}
}
__result = val;
return false;
}
}
[HarmonyPatch(typeof(Humanoid), "GiveDefaultItems")]
public static class Humanoid_GiveDefaultItems_Patch
{
public static void Postfix(Humanoid __instance)
{
if (!IsPacifist() || (Object)(object)__instance == (Object)null || !(((object)__instance).GetType() == typeof(Player)))
{
return;
}
Inventory inventory = __instance.GetInventory();
if (inventory != null && !inventory.HaveItem("$item_bow", true))
{
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Bow");
if ((Object)(object)itemPrefab != (Object)null)
{
__instance.GiveDefaultItem(itemPrefab);
}
else
{
Debug.LogWarning((object)"Could not find Bow prefab in ObjectDB");
}
}
}
}
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public static class Character_RPC_Damage_Patch
{
public static bool Prefix(Character __instance, long sender, HitData hit)
{
if (!IsPacifist())
{
return true;
}
if ((Object)(object)hit.GetAttacker() == (Object)(object)Player.m_localPlayer)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Humanoid), "StartAttack")]
public static class Humanoid_StartAttack_Patch
{
public static bool Prefix(Humanoid __instance, Character target, bool secondaryAttack, bool __result)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Invalid comparison between Unknown and I4
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Invalid comparison between Unknown and I4
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Invalid comparison between Unknown and I4
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Invalid comparison between Unknown and I4
if (!IsPacifist())
{
return true;
}
if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
{
ItemData currentWeapon = __instance.GetCurrentWeapon();
if (currentWeapon != null && (int)currentWeapon.m_shared.m_itemType == 4)
{
ItemData ammoItem = __instance.GetAmmoItem();
if (ammoItem != null && IsThrallArrow(ammoItem.m_shared.m_name))
{
return true;
}
}
else if ((int)currentWeapon.m_shared.m_skillType == 7 || (int)currentWeapon.m_shared.m_skillType == 12 || (int)currentWeapon.m_shared.m_skillType == 13)
{
return true;
}
__result = false;
return false;
}
return true;
}
}
public class CharmedCharacter
{
public Guid m_charmGUID = Guid.Empty;
public PinData m_pin = null;
public long m_charmExpireTime = 0L;
public Faction m_originalFaction = (Faction)12;
public float m_swimSpeed = 2f;
public int m_charmLevel = 1;
}
[HarmonyPatch(typeof(MonsterAI), "Awake")]
public static class MonsterAI_Awake_Patch
{
public static void Postfix(MonsterAI __instance)
{
if (IsPacifist() && !((Object)(object)__instance == (Object)null) && !((Object)(object)((BaseAI)__instance).m_character == (Object)null))
{
Guid cGUID = GetGUIDFromCharacter(((BaseAI)__instance).m_character);
CharmedCharacter charmedCharacter = __m_allCharmedCharacters.Find((CharmedCharacter c) => c.m_charmGUID == cGUID);
if (charmedCharacter != null)
{
SetCharmedState(charmedCharacter);
}
}
}
}
[HarmonyPatch(typeof(Character), "OnDestroy")]
public static class Character_OnDestroy_Patch
{
public static void Prefix(Character __instance)
{
if (IsPacifist())
{
}
}
}
[HarmonyPatch(typeof(Projectile), "OnHit")]
public static class Projectile_OnHit_Patch
{
public static bool Prefix(Projectile __instance, Collider collider)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (!IsPacifist())
{
return true;
}
if ((Object)(object)__instance == (Object)null)
{
return true;
}
ItemData ammo = __instance.m_ammo;
if (ammo == null || ammo.m_shared == null)
{
return true;
}
if (!IsThrallArrow(ammo.m_shared.m_name))
{
return true;
}
__instance.m_damage = default(DamageTypes);
return false;
}
public static void Postfix(Projectile __instance, Collider collider)
{
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Invalid comparison between Unknown and I4
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
if (!IsPacifist())
{
return;
}
try
{
if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.m_owner == (Object)null)
{
return;
}
ItemData ammo = __instance.m_ammo;
if (ammo == null || ammo.m_shared == null)
{
return;
}
string name = ammo.m_shared.m_name;
if (!IsThrallArrow(name))
{
return;
}
GameObject val = Projectile.FindHitObject(collider);
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)("Unable find hit object for Projectile with collilder " + ((Object)collider).name));
return;
}
Character component = val.GetComponent<Character>();
if ((Object)(object)component == (Object)null || component.IsPlayer() || component.IsDead())
{
return;
}
if ((int)component.m_faction == 8)
{
((Character)Player.m_localPlayer).Message((MessageType)2, "Bosses cannot be charmed.", 0, (Sprite)null);
return;
}
if (!IsCharmed(component) && __m_allCharmedCharacters.Count >= 5)
{
((Character)Player.m_localPlayer).Message((MessageType)2, $"You already have {5} thralls.", 0, (Sprite)null);
return;
}
if ((Object)(object)__instance.m_owner != (Object)null && Object.op_Implicit((Object)(object)component))
{
__instance.m_owner.RaiseSkill(__instance.m_skill, __instance.m_raiseSkillAmount);
__instance.m_owner.AddAdrenaline(__instance.m_adrenaline);
}
bool wasCharmed = false;
if (IsCharmed(component))
{
CharmedCharacter charmedCharacter = GetCharmedCharacter(component);
if (charmedCharacter != null)
{
if (name.Contains("Wood"))
{
((Character)Player.m_localPlayer).Message((MessageType)2, "Thrall " + component.GetHoverName() + " released from bondage.", 0, (Sprite)null);
SetUncharmedState(charmedCharacter);
RemoveGUIDFromCharmedList(charmedCharacter.m_charmGUID);
ZNetScene.instance.Destroy(((Component)__instance).gameObject);
return;
}
charmedCharacter.m_charmExpireTime = __m_charmTimerSeconds + (long)GetCharmDuration();
wasCharmed = true;
}
}
else
{
AddToCharmedList(component, (long)GetCharmDuration());
}
ApplyGandrEffect(name, component, wasCharmed);
ZNetScene.instance.Destroy(((Component)__instance).gameObject);
}
catch (Exception arg)
{
Debug.LogError((object)$"[WoodArrowCharm] Error: {arg}");
}
}
}
public class SavedItemData
{
public string m_name;
public string m_description;
}
[HarmonyPatch(typeof(ObjectDB), "Awake")]
public static class ObjectDB_Awake_Patch
{
private static void Postfix(ObjectDB __instance)
{
if (IsPacifist() && (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null)
{
ChangeArrowsAndRecipes(__instance);
}
}
}
[HarmonyPatch(typeof(Player), "AddAdrenaline")]
public static class Player_AddAdrenaline_Patch
{
public static bool Prefix(Player __instance, ref float v)
{
if (!IsPacifist())
{
return true;
}
if (HasThrall())
{
if (v > 0f)
{
v *= 2f;
}
else
{
v *= 0.5f;
}
}
return true;
}
}
[HarmonyPatch(typeof(SEMan), "ModifyAdrenaline")]
public static class SEMan_ModifyAdrenaline_Patch
{
public static bool Prefix(SEMan __instance, float baseValue, ref float use)
{
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
if (!IsPacifist())
{
return true;
}
if ((Object)(object)__instance.m_character != (Object)(object)Player.m_localPlayer)
{
return true;
}
Player localPlayer = Player.m_localPlayer;
if (use > 0f)
{
use *= 2f;
if (localPlayer.m_adrenaline + use > localPlayer.m_maxAdrenaline)
{
bool flag = false;
StatusEffect val = null;
foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems())
{
if (allItem.m_equipped && (Object)(object)allItem.m_shared.m_fullAdrenalineSE != (Object)null)
{
flag = true;
val = allItem.m_shared.m_fullAdrenalineSE;
break;
}
}
foreach (CharmedCharacter _m_allCharmedCharacter in __m_allCharmedCharacters)
{
Character characterFromGUID = GetCharacterFromGUID(_m_allCharmedCharacter.m_charmGUID);
if (!Object.op_Implicit((Object)(object)characterFromGUID))
{
continue;
}
characterFromGUID.Heal(characterFromGUID.GetMaxHealth() - characterFromGUID.GetHealth(), true);
if (flag)
{
localPlayer.m_adrenalinePopEffects.Create(((Component)characterFromGUID).transform.position, Quaternion.identity, (Transform)null, 1f, -1);
StatusEffect statusEffect = characterFromGUID.m_seman.GetStatusEffect(val.m_nameHash);
if (Object.op_Implicit((Object)(object)statusEffect))
{
statusEffect.ResetTime();
}
else
{
characterFromGUID.m_seman.AddStatusEffect(val, false, 0, 0f);
}
}
else
{
localPlayer.m_adrenaline = 0f;
}
_m_allCharmedCharacter.m_charmLevel++;
Hud.instance.AdrenalineBarFlash();
((Character)Player.m_localPlayer).Message((MessageType)1, $"Thrall {characterFromGUID.GetHoverName()} reached Charm Level {_m_allCharmedCharacter.m_charmLevel}!", 0, (Sprite)null);
}
((Character)Player.m_localPlayer).Message((MessageType)2, "Your thralls grow stronger!", 0, (Sprite)null);
}
}
return true;
}
}
[HarmonyPatch(typeof(Attack), "ModifyDamage")]
public class Attack_ModifyDamage_Patch
{
public static bool Prefix(Attack __instance, HitData hitData, float damageFactor)
{
Character character = (Character)(object)__instance.m_character;
if (IsPacifist() && IsCharmed(character) && character != null && character.m_seman.GetStatusEffects().Count == 0)
{
CharmedCharacter charmedCharacter = GetCharmedCharacter(character);
if (charmedCharacter != null)
{
float adrenalineScalar = Player.m_localPlayer.GetAdrenaline() / ((Character)Player.m_localPlayer).GetMaxAdrenaline();
ScaleThrallOutgoingDamage(ref hitData, charmedCharacter.m_charmLevel, adrenalineScalar, 1.1f);
}
}
return true;
}
}
[HarmonyPatch(typeof(Character), "Damage")]
public class Character_Damage_Patch
{
public static bool Prefix(Character __instance, HitData hit)
{
if (IsPacifist() && IsCharmed(__instance) && __instance != null && __instance.m_seman.GetStatusEffects().Count == 0)
{
CharmedCharacter charmedCharacter = GetCharmedCharacter(__instance);
if (charmedCharacter != null)
{
float adrenalineScalar = Player.m_localPlayer.GetAdrenaline() / ((Character)Player.m_localPlayer).GetMaxAdrenaline();
ScaleThrallIncomingDamage(__instance, ref hit, charmedCharacter.m_charmLevel, adrenalineScalar, 0.7f);
}
}
return true;
}
}
public class GandrSEData
{
public Type m_type;
public float m_inflicted;
public float m_received;
public float m_typedDamage;
public string m_name;
public GandrSEData(Type type, float inflited, float received, float typedDamage, string name)
{
m_type = type;
m_inflicted = inflited;
m_received = received;
m_typedDamage = typedDamage;
m_name = name;
}
}
public class SE_GandrEffect : SE_Stats
{
public float m_adrenalineScalar = 0f;
public float m_baseDamageInflictedModifier = 1f;
public float m_baseDamageReceivedModifier = 1.2f;
public float m_baseTypedDamageModifier = 0.5f;
public float m_charmLevel = 1f;
public GandrSEData m_seData = null;
public override void Setup(Character character)
{
((SE_Stats)this).Setup(character);
((StatusEffect)this).m_ttl = 120f;
((StatusEffect)this).m_name = "Base Gandr Effect";
GandrArrowData gandrArrowData = __m_gandrArrowData.First((GandrArrowData a) => a.m_statusEffectType == ((object)this).GetType());
if (gandrArrowData != null)
{
((StatusEffect)this).m_icon = __m_cachedPacifistSprites[(int)gandrArrowData.m_spriteIndex].m_sprite;
}
GandrSEData gandrSEData = __m_gandrSEData.First((GandrSEData s) => s.m_type == ((object)this).GetType());
if (gandrSEData != null)
{
m_baseDamageInflictedModifier = gandrSEData.m_inflicted;
m_baseDamageReceivedModifier = gandrSEData.m_received;
m_baseTypedDamageModifier = gandrSEData.m_typedDamage;
((StatusEffect)this).m_name = gandrSEData.m_name;
((StatusEffect)this).m_nameHash = StringExtensionMethods.GetStableHashCode(((StatusEffect)this).m_name);
m_seData = gandrSEData;
}
}
public override void UpdateStatusEffect(float dt)
{
((SE_Stats)this).UpdateStatusEffect(dt);
CharmedCharacter charmedCharacter = GetCharmedCharacter(((StatusEffect)this).m_character);
if (charmedCharacter != null)
{
m_charmLevel = charmedCharacter.m_charmLevel;
}
Player localPlayer = Player.m_localPlayer;
if (localPlayer != null && ((Character)localPlayer).GetMaxAdrenaline() > 0f)
{
m_adrenalineScalar = Player.m_localPlayer.GetAdrenaline() / ((Character)Player.m_localPlayer).GetMaxAdrenaline();
}
else
{
m_adrenalineScalar = 0f;
}
}
public override void ModifyAttack(SkillType skill, ref HitData hitData)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
DamageTypes percentigeDamageModifiers = base.m_percentigeDamageModifiers;
float num = 0f;
((DamageTypes)(ref hitData.m_damage)).GetMajorityDamageType(ref num);
((DamageTypes)(ref percentigeDamageModifiers)).Modify(num * m_baseTypedDamageModifier);
((DamageTypes)(ref hitData.m_damage)).Add(percentigeDamageModifiers, 1);
ScaleThrallOutgoingDamage(ref hitData, m_charmLevel, base.m_adrenalineModifier, m_baseDamageInflictedModifier);
((SE_Stats)this).ModifyAttack(skill, ref hitData);
}
public override void OnDamaged(HitData hit, Character attacker)
{
((StatusEffect)this).OnDamaged(hit, attacker);
ScaleThrallIncomingDamage(((StatusEffect)this).m_character, ref hit, m_charmLevel, m_adrenalineScalar, m_baseDamageReceivedModifier);
}
public override void Stop()
{
((StatusEffect)this).Stop();
}
}
public class SE_GandrFlint : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_pierce = m_seData.m_typedDamage;
}
}
public class SE_GandrFire : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_fire = m_seData.m_typedDamage;
}
}
public class SE_GandrBronze : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_blunt = m_seData.m_typedDamage;
}
}
public class SE_GandrPoison : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_poison = m_seData.m_typedDamage;
}
}
public class SE_GandrIron : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_slash = m_seData.m_typedDamage;
}
}
public class SE_GandrFrost : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_frost = m_seData.m_typedDamage;
}
}
public class SE_GandrObsidian : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_slash = m_seData.m_typedDamage;
}
}
public class SE_GandrSilver : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_spirit = m_seData.m_typedDamage;
}
}
public class SE_GandrNeedle : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_pierce = m_seData.m_typedDamage;
}
}
public class SE_GandrCarapace : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_blunt = m_seData.m_typedDamage;
}
}
public class SE_GandrCharred : SE_GandrEffect
{
public override void Setup(Character character)
{
base.Setup(character);
((SE_Stats)this).m_percentigeDamageModifiers.m_lightning = m_seData.m_typedDamage;
}
}
[HarmonyPatch(typeof(EnemyHud), "UpdateHuds")]
public class EnemyHud_UpdateHud_Patch
{
public static void Postfix(EnemyHud __instance, Player player, Sadle sadle, float dt)
{
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
if (!IsPacifist())
{
return;
}
foreach (KeyValuePair<Character, HudData> hud in __instance.m_huds)
{
Character key = hud.Key;
if ((Object)(object)key == (Object)null)
{
continue;
}
HudData value = hud.Value;
Transform val = value.m_gui.transform.Find("Charm");
List<GameObject> list = new List<GameObject>();
for (int i = 0; i < MAX_NUM_CHARM_ICONS; i++)
{
object obj;
if (value == null)
{
obj = null;
}
else
{
GameObject gui = value.m_gui;
if (gui == null)
{
obj = null;
}
else
{
Transform obj2 = gui.transform.Find($"Charm/CharmIcon{i}");
obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
}
}
GameObject val2 = (GameObject)obj;
if (Object.op_Implicit((Object)(object)val2))
{
val2.SetActive(false);
list.Add(val2);
}
}
CharmedCharacter charmedCharacter = GetCharmedCharacter(key);
if (charmedCharacter == null)
{
if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeSelf)
{
((Component)val).gameObject.SetActive(false);
}
}
else
{
if (!IsCharmed(key))
{
continue;
}
if (Object.op_Implicit((Object)(object)val) && !((Component)val).gameObject.activeSelf)
{
((Component)val).gameObject.SetActive(true);
}
int num = 0;
List<StatusEffect> statusEffects = key.m_seman.m_statusEffects;
foreach (StatusEffect item in statusEffects)
{
if (!((Object)(object)item.m_icon == (Object)null))
{
GameObject val3 = list[num];
val3.gameObject.SetActive(true);
Image component = val3.GetComponent<Image>();
component.sprite = item.m_icon;
RectTransform component2 = val3.GetComponent<RectTransform>();
int num2 = 28;
component2.sizeDelta = new Vector2((float)num2, (float)num2);
((Transform)component2).localScale = Vector3.one;
float num3 = 1f;
float num4 = ((float)num2 + num3) * (float)(statusEffects.Count - 1) / 2f;
float num5 = ((float)num2 + num3) * (float)num;
component2.anchoredPosition = new Vector2(0f - num4 + num5, (float)(-num2 / 2 - 1));
num++;
}
}
GuiBar component3 = ((Component)value.m_gui.transform.Find("Charm/CharmBar")).GetComponent<GuiBar>();
float num6 = charmedCharacter.m_charmExpireTime - __m_charmTimerSeconds;
component3.SetWidth(100f);
component3.SetValue(num6 / GetCharmDuration());
component3.SetColor(__m_pinkColor);
GameObject gameObject = ((Component)value.m_gui.transform.Find("Charm/CharmLevelText")).gameObject;
TextMeshProUGUI component4 = gameObject.GetComponent<TextMeshProUGUI>();
((TMP_Text)component4).text = $"{charmedCharacter.m_charmLevel}";
}
}
}
}
[HarmonyPatch(typeof(EnemyHud), "Awake")]
public class EnemyHud_Awake_Patch
{
public static void Postfix(EnemyHud __instance)
{
//IL_0048: 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)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Expected O, but got Unknown
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
Transform val = __instance.m_baseHud.transform.Find("Health");
GameObject gameObject = ((Component)val).gameObject;
GameObject val2 = Object.Instantiate<GameObject>(gameObject, val.parent);
((Object)val2).name = "Charm";
val2.SetActive(false);
Transform transform = val2.transform;
transform.localPosition += new Vector3(0f, -10f, 0f);
Transform val3 = transform.Find("health_fast");
if ((Object)(object)val3 != (Object)null)
{
Object.Destroy((Object)(object)((Component)val3).gameObject);
}
Transform val4 = transform.Find("health_slow");
if ((Object)(object)val4 != (Object)null)
{
Object.Destroy((Object)(object)((Component)val4).gameObject);
}
Transform val5 = transform.Find("health_fast_friendly");
((Object)val5).name = "CharmBar";
object obj;
if (val5 == null)
{
obj = null;
}
else
{
GameObject gameObject2 = ((Component)val5).gameObject;
obj = ((gameObject2 != null) ? gameObject2.GetComponent<GuiBar>() : null);
}
GuiBar val6 = (GuiBar)obj;
CreateCharmIconsInMasterHud(val2.transform);
GameObject val7 = new GameObject("CharmLevelText");
val7.transform.SetParent(val2.transform);
RectTransform val8 = val7.AddComponent<RectTransform>();
val8.sizeDelta = new Vector2(20f, 20f);
((Transform)val8).localScale = Vector3.one;
((Transform)val8).localPosition = Vector2.op_Implicit(Vector2.zero);
TextMeshProUGUI val9 = AddTextMeshProComponent(val7);
((TMP_Text)val9).text = "X";
((TMP_Text)val9).fontSize = 13f;
((TMP_Text)val9).fontStyle = (FontStyles)1;
((Graphic)val9).color = Color.white;
((Graphic)val9).raycastTarget = false;
((TMP_Text)val9).fontMaterial.EnableKeyword("OUTLINE_ON");
((TMP_Text)val9).outlineColor = Color32.op_Implicit(Color.black);
((TMP_Text)val9).outlineWidth = 0.125f;
((TMP_Text)val9).verticalAlignment = (VerticalAlignmentOptions)512;
((TMP_Text)val9).horizontalAlignment = (HorizontalAlignmentOptions)2;
}
}
public class CachedSprite
{
public GandrTypeIndex m_index;
public string m_name;
public Sprite m_sprite;
public CachedSprite(GandrTypeIndex index, string name, Sprite sprite)
{
m_index = index;
m_name = name;
m_sprite = sprite;
}
}
public enum GandrTypeIndex
{
Wood,
Flint,
Fire,
Bronze,
Poison,
Iron,
Frost,
Obsidian,
Silver,
Needle,
Carapace,
Charred
}
[HarmonyPatch(typeof(ZoneSystem), "SetupLocations")]
public static class ZoneSystem_SetupLocations_Patch
{
public static void Postfix(ZoneSystem __instance)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
if (!IsPacifist())
{
return;
}
if ((Object)(object)ZNetScene.instance == (Object)null)
{
Debug.LogWarning((object)"[MyMod] ZNetScene not loaded when SetupLocations patched.");
return;
}
List<ZoneLocation> locations = __instance.m_locations;
if (locations == null)
{
return;
}
foreach (ZoneLocation item in locations)
{
if (item != null)
{
float num = 1.5f;
if (((Enum)item.m_biome).HasFlag((Enum)(object)(Biome)1) && item.m_prefabName.Contains("Runestone_Boars"))
{
num = 10f;
}
if (((Enum)item.m_biome).HasFlag((Enum)(object)(Biome)8))
{
}
if (((Enum)item.m_biome).HasFlag((Enum)(object)(Biome)2))
{
}
if (((Enum)item.m_biome).HasFlag((Enum)(object)(Biome)4))
{
}
if (((Enum)item.m_biome).HasFlag((Enum)(object)(Biome)16))
{
}
if (((Enum)item.m_biome).HasFlag((Enum)(object)(Biome)512))
{
}
if (((Enum)item.m_biome).HasFlag((Enum)(object)(Biome)32))
{
}
if (((Enum)item.m_biome).HasFlag((Enum)(object)(Biome)64))
{
}
if (item.m_quantity > 1)
{
item.m_quantity = Mathf.RoundToInt((float)item.m_quantity * num);
}
if (item.m_minDistance > 0f && item.m_maxDistance > 0f)
{
item.m_minDistance = Mathf.Max(10f, item.m_minDistance * (1f / num));
item.m_maxDistance = Mathf.Max(10f, item.m_maxDistance * (1f / num));
}
if (item.m_minDistanceFromSimilar > 0f)
{
item.m_minDistanceFromSimilar /= num;
}
}
}
}
}
public class BackupSpawnData
{
public float m_spawnChance;
public int m_maxSpawned;
public float m_spawnInterval;
public float m_spawnRadiusMin;
public float m_spawnRadiusMax;
public float m_spawnDistance;
}
public class SpawnModifierData
{
public float m_chance = 1.1f;
public float m_max = 2f;
public float m_interval = 0.9f;
public float m_minRadius = 0f;
public float m_maxRadius = 0f;
public float m_distance = 0.85f;
}
[HarmonyPatch(typeof(SpawnSystem), "OnDestroy")]
public static class SpawnSystem_OnDestroy_Patch
{
public static void Postfix(SpawnSystem __instance)
{
if (IsPacifist() && --__m_spawnListsPatched < 1)
{
DoRestoreSpawnData(__m_originalSpawnData, ref __instance.m_spawnLists);
}
}
}
[HarmonyPatch(typeof(SpawnSystem), "Awake")]
public static class SpawnSystem_Awake_Patch
{
public static void Postfix(SpawnSystem __instance)
{
if (!IsPacifist() || (Object)(object)__instance == (Object)null || __m_spawnListsPatched++ != 0)
{
return;
}
DoBackupSpawnData(__instance.m_spawnLists, ref __m_originalSpawnData);
foreach (SpawnSystemList spawnList in __instance.m_spawnLists)
{
foreach (SpawnData spawner in spawnList.m_spawners)
{
if (spawner != null)
{
if (__m_spawnMultipliers.TryGetValue(((Object)spawner.m_prefab).name, out var value))
{
spawner.m_spawnChance = Math.Min(spawner.m_spawnChance * value.m_chance, 100f);
spawner.m_maxSpawned = (int)Math.Max((float)spawner.m_maxSpawned * value.m_max, 1f);
spawner.m_spawnInterval = Math.Max(1f, spawner.m_spawnInterval * value.m_interval);
spawner.m_spawnRadiusMin = value.m_minRadius;
spawner.m_spawnRadiusMax = value.m_maxRadius;
spawner.m_spawnDistance = Math.Max(1f, spawner.m_spawnDistance * value.m_distance);
}
else
{
Debug.LogWarning((object)("Did not find spawn modifier for " + ((Object)spawner.m_prefab).name));
}
}
}
}
}
}
[HarmonyPatch(typeof(SpawnSystem), "UpdateSpawning")]
public static class SpawnSystem_UpdateSpawning_Patch
{
public static bool Prefix(SpawnSystem __instance)
{
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
if (!IsPacifist())
{
return true;
}
if ((Object)(object)__instance == (Object)null)
{
return true;
}
if ((Object)(object)Player.m_localPlayer == (Object)null)
{
return true;
}
foreach (SpawnSystemList spawnList in __instance.m_spawnLists)
{
if ((Object)(object)spawnList == (Object)null)
{
continue;
}
foreach (SpawnData spawner in spawnList.m_spawners)
{
if (spawner != null)
{
Biome currentBiome = Player.m_localPlayer.GetCurrentBiome();
if (currentBiome == spawner.m_biome)
{
spawner.m_maxSpawned = Math.Max(2, __m_allCharmedCharacters.Count + 1);
}
}
}
}
return true;
}
}
[HarmonyPatch(typeof(Player), "OnSpawned")]
public class Player_OnSpawned_Patch
{
private static void Postfix(Player __instance)
{
if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
{
return;
}
CacheSprites();
DoPacifistPostPlayerSpawnTasks();
if ((Object)(object)__m_thrallsWindowObject == (Object)null)
{
Transform val = ((Component)Hud.instance).transform.Find("hudroot/healthpanel");
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)"Health panel transform not found.");
return;
}
CreateThrallsWindow(val);
}
StartCharmTimer();
UpdateModUI(Player.m_localPlayer);
}
}
[HarmonyPatch(typeof(FejdStartup), "Start")]
public class FejdStartup_Start_Patch
{
private static void Postfix()
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Menu");
if ((Object)(object)val != (Object)null)
{
GameObject val2 = GameObject.Find("Topic");
TextMeshProUGUI val3 = ((val2 != null) ? val2.GetComponent<TextMeshProUGUI>() : null);
__m_globalFontObject = ((TMP_Text)val3).font;
Transform val4 = val.transform.Find("Logo");
if ((Object)(object)val4 != (Object)null)
{
GameObject val5 = new GameObject("PacifistModLogoText");
val5.transform.SetParent(val4.parent);
RectTransform val6 = val5.AddComponent<RectTransform>();
((Transform)val6).localScale = Vector3.one;
val6.anchorMin = new Vector2(0f, 0f);
val6.anchorMax = new Vector2(1f, 1f);
val6.pivot = new Vector2(1f, 1f);
val6.anchoredPosition = new Vector2(0f, 300f);
val6.sizeDelta = new Vector2(0f, 0f);
val6.offsetMax = new Vector2(0f, 0f);
val6.offsetMin = new Vector2(0f, 0f);
__m_pacifistMainMenuText = AddTextMeshProComponent(val5);
((TMP_Text)__m_pacifistMainMenuText).font = __m_globalFontObject;
((TMP_Text)__m_pacifistMainMenuText).fontMaterial = ((TMP_Asset)__m_globalFontObject).material;
((TMP_Text)__m_pacifistMainMenuText).fontStyle = (FontStyles)1;
((Graphic)__m_pacifistMainMenuText).raycastTarget = false;
((TMP_Text)__m_pacifistMainMenuText).text = "<color=#F387C5><size=64>Pacifist</size></color><size=20>\nVersion 0.1.0</size><size=32>\n\ud83d\udd4a\ufe0f <color=yellow>You may not directly cause harm.</color> \ud83d\udd4a\ufe0f\n</size><size=28>→ <color=#FFFF0050>Use arrows to charm enemies.</color> ←\n→ <color=#FFFF0050>Your Thralls fight for you.</color> ←\n→ <color=#FFFF0050>Buff them with upgraded arrows.</color> ←\n→ <color=#FFFF0050>Level your thralls with Adrenaline.</color> ←\n→ <color=#FFFF0050>Defeat the forsaken without lifting a sword.</color> ←</size>";
((TMP_Text)__m_pacifistMainMenuText).alignment = (TextAlignmentOptions)514;
((TMP_Text)__m_pacifistMainMenuText).lineSpacingAdjustment = -5f;
}
else
{
Debug.LogWarning((object)"Valheim logo not found!");
}
}
else
{
Debug.LogWarning((object)"Main menu not found!");
}
}
}
public static bool __m_charmTimerStarted = false;
private static List<CharmedCharacter> __m_allCharmedCharacters = new List<CharmedCharacter>();
private const float TROPHY_PACIFIST_CHARM_DURATION = 300f;
public const float cFollowDistance = 3f;
public const float cRadiusScale = 2f;
public const float PACIFIST_THRALL_PLAYER_TARGET_DISTANCE = 50f;
public static bool __m_showCharmList = false;
public static Color __m_pinkColor = new Color(0.95f, 0.53f, 0.77f);
public const int MAX_NUM_THRALLS = 5;
public static GandrArrowData[] __m_gandrArrowData = new GandrArrowData[12]
{
new GandrArrowData("ArrowWood", "Wood", "Wooden Gandr", " is under your thrall.", null, GandrTypeIndex.Wood),
new GandrArrowData("ArrowFlint", "Flint", "Flint Gandr", " thrall is piercing.", typeof(SE_GandrFlint), GandrTypeIndex.Flint),
new GandrArrowData("ArrowFire", "Resin", "Fire Gandr", " thrall channels fire.", typeof(SE_GandrFire), GandrTypeIndex.Fire),
new GandrArrowData("ArrowBronze", "Bronze", "Bronze Gandr", " thrall is blunt.", typeof(SE_GandrBronze), GandrTypeIndex.Bronze),
new GandrArrowData("ArrowPoison", "Ooze", "Poison Gandr", " thrall channels poison.", typeof(SE_GandrPoison), GandrTypeIndex.Poison),
new GandrArrowData("ArrowIron", "Iron", "Iron Gandr", " thrall is sharp.", typeof(SE_GandrIron), GandrTypeIndex.Iron),
new GandrArrowData("ArrowFrost", "FreezeGland", "Frost Gandr", " thrall channels frost.", typeof(SE_GandrFrost), GandrTypeIndex.Frost),
new GandrArrowData("ArrowObsidian", "Obsidian", "Glass Gandr", " thrall is very sharp.", typeof(SE_GandrObsidian), GandrTypeIndex.Obsidian),
new GandrArrowData("ArrowSilver", "Silver", "Silver Gandr", " thrall channels spirit.", typeof(SE_GandrSilver), GandrTypeIndex.Silver),
new GandrArrowData("ArrowNeedle", "Needle", "Needle Gandr", " thrall is very piercing.", typeof(SE_GandrNeedle), GandrTypeIndex.Needle),
new GandrArrowData("ArrowCarapace", "Carapace", "Bug Gandr", " thrall is very blunt.", typeof(SE_GandrCarapace), GandrTypeIndex.Carapace),
new GandrArrowData("ArrowCharred", "Blackwood", "Charred Gandr", " thrall channels lightning.", typeof(SE_GandrCharred), GandrTypeIndex.Charred)
};
public static long __m_charmTimerSeconds = 0L;
public static Dictionary<string, SavedItemData> __m_originalArrows = new Dictionary<string, SavedItemData>();
public static Dictionary<string, Recipe> __m_originalArrowRecipes = new Dictionary<string, Recipe>();
public const float DEFAULT_THRALL_INCOMING_DAMAGE_SCALAR = 0.7f;
public const float DEFAULT_THRALL_OUTGOING_DAMAGE_SCALAR = 1.1f;
public static GandrSEData[] __m_gandrSEData = new GandrSEData[11]
{
new GandrSEData(typeof(SE_GandrFlint), 1.1f, 0.7f, 0.5f, "Flint Gandr"),
new GandrSEData(typeof(SE_GandrFire), 1.2f, 0.65f, 0.6f, "Fire Gandr"),
new GandrSEData(typeof(SE_GandrBronze), 1.3f, 0.6f, 0.7f, "Bronze Gandr"),
new GandrSEData(typeof(SE_GandrPoison), 1.4f, 0.55f, 0.8f, "Poison Gandr"),
new GandrSEData(typeof(SE_GandrIron), 1.5f, 0.5f, 0.9f, "Iron Gandr"),
new GandrSEData(typeof(SE_GandrFrost), 1.6f, 0.45f, 1f, "Frost Gandr"),
new GandrSEData(typeof(SE_GandrObsidian), 1.7f, 0.4f, 1.1f, "Glass Gandr"),
new GandrSEData(typeof(SE_GandrSilver), 1.8f, 0.35f, 1.2f, "Silver Gandr"),
new GandrSEData(typeof(SE_GandrNeedle), 1.9f, 0.3f, 1.3f, "Needle Gandr"),
new GandrSEData(typeof(SE_GandrCarapace), 2f, 0.25f, 1.4f, "Bug Gandr"),
new GandrSEData(typeof(SE_GandrCharred), 2.5f, 0.2f, 1.5f, "Charred Gandr")
};
public static int MAX_NUM_CHARM_ICONS = 16;
private static CachedSprite[] __m_cachedPacifistSprites = new CachedSprite[12]
{
new CachedSprite(GandrTypeIndex.Wood, "T_emote_flex", null),
new CachedSprite(GandrTypeIndex.Flint, "SpearFlint", null),
new CachedSprite(GandrTypeIndex.Fire, "Burning", null),
new CachedSprite(GandrTypeIndex.Bronze, "MaceBronze", null),
new CachedSprite(GandrTypeIndex.Poison, "Poison", null),
new CachedSprite(GandrTypeIndex.Iron, "SwordIron", null),
new CachedSprite(GandrTypeIndex.Frost, "Frost", null),
new CachedSprite(GandrTypeIndex.Obsidian, "ArrowObsidian", null),
new CachedSprite(GandrTypeIndex.Silver, "SwordMistwalker", null),
new CachedSprite(GandrTypeIndex.Needle, "needle", null),
new CachedSprite(GandrTypeIndex.Carapace, "MaceIron", null),
new CachedSprite(GandrTypeIndex.Charred, "Lightning", null)
};
public static Dictionary<string, SpawnModifierData> __m_spawnMultipliers = new Dictionary<string, SpawnModifierData>
{
{
"Abomination",
new SpawnModifierData()
},
{
"Asksvin",
new SpawnModifierData()
},
{
"Bjorn",
new SpawnModifierData()
},
{
"Blob",
new SpawnModifierData()
},
{
"BlobElite",
new SpawnModifierData()
},
{
"BlobLava",
new SpawnModifierData()
},
{
"Boar",
new SpawnModifierData
{
m_chance = 4f,
m_max = 8f,
m_interval = 0.25f,
m_distance = 0.1f
}
},
{
"BonemawSerpent",
new SpawnModifierData()
},
{
"Charred_Archer",
new SpawnModifierData()
},
{
"Charred_Melee",
new SpawnModifierData()
},
{
"Charred_Twitcher",
new SpawnModifierData()
},
{
"CinderSky",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"CinderStorm",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Deathsquito",
new SpawnModifierData()
},
{
"Deer",
new SpawnModifierData
{
m_chance = 1.2f,
m_max = 3f,
m_interval = 1f,
m_distance = 0.75f
}
},
{
"Draugr",
new SpawnModifierData()
},
{
"Draugr_Elite",
new SpawnModifierData()
},
{
"Dverger",
new SpawnModifierData()
},
{
"DvergerAshlands",
new SpawnModifierData()
},
{
"FallenValkyrie",
new SpawnModifierData()
},
{
"Fenring",
new SpawnModifierData()
},
{
"FireFlies",
new SpawnModifierData()
},
{
"Fish1",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish10",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish11",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish12",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish2",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish3",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish5",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish6",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish7",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish8",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Fish9",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Gjall",
new SpawnModifierData()
},
{
"Goblin",
new SpawnModifierData()
},
{
"GoblinBrute",
new SpawnModifierData()
},
{
"Greydwarf",
new SpawnModifierData()
},
{
"Greydwarf_Elite",
new SpawnModifierData()
},
{
"Greydwarf_Shaman",
new SpawnModifierData()
},
{
"Greyling",
new SpawnModifierData
{
m_chance = 3f,
m_max = 4f,
m_interval = 0.5f,
m_distance = 0.3f
}
},
{
"Hare",
new SpawnModifierData()
},
{
"Hatchling",
new SpawnModifierData()
},
{
"LavaRock",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Leech",
new SpawnModifierData()
},
{
"Lox",
new SpawnModifierData()
},
{
"Morgen_NonSleeping",
new SpawnModifierData()
},
{
"Neck",
new SpawnModifierData
{
m_chance = 2f,
m_max = 4f,
m_interval = 0.5f,
m_distance = 0.5f
}
},
{
"Seagal",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"Seeker",
new SpawnModifierData()
},
{
"SeekerBrood",
new SpawnModifierData()
},
{
"SeekerBrute",
new SpawnModifierData()
},
{
"Serpent",
new SpawnModifierData()
},
{
"Skeleton",
new SpawnModifierData()
},
{
"StoneGolem",
new SpawnModifierData()
},
{
"Surtling",
new SpawnModifierData()
},
{
"Tick",
new SpawnModifierData()
},
{
"Troll",
new SpawnModifierData()
},
{
"Unbjorn",
new SpawnModifierData()
},
{
"Volture",
new SpawnModifierData()
},
{
"Wolf",
new SpawnModifierData()
},
{
"Wraith",
new SpawnModifierData()
},
{
"odin",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
},
{
"projectile_ashlandmeteor",
new SpawnModifierData
{
m_chance = 1f,
m_max = 1f,
m_interval = 1f,
m_distance = 1f
}
}
};
public static int __m_spawnListsPatched = 0;
public static Dictionary<int, Dictionary<int, BackupSpawnData>> __m_originalSpawnData = new Dictionary<int, Dictionary<int, BackupSpawnData>>();
public const string PluginGUID = "com.oathorse.Pacifist";
public const string PluginName = "Pacifist";
public const string PluginVersion = "0.1.0";
private readonly Harmony harmony = new Harmony("com.oathorse.Pacifist");
public const float CHARMED_ENEMY_SPEED_MULTIPLIER = 3f;
private static TMP_FontAsset __m_globalFontObject = null;
public static TrophyHuntMod __m_trophyHuntMod;
private static GameObject __m_thrallsWindowObject = null;
private static GameObject __m_thrallsWindowBackground = null;
private static TextMeshProUGUI __m_thrallsWindowText = null;
private static Vector2 __m_thrallsTooltipWindowSize = new Vector2(410f, 170f);
private static Vector2 __m_thrallsTooltipTextOffset = new Vector2(5f, 2f);
public static TextMeshProUGUI __m_pacifistMainMenuText = null;
public static bool IsThrallArrow(string ammoName)
{
if (ammoName.ToLower().Contains("Gandr".ToLower()))
{
return true;
}
return false;
}
public static bool HasThrall()
{
if (!IsPacifist())
{
return false;
}
return __m_allCharmedCharacters.Count > 0;
}
public static float GetCharmDuration()
{
Random random = new Random();
return 300f;
}
public static Guid GetGUIDFromCharacter(Character character)
{
if ((Object)(object)character == (Object)null)
{
return Guid.Empty;
}
ZNetView component = ((Component)character).GetComponent<ZNetView>();
ZDO val = ((component != null) ? component.GetZDO() : null);
if (val == null)
{
return Guid.Empty;
}
string @string = val.GetString("CharmGUID", "");
Guid result = Guid.Empty;
Guid.TryParse(@string, out result);
return result;
}
public static Character GetCharacterFromGUID(Guid guid)
{
List<Character> allCharacters = Character.GetAllCharacters();
foreach (Character item in allCharacters)
{
ZNetView component = ((Component)item).GetComponent<ZNetView>();
ZDO val = ((component != null) ? component.GetZDO() : null);
if (val != null)
{
string @string = val.GetString("CharmGUID", "");
Guid result = Guid.Empty;
Guid.TryParse(@string, out result);
if (result == guid)
{
return item;
}
}
}
return null;
}
public static void SetNonTrinketAdrenaline()
{
if (((Humanoid)(Player.m_localPlayer?)).m_trinketItem == null && __m_allCharmedCharacters != null && __m_allCharmedCharacters.Count > 0 && Player.m_localPlayer.m_maxAdrenaline == 0f)
{
Player.m_localPlayer.m_maxAdrenaline = 30f;
Player.m_localPlayer.m_adrenaline = 0f;
}
}
public static void DoPacifistPostPlayerSpawnTasks()
{
if (!IsPacifist() || !Object.op_Implicit((Object)(object)Player.m_localPlayer))
{
return;
}
foreach (CharmedCharacter _m_allCharmedCharacter in __m_allCharmedCharacters)
{
if (_m_allCharmedCharacter != null)
{
SetCharmedState(_m_allCharmedCharacter, playParticleEffect: false);
}
}
SetNonTrinketAdrenaline();
}
public static bool IsCharmed(Character character)
{
Guid cGUID = GetGUIDFromCharacter(character);
CharmedCharacter charmedCharacter = __m_allCharmedCharacters.Find((CharmedCharacter c) => c.m_charmGUID == cGUID);
return charmedCharacter != null;
}
public static CharmedCharacter GetCharmedCharacter(Character character)
{
Guid cGUID = GetGUIDFromCharacter(character);
return __m_allCharmedCharacters.Find((CharmedCharacter c) => c.m_charmGUID == cGUID);
}
public static void AddToCharmedList(Character enemy, long duration)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
CharmedCharacter charmedCharacter = new CharmedCharacter();
ZDO zDO = ((Component)enemy).GetComponent<ZNetView>().GetZDO();
Guid charmGUID = Guid.NewGuid();
zDO.Set("CharmGUID", charmGUID.ToString());
zDO.Persistent = true;
charmedCharacter.m_charmGUID = charmGUID;
charmedCharacter.m_pin = Minimap.instance.AddPin(((Component)enemy).transform.position, (PinType)3, "", false, false, 0L, default(PlatformUserID));
charmedCharacter.m_originalFaction = enemy.m_faction;
charmedCharacter.m_charmExpireTime = __m_charmTimerSeconds + duration;
charmedCharacter.m_swimSpeed = enemy.m_swimSpeed;
__m_allCharmedCharacters.Add(charmedCharacter);
SetCharmedState(charmedCharacter);
UpdateModUI(Player.m_localPlayer);
}
public static void RemoveFromCharmedList(CharmedCharacter cc)
{
if (cc != null)
{
RemoveGUIDFromCharmedList(cc.m_charmGUID);
}
}
public static void RemoveFromCharmedList(Character enemy)
{
if (!((Object)(object)enemy == (Object)null))
{
ZDO zDO = ((Component)enemy).GetComponent<ZNetView>().GetZDO();
string @string = zDO.GetString("CharmGUID", "");
Guid guid = Guid.Parse(@string);
RemoveGUIDFromCharmedList(guid);
}
}
public static void RemoveGUIDFromCharmedList(Guid guid)
{
CharmedCharacter charmedCharacter = __m_allCharmedCharacters.Find((CharmedCharacter c) => c.m_charmGUID == guid);
if (charmedCharacter != null)
{
Minimap.instance.RemovePin(charmedCharacter.m_pin);
__m_allCharmedCharacters.Remove(charmedCharacter);
}
if (__m_allCharmedCharacters.Count < 1 && (Object)(object)Player.m_localPlayer != (Object)null)
{
Player.m_localPlayer.m_maxAdrenaline = 0f;
Player.m_localPlayer.m_adrenaline = 0f;
}
UpdateModUI(Player.m_localPlayer);
}
public static bool SetCharmedState(CharmedCharacter cc, bool playParticleEffect = true)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
CharmedCharacter charmedCharacter = __m_allCharmedCharacters.Find((CharmedCharacter c) => c.m_charmGUID == cc.m_charmGUID);
if (charmedCharacter != null)
{
Character characterFromGUID = GetCharacterFromGUID(charmedCharacter.m_charmGUID);
if ((Object)(object)characterFromGUID == (Object)null)
{
Debug.LogWarning((object)("Unable to SetCharmedState for GUID " + charmedCharacter.m_charmGUID.ToString() + " - character not found!"));
return false;
}
characterFromGUID.m_faction = (Faction)0;
characterFromGUID.m_swimSpeed *= 10f;
AddCharmEffect(characterFromGUID, playParticleEffect);
MonsterAI component = ((Component)characterFromGUID).GetComponent<MonsterAI>();
if (Object.op_Implicit((Object)(object)component))
{
if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)((Component)Player.m_localPlayer).gameObject != (Object)null)
{
component.SetFollowTarget(((Component)Player.m_localPlayer).gameObject);
}
component.m_attackPlayerObjects = false;
component.m_fleeIfNotAlerted = false;
component.m_fleeIfLowHealth = 0f;
component.m_fleeIfHurtWhenTargetCantBeReached = false;
((BaseAI)component).m_afraidOfFire = false;
((BaseAI)component).m_avoidFire = false;
component.m_avoidLand = false;
((BaseAI)component).m_avoidWater = true;
component.m_circulateWhileCharging = false;
component.m_circleTargetInterval = 0f;
((BaseAI)component).m_passiveAggresive = true;
((BaseAI)component).m_character.m_group = "";
((BaseAI)component).SetHuntPlayer(false);
component.SetTarget(((BaseAI)component).FindEnemy());
((BaseAI)component).SetTargetInfo(ZDOID.None);
((BaseAI)component).SetAlerted(true);
component.SetDespawnInDay(false);
}
}
SetNonTrinketAdrenaline();
return true;
}
public static void SetUncharmedState(CharmedCharacter cc)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
Character characterFromGUID = GetCharacterFromGUID(cc.m_charmGUID);
if (!Object.op_Implicit((Object)(object)characterFromGUID))
{
Debug.LogError((object)("Unable to SetUncharmedState for GUID " + cc.m_charmGUID.ToString() + " - character not found!"));
return;
}
RemoveCharmEffect(characterFromGUID);
characterFromGUID.m_faction = cc.m_originalFaction;
characterFromGUID.m_swimSpeed = cc.m_swimSpeed;
MonsterAI component = ((Component)characterFromGUID).GetComponent<MonsterAI>();
if (Object.op_Implicit((Object)(object)component))
{
component.SetFollowTarget((GameObject)null);
component.SetTarget((Character)null);
}
}
public static void StartCharmTimer()
{
if (!__m_charmTimerStarted)
{
__m_charmTimerStarted = true;
((MonoBehaviour)__m_trophyHuntMod).StartCoroutine(CharmTimerUpdate());
}
}
public static void StopCharmTimer()
{
__m_charmTimerStarted = false;
}
private static IEnumerator CharmTimerUpdate()
{
while (__m_charmTimerStarted)
{
__m_charmTimerSeconds++;
if (__m_showCharmList)
{
Debug.LogWarning((object)$"Charm List: {__m_allCharmedCharacters.Count} Timer: {__m_charmTimerSeconds}");
for (int i = 0; i < __m_allCharmedCharacters.Count; i++)
{
CharmedCharacter cc = __m_allCharmedCharacters[i];
Debug.LogWarning((object)$" Charm {i}: GUID {cc.m_charmGUID.ToString()} ExpireTime: {cc.m_charmExpireTime} Orig Faction: {cc.m_originalFaction}");
Character character = GetCharacterFromGUID(cc.m_charmGUID);
if (!((Object)(object)character != (Object)null))
{
continue;
}
foreach (StatusEffect statusEffect in character.m_seman.GetStatusEffects())
{
Debug.LogWarning((object)$" Status Effect: {statusEffect.m_name} TTL: {statusEffect.m_ttl}");
}
}
}
if (__m_allCharmedCharacters.Count > 0)
{
ShowThrallsWindow(__m_thrallsWindowObject);
}
else
{
HideThrallsWindow();
}
CharmedCharacter toRemove = null;
foreach (CharmedCharacter cc2 in __m_allCharmedCharacters)
{
if ((Object)(object)Minimap.instance != (Object)null)
{
Minimap.instance.RemovePin(cc2.m_pin);
}
if (__m_charmTimerSeconds >= cc2.m_charmExpireTime)
{
toRemove = cc2;
break;
}
Character target2 = GetCharacterFromGUID(cc2.m_charmGUID);
if (Object.op_Implicit((Object)(object)target2))
{
cc2.m_pin = Minimap.instance.AddPin(((Component)target2).transform.position, (PinType)3, "", false, false, 0L, default(PlatformUserID));
DarkenThrall(target2);
}
}
if (toRemove != null)
{
SetUncharmedState(toRemove);
if ((Object)(object)Minimap.instance != (Object)null)
{
Minimap.instance.RemovePin(toRemove.m_pin);
}
Character target = GetCharacterFromGUID(toRemove.m_charmGUID);
if (Object.op_Implicit((Object)(object)target))
{
((Character)Player.m_localPlayer).Message((MessageType)2, ((target != null) ? target.GetHoverName() : null) + " is no longer yours.", 0, (Sprite)null);
}
else
{
Debug.LogWarning((object)("Target to uncharm not found for Guid " + toRemove.m_charmGUID));
}
RemoveFromCharmedList(toRemove);
}
yield return (object)new WaitForSeconds(1f);
}
}
public static void DarkenThrall(Character target)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
Renderer[] componentsInChildren = ((Component)target).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
Material[] materials = val.materials;
foreach (Material val2 in materials)
{
if (val2.HasProperty("_Color"))
{
val2.color = new Color(0f, 0f, 0f, 1f);
}
}
}
}
public static void LightenThrall(Character target)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
Renderer[] componentsInChildren = ((Component)target).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
Material[] materials = val.materials;
foreach (Material val2 in materials)
{
if (val2.HasProperty("_Color"))
{
val2.color = Color.white;
}
}
}
}
public static void AddCharmEffect(Character target, bool particleEffect = true)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//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)
DarkenThrall(target);
if (!particleEffect)
{
return;
}
GameObject prefab = ZNetScene.instance.GetPrefab("fx_hen_love");
if ((Object)(object)prefab != (Object)null)
{
GameObject val = Object.Instantiate<GameObject>(prefab, ((Component)target).transform.position, Quaternion.identity);
ParticleSystem componentInChildren = val.GetComponentInChildren<ParticleSystem>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.Stop();
MainModule main = componentInChildren.main;
((MainModule)(ref main)).startColor = new MinMaxGradient(__m_pinkColor);
componentInChildren.Play();
}
}
else
{
Debug.LogWarning((object)"[heartVFX] not found.");
}
}
private static void RemoveCharmEffect(Character target)
{
LightenThrall(target);
}
public static void ChangeArrow(ObjectDB db, string prefabName, string ingredient, string newName, string newDescription)
{
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Expected O, but got Unknown
GameObject itemPrefab = db.GetItemPrefab(prefabName);
if (!Object.op_Implicit((Object)(object)itemPrefab))
{
Debug.LogError((object)("Could not find " + prefabName));
return;
}
ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
if (!Object.op_Implicit((Object)(object)component))
{
Debug.LogError((object)("Could not find ItemDrop on " + prefabName));
return;
}
SavedItemData savedItemData = new SavedItemData();
savedItemData.m_name = component.m_itemData.m_shared.m_name;
savedItemData.m_description = component.m_itemData.m_shared.m_description;
if (!__m_originalArrows.ContainsKey(prefabName))
{
__m_originalArrows[prefabName] = savedItemData;
}
component.m_itemData.m_shared.m_description = newDescription;
component.m_itemData.m_shared.m_name = newName;
Recipe val = db.m_recipes.Find((Recipe r) => ((Object)r).name == "Recipe_" + prefabName);
if (Object.op_Implicit((Object)(object)val))
{
__m_originalArrowRecipes[prefabName] = val;
db.m_recipes.Remove(val);
Recipe val2 = Object.Instantiate<Recipe>(val);
val2.m_item = component;
val2.m_amount = 20;
val2.m_enabled = true;
if (prefabName == "ArrowWood")
{
val2.m_craftingStation = null;
val2.m_minStationLevel = 0;
}
val2.m_resources = (Requirement[])(object)new Requirement[1]
{
new Requirement
{
m_resItem = db.GetItemPrefab(ingredient).GetComponent<ItemDrop>(),
m_amount = 1,
m_amountPerLevel = 0
}
};
db.m_recipes.Add(val2);
}
else
{
Debug.LogError((object)("Could not find Recipe_" + prefabName));
}
}
public static void RestoreArrow(ObjectDB db, string prefabName)
{
if (__m_originalArrows.ContainsKey(prefabName))
{
GameObject itemPrefab = db.GetItemPrefab(prefabName);
if (Object.op_Implicit((Object)(object)itemPrefab))
{
ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
component.m_itemData.m_shared.m_name = __m_originalArrows[prefabName].m_name;
component.m_itemData.m_shared.m_description = __m_originalArrows[prefabName].m_description;
}
}
if (!__m_originalArrowRecipes.ContainsKey(prefabName))
{
return;
}
Recipe val = __m_originalArrowRecipes[prefabName];
if (Object.op_Implicit((Object)(object)val))
{
Recipe val2 = db.m_recipes.Find((Recipe r) => ((Object)r).name == "Recipe_" + prefabName);
if (Object.op_Implicit((Object)(object)val2))
{
db.m_recipes.Remove(val2);
}
db.m_recipes.Add(val);
}
}
public static void ChangeArrowsAndRecipes(ObjectDB db)
{
__m_originalArrows.Clear();
__m_originalArrowRecipes.Clear();
GandrArrowData[] _m_gandrArrowData = __m_gandrArrowData;
foreach (GandrArrowData gandrArrowData in _m_gandrArrowData)
{
ChangeArrow(db, gandrArrowData.m_arrowName, gandrArrowData.m_ingredient, gandrArrowData.m_name, gandrArrowData.m_description);
}
db.UpdateRegisters();
}
public static void RestoreArrowsAndRecipes(ObjectDB db)
{
GandrArrowData[] _m_gandrArrowData = __m_gandrArrowData;
foreach (GandrArrowData gandrArrowData in _m_gandrArrowData)
{
RestoreArrow(db, gandrArrowData.m_arrowName);
}
__m_originalArrows.Clear();
__m_originalArrowRecipes.Clear();
db.UpdateRegisters();
}
public static void ApplyGandrEffect(string arrowName, Character hitChar, bool wasCharmed = false)
{
if ((Object)(object)hitChar == (Object)null)
{
return;
}
GandrArrowData gandrArrowData = __m_gandrArrowData.First((GandrArrowData a) => arrowName.ToLower() == a.m_name.ToLower());
if (gandrArrowData == null)
{
Debug.LogError((object)("No GandrArrowData found for arrow " + arrowName));
}
else if (gandrArrowData.m_statusEffectType != null)
{
List<StatusEffect> statusEffects = hitChar.m_seman.GetStatusEffects();
foreach (StatusEffect item in statusEffects)
{
if (((object)item).GetType() == gandrArrowData.m_statusEffectType)
{
statusEffects.Remove(item);
break;
}
}
ScriptableObject obj = ScriptableObject.CreateInstance(gandrArrowData.m_statusEffectType);
StatusEffect val = (StatusEffect)(object)((obj is StatusEffect) ? obj : null);
val = hitChar.m_seman.AddStatusEffect(val, true, 0, 0f);
if ((Object)(object)val != (Object)null)
{
((Character)Player.m_localPlayer).Message((MessageType)2, hitChar.GetHoverName() + gandrArrowData.m_description, 0, (Sprite)null);
}
else
{
Debug.LogError((object)$"ApplyGandrEffect: Failed to add status effect {gandrArrowData.m_statusEffectType} to {((Object)hitChar).name}");
}
}
else if (wasCharmed)
{
((Character)Player.m_localPlayer).Message((MessageType)2, hitChar.GetHoverName() + " continues to serve you!", 0, (Sprite)null);
}
else
{
((Character)Player.m_localPlayer).Message((MessageType)2, hitChar.GetHoverName() + " is under your thrall!", 0, (Sprite)null);
}
}
public static void ScaleThrallIncomingDamage(Character me, ref HitData hit, float charmLevel = 1f, float adrenalineScalar = 0.5f, float damageReceivedModifier = 1f)
{
((DamageTypes)(ref hit.m_damage)).Modify(1f / Math.Max(1f, charmLevel / 2f + adrenalineScalar) * damageReceivedModifier);
}
public static void ScaleThrallOutgoingDamage(ref HitData hit, float charmLevel = 1f, float adrenalineScalar = 0.5f, float damageInflictedModifier = 1f)
{
((DamageTypes)(ref hit.m_damage)).Modify(Math.Max(1f, charmLevel / 2f + adrenalineScalar) * damageInflictedModifier);
}
public static void CreateCharmIconsInMasterHud(Transform parentTransform)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < MAX_NUM_CHARM_ICONS; i++)
{
GameObject val = new GameObject($"CharmIcon{i}");
val.transform.SetParent(parentTransform);
RectTransform val2 = val.AddComponent<RectTransform>();
val2.sizeDelta = new Vector2(32f, 32f);
val2.anchoredPosition = new Vector2(0f, 0f);
((Transform)val2).localScale = new Vector3(1f, 1f, 1f);
Image val3 = val.AddComponent<Image>();
((Graphic)val3).color = Color.white;
((Graphic)val3).raycastTarget = false;
}
}
public static void CacheSprites()
{
CachedSprite[] _m_cachedPacifistSprites = __m_cachedPacifistSprites;
foreach (CachedSprite cachedSprite in _m_cachedPacifistSprites)
{
if ((Object)(object)cachedSprite.m_sprite == (Object)null)
{
cachedSprite.m_sprite = GetSpriteFromAtlas(cachedSprite.m_name, "IconAtlas");
}
}
}
public static Sprite LoadSpriteByName(string spriteName)
{
Sprite val = null;
Sprite[] source = Resources.FindObjectsOfTypeAll<Sprite>();
return ((IEnumerable<Sprite>)source).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name == spriteName));
}
public static Sprite GetSpriteFromAtlas(string spriteName, string atlasName)
{
SpriteAtlas[] array = Resources.FindObjectsOfTypeAll<SpriteAtlas>();
SpriteAtlas[] array2 = array;
foreach (SpriteAtlas val in array2)
{
if (!(((Object)val).name != atlasName))
{
Sprite sprite = val.GetSprite(spriteName);
if (sprite != null)
{
return sprite;
}
}
}
return null;
}
public static void ReleaseAllThralls()
{
for (int num = __m_allCharmedCharacters.Count - 1; num >= 0; num--)
{
CharmedCharacter charmedCharacter = __m_allCharmedCharacters[num];
SetUncharmedState(charmedCharacter);
RemoveGUIDFromCharmedList(charmedCharacter.m_charmGUID);
}
}
public static void SetCharmLevel(int charmLevel)
{
for (int num = __m_allCharmedCharacters.Count - 1; num >= 0; num--)
{
CharmedCharacter charmedCharacter = __m_allCharmedCharacters[num];
charmedCharacter.m_charmLevel = charmLevel;
}
}
public static void PrintSpawnSystem(List<SpawnSystemList> ssls, string name)
{
Debug.Log((object)$" SpawnLists '{name}' Count: {ssls.Count} {ssls.GetHashCode()}");
using StreamWriter streamWriter = new StreamWriter("SpawnDataDump2" + name + ".txt", append: false);
foreach (SpawnSystemList ssl in ssls)
{
streamWriter.WriteLine($"SpawnList: {((ssl != null) ? ((Object)ssl).name : null)} {((object)ssl)?.GetHashCode().ToString()} {ssl.m_spawners?.Count}");
foreach (SpawnData item in ssl?.m_spawners)
{
streamWriter.WriteLine($" {item.m_name} {item.m_spawnChance}% Max: {item.m_maxSpawned} Interval:{item.m_spawnInterval} RadiusMin:{item.m_spawnRadiusMin} RadiusMax:{item.m_spawnRadiusMax} SpawnDistance: {item.m_spawnDistance}");
}
}
}
public static void DoBackupSpawnData(List<SpawnSystemList> spawnLists, ref Dictionary<int, Dictionary<int, BackupSpawnData>> outDict)
{
outDict = new Dictionary<int, Dictionary<int, BackupSpawnData>>();
foreach (SpawnSystemList spawnList in spawnLists)
{
int hashCode = ((object)spawnList).GetHashCode();
Dictionary<int, BackupSpawnData> dictionary = new Dictionary<int, BackupSpawnData>();
outDict.Add(hashCode, dictionary);
foreach (SpawnData spawner in spawnList.m_spawners)
{
int hashCode2 = ((object)spawner).GetHashCode();
BackupSpawnData backupSpawnData = new BackupSpawnData();
backupSpawnData.m_spawnInterval = spawner.m_spawnInterval;
backupSpawnData.m_spawnChance = spawner.m_spawnChance;
backupSpawnData.m_maxSpawned = spawner.m_maxSpawned;
backupSpawnData.m_spawnRadiusMin = spawner.m_spawnRadiusMin;
backupSpawnData.m_spawnRadiusMax = spawner.m_spawnRadiusMax;
backupSpawnData.m_spawnDistance = spawner.m_spawnDistance;
dictionary.Add(hashCode2, backupSpawnData);
}
}
}
public static void DoRestoreSpawnData(Dictionary<int, Dictionary<int, BackupSpawnData>> backupData, ref List<SpawnSystemList> spawnLists)
{
foreach (SpawnSystemList spawnList in spawnLists)
{
Dictionary<int, BackupSpawnData> dictionary = backupData[((object)spawnList).GetHashCode()];
foreach (SpawnData spawner in spawnList.m_spawners)
{
BackupSpawnData backupSpawnData = dictionary[((object)spawner).GetHashCode()];
spawner.m_spawnInterval = backupSpawnData.m_spawnInterval;
spawner.m_spawnChance = backupSpawnData.m_spawnChance;
spawner.m_maxSpawned = backupSpawnData.m_maxSpawned;
spawner.m_spawnRadiusMin = backupSpawnData.m_spawnRadiusMin;
spawner.m_spawnRadiusMax = backupSpawnData.m_spawnRadiusMax;
spawner.m_spawnDistance = backupSpawnData.m_spawnDistance;
}
}
}
public void Awake()
{
__m_trophyHuntMod = this;
HarmonyFileLog.Enabled = true;
harmony.PatchAll();
}
public static bool IsPacifist()
{
return true;
}
public static TextMeshProUGUI AddTextMeshProComponent(GameObject toThisObject)
{
TextMeshProUGUI val = toThisObject.AddComponent<TextMeshProUGUI>();
((TMP_Text)val).font = __m_globalFontObject;
((Graphic)val).material = ((TMP_Asset)__m_globalFontObject).material;
return val;
}
public static void UpdateModUI(Player player)
{
}
public static void CreateThrallsWindow(Transform parentTransform)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_003f: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
__m_thrallsWindowBackground = new GameObject("Thrall Window Background");
__m_thrallsWindowBackground.transform.SetParent(parentTransform, false);
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(-90f, 360f);
RectTransform val2 = __m_thrallsWindowBackground.AddComponent<RectTransform>();
val2.sizeDelta = __m_thrallsTooltipWindowSize;
val2.anchoredPosition = val;
val2.pivot = new Vector2(0f, 0f);
Image val3 = __m_thrallsWindowBackground.AddComponent<Image>();
((Graphic)val3).color = new Color(0f, 0f, 0f, 0.9f);
__m_thrallsWindowBackground.SetActive(false);
__m_thrallsWindowObject = new GameObject("Thrall Window Text");
__m_thrallsWindowObject.transform.SetParent(parentTransform, false);
RectTransform val4 = __m_thrallsWindowObject.AddComponent<RectTransform>();
val4.sizeDelta = new Vector2(__m_thrallsTooltipWindowSize.x - __m_thrallsTooltipTextOffset.x, __m_thrallsTooltipWindowSize.y - __m_thrallsTooltipTextOffset.y);
val4.anchoredPosition = val + new Vector2(5f, 0f);
val4.pivot = new Vector2(0f, 0f);
__m_thrallsWindowText = AddTextMeshProComponent(__m_thrallsWindowObject);
((TMP_Text)__m_thrallsWindowText).fontSize = 14f;
((TMP_Text)__m_thrallsWindowText).alignment = (TextAlignmentOptions)257;
((Graphic)__m_thrallsWindowText).color = Color.yellow;
__m_thrallsWindowObject.SetActive(true);
}
public static string BuildThrallsWindowText(ref int lines)
{
string text = "<size=20><b><color=#FFB75B>Thralls</color><b></size>\n";
text += "\n<size=16><pos=0%><color=white><u>Friend</u></color><pos=35%><u><color=yellow>(Level)</color></u><pos=50%><color=red><u>Health</u></color><pos=78%><color=orange><u>Remain</u></color>\n";
int num = 0;
foreach (CharmedCharacter _m_allCharmedCharacter in __m_allCharmedCharacters)
{
Character characterFromGUID = GetCharacterFromGUID(_m_allCharmedCharacter.m_charmGUID);
if (!((Object)(object)characterFromGUID == (Object)null))
{
float num2 = _m_allCharmedCharacter.m_charmExpireTime - __m_charmTimerSeconds;
DateTime minValue = DateTime.MinValue;
string text2 = minValue.AddSeconds(num2).ToString("m'm 's's'");
text += $"<color=yellow>{num + 1}:</color> <pos=5%><color=white>{characterFromGUID.GetHoverName()}<pos=40%><color=yellow>({_m_allCharmedCharacter.m_charmLevel})</color><pos=50%><color=red>{(int)(characterFromGUID.GetHealthPercentage() * 100f)}%</color><pos=78%></color><color=orange>{text2}</color></size>\n";
num++;
}
}
for (int num3 = 5 - num; num3 > 0; num3--)
{
text += $"<color=yellow>{num + 1}:</color> <pos=5%><color=#505050> -- Unused -- <pos=40%><color=#505050>--<pos=50%><color=#505050>---<pos=78%><color=#505050>---</color></size>\n";
num++;
}
lines = num;
return text;
}
public static void ShowThrallsWindow(GameObject uiObject)
{
if ((Object)(object)uiObject == (Object)null)
{
Debug.LogError((object)"ShowThrallsWindow: uiObject is null!");
return;
}
int lines = 0;
string text = BuildThrallsWindowText(ref lines);
((TMP_Text)__m_thrallsWindowText).text = text;
((TMP_Text)__m_thrallsWindowText).ForceMeshUpdate(true, true);
__m_thrallsWindowBackground.SetActive(true);
__m_thrallsWindowObject.SetActive(true);
((TMP_Text)__m_thrallsWindowText).ForceMeshUpdate(true, true);
}
public static void HideThrallsWindow()
{
__m_thrallsWindowBackground.SetActive(false);
__m_thrallsWindowObject.SetActive(false);
}
}