using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AnimalKingdom.Properties;
using BepInEx;
using DM;
using HarmonyLib;
using Landfall.MonoBatch;
using Landfall.TABS;
using Landfall.TABS.AI;
using Landfall.TABS.AI.Components;
using Landfall.TABS.AI.Components.Modifiers;
using Landfall.TABS.AI.Components.Tags;
using Landfall.TABS.AI.Systems;
using Landfall.TABS.GameMode;
using Landfall.TABS.GameState;
using Landfall.TABS.UnitEditor;
using Landfall.TABS.Workshop;
using Pathfinding;
using TFBGames;
using Unity.Entities;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AnimalKingdom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AnimalKingdom")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("709963a3-9cff-4ada-8c38-5d03357269a5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public class Afraid : UnitEffectBase
{
public UnityEvent pingEvent;
private DataHandler data;
private Unit unit;
private float amount;
public float multiplier = 1f;
public float torque = 1f;
public float force = 1f;
private float counter;
private Vector3 direction;
private bool done;
private void Init()
{
unit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
data = ((Component)unit).GetComponentInChildren<DataHandler>();
}
public override void DoEffect()
{
//IL_0078: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
Init();
if (Object.op_Implicit((Object)(object)data) && !((Object)(object)data.targetData == (Object)null))
{
amount += 1.5f / Mathf.Clamp(data.maxHealth * 0.02f, 0.1f, float.PositiveInfinity);
Vector3 val = data.targetData.mainRig.position - data.mainRig.position;
direction = -((Vector3)(ref val)).normalized;
direction.y = 0.2f;
direction = ((Vector3)(ref direction)).normalized;
counter = 0f;
}
}
public override void Ping()
{
//IL_0078: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
Init();
if (Object.op_Implicit((Object)(object)data) && !((Object)(object)data.targetData == (Object)null))
{
amount += 1.5f / Mathf.Clamp(data.maxHealth * 0.02f, 0.1f, float.PositiveInfinity);
Vector3 val = data.targetData.mainRig.position - data.mainRig.position;
direction = -((Vector3)(ref val)).normalized;
direction.y = 0.2f;
direction = ((Vector3)(ref direction)).normalized;
counter = 0f;
pingEvent.Invoke();
done = false;
}
}
private void Update()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)data))
{
return;
}
counter += Time.deltaTime;
if (counter < 2.5f)
{
unit.unitConfusion = amount * multiplier * direction;
counter += Time.deltaTime;
if ((Object)(object)unit.data.weaponHandler != (Object)null)
{
unit.data.weaponHandler.StopAttacksFor(1f);
}
Vector3 forward = ((Component)unit.data.mainRig).transform.forward;
unit.data.mainRig.AddTorque(torque * Vector2.Angle(Vector2.op_Implicit(forward), Vector2.op_Implicit(direction)) * Time.deltaTime * Vector3.up, (ForceMode)5);
Rigidbody[] allRigs = unit.data.allRigs.AllRigs;
for (int i = 0; i < allRigs.Length; i++)
{
if (Object.op_Implicit((Object)(object)allRigs[i]))
{
allRigs[i].AddForce(force * Time.deltaTime * Mathf.Clamp(allRigs[i].drag, 0f, 1f) * direction, (ForceMode)5);
}
}
data.mainRig.AddForce(force * Mathf.Clamp(data.mainRig.drag, 0f, 1f) * Time.deltaTime * direction, (ForceMode)5);
}
else if (!done)
{
done = true;
unit.unitConfusion = Vector3.zero;
}
}
}
public class PlagueBite : MonoBehaviour
{
public enum BodyTarget
{
Head,
RightFoot,
LeftFoot,
RightHand,
LeftHand
}
public BodyTarget bodyTarget;
private CollisionWeapon newWeapon;
private void Start()
{
GameObject val = null;
if (bodyTarget == BodyTarget.Head)
{
val = ((Component)((Component)((Component)this).transform.root).GetComponentInChildren<Head>()).gameObject;
}
else if (bodyTarget == BodyTarget.RightFoot)
{
val = ((Component)((Component)((Component)this).transform.root).GetComponentInChildren<KneeRight>()).gameObject;
}
else if (bodyTarget == BodyTarget.LeftFoot)
{
val = ((Component)((Component)((Component)this).transform.root).GetComponentInChildren<KneeLeft>()).gameObject;
}
else if (bodyTarget == BodyTarget.RightHand)
{
val = ((Component)((Component)((Component)this).transform.root).GetComponentInChildren<HandRight>()).gameObject;
}
else if (bodyTarget == BodyTarget.LeftHand)
{
val = ((Component)((Component)((Component)this).transform.root).GetComponentInChildren<HandLeft>()).gameObject;
}
CollisionWeapon component = ((Component)this).GetComponent<CollisionWeapon>();
newWeapon = val.AddComponent<CollisionWeapon>();
newWeapon.damage = component.damage;
newWeapon.impactMultiplier = component.impactMultiplier;
newWeapon.onImpactForce = component.onImpactForce;
newWeapon.massCap = component.massCap;
newWeapon.ignoreTeamMates = component.ignoreTeamMates;
newWeapon.staticDamageValue = component.staticDamageValue;
newWeapon.onlyOncePerData = component.onlyOncePerData;
newWeapon.cooldown = component.cooldown;
newWeapon.onlyCollideWithRigs = true;
newWeapon.dealDamageEvent = component.dealDamageEvent;
CollisionSound component2 = ((Component)this).GetComponent<CollisionSound>();
if (Object.op_Implicit((Object)(object)component2))
{
CollisionSound val2 = val.AddComponent<CollisionSound>();
val2.SoundEffectRef = component2.SoundEffectRef;
val2.multiplier = component2.multiplier;
Object.Destroy((Object)(object)component2);
}
if (Object.op_Implicit((Object)(object)((Component)this).GetComponent<MeleeWeaponAddEffect>()))
{
MeleeWeaponAddEffect val3 = val.AddComponent<MeleeWeaponAddEffect>();
val3.EffectPrefab = ((Component)this).GetComponent<MeleeWeaponAddEffect>().EffectPrefab;
val3.ignoreTeamMates = ((Component)this).GetComponent<MeleeWeaponAddEffect>().ignoreTeamMates;
Object.Destroy((Object)(object)((Component)this).GetComponent<MeleeWeaponAddEffect>());
}
Object.Destroy((Object)(object)component);
}
private void OnDestroy()
{
if (Object.op_Implicit((Object)(object)newWeapon))
{
Object.Destroy((Object)(object)newWeapon);
}
}
}
public class RotationHandlerDragon : BatchedMonobehaviour
{
public float rotationForce;
public bool ignoreX;
public bool lockXToZero;
public bool rotateTowardsMovement;
private Rigidbody torso;
private Rigidbody hip;
private DataHandler data;
[HideInInspector]
public float rotationMultiplier = 1f;
protected override void Start()
{
((BatchedMonobehaviour)this).Start();
data = ((Component)this).GetComponent<DataHandler>();
torso = ((Component)((Component)this).GetComponentInChildren<Torso>()).GetComponent<Rigidbody>();
hip = ((Component)((Component)this).GetComponentInChildren<Hip>()).GetComponent<Rigidbody>();
}
public override void BatchedFixedUpdate()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: 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_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: 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_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if (!data.Dead && data.isGrounded && ((Behaviour)this).enabled)
{
Vector3 forward = ((Component)hip).transform.forward;
Vector3 forward2 = ((Component)torso).transform.forward;
Vector3 forward3 = data.characterForwardObject.forward;
if (ignoreX)
{
forward.z = 0f;
forward2.z = 0f;
forward3.z = 0f;
}
if (lockXToZero)
{
forward3.z = 0f;
}
if (rotateTowardsMovement)
{
forward3 = data.groundedMovementDirectionObject.forward;
}
Rigidbody obj = hip;
Vector3 val = Vector3.Cross(forward3, forward);
obj.AddTorque(-((Vector3)(ref val)).normalized * rotationMultiplier * data.muscleControl * Mathf.Clamp(Vector3.Angle(forward3, forward), 0f, 15f) * rotationForce * data.torsoAngleMultiplier, (ForceMode)5);
Rigidbody obj2 = torso;
val = Vector3.Cross(forward3, forward2);
obj2.AddTorque(-((Vector3)(ref val)).normalized * rotationMultiplier * data.muscleControl * Mathf.Clamp(Vector3.Angle(forward3, forward2), 0f, 15f) * rotationForce * data.torsoAngleMultiplier, (ForceMode)5);
}
}
}
public class SecretUnlockDragon : GameStateListener
{
[SerializeField]
private string m_secret_key = "";
public TABSCampaignAsset m_unlockCampaign;
[SerializeField]
private float m_distanceToUnlock = 5f;
private RotationShake m_rotationShake;
private Rigidbody m_secretObject;
private float m_lookValue;
private float m_unlockValue;
public AudioClip hitClip;
private AudioSource loopSource;
private Transform m_mainCamTransform;
public UnityEvent unlockEvent;
public UnityEvent hideEvent;
private bool done;
public Color glowColor;
public GameObject unlockSparkEffect;
protected override void Awake()
{
((GameStateListener)this).Awake();
if ((Object)(object)m_mainCamTransform == (Object)null)
{
((GameStateListener)this).OnEnterNewScene();
}
}
private void Update()
{
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)m_mainCamTransform != (Object)null) || !Object.op_Implicit((Object)(object)m_secretObject) || done)
{
return;
}
loopSource.volume = Mathf.Pow(m_unlockValue * 0.25f, 1.3f);
float num = 1f + 1f * m_unlockValue;
loopSource.pitch = ((num >= 0f) ? num : 0f);
if (m_unlockValue > 0f || m_lookValue > 10f)
{
SetColor();
}
float num2 = Vector3.Distance(m_secretObject.worldCenterOfMass, m_mainCamTransform.position);
if (num2 > m_distanceToUnlock)
{
m_unlockValue -= Time.unscaledDeltaTime * 0.2f;
return;
}
float num3 = Vector3.Angle(m_mainCamTransform.forward, m_secretObject.worldCenterOfMass - m_mainCamTransform.position);
m_lookValue = 1000f / (num2 * num3);
if (m_lookValue > 8f)
{
float num4 = 0.2f;
m_unlockValue += num4 * Time.unscaledDeltaTime;
UnlockProgressFeedback();
if (m_unlockValue > 1f)
{
UnlockSecret();
}
}
else
{
m_unlockValue -= Time.unscaledDeltaTime * 0.2f;
}
}
private void UnlockProgressFeedback()
{
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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)
if (Object.op_Implicit((Object)(object)m_rotationShake))
{
if (m_unlockValue <= 0f)
{
m_rotationShake.AddForce(Random.onUnitSphere * 2f);
m_unlockValue = 0f;
}
((Behaviour)m_rotationShake).enabled = true;
m_rotationShake.AddForce(Random.onUnitSphere * m_unlockValue * Time.deltaTime * 50f);
}
}
private void SetColor()
{
//IL_0066: 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_007b: Unknown result type (might be due to invalid IL or missing references)
m_unlockValue = Mathf.Clamp(m_unlockValue, 0f, float.PositiveInfinity);
Renderer[] componentsInChildren = ((Component)m_secretObject).GetComponentsInChildren<Renderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Material[] materials = componentsInChildren[i].materials;
for (int j = 0; j < materials.Length; j++)
{
if (materials[j].HasProperty("_EmissionColor"))
{
materials[j].EnableKeyword("_EMISSION");
materials[j].SetColor("_EmissionColor", glowColor * m_unlockValue * 2f);
}
}
componentsInChildren[i].materials = materials;
}
}
private void UnlockSecret()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
if (!((Behaviour)this).enabled)
{
return;
}
if (Object.op_Implicit((Object)(object)ScreenShake.Instance))
{
ScreenShake.Instance.AddForce(Vector3.up * 8f, ((Component)m_secretObject).transform.position);
}
if (Object.op_Implicit((Object)(object)unlockSparkEffect))
{
GameObject val = Object.Instantiate<GameObject>(unlockSparkEffect, ((Component)m_secretObject).transform.position, ((Component)m_secretObject).transform.rotation);
val.AddComponent<RemoveAfterSeconds>().seconds = 5f;
MeshRenderer componentInChildren = ((Component)m_secretObject).GetComponentInChildren<MeshRenderer>();
if (Object.op_Implicit((Object)(object)componentInChildren))
{
ShapeModule shape = val.GetComponent<ParticleSystem>().shape;
((ShapeModule)(ref shape)).meshRenderer = componentInChildren;
}
}
((Component)m_secretObject).gameObject.SetActive(false);
UnityEvent obj = unlockEvent;
if (obj != null)
{
obj.Invoke();
}
loopSource.Stop();
loopSource.volume = 1f;
loopSource.PlayOneShot(hitClip);
done = true;
List<Faction> list = new List<Faction>();
foreach (IDatabaseEntity faction in LandfallUnitDatabase.GetDatabase().FactionList)
{
if (faction.Entity.Name.Contains("Medieval"))
{
list.Add(LandfallUnitDatabase.GetDatabase().GetFactionByGUID(faction.Entity.GUID));
}
if (faction.Entity.Name.Contains("Farmer"))
{
list.Add(LandfallUnitDatabase.GetDatabase().GetFactionByGUID(faction.Entity.GUID));
}
}
m_unlockCampaign.LevelsInCampaign[0].AllowedFactions = list.ToArray();
m_unlockCampaign.LevelsInCampaign[0].MapAsset = LandfallUnitDatabase.GetDatabase().GetMap(new DatabaseID(-1, 835120575));
CampaignPlayerDataHolder.StartedPlayingNewCampaign(m_unlockCampaign, 0, true, true);
TABSSceneManager.LoadCampaign();
LandfallUnitDatabase.GetDatabase().AddCampaignWithID(m_unlockCampaign);
if (!string.IsNullOrWhiteSpace(m_secret_key))
{
ServiceLocator.GetService<ISaveLoaderService>().UnlockSecret(m_secret_key);
CheckAchievements();
PlacementUI val2 = Object.FindObjectOfType<PlacementUI>();
if ((Object)(object)val2 != (Object)null)
{
val2.RedrawUI(m_secret_key);
}
}
}
public override void OnEnterNewScene()
{
((GameStateListener)this).OnEnterNewScene();
loopSource = ((Component)this).GetComponent<AudioSource>();
if (Object.op_Implicit((Object)(object)loopSource))
{
loopSource.volume = 0f;
}
m_rotationShake = ((Component)this).GetComponentInChildren<RotationShake>();
m_secretObject = ((Component)this).GetComponentInChildren<Rigidbody>();
if (Object.op_Implicit((Object)(object)m_secretObject))
{
m_secretObject.isKinematic = true;
}
PlayerCamerasManager service = ServiceLocator.GetService<PlayerCamerasManager>();
MainCam val = ((service != null) ? service.GetMainCam((Player)0) : null);
m_mainCamTransform = (((Object)(object)val != (Object)null) ? ((Component)val).transform : null);
}
public override void OnEnterPlacementState()
{
}
public override void OnEnterBattleState()
{
}
private void CheckAchievements()
{
AchievementService service = ServiceLocator.GetService<AchievementService>();
ISaveLoaderService secretService = ServiceLocator.GetService<ISaveLoaderService>();
if (HasUnlockedFaction(874593522))
{
service.UnlockAchievement("UNLOCKED_ALL_SECRET");
}
if (HasUnlockedFaction(673578412))
{
service.UnlockAchievement("UNLOCKED_ALL_LEGACY");
}
bool HasUnlockedFaction(int factionId)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
UnitBlueprint[] units = LandfallUnitDatabase.GetDatabase().GetFactionByGUID(new DatabaseID(-1, factionId)).Units;
UnitBlueprint[] array = units;
foreach (UnitBlueprint val in array)
{
if (!string.IsNullOrEmpty(val.Entity.UnlockKey) && !secretService.HasUnlockedSecret(val.Entity.UnlockKey))
{
return false;
}
}
return true;
}
}
}
namespace HiddenUnits
{
public class FindCodeAnimation : MonoBehaviour
{
public void Find()
{
((Component)((Component)((Component)this).transform.root).GetComponent<Unit>().data.head).GetComponentInChildren<CodeAnimation>().PlayIn();
}
}
}
namespace AnimalKingdom
{
public class AKMaterialEvent : MonoBehaviour
{
private bool changing;
private bool useOriginalMat;
private float t;
public Renderer rend;
public int index;
public Material newMat;
private Material originalMat;
public float lerpTime = 0.6f;
public void Start()
{
originalMat = Object.Instantiate<Material>(rend.materials[index]);
}
public void ChangeMaterial()
{
t = 0f;
changing = true;
}
public void RevertMaterial()
{
t = 0f;
changing = true;
useOriginalMat = true;
}
private void Update()
{
if (Object.op_Implicit((Object)(object)((Component)((Component)this).transform.root).GetComponentsInChildren<UnitEffectBase>().ToList().Find((UnitEffectBase x) => x.effectID == 1987)))
{
Reset();
}
if (changing && t < lerpTime && Time.timeScale != 0f)
{
t += Mathf.Clamp(Time.deltaTime / lerpTime, 0f, 1f);
if (useOriginalMat)
{
rend.materials[index].Lerp(rend.materials[index], originalMat, t);
}
else
{
rend.materials[index].Lerp(rend.materials[index], newMat, t);
}
}
else if (t > lerpTime)
{
changing = false;
useOriginalMat = false;
}
if (!changing)
{
t = 0f;
}
}
public void Reset()
{
changing = false;
useOriginalMat = false;
}
}
public class AKRandomChance : MonoBehaviour
{
public UnityEvent randomEvent;
public float randomChance;
public bool onStart;
public void Start()
{
if (onStart)
{
Randomize();
}
}
public void Randomize()
{
if (Random.value > randomChance)
{
randomEvent.Invoke();
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal class DeathPatch
{
[HarmonyPrefix]
public static bool Prefix(DataHandler __instance, ref bool value)
{
if (value && !(bool)GetField(typeof(DataHandler), __instance, "dead"))
{
GameModeService service = ServiceLocator.GetService<GameModeService>();
if (service.CurrentGameMode == null)
{
Debug.LogError((object)"Could not find CurrentGameMode!");
}
else if (!__instance.healthHandler.willBeRewived)
{
service.CurrentGameMode.OnUnitDied(__instance.unit);
}
}
SetField(__instance, "dead", value);
return false;
}
public static object GetField(Type type, object instance, string fieldName)
{
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
FieldInfo field = type.GetField(fieldName, bindingAttr);
return field.GetValue(instance);
}
public static void SetField<T>(object originalObject, string fieldName, T newValue)
{
BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
FieldInfo field = originalObject.GetType().GetField(fieldName, bindingAttr);
field.SetValue(originalObject, newValue);
}
}
public class DragonUnlocker : MonoBehaviour
{
public string unlockKey;
public void Unlock()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)CampaignPlayerDataHolder.CurrentGameModeState == 4 && !ServiceLocator.GetService<ISaveLoaderService>().HasUnlockedSecret(unlockKey))
{
ServiceLocator.GetService<ISaveLoaderService>().UnlockSecret(unlockKey);
}
}
}
public class Effect_Plague : UnitEffectBase
{
public enum ZombificationType
{
Standard,
Virus,
Support
}
private Unit unit;
private GameObject weapon1;
private GameObject weapon2;
private bool done;
[Header("Zombification")]
public ZombificationType zombieType;
private float currentProgress;
public float progressToAdd = 100f;
[Header("Revive")]
public UnityEvent reviveEvent;
public float reviveDelay;
[Range(0f, 1f)]
public float reviveHealthMultiplier = 0.5f;
public float reviveTargetingPriority = 0.2f;
public GameObject reviveWeapon;
public List<GameObject> reviveAbilities = new List<GameObject>();
public GameObject reviveEye;
public GameObject zombieStats;
[Header("Color")]
public UnitColorInstance color = new UnitColorInstance();
private float lerpProgress;
public float lerpSpeed = 1f;
public override void DoEffect()
{
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Invalid comparison between Unknown and I4
unit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
if (Object.op_Implicit((Object)(object)unit.holdingHandler))
{
weapon1 = (Object.op_Implicit((Object)(object)unit.holdingHandler.rightObject) ? ((Component)unit.holdingHandler.rightObject).gameObject : null);
weapon2 = (Object.op_Implicit((Object)(object)unit.holdingHandler.leftObject) ? ((Component)unit.holdingHandler.leftObject).gameObject : null);
if (zombieType != ZombificationType.Virus)
{
if (Object.op_Implicit((Object)(object)weapon1) && Object.op_Implicit((Object)(object)weapon1.GetComponent<Holdable>()))
{
weapon1.GetComponent<Holdable>().ignoreDissarm = true;
}
if (Object.op_Implicit((Object)(object)weapon2) && Object.op_Implicit((Object)(object)weapon2.GetComponent<Holdable>()))
{
weapon2.GetComponent<Holdable>().ignoreDissarm = true;
}
}
}
UnitEffectBase val = ((Component)unit).GetComponentsInChildren<UnitEffectBase>().ToList().Find((UnitEffectBase x) => x.effectID == 1984);
if ((Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)this) || (int)unit.unitType == 1)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
unit.data.healthHandler.RemoveDieAction((Action)Revive);
}
else
{
unit.data.healthHandler.AddDieAction((Action)Revive);
}
((UnitEffectBase)this).Ping();
}
public override void Ping()
{
if (!done)
{
currentProgress += Mathf.Clamp(progressToAdd / unit.data.health, 0f, 1f);
if (zombieType != ZombificationType.Support)
{
AddLerpProgress();
}
else
{
((MonoBehaviour)this).StartCoroutine(DoZombieChecks());
}
}
}
public void AddLerpProgress()
{
if (!done || zombieType == ZombificationType.Support)
{
((MonoBehaviour)this).StopCoroutine(DoLerp());
((MonoBehaviour)this).StartCoroutine(DoLerp());
}
}
public IEnumerator DoLerp()
{
if (!done || zombieType == ZombificationType.Support)
{
float c = 0f;
float startProgress = lerpProgress;
while (c < 1f)
{
c += Mathf.Clamp(Time.deltaTime * lerpSpeed, 0f, 1f);
lerpProgress = Mathf.Lerp(startProgress, currentProgress, c);
yield return null;
}
((MonoBehaviour)this).StartCoroutine(DoZombieChecks());
}
}
public IEnumerator DoZombieChecks()
{
if (done)
{
yield break;
}
yield return (object)new WaitForEndOfFrame();
if (done)
{
yield break;
}
if (currentProgress >= 0.5f)
{
unit.data.healthHandler.willBeRewived = true;
if (Object.op_Implicit((Object)(object)((Component)unit).GetComponentInChildren<AddRigidbodyOnDeath>()))
{
AddRigidbodyOnDeath[] componentsInChildren = ((Component)unit).GetComponentsInChildren<AddRigidbodyOnDeath>();
foreach (AddRigidbodyOnDeath script in componentsInChildren)
{
unit.data.healthHandler.RemoveDieAction((Action)script.Die);
Object.Destroy((Object)(object)script);
}
}
if (Object.op_Implicit((Object)(object)((Component)unit).GetComponentInChildren<SinkOnDeath>()))
{
SinkOnDeath[] componentsInChildren2 = ((Component)unit).GetComponentsInChildren<SinkOnDeath>();
foreach (SinkOnDeath script2 in componentsInChildren2)
{
unit.data.healthHandler.RemoveDieAction((Action)script2.Sink);
Object.Destroy((Object)(object)script2);
}
}
if (Object.op_Implicit((Object)(object)((Component)unit).GetComponentInChildren<RemoveJointsOnDeath>()))
{
RemoveJointsOnDeath[] componentsInChildren3 = ((Component)unit).GetComponentsInChildren<RemoveJointsOnDeath>();
foreach (RemoveJointsOnDeath script3 in componentsInChildren3)
{
unit.data.healthHandler.RemoveDieAction((Action)script3.Die);
Object.Destroy((Object)(object)script3);
}
}
if (Object.op_Implicit((Object)(object)((Component)unit).GetComponentInChildren<DisableAllSkinnedClothes>()))
{
DisableAllSkinnedClothes[] componentsInChildren4 = ((Component)unit).GetComponentsInChildren<DisableAllSkinnedClothes>();
foreach (DisableAllSkinnedClothes script4 in componentsInChildren4)
{
Object.Destroy((Object)(object)script4);
}
}
}
if (currentProgress >= 1f && zombieType != ZombificationType.Support)
{
((Damagable)unit.data.healthHandler).TakeDamage(unit.data.maxHealth, Vector3.zero, unit, (DamageType)3);
}
}
public void Revive()
{
if (!done && unit.data.healthHandler.willBeRewived)
{
done = true;
((MonoBehaviour)this).StartCoroutine(DoRevive());
}
}
public IEnumerator DoRevive()
{
ServiceLocator.GetService<GameModeService>().CurrentGameMode.OnUnitDied(unit);
Team newTeam = ((zombieType != ZombificationType.Support) ? ((Team)((int)unit.data.team == 0)) : unit.data.team);
unit.data.team = newTeam;
unit.Team = newTeam;
unit.targetingPriorityMultiplier = reviveTargetingPriority;
GameObjectEntity goe = ((Component)unit).GetComponent<GameObjectEntity>();
goe.EntityManager.RemoveComponent<IsDead>(goe.Entity);
goe.EntityManager.AddComponent(goe.Entity, ComponentType.Create<UnitTag>());
goe.EntityManager.SetSharedComponentData<Team>(goe.Entity, new Team
{
Value = (int)unit.Team
});
World.Active.GetOrCreateManager<TeamSystem>().AddUnit(goe.Entity, ((Component)unit).gameObject, ((Component)unit).transform, unit.data.mainRig, unit.data, newTeam, unit, false);
if (zombieType == ZombificationType.Support)
{
AddLerpProgress();
}
yield return (object)new WaitForSeconds(reviveDelay);
unit.data.Dead = false;
unit.dead = false;
unit.data.hasBeenRevived = true;
unit.data.healthHandler.willBeRewived = false;
unit.data.ragdollControl = 1f;
unit.data.muscleControl = 1f;
unit.data.health = unit.data.maxHealth * reviveHealthMultiplier;
if (zombieType == ZombificationType.Virus)
{
if (Object.op_Implicit((Object)(object)unit.holdingHandler))
{
if (Object.op_Implicit((Object)(object)weapon1))
{
weapon1.AddComponent<RemoveAfterSeconds>().shrink = true;
}
if (Object.op_Implicit((Object)(object)weapon2))
{
weapon1.AddComponent<RemoveAfterSeconds>().shrink = true;
}
unit.holdingHandler.LetGoOfAll();
unit.unitBlueprint.SetWeapon(unit, newTeam, reviveWeapon, new PropItemData(), (HandType)0, unit.data.mainRig.rotation, new List<GameObject>(), false);
unit.unitBlueprint.SetWeapon(unit, newTeam, reviveWeapon, new PropItemData(), (HandType)1, unit.data.mainRig.rotation, new List<GameObject>(), false);
}
}
else
{
if (Object.op_Implicit((Object)(object)weapon1) && Object.op_Implicit((Object)(object)weapon1.GetComponent<Holdable>()))
{
weapon1.GetComponent<Holdable>().ignoreDissarm = false;
}
if (Object.op_Implicit((Object)(object)weapon2) && Object.op_Implicit((Object)(object)weapon2.GetComponent<Holdable>()))
{
weapon2.GetComponent<Holdable>().ignoreDissarm = false;
}
}
foreach (GameObject ability in reviveAbilities)
{
Object.Instantiate<GameObject>(ability, ((Component)unit).transform.position, ((Component)unit).transform.rotation, ((Component)unit).transform);
}
if (Object.op_Implicit((Object)(object)((Component)unit).GetComponentInChildren<TeamColor>()))
{
TeamColor[] componentsInChildren = ((Component)unit).GetComponentsInChildren<TeamColor>();
foreach (TeamColor tc in componentsInChildren)
{
tc.SetTeamColor(newTeam);
}
}
if (Object.op_Implicit((Object)(object)((Component)unit.data).GetComponent<StandingHandler>()) && (((Object)unit).name.Contains("Humanoid") || ((Object)unit).name.Contains("Stiffy") || ((Object)unit).name.Contains("Blackbeard") || ((Object)unit).name.Contains("Halfling")))
{
RandomCharacterStats ran = ((Component)unit.data).gameObject.AddComponent<RandomCharacterStats>();
ran.minStandingOffset = zombieStats.GetComponent<RandomCharacterStats>().minStandingOffset;
ran.maxStandingOffset = zombieStats.GetComponent<RandomCharacterStats>().maxStandingOffset;
ran.minMovement = zombieStats.GetComponent<RandomCharacterStats>().minMovement;
ran.maxMovemenmt = zombieStats.GetComponent<RandomCharacterStats>().maxMovemenmt;
ran.randomCurve = zombieStats.GetComponent<RandomCharacterStats>().randomCurve;
}
if (Object.op_Implicit((Object)(object)((Component)unit).GetComponentInChildren<EyeSpawner>()))
{
EyeSpawner[] componentsInChildren2 = ((Component)unit).GetComponentsInChildren<EyeSpawner>();
foreach (EyeSpawner eyeSet in componentsInChildren2)
{
foreach (GooglyEye eye in eyeSet.spawnedEyes)
{
GooglyEyes.instance.eyes.Remove(eye);
Object.Destroy((Object)(object)((Component)eye).gameObject);
}
eyeSet.spawnedEyes.Clear();
eyeSet.eyeObject = reviveEye;
((object)eyeSet).GetType().GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(eyeSet, new object[0]);
}
}
unit.api.SetTargetingType(unit.unitBlueprint.TargetingComponent);
ServiceLocator.GetService<UnitHealthbars>().HandleUnitSpawned(unit);
unit.api.UpdateECSValues();
unit.InitializeUnit(newTeam);
reviveEvent.Invoke();
}
public void Update()
{
if (Object.op_Implicit((Object)(object)unit))
{
((Component)unit.data).GetComponent<UnitColorHandler>().SetColor(color, lerpProgress);
}
}
}
public class GeyserTimer : MonoBehaviour
{
private DelayEvent[] availableEvents;
public List<DelayEvent> events = new List<DelayEvent>();
public List<bool> isErupting = new List<bool>();
public float doMultipleEruptionsChance = 0.2f;
public void Start()
{
foreach (DelayEvent @event in events)
{
isErupting.Add(item: false);
}
}
public void DoRandomEvent()
{
((MonoBehaviour)this).StartCoroutine(DoEruption());
}
public IEnumerator DoEruption(bool isSecondEruption = false)
{
availableEvents = events.Where((DelayEvent x) => !isErupting[events.IndexOf(x)]).ToArray();
int index = Random.Range(0, availableEvents.Length - 1);
if (availableEvents.Length != 0)
{
isErupting[index] = true;
DelayEvent chosenEvent = availableEvents[index];
chosenEvent.Go();
if (!isSecondEruption && Random.value < doMultipleEruptionsChance)
{
((MonoBehaviour)this).StartCoroutine(DoEruption(isSecondEruption: true));
}
yield return (object)new WaitForSeconds(3f);
isErupting[index] = false;
}
}
}
[HarmonyPatch(typeof(GroundChecker), "OnCollisionEnter")]
internal class GroundFixer
{
[HarmonyPrefix]
public static bool Prefix(GroundChecker __instance, Collision collision)
{
if (__instance.ignoreRigidbodies && ((Object)collision.transform.root).name == "Map")
{
__instance.ignoreRigidbodies = false;
}
return true;
}
}
public class NuckSpear : MonoBehaviour
{
private Transform shootPosition;
public GameObject objectToSpawn;
private GameObject spawnedObject;
private Level myLevel;
public float spawnDelay = 0.4f;
public bool callHammerEffects = true;
private float levelMultiplier = 1f;
private AnimationCurve shootHelpAngleCurve = new AnimationCurve();
public bool parentToMe;
private void Awake()
{
if (Object.op_Implicit((Object)(object)((Component)this).GetComponent<RangeWeapon>()) && Object.op_Implicit((Object)(object)((Component)this).GetComponent<RangeWeapon>().ObjectToSpawn))
{
GameObject val = objectToSpawn;
objectToSpawn = ((Component)this).GetComponent<RangeWeapon>().ObjectToSpawn;
((Component)this).GetComponent<RangeWeapon>().ObjectToSpawn = val;
}
}
private void Start()
{
myLevel = ((Component)this).GetComponent<Level>();
shootPosition = (Object.op_Implicit((Object)(object)((Component)this).GetComponentInChildren<ShootPosition>()) ? ((Component)((Component)this).GetComponentInChildren<ShootPosition>()).transform : ((Component)this).transform);
}
public void Throw()
{
((MonoBehaviour)this).StartCoroutine(DelayedSwing());
}
public IEnumerator DelayedSwing()
{
Unit target = ((Component)this).GetComponent<Weapon>().connectedData.targetData.unit;
yield return (object)new WaitForSeconds(spawnDelay);
spawnedObject = Object.Instantiate<GameObject>(objectToSpawn, shootPosition.position, shootPosition.rotation, parentToMe ? ((Component)this).transform : null);
MoveTransform component = spawnedObject.GetComponent<MoveTransform>();
Vector3 val = target.data.mainRig.position - ((Component)this).transform.position;
component.velocity = ((Vector3)(ref val)).normalized * ((Vector3)(ref spawnedObject.GetComponent<MoveTransform>().selfImpulse)).magnitude;
NuckSpear nuckSpear = this;
GameObject obj = spawnedObject;
NuckSpear nuckSpear2 = this;
val = target.data.mainRig.position - shootPosition.position;
Vector3 spawnDirection = nuckSpear2.GetSpawnDirection(((Vector3)(ref val)).normalized, target.data.mainRig, new Vector3(0f, 0f, 0f));
val = target.data.mainRig.position - shootPosition.position;
nuckSpear.SetProjectileStats(obj, spawnDirection, ((Vector3)(ref val)).normalized, target.data.mainRig, shootPosition.forward, target.data.mainRig.position, target.data.mainRig.velocity);
TeamHolder team = spawnedObject.AddComponent<TeamHolder>();
team.spawner = ((Component)((Component)this).GetComponent<Weapon>().connectedData.unit).gameObject;
team.spawnerWeapon = ((Component)this).gameObject;
team.team = ((Component)this).GetComponent<Weapon>().connectedData.unit.Team;
team.target = target.data.mainRig;
TeamColor[] componentsInChildren = spawnedObject.GetComponentsInChildren<TeamColor>();
foreach (TeamColor teamc in componentsInChildren)
{
teamc.SetTeamColor(team.team);
}
}
public void SetProjectileStats(GameObject spawnedObject, Vector3 spawnDir, Vector3 directionToTarget, Rigidbody targetRig, Vector3 shootPositionForward, Vector3 targetRigPosition, Vector3 targetRigVelocity)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
Transform[] componentsInChildren = spawnedObject.GetComponentsInChildren<Transform>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
Rigidbody component = ((Component)componentsInChildren[i]).GetComponent<Rigidbody>();
if (Object.op_Implicit((Object)(object)component))
{
component.AddForce(spawnDir * 1f, (ForceMode)2);
if (Object.op_Implicit((Object)(object)myLevel))
{
component.mass *= Mathf.Pow((float)myLevel.level, 1.5f);
}
}
Compensation componentInChildren = ((Component)componentsInChildren[i]).GetComponentInChildren<Compensation>();
if (Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)targetRig))
{
((Component)componentInChildren).transform.rotation = Quaternion.LookRotation(componentInChildren.GetCompensation(targetRigPosition, targetRigVelocity, shootHelpAngleCurve.Evaluate(Vector3.Angle(directionToTarget, shootPositionForward))) + Random.insideUnitSphere * 1f * 0.01f);
}
MoveTransform componentInChildren2 = spawnedObject.GetComponentInChildren<MoveTransform>();
if (Object.op_Implicit((Object)(object)componentInChildren2) && Object.op_Implicit((Object)(object)componentInChildren) && componentInChildren.forwardCompensation > 0f && Object.op_Implicit((Object)(object)targetRig))
{
MoveTransform val = componentInChildren2;
val.selfImpulse.z = val.selfImpulse.z + Mathf.Pow(Mathf.Clamp(Vector3.Distance(targetRigPosition, ((Component)this).transform.position), 0f, componentInChildren.clampDistance), componentInChildren.rangePow) * componentInChildren.forwardCompensation;
}
AddForce component2 = spawnedObject.GetComponent<AddForce>();
if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)componentInChildren) && componentInChildren.forwardCompensation > 0f && Object.op_Implicit((Object)(object)targetRig))
{
AddForce val2 = component2;
val2.force.z = val2.force.z + Mathf.Pow(Mathf.Clamp(Vector3.Distance(targetRigPosition, ((Component)this).transform.position), 0f, componentInChildren.clampDistance), componentInChildren.rangePow) * componentInChildren.forwardCompensation;
}
ProjectileHit componentInChildren3 = ((Component)componentsInChildren[i]).GetComponentInChildren<ProjectileHit>();
if (Object.op_Implicit((Object)(object)componentInChildren3))
{
componentInChildren3.damage *= levelMultiplier;
if (Object.op_Implicit((Object)(object)((Component)this).GetComponent<Weapon>().connectedData) && ((Component)this).GetComponent<Weapon>().connectedData.input.hasControl)
{
componentInChildren3.alwaysHitTeamMates = true;
}
if (Object.op_Implicit((Object)(object)myLevel))
{
componentInChildren3.ignoreTeamMates = myLevel.ignoreTeam;
}
}
CollisionWeapon componentInChildren4 = ((Component)componentsInChildren[i]).GetComponentInChildren<CollisionWeapon>();
if (Object.op_Implicit((Object)(object)componentInChildren4))
{
componentInChildren4.damage *= levelMultiplier;
}
if (Object.op_Implicit((Object)(object)componentInChildren2))
{
componentInChildren2.selfImpulse *= 1f;
componentInChildren2.worldImpulse.y = 0f;
}
if (Object.op_Implicit((Object)(object)componentInChildren3))
{
componentInChildren3.damage *= 1f;
componentInChildren3.force *= 1f;
}
}
Level val3 = spawnedObject.GetComponent<Level>();
if ((Object)(object)val3 == (Object)null)
{
val3 = spawnedObject.AddComponent<Level>();
}
val3.levelMultiplier = levelMultiplier;
if (Object.op_Implicit((Object)(object)myLevel))
{
val3.ignoreTeam = myLevel.ignoreTeam;
val3.level = myLevel.level;
}
}
private Vector3 GetSpawnDirection(Vector3 directionToTarget, Rigidbody targetRig, Vector3 forcedDirection)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//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)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
Vector3 normalized = ((Vector3)(ref directionToTarget)).normalized;
Vector3 val = Vector3.Lerp(directionToTarget, shootPosition.forward, shootHelpAngleCurve.Evaluate(Vector3.Angle(directionToTarget, shootPosition.forward)));
normalized = ((Vector3)(ref val)).normalized;
if (Object.op_Implicit((Object)(object)((Component)this).GetComponent<Weapon>().connectedData) && ((Component)this).GetComponent<Weapon>().connectedData.input.hasControl && !Object.op_Implicit((Object)(object)targetRig))
{
normalized = forcedDirection;
}
return normalized;
}
}
public class PBRevive : MonoBehaviour
{
private Unit unit;
private EyeSpawner eyeSpawner;
private PlaguePhases plaguePhases;
[Header("Revive Settings")]
public UnityEvent preReviveEvent = new UnityEvent();
public UnityEvent reviveEvent = new UnityEvent();
public float reviveDelay = 4f;
[Range(0f, 1f)]
public float reviveHealthMultiplier = 0.5f;
public bool openEyes = true;
[Header("Weapon Settings")]
public bool letGoOfWeapons;
public bool useWeaponsAfterRevive = true;
public GameObject rightWeaponToSpawn;
public GameObject leftWeaponToSpawn;
private GameObject rightWeaponOriginal;
private GameObject leftWeaponOriginal;
public bool holdWithTwoHands;
public float removeWeaponsAfterSeconds;
public void Start()
{
unit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
eyeSpawner = ((Component)unit).GetComponentInChildren<EyeSpawner>();
plaguePhases = ((Component)this).GetComponent<PlaguePhases>();
unit.data.healthHandler.willBeRewived = true;
if ((Object)(object)unit.data.weaponHandler.rightWeapon != (Object)null && Object.op_Implicit((Object)(object)((Component)unit.data.weaponHandler.rightWeapon).GetComponent<Holdable>()))
{
rightWeaponOriginal = ((Component)unit.data.weaponHandler.rightWeapon).gameObject;
if (!letGoOfWeapons)
{
((Component)unit.data.weaponHandler.rightWeapon).GetComponent<Holdable>().ignoreDissarm = true;
}
}
if ((Object)(object)unit.data.weaponHandler.leftWeapon != (Object)null && Object.op_Implicit((Object)(object)((Component)unit.data.weaponHandler.leftWeapon).GetComponent<Holdable>()))
{
leftWeaponOriginal = ((Component)unit.data.weaponHandler.leftWeapon).gameObject;
if (!letGoOfWeapons)
{
((Component)unit.data.weaponHandler.leftWeapon).GetComponent<Holdable>().ignoreDissarm = true;
}
}
}
public void DoRevive()
{
if (plaguePhases.currentState == PlaguePhases.PlagueState.Sickly)
{
((MonoBehaviour)this).StartCoroutine(Revival());
}
else if (unit.data.healthHandler.willBeRewived)
{
unit.data.healthHandler.willBeRewived = false;
unit.data.healthHandler.Die((Unit)null);
Object.Destroy((Object)(object)this);
}
}
public IEnumerator Revival()
{
UnitEffectBase effect = ((Component)unit).GetComponentsInChildren<UnitEffectBase>().ToList().Find((UnitEffectBase x) => x.effectID == 1984 || x.effectID == 1987);
if (unit.data.health > 0f || Object.op_Implicit((Object)(object)effect) || !unit.data.healthHandler.willBeRewived)
{
unit.data.healthHandler.willBeRewived = false;
ServiceLocator.GetService<GameModeService>().CurrentGameMode.OnUnitDied(unit);
Object.Destroy((Object)(object)this);
yield break;
}
preReviveEvent.Invoke();
((MonoBehaviour)this).StartCoroutine(plaguePhases.PlayPartWithDelay(reviveDelay - 0.5f));
yield return (object)new WaitForSeconds(reviveDelay);
unit.data.Dead = false;
unit.dead = false;
unit.data.hasBeenRevived = true;
unit.data.healthHandler.willBeRewived = false;
plaguePhases.currentState = PlaguePhases.PlagueState.Zombie;
unit.data.ragdollControl = 1f;
unit.data.muscleControl = 1f;
unit.data.health = unit.data.maxHealth * reviveHealthMultiplier;
if (letGoOfWeapons)
{
if (Object.op_Implicit((Object)(object)rightWeaponToSpawn))
{
Weapon weapon = unit.unitBlueprint.SetWeapon(unit, unit.Team, rightWeaponToSpawn, new PropItemData(), (HandType)0, unit.data.mainRig.rotation, new List<GameObject>(), false);
Rigidbody rigidbody = weapon.rigidbody;
rigidbody.mass *= unit.unitBlueprint.massMultiplier;
if (holdWithTwoHands)
{
unit.holdingHandler.leftHandActivity = (HandActivity)1;
}
}
else if (useWeaponsAfterRevive && Object.op_Implicit((Object)(object)rightWeaponOriginal))
{
Weapon weapon2 = unit.unitBlueprint.SetWeapon(unit, unit.Team, rightWeaponOriginal, new PropItemData(), (HandType)0, unit.data.mainRig.rotation, new List<GameObject>(), false);
Rigidbody rigidbody2 = weapon2.rigidbody;
rigidbody2.mass *= unit.unitBlueprint.massMultiplier;
}
if (!holdWithTwoHands)
{
if (Object.op_Implicit((Object)(object)leftWeaponToSpawn))
{
Weapon weapon3 = unit.unitBlueprint.SetWeapon(unit, unit.Team, leftWeaponToSpawn, new PropItemData(), (HandType)1, unit.data.mainRig.rotation, new List<GameObject>(), false);
Rigidbody rigidbody3 = weapon3.rigidbody;
rigidbody3.mass *= unit.unitBlueprint.massMultiplier;
}
else if (useWeaponsAfterRevive && Object.op_Implicit((Object)(object)leftWeaponOriginal))
{
Weapon weapon4 = unit.unitBlueprint.SetWeapon(unit, unit.Team, leftWeaponOriginal, new PropItemData(), (HandType)1, unit.data.mainRig.rotation, new List<GameObject>(), false);
Rigidbody rigidbody4 = weapon4.rigidbody;
rigidbody4.mass *= unit.unitBlueprint.massMultiplier;
}
}
if (Object.op_Implicit((Object)(object)rightWeaponOriginal))
{
rightWeaponOriginal.transform.SetParent((Transform)null);
if (removeWeaponsAfterSeconds > 0f)
{
RemoveAfterSeconds sec = rightWeaponOriginal.AddComponent<RemoveAfterSeconds>();
sec.shrink = true;
sec.seconds = removeWeaponsAfterSeconds;
}
else if (removeWeaponsAfterSeconds < 0f)
{
Object.Destroy((Object)(object)rightWeaponOriginal);
}
}
if (Object.op_Implicit((Object)(object)leftWeaponOriginal))
{
leftWeaponOriginal.transform.SetParent((Transform)null);
if (removeWeaponsAfterSeconds > 0f)
{
RemoveAfterSeconds sec2 = leftWeaponOriginal.AddComponent<RemoveAfterSeconds>();
sec2.shrink = true;
sec2.seconds = removeWeaponsAfterSeconds;
}
else if (removeWeaponsAfterSeconds < 0f)
{
Object.Destroy((Object)(object)leftWeaponOriginal);
}
}
}
if (openEyes && Object.op_Implicit((Object)(object)eyeSpawner) && eyeSpawner.spawnedEyes != null)
{
foreach (GooglyEye eye in eyeSpawner.spawnedEyes)
{
eye.dead.SetActive(false);
eye.currentEyeState = (EyeState)0;
eye.SetState((EyeState)0);
GooglyEyes.instance.AddEye(eye);
}
}
if (unit.unitBlueprint.MovementComponents != null && unit.unitBlueprint.MovementComponents.Count > 0)
{
foreach (IMovementComponent mov in unit.unitBlueprint.MovementComponents)
{
MethodInfo mi = (MethodInfo)typeof(UnitAPI).GetMethod("CreateGenericRemoveComponentData", (BindingFlags)(-1)).Invoke(unit.api, new object[1] { ((object)mov).GetType() });
mi.Invoke(((Component)unit).GetComponent<GameObjectEntity>().EntityManager, new object[1] { ((Component)unit).GetComponent<GameObjectEntity>().Entity });
}
}
((UnityEventBase)unit.data.healthHandler.deathEvent).RemoveAllListeners();
AddRigidbodyOnDeath[] componentsInChildren = ((Component)unit).GetComponentsInChildren<AddRigidbodyOnDeath>();
foreach (AddRigidbodyOnDeath rigidbodyOnDeath in componentsInChildren)
{
unit.data.healthHandler.RemoveDieAction((Action)rigidbodyOnDeath.Die);
}
DeathEvent[] componentsInChildren2 = ((Component)unit).GetComponentsInChildren<DeathEvent>();
foreach (DeathEvent deathEvent in componentsInChildren2)
{
unit.data.healthHandler.RemoveDieAction((Action)deathEvent.Die);
}
ServiceLocator.GetService<UnitHealthbars>().HandleUnitSpawned(unit);
unit.api.SetTargetingType(unit.unitBlueprint.TargetingComponent);
unit.api.UpdateECSValues();
unit.InitializeUnit(unit.Team);
reviveEvent.Invoke();
plaguePhases.SetRenderer();
plaguePhases.part.Play();
Object.Destroy((Object)(object)this);
}
}
public class PlaguePhases : MonoBehaviour
{
public enum PlagueState
{
Alive,
Sickly,
Zombie
}
private Unit unit;
public PlagueState currentState;
public Renderer renderer;
public Renderer sickRenderer;
public Renderer zombieRenderer;
public ParticleSystem part;
public List<Material> sicklyMaterials = new List<Material>();
public List<int> aliveMaterialIndexes = new List<int>();
public GameObject reviveEye;
public float sickenTime = 6f;
private void Start()
{
unit = ((Component)((Component)this).transform.root).GetComponent<Unit>();
unit.data.healthHandler.willBeRewived = false;
}
public void BeginTransition()
{
((MonoBehaviour)this).StartCoroutine(DoSickening());
}
private IEnumerator DoSickening()
{
((MonoBehaviour)this).StartCoroutine(PlayPartWithDelay(sickenTime - 0.5f));
List<Material> storedAliveMaterials = new List<Material>();
foreach (int index in aliveMaterialIndexes)
{
storedAliveMaterials.Add(Object.Instantiate<Material>(renderer.materials[index]));
}
float t = 0f;
while (t < sickenTime && !unit.data.Dead)
{
for (int i = 0; i < aliveMaterialIndexes.Count; i++)
{
renderer.materials[aliveMaterialIndexes[i]].Lerp(storedAliveMaterials[i], sicklyMaterials[i], t / sickenTime);
}
t += Time.deltaTime;
yield return null;
}
if (unit.data.Dead)
{
part.Stop();
Object.Destroy((Object)(object)((Component)this).gameObject);
yield break;
}
currentState = PlagueState.Sickly;
SetRenderer();
if (Object.op_Implicit((Object)(object)((Component)unit).GetComponentInChildren<EyeSpawner>()))
{
EyeSpawner[] componentsInChildren = ((Component)unit).GetComponentsInChildren<EyeSpawner>();
foreach (EyeSpawner eyeSet in componentsInChildren)
{
foreach (GooglyEye eye in eyeSet.spawnedEyes)
{
Object.Destroy((Object)(object)((Component)eye).gameObject);
}
eyeSet.spawnedEyes.Clear();
eyeSet.eyeObject = reviveEye;
((object)eyeSet).GetType().GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(eyeSet, new object[0]);
}
}
((MonoBehaviour)this).StartCoroutine(PlayPartWithDelay(0.5f));
}
public IEnumerator PlayPartWithDelay(float delay = 0f)
{
yield return (object)new WaitForSeconds(delay);
part.Play();
}
public void SetRenderer()
{
if (currentState == PlagueState.Alive)
{
((Component)renderer).gameObject.SetActive(true);
((Component)sickRenderer).gameObject.SetActive(false);
((Component)zombieRenderer).gameObject.SetActive(false);
}
else if (currentState == PlagueState.Sickly)
{
((Component)renderer).gameObject.SetActive(false);
((Component)sickRenderer).gameObject.SetActive(true);
((Component)zombieRenderer).gameObject.SetActive(false);
}
else if (currentState == PlagueState.Zombie)
{
((Component)renderer).gameObject.SetActive(false);
((Component)sickRenderer).gameObject.SetActive(false);
((Component)zombieRenderer).gameObject.SetActive(true);
}
}
}
public class ReturnableProjectile : MonoBehaviour
{
private Transform returnObject;
private GameObject weapon;
public string objectToReturnTo;
public float speed = 1f;
private void Start()
{
weapon = ((Component)this).GetComponent<TeamHolder>().spawnerWeapon;
returnObject = TransformExtensions.FindChildRecursive(weapon.transform, objectToReturnTo);
}
public void Return()
{
((MonoBehaviour)this).StartCoroutine(DoReturn());
}
public IEnumerator DoReturn()
{
if (Object.op_Implicit((Object)(object)((Component)this).GetComponent<ProjectileStick>()))
{
Object.Destroy((Object)(object)((Component)this).GetComponent<ProjectileStick>());
}
float t = 0f;
Vector3 beginPosition = ((Component)this).transform.position;
Quaternion beginRotation = ((Component)this).transform.rotation;
while (t < 1f)
{
((Component)this).transform.position = Vector3.Lerp(beginPosition, returnObject.position, t);
((Component)this).transform.rotation = Quaternion.Lerp(beginRotation, returnObject.rotation, t);
t += Time.deltaTime * speed;
yield return null;
}
weapon.GetComponent<DelayEvent>().Go();
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public class AKSceneManager
{
public AKSceneManager()
{
SceneManager.sceneLoaded += SceneLoaded;
}
public void SceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
//IL_037e: Unknown result type (might be due to invalid IL or missing references)
//IL_0383: Unknown result type (might be due to invalid IL or missing references)
//IL_0391: Expected O, but got Unknown
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_0351: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
if (((Scene)(ref scene)).name.Contains("AK_"))
{
GameObject val = null;
GameObject val2 = null;
GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
foreach (GameObject val3 in rootGameObjects)
{
if (((Object)val3).name == "AStar_Lvl1_Grid")
{
val = val3;
}
if (((Object)val3).name == "Map")
{
val2 = val3;
List<MeshRenderer> list = new List<MeshRenderer>(val3.GetComponentsInChildren<MeshRenderer>(true).ToList().FindAll((MeshRenderer x) => ((Object)x).name.Contains("_ReplaceMe")));
foreach (MeshRenderer item in list)
{
Material[] materials = ((Renderer)item).materials;
foreach (Material val4 in materials)
{
val4.shader = Shader.Find(((Object)val4.shader).name);
}
if (Object.op_Implicit((Object)(object)((Component)item).GetComponent<PiratePlacementTransparency>()))
{
((Component)item).GetComponent<PiratePlacementTransparency>().Materials[0].m_oldMaterial.shader = Shader.Find(((Object)((Component)item).GetComponent<PiratePlacementTransparency>().Materials[0].m_oldMaterial.shader).name);
}
}
}
if (((Object)val3).name.Contains("_ReplaceMe"))
{
((Renderer)val3.GetComponent<MeshRenderer>()).material.shader = Shader.Find(((Object)((Renderer)val3.GetComponent<MeshRenderer>()).material.shader).name);
}
if (((Object)val3).name == "WaterManager")
{
val3.GetComponent<PirateWaterManager>().WaterMaterial = ((Renderer)val3.GetComponent<MeshRenderer>()).material;
}
}
if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
{
AstarPath componentInChildren = val.GetComponentInChildren<AstarPath>(true);
val.SetActive(true);
if (componentInChildren.data.graphs.Length != 0)
{
componentInChildren.data.RemoveGraph(componentInChildren.data.graphs[0]);
}
componentInChildren.data.AddGraph(typeof(RecastGraph));
componentInChildren.data.recastGraph.minRegionSize = 0.1f;
componentInChildren.data.recastGraph.characterRadius = 0.3f;
componentInChildren.data.recastGraph.cellSize = 0.2f;
((NavmeshBase)componentInChildren.data.recastGraph).forcedBoundsSize = new Vector3(val2.GetComponent<MapSettings>().m_mapRadius * 2f, val2.GetComponent<MapSettings>().m_mapRadius * val2.GetComponent<MapSettings>().mapRadiusYMultiplier * 2f, val2.GetComponent<MapSettings>().m_mapRadius * 2f);
componentInChildren.data.recastGraph.rasterizeMeshes = false;
componentInChildren.data.recastGraph.rasterizeColliders = true;
componentInChildren.data.recastGraph.mask = AKMain.kermate.LoadAsset<GameObject>("AStarDummy").GetComponent<Explosion>().layerMask;
componentInChildren.Scan((NavGraph[])null);
}
}
if (((Scene)(ref scene)).name == "05_Lvl1_Medieval_VC")
{
GameObject val5 = new GameObject
{
name = "Secrets"
};
Object.Instantiate<GameObject>(AKMain.kermate.LoadAsset<GameObject>("GreaterDragon_Unlock"), val5.transform, true);
}
}
}
public class SinkingPlatforms : GameStateListener
{
public int originalMask;
public int newMask;
public override void OnEnterPlacementState()
{
((Component)((Component)this).transform).gameObject.layer = originalMask;
for (int i = 0; i < ((Component)this).transform.childCount; i++)
{
((Component)((Component)this).transform.GetChild(i)).gameObject.layer = originalMask;
}
}
public override void OnEnterBattleState()
{
((Component)((Component)this).transform).gameObject.layer = newMask;
for (int i = 0; i < ((Component)this).transform.childCount; i++)
{
((Component)((Component)this).transform.GetChild(i)).gameObject.layer = newMask;
}
}
}
public class StealthMode : MonoBehaviour
{
public bool stealthOnStart = true;
public void Start()
{
if (stealthOnStart)
{
EnterStealth();
}
}
public void EnterStealth()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
((Component)((Component)this).transform.root).GetComponent<GameObjectEntity>().EntityManager.AddComponentData<IsDead>(((Component)((Component)this).transform.root).GetComponent<GameObjectEntity>().Entity, default(IsDead));
}
public void LeaveStealth()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
if (!((Component)((Component)this).transform.root).GetComponent<Unit>().data.Dead)
{
((Component)((Component)this).transform.root).GetComponent<GameObjectEntity>().EntityManager.RemoveComponent<IsDead>(((Component)((Component)this).transform.root).GetComponent<GameObjectEntity>().Entity);
}
}
}
[BepInPlugin("teamgrad.animalkingdom", "Animal Kingdom", "1.0.4")]
public class AKLauncher : BaseUnityPlugin
{
public void Awake()
{
((MonoBehaviour)this).StartCoroutine(LaunchMod());
}
private static IEnumerator LaunchMod()
{
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
new AKMain();
}
}
public class AKMain
{
public List<UnitBlueprint> newUnits = new List<UnitBlueprint>();
public List<Faction> newFactions = new List<Faction>();
public List<TABSCampaignAsset> newCampaigns = new List<TABSCampaignAsset>();
public List<TABSCampaignLevelAsset> newCampaignLevels = new List<TABSCampaignLevelAsset>();
public List<VoiceBundle> newVoiceBundles = new List<VoiceBundle>();
public List<FactionIcon> newFactionIcons = new List<FactionIcon>();
public List<GameObject> newBases = new List<GameObject>();
public List<GameObject> newProps = new List<GameObject>();
public List<GameObject> newAbilities = new List<GameObject>();
public List<GameObject> newWeapons = new List<GameObject>();
public List<GameObject> newProjectiles = new List<GameObject>();
public static AssetBundle kermate = AssetBundle.LoadFromMemory(Resources.animalkingdom);
public AKMain()
{
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
//IL_042e: Unknown result type (might be due to invalid IL or missing references)
//IL_0433: Unknown result type (might be due to invalid IL or missing references)
//IL_0449: Unknown result type (might be due to invalid IL or missing references)
//IL_0451: Unknown result type (might be due to invalid IL or missing references)
//IL_0471: Expected O, but got Unknown
ContentDatabase val = ContentDatabase.Instance();
AssetBundle.LoadFromMemory(Resources.calderaceum);
AssetBundle.LoadFromMemory(Resources.weepingcopse);
List<MapAsset> list = ((MapAsset[])typeof(LandfallContentDatabase).GetField("m_orderedMapAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val.LandfallContentDatabase)).ToList();
Dictionary<DatabaseID, int> dictionary = (Dictionary<DatabaseID, int>)typeof(LandfallContentDatabase).GetField("m_mapAssetIndexLookup", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(val.LandfallContentDatabase);
MapAsset[] array = kermate.LoadAllAssets<MapAsset>();
foreach (MapAsset val2 in array)
{
list.Add(val2);
dictionary.Add(val2.Entity.GUID, list.IndexOf(val2));
}
typeof(LandfallContentDatabase).GetField("m_orderedMapAssets", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(val.LandfallContentDatabase, list.ToArray());
typeof(LandfallContentDatabase).GetField("m_mapAssetIndexLookup", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(val.LandfallContentDatabase, dictionary);
List<Faction> list2 = val.LandfallContentDatabase.GetFactions().ToList();
Faction[] array2 = kermate.LoadAllAssets<Faction>();
foreach (Faction val3 in array2)
{
UnitBlueprint[] source = (from x in val3.Units
where Object.op_Implicit((Object)(object)x)
orderby x.GetUnitCost(true)
select x).ToArray();
val3.Units = source.ToArray();
foreach (Faction item6 in list2)
{
if (val3.Entity.Name == item6.Entity.Name + "_NEW")
{
List<UnitBlueprint> list3 = new List<UnitBlueprint>(item6.Units);
list3.AddRange(val3.Units);
item6.Units = (from x in list3
where Object.op_Implicit((Object)(object)x)
orderby x.GetUnitCost(true)
select x).ToArray();
Object.Destroy((Object)(object)val3);
}
}
}
SoundBank[] array3 = kermate.LoadAllAssets<SoundBank>();
foreach (SoundBank val4 in array3)
{
if (((Object)val4).name.Contains("Sound"))
{
SoundBank soundBank = ServiceLocator.GetService<SoundPlayer>().soundBank;
SoundBankCategory[] categories = val4.Categories;
foreach (SoundBankCategory val5 in categories)
{
val5.categoryMixerGroup = soundBank.Categories[0].categoryMixerGroup;
}
List<SoundBankCategory> list4 = soundBank.Categories.ToList();
list4.AddRange(val4.Categories);
soundBank.Categories = list4.ToArray();
}
else
{
if (!((Object)val4).name.Contains("Music"))
{
continue;
}
SoundBank bank = ServiceLocator.GetService<MusicHandler>().bank;
List<SoundBankCategory> list5 = bank.Categories.ToList();
list5.AddRange(val4.Categories);
SoundBankCategory[] categories2 = val4.Categories;
foreach (SoundBankCategory val6 in categories2)
{
SoundEffectInstance[] soundEffects = val6.soundEffects;
foreach (SoundEffectInstance val7 in soundEffects)
{
SongInstance val8 = new SongInstance
{
clip = val7.clipTypes[0].clips[0],
soundEffectInstance = val7,
songRef = val6.categoryName + "/" + val7.soundRef
};
ServiceLocator.GetService<MusicHandler>().m_songs.Add(val8.songRef, val8);
}
}
bank.Categories = list5.ToArray();
}
}
new AKSceneManager();
new Harmony("DAMNTHEYREALLYCALLEDTHISTHINGFERNASS").PatchAll();
Faction[] array4 = kermate.LoadAllAssets<Faction>();
foreach (Faction item in array4)
{
newFactions.Add(item);
}
UnitBlueprint[] array5 = kermate.LoadAllAssets<UnitBlueprint>();
foreach (UnitBlueprint val9 in array5)
{
newUnits.Add(val9);
foreach (GameObject item7 in val.LandfallContentDatabase.GetUnitBases().ToList())
{
if ((Object)(object)val9.UnitBase != (Object)null && ((Object)item7).name == ((Object)val9.UnitBase).name)
{
val9.UnitBase = item7;
}
}
foreach (GameObject item8 in val.LandfallContentDatabase.GetWeapons().ToList())
{
if ((Object)(object)val9.RightWeapon != (Object)null && ((Object)item8).name == ((Object)val9.RightWeapon).name)
{
val9.RightWeapon = item8;
}
if ((Object)(object)val9.LeftWeapon != (Object)null && ((Object)item8).name == ((Object)val9.LeftWeapon).name)
{
val9.LeftWeapon = item8;
}
}
}
VoiceBundle[] array6 = kermate.LoadAllAssets<VoiceBundle>();
foreach (VoiceBundle item2 in array6)
{
newVoiceBundles.Add(item2);
}
FactionIcon[] array7 = kermate.LoadAllAssets<FactionIcon>();
foreach (FactionIcon item3 in array7)
{
newFactionIcons.Add(item3);
}
GameObject[] array8 = kermate.LoadAllAssets<GameObject>();
foreach (GameObject val10 in array8)
{
if (!((Object)(object)val10 != (Object)null))
{
continue;
}
AudioSource[] componentsInChildren = val10.GetComponentsInChildren<AudioSource>(true);
foreach (AudioSource val11 in componentsInChildren)
{
val11.outputAudioMixerGroup = ServiceLocator.GetService<GameModeService>().AudioSettings.AudioMixer.outputAudioMixerGroup;
}
if (Object.op_Implicit((Object)(object)val10.GetComponent<Unit>()))
{
newBases.Add(val10);
}
else if (Object.op_Implicit((Object)(object)val10.GetComponent<WeaponItem>()))
{
newWeapons.Add(val10);
int num11 = 0;
MeshFilter[] componentsInChildren2 = val10.GetComponentsInChildren<MeshFilter>();
foreach (MeshFilter val12 in componentsInChildren2)
{
if (((Component)val12).gameObject.activeSelf && ((Component)val12).gameObject.activeInHierarchy && val12.mesh.subMeshCount > 0 && Object.op_Implicit((Object)(object)((Component)val12).GetComponent<MeshRenderer>()) && ((Renderer)((Component)val12).GetComponent<MeshRenderer>()).enabled)
{
num11 += val12.mesh.subMeshCount;
}
}
SkinnedMeshRenderer[] componentsInChildren3 = val10.GetComponentsInChildren<SkinnedMeshRenderer>();
foreach (SkinnedMeshRenderer val13 in componentsInChildren3)
{
if (((Component)val13).gameObject.activeSelf && val13.sharedMesh.subMeshCount > 0 && ((Renderer)val13).enabled)
{
num11 += val13.sharedMesh.subMeshCount;
}
}
if (num11 != 0)
{
float item4 = 1f / (float)num11;
List<float> list6 = new List<float>();
for (int num14 = 0; num14 < num11; num14++)
{
list6.Add(item4);
}
((CharacterItem)val10.GetComponent<WeaponItem>()).SubmeshArea = null;
((CharacterItem)val10.GetComponent<WeaponItem>()).SubmeshArea = list6.ToArray();
}
}
else if (Object.op_Implicit((Object)(object)val10.GetComponent<ProjectileEntity>()))
{
newProjectiles.Add(val10);
}
else if (Object.op_Implicit((Object)(object)val10.GetComponent<SpecialAbility>()))
{
newAbilities.Add(val10);
}
else
{
if (!Object.op_Implicit((Object)(object)val10.GetComponent<PropItem>()) || !((CharacterItem)val10.GetComponent<PropItem>()).ShowInEditor)
{
continue;
}
newProps.Add(val10);
int num15 = 0;
MeshFilter[] componentsInChildren4 = val10.GetComponentsInChildren<MeshFilter>();
foreach (MeshFilter val14 in componentsInChildren4)
{
if (((Component)val14).gameObject.activeSelf && ((Component)val14).gameObject.activeInHierarchy && val14.mesh.subMeshCount > 0 && Object.op_Implicit((Object)(object)((Component)val14).GetComponent<MeshRenderer>()) && ((Renderer)((Component)val14).GetComponent<MeshRenderer>()).enabled)
{
num15 += val14.mesh.subMeshCount;
}
}
SkinnedMeshRenderer[] componentsInChildren5 = val10.GetComponentsInChildren<SkinnedMeshRenderer>();
foreach (SkinnedMeshRenderer val15 in componentsInChildren5)
{
if (((Component)val15).gameObject.activeSelf && val15.sharedMesh.subMeshCount > 0 && ((Renderer)val15).enabled)
{
num15 += val15.sharedMesh.subMeshCount;
}
}
if (num15 != 0)
{
float item5 = 1f / (float)num15;
List<float> list7 = new List<float>();
for (int num18 = 0; num18 < num15; num18++)
{
list7.Add(item5);
}
((CharacterItem)val10.GetComponent<PropItem>()).SubmeshArea = null;
((CharacterItem)val10.GetComponent<PropItem>()).SubmeshArea = list7.ToArray();
}
}
}
AddContentToDatabase();
}
public void AddContentToDatabase()
{
//IL_0081: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: 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_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0418: Unknown result type (might be due to invalid IL or missing references)
//IL_042d: Unknown result type (might be due to invalid IL or missing references)
//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
//IL_057e: Unknown result type (might be due to invalid IL or missing references)
//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
//IL_064d: Unknown result type (might be due to invalid IL or missing references)
//IL_066f: Unknown result type (might be due to invalid IL or missing references)
//IL_0689: Unknown result type (might be due to invalid IL or missing references)
//IL_071c: Unknown result type (might be due to invalid IL or missing references)
//IL_073e: Unknown result type (might be due to invalid IL or missing references)
//IL_0758: Unknown result type (might be due to invalid IL or missing references)
//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
//IL_080d: Unknown result type (might be due to invalid IL or missing references)
//IL_0827: Unknown result type (might be due to invalid IL or missing references)
//IL_08ba: Unknown result type (might be due to invalid IL or missing references)
//IL_08dc: Unknown result type (might be due to invalid IL or missing references)
//IL_08f6: Unknown result type (might be due to invalid IL or missing references)
Dictionary<DatabaseID, Object> dictionary = (Dictionary<DatabaseID, Object>)typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ContentDatabase.Instance().AssetLoader);
LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
Dictionary<DatabaseID, UnitBlueprint> dictionary2 = (Dictionary<DatabaseID, UnitBlueprint>)typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (UnitBlueprint newUnit in newUnits)
{
if (!dictionary2.ContainsKey(newUnit.Entity.GUID))
{
dictionary2.Add(newUnit.Entity.GUID, newUnit);
dictionary.Add(newUnit.Entity.GUID, (Object)(object)newUnit);
}
}
typeof(LandfallContentDatabase).GetField("m_unitBlueprints", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary2);
Dictionary<DatabaseID, Faction> factions = (Dictionary<DatabaseID, Faction>)typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
List<DatabaseID> list = (List<DatabaseID>)typeof(LandfallContentDatabase).GetField("m_defaultHotbarFactionIds", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (Faction newFaction in newFactions)
{
if (!factions.ContainsKey(newFaction.Entity.GUID))
{
factions.Add(newFaction.Entity.GUID, newFaction);
dictionary.Add(newFaction.Entity.GUID, (Object)(object)newFaction);
list.Add(newFaction.Entity.GUID);
}
}
typeof(LandfallContentDatabase).GetField("m_factions", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, factions);
typeof(LandfallContentDatabase).GetField("m_defaultHotbarFactionIds", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, list.OrderBy((DatabaseID x) => factions[x].index).ToList());
Dictionary<DatabaseID, TABSCampaignAsset> dictionary3 = (Dictionary<DatabaseID, TABSCampaignAsset>)typeof(LandfallContentDatabase).GetField("m_campaigns", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (TABSCampaignAsset newCampaign in newCampaigns)
{
if (!dictionary3.ContainsKey(newCampaign.Entity.GUID))
{
dictionary3.Add(newCampaign.Entity.GUID, newCampaign);
dictionary.Add(newCampaign.Entity.GUID, (Object)(object)newCampaign);
}
}
typeof(LandfallContentDatabase).GetField("m_campaigns", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary3);
Dictionary<DatabaseID, TABSCampaignLevelAsset> dictionary4 = (Dictionary<DatabaseID, TABSCampaignLevelAsset>)typeof(LandfallContentDatabase).GetField("m_campaignLevels", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (TABSCampaignLevelAsset newCampaignLevel in newCampaignLevels)
{
if (!dictionary4.ContainsKey(newCampaignLevel.Entity.GUID))
{
dictionary4.Add(newCampaignLevel.Entity.GUID, newCampaignLevel);
dictionary.Add(newCampaignLevel.Entity.GUID, (Object)(object)newCampaignLevel);
}
}
typeof(LandfallContentDatabase).GetField("m_campaignLevels", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary4);
Dictionary<DatabaseID, VoiceBundle> dictionary5 = (Dictionary<DatabaseID, VoiceBundle>)typeof(LandfallContentDatabase).GetField("m_voiceBundles", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (VoiceBundle newVoiceBundle in newVoiceBundles)
{
if (!dictionary5.ContainsKey(newVoiceBundle.Entity.GUID))
{
dictionary5.Add(newVoiceBundle.Entity.GUID, newVoiceBundle);
dictionary.Add(newVoiceBundle.Entity.GUID, (Object)(object)newVoiceBundle);
}
}
typeof(LandfallContentDatabase).GetField("m_voiceBundles", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary5);
List<DatabaseID> list2 = (List<DatabaseID>)typeof(LandfallContentDatabase).GetField("m_factionIconIds", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (FactionIcon newFactionIcon in newFactionIcons)
{
if (!list2.Contains(newFactionIcon.Entity.GUID))
{
list2.Add(newFactionIcon.Entity.GUID);
dictionary.Add(newFactionIcon.Entity.GUID, (Object)(object)newFactionIcon);
}
}
typeof(LandfallContentDatabase).GetField("m_factionIconIds", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, list2);
Dictionary<DatabaseID, GameObject> dictionary6 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_unitBases", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (GameObject newBasis in newBases)
{
if (!dictionary6.ContainsKey(newBasis.GetComponent<Unit>().Entity.GUID))
{
dictionary6.Add(newBasis.GetComponent<Unit>().Entity.GUID, newBasis);
dictionary.Add(newBasis.GetComponent<Unit>().Entity.GUID, (Object)(object)newBasis);
}
}
typeof(LandfallContentDatabase).GetField("m_unitBases", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary6);
Dictionary<DatabaseID, GameObject> dictionary7 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_characterProps", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (GameObject newProp in newProps)
{
if (!dictionary7.ContainsKey(((CharacterItem)newProp.GetComponent<PropItem>()).Entity.GUID))
{
dictionary7.Add(((CharacterItem)newProp.GetComponent<PropItem>()).Entity.GUID, newProp);
dictionary.Add(((CharacterItem)newProp.GetComponent<PropItem>()).Entity.GUID, (Object)(object)newProp);
}
}
typeof(LandfallContentDatabase).GetField("m_characterProps", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary7);
Dictionary<DatabaseID, GameObject> dictionary8 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_combatMoves", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (GameObject newAbility in newAbilities)
{
if (!dictionary8.ContainsKey(((CharacterItem)newAbility.GetComponent<SpecialAbility>()).Entity.GUID))
{
dictionary8.Add(((CharacterItem)newAbility.GetComponent<SpecialAbility>()).Entity.GUID, newAbility);
dictionary.Add(((CharacterItem)newAbility.GetComponent<SpecialAbility>()).Entity.GUID, (Object)(object)newAbility);
}
}
typeof(LandfallContentDatabase).GetField("m_combatMoves", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary8);
Dictionary<DatabaseID, GameObject> dictionary9 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_weapons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (GameObject newWeapon in newWeapons)
{
if (!dictionary9.ContainsKey(((CharacterItem)newWeapon.GetComponent<WeaponItem>()).Entity.GUID))
{
dictionary9.Add(((CharacterItem)newWeapon.GetComponent<WeaponItem>()).Entity.GUID, newWeapon);
dictionary.Add(((CharacterItem)newWeapon.GetComponent<WeaponItem>()).Entity.GUID, (Object)(object)newWeapon);
}
}
typeof(LandfallContentDatabase).GetField("m_weapons", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary9);
Dictionary<DatabaseID, GameObject> dictionary10 = (Dictionary<DatabaseID, GameObject>)typeof(LandfallContentDatabase).GetField("m_projectiles", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(landfallContentDatabase);
foreach (GameObject newProjectile in newProjectiles)
{
if (!dictionary10.ContainsKey(newProjectile.GetComponent<ProjectileEntity>().Entity.GUID))
{
dictionary10.Add(newProjectile.GetComponent<ProjectileEntity>().Entity.GUID, newProjectile);
dictionary.Add(newProjectile.GetComponent<ProjectileEntity>().Entity.GUID, (Object)(object)newProjectile);
}
}
typeof(LandfallContentDatabase).GetField("m_projectiles", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(landfallContentDatabase, dictionary10);
ServiceLocator.GetService<CustomContentLoaderModIO>().QuickRefresh((WorkshopContentType)0, (Action)null);
}
}
}
namespace AnimalKingdom.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("AnimalKingdom.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] animalkingdom
{
get
{
object obj = ResourceManager.GetObject("animalkingdom", resourceCulture);
return (byte[])obj;
}
}
internal static byte[] calderaceum
{
get
{
object obj = ResourceManager.GetObject("calderaceum", resourceCulture);
return (byte[])obj;
}
}
internal static byte[] weepingcopse
{
get
{
object obj = ResourceManager.GetObject("weepingcopse", resourceCulture);
return (byte[])obj;
}
}
internal Resources()
{
}
}
}