Decompiled source of Synth v1.0.0

plugins/Synth.dll

Decompiled 38 minutes ago
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.Mage.Weapon;
using HarmonyLib;
using KinematicCharacterController;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Achievements;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace SynthSurvivor;

[BepInPlugin("com.tox.synth", "Synth", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public sealed class Plugin : BaseUnityPlugin
{
	public static Plugin Instance;

	public static GameObject BodyPrefab;

	public static GameObject DisplayPrefab;

	public static GameObject Bolt;

	public static GameObject VolleyBolt;

	public static GameObject HeavyBolt;

	public static SurvivorDef Survivor;

	public static Sprite PrimaryIcon;

	public static Sprite SecondaryIcon;

	public static Sprite UtilityIcon;

	public static Sprite SpecialIcon;

	public static Sprite BoltIcon;

	public static Sprite PinIcon;

	public static Sprite PassiveIcon;

	public static ModdedDamageType AmbushDamage;

	public static ModdedDamageType PinDamage;

	public static ModdedDamageType DisengageDamage;

	public static BuffDef BarrierFlash;

	public static readonly Color Burgundy = new Color(0.35f, 0.14f, 0.57f);

	public static readonly Color Accent = new Color(0.61f, 0.37f, 0.84f);

	private Harmony harmony;

	public const BindingFlags Flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

	private void Awake()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Expected O, but got Unknown
		Instance = this;
		FeralTune.Load(((BaseUnityPlugin)this).Config);
		try
		{
			AmbushDamage = DamageAPI.ReserveDamageType();
			PinDamage = DamageAPI.ReserveDamageType();
			DisengageDamage = DamageAPI.ReserveDamageType();
			PrimaryIcon = SynthIcons.Make(0);
			SecondaryIcon = SynthIcons.Make(1);
			UtilityIcon = SynthIcons.Make(2);
			SpecialIcon = SynthIcons.Make(3);
			BoltIcon = SynthIcons.Make(4);
			PinIcon = SynthIcons.Make(5);
			PassiveIcon = SynthIcons.Make(6);
			SynthArsenal.Register();
			SynthMomentum.Register();
			SynthFeral.Register();
			SynthGuard.Register();
			SynthGoals.Register();
			SynthSkins.RegisterUnlocks();
			SynthVeil.Register();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SynthFireball.LoadTiming));
			NetworkingAPI.RegisterMessageType<RecallRequestMessage>();
			NetworkingAPI.RegisterMessageType<RecallViewMessage>();
			RegisterStates();
			SynthArsenal.RegisterStates();
			BuildBody();
			BuildProjectiles();
			SynthArsenal.BuildProjectiles();
			GlobalEventManager.onServerDamageDealt += SynthArsenal.Damage;
			harmony = new Harmony("com.tox.synth");
			harmony.PatchAll(typeof(SynthSurfMotor));
			harmony.PatchAll(typeof(SynthStandStill));
			harmony.PatchAll(typeof(SynthSurfStock));
			harmony.PatchAll(typeof(SynthMirrorParry));
			harmony.PatchAll(typeof(SynthVoidOverlay));
			harmony.PatchAll(typeof(SynthSurfLock));
			harmony.PatchAll(typeof(SynthGuardState).Assembly.GetType("SynthSurvivor.SynthGuardBlock"));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Synth 0.2.6: human casting hands, arcane projectiles and floating swords registered.");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)ex);
			throw;
		}
	}

	private void OnDestroy()
	{
		HunterKit.Cleanup();
		GlobalEventManager.onServerDamageDealt -= SynthArsenal.Damage;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}

	private static void RegisterStates()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: 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_002a: 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_003a: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		bool flag = default(bool);
		ContentAddition.AddEntityState<SynthDab>(ref flag);
		ContentAddition.AddEntityState<PrimaryBolt>(ref flag);
		ContentAddition.AddEntityState<TwinVolley>(ref flag);
		ContentAddition.AddEntityState<Dive>(ref flag);
		ContentAddition.AddEntityState<Recall>(ref flag);
		ContentAddition.AddEntityState<NightBolt>(ref flag);
		ContentAddition.AddEntityState<Impale>(ref flag);
		ContentAddition.AddEntityState<Arrowstorm>(ref flag);
		ContentAddition.AddEntityState<Disengage>(ref flag);
		ContentAddition.AddEntityState<HunterHook>(ref flag);
		ContentAddition.AddEntityState<WildHunt>(ref flag);
	}

	private static void Text(string token, string title, string description)
	{
		LanguageAPI.Add(token + "_NAME", title);
		LanguageAPI.Add(token + "_DESC", description);
	}

	private static SkillDef Skill<T>(string token, string title, string description, Sprite icon, float recharge, int stock, bool press, string machine = "Weapon") where T : EntityState
	{
		//IL_00b0: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
		object obj;
		switch (token)
		{
		case "SYNTH_PRIMARY":
		case "SYNTH_SWORDS":
			obj = ScriptableObject.CreateInstance<SynthPrimarySkillDef>();
			break;
		case "SYNTH_HUNTERS":
			obj = ScriptableObject.CreateInstance<SynthSwordSkillDef>();
			break;
		case "SYNTH_SWAP":
			obj = ScriptableObject.CreateInstance<SynthSwapSkillDef>();
			break;
		default:
			obj = ScriptableObject.CreateInstance<SkillDef>();
			break;
		}
		SkillDef val = (SkillDef)obj;
		((Object)val).name = (val.skillName = token);
		val.skillNameToken = token + "_NAME";
		val.skillDescriptionToken = token + "_DESC";
		Text(token, title, description);
		val.icon = icon;
		val.activationState = new SerializableEntityStateType(typeof(T));
		val.activationStateMachineName = machine;
		int num;
		switch (token)
		{
		case "SYNTH_PRIMARY":
		case "SYNTH_HUNTERS":
		case "SYNTH_SLASH":
			num = 0;
			break;
		default:
			num = 2;
			break;
		}
		val.interruptPriority = (InterruptPriority)num;
		val.baseMaxStock = stock;
		val.baseRechargeInterval = recharge;
		val.rechargeStock = 1;
		val.requiredStock = 1;
		val.stockToConsume = 1;
		val.fullRestockOnAssign = true;
		int resetCooldownTimerOnUse;
		switch (token)
		{
		default:
			resetCooldownTimerOnUse = ((token == "SYNTH_HOOK") ? 1 : 0);
			break;
		case "SYNTH_BOLT":
		case "SYNTH_HUNT":
		case "SYNTH_DISENGAGE":
			resetCooldownTimerOnUse = 1;
			break;
		}
		val.resetCooldownTimerOnUse = (byte)resetCooldownTimerOnUse != 0;
		int beginSkillCooldownOnSkillEnd;
		switch (token)
		{
		default:
			beginSkillCooldownOnSkillEnd = ((token == "SYNTH_HUNT") ? 1 : 0);
			break;
		case "SYNTH_FERAL":
		case "SYNTH_SECONDARY":
		case "SYNTH_SPECIAL":
		case "SYNTH_UTILITY":
		case "SYNTH_SURF":
		case "SYNTH_BOLT":
		case "SYNTH_DISENGAGE":
		case "SYNTH_HOOK":
			beginSkillCooldownOnSkillEnd = 1;
			break;
		}
		val.beginSkillCooldownOnSkillEnd = (byte)beginSkillCooldownOnSkillEnd != 0;
		val.attackSpeedBuffsRestockSpeed = false;
		val.cancelSprintingOnActivation = true;
		val.canceledFromSprinting = false;
		val.isCombatSkill = true;
		val.mustKeyPress = press;
		if (token == "SYNTH_SWORDS")
		{
			val.rechargeStock = 5;
			val.resetCooldownTimerOnUse = true;
		}
		if (token == "SYNTH_SURF" || token == "SYNTH_FERAL")
		{
			val.isCombatSkill = false;
			val.cancelSprintingOnActivation = false;
		}
		ContentAddition.AddSkillDef(val);
		return val;
	}

	private static void Family(GenericSkill skill, params Variant[] variants)
	{
		SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
		((Object)val).name = "Synth" + variants[0].skillDef.skillName + "Family";
		val.variants = variants;
		typeof(GenericSkill).GetField("_skillFamily", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SetValue(skill, val);
		ContentAddition.AddSkillFamily(val);
	}

	private static Variant Variant(SkillDef skill, UnlockableDef unlock = null)
	{
		//IL_0002: 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_002c: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		Variant result = new Variant
		{
			skillDef = skill,
			unlockableDef = unlock
		};
		((Variant)(ref result)).viewableNode = new Node(skill.skillNameToken, false, (Node)null);
		return result;
	}

	private static void BuildBody()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: 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_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Unknown result type (might be due to invalid IL or missing references)
		//IL_036f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0471: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0531: Unknown result type (might be due to invalid IL or missing references)
		//IL_0536: Unknown result type (might be due to invalid IL or missing references)
		//IL_056e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0573: Unknown result type (might be due to invalid IL or missing references)
		//IL_0603: Unknown result type (might be due to invalid IL or missing references)
		//IL_0608: Unknown result type (might be due to invalid IL or missing references)
		//IL_063e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0643: Unknown result type (might be due to invalid IL or missing references)
		//IL_0679: Unknown result type (might be due to invalid IL or missing references)
		//IL_067e: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0786: Unknown result type (might be due to invalid IL or missing references)
		//IL_078b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0794: Unknown result type (might be due to invalid IL or missing references)
		//IL_0799: Unknown result type (might be due to invalid IL or missing references)
		//IL_092a: Unknown result type (might be due to invalid IL or missing references)
		//IL_092f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = null;
		try
		{
			val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Seeker/SeekerBody.prefab").WaitForCompletion();
		}
		catch (Exception ex)
		{
			Debug.LogWarning((object)("Seeker body unavailable: " + ex.Message));
		}
		if (!Object.op_Implicit((Object)(object)val))
		{
			throw new Exception("Native Seeker body unavailable (Seekers of the Storm needed)");
		}
		BodyPrefab = PrefabAPI.InstantiateClone(val, "SynthBody", true);
		CharacterBody component = BodyPrefab.GetComponent<CharacterBody>();
		component.baseNameToken = "SYNTH_NAME";
		component.subtitleNameToken = "SYNTH_SUBTITLE";
		component.baseMaxHealth = 80f;
		component.levelMaxHealth = 24f;
		component.baseRegen = 1f;
		component.levelRegen = 0.2f;
		component.baseDamage = 11f;
		component.levelDamage = 2.2f;
		component.baseArmor = 0f;
		component.levelArmor = 0f;
		component.baseMoveSpeed = 7f;
		component.baseAttackSpeed = 1f;
		component.levelAttackSpeed = 0f;
		component.baseCrit = 1f;
		component.levelCrit = 0f;
		component.baseJumpCount = 1;
		component.bodyColor = Burgundy;
		component.portraitIcon = (Texture)(object)SynthIcons.Make(7).texture;
		BodyPrefab.AddComponent<SynthGuardState>();
		component.defaultCrosshairPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponent<CharacterBody>().defaultCrosshairPrefab;
		component.preferredPodPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponent<CharacterBody>().preferredPodPrefab;
		component.bodyFlags = (BodyFlags)(component.bodyFlags & -129);
		MonoBehaviour[] componentsInChildren = BodyPrefab.GetComponentsInChildren<MonoBehaviour>(true);
		foreach (MonoBehaviour val2 in componentsInChildren)
		{
			if (Object.op_Implicit((Object)(object)val2) && (((object)val2).GetType().Name.StartsWith("Bandit", StringComparison.Ordinal) || ((object)val2).GetType().Name.StartsWith("Seeker", StringComparison.Ordinal) || ((object)val2).GetType().Name.StartsWith("Huntress", StringComparison.Ordinal)))
			{
				Object.DestroyImmediate((Object)(object)val2);
			}
		}
		SkillLocator component2 = BodyPrefab.GetComponent<SkillLocator>();
		GenericSkill[] components = BodyPrefab.GetComponents<GenericSkill>();
		foreach (GenericSkill val3 in components)
		{
			if ((Object)(object)val3 != (Object)(object)component2.primary && (Object)(object)val3 != (Object)(object)component2.secondary && (Object)(object)val3 != (Object)(object)component2.utility && (Object)(object)val3 != (Object)(object)component2.special)
			{
				Object.DestroyImmediate((Object)(object)val3);
			}
		}
		component2.passiveSkill.enabled = true;
		component2.passiveSkill.skillNameToken = "SYNTH_PASSIVE_NAME";
		component2.passiveSkill.skillDescriptionToken = "SYNTH_PASSIVE_DESC";
		component2.passiveSkill.icon = PassiveIcon;
		Text("SYNTH_PASSIVE", "Klingenwacht", "Eines deiner schwebenden Schwerter wacht über dich: Es <style=cIsUtility>fängt den nächsten direkten Treffer vollständig ab</style>. Danach braucht es <style=cIsUtility>10 Sekunden</style>, bis es wieder bereit ist. Schaden über Zeit wird nicht abgefangen.");
		Family(component2.primary, Variant(Skill<ArcaneImpulse>("SYNTH_PRIMARY", "Arkaner Impuls", "Unbegrenzte violette Arkanbolzen: <style=cIsDamage>120 % Schaden</style>, Proc 1,0. Direkte Treffer geben <style=cIsUtility>Einklang</style> (bis 8 Stapel): je Stapel <style=cIsDamage>+3 % Angriffstempo</style> und <style=cIsUtility>+8 % Größe</style> für alle deine Fähigkeiten (bis +64 %). Nach 3 Sekunden ohne Treffer verfällt alle 0,5 Sekunden ein Stapel.", PrimaryIcon, 0f, 1, press: false, "Weapon")), Variant(Skill<HunterSwordCast>("SYNTH_HUNTERS", "Klingenmeute", "Halten: Schicke eines deiner fünf Schwerter an den Zielort. Dort sucht es sich den nächsten Gegner im Umkreis von 18 Metern und schneidet immer wieder aus wechselnden Richtungen durch ihn hindurch: <style=cIsDamage>130 % Schaden pro Schnitt</style>, Proc 0,6. Es verfolgt fliehende Gegner, sucht sich nach einem Kill den nächsten und kehrt nach 6,5 Sekunden zurück. Jedes Schwert hat ab seiner Rückkehr eine eigene Abklingzeit von <style=cIsUtility>5 Sekunden</style>. Erzeugt keinen Einklang.", SynthIcons.Make(16), 5f, 5, press: false, "Weapon"), SynthGoals.MeuteUnlock), Variant(Skill<BladeSlash>("SYNTH_SLASH", "Kreuzhieb", "Die äußeren Schwerter schneiden immer abwechselnd vor dir: links nach rechts, rechts nach links, und so weiter. Jeder Hieb trifft alles im Bogen vor dir (5,5 m, wächst mit Einklang) für <style=cIsDamage>170 % Schaden</style>, jeder dritte für <style=cIsDamage>260 % Schaden</style> mit etwas mehr Reichweite. Treffer geben <style=cIsUtility>Schwung</style>: +10 % Angriffs- und Bewegungstempo für 2 Sekunden, bis zu 5 Stapel.", SynthIcons.Make(27), 0f, 1, press: false, "Weapon"), SynthGoals.KreuzUnlock));
		Family(component2.secondary, Variant(Skill<BladeCometCast>("SYNTH_COMET", "Ansturm", "Deine Schwerter schießen nacheinander in einem schmalen Fächer in Blickrichtung (bis 70 m). Jedes bleibt im ersten Gegner stecken, auch in der Luft, sonst im Boden oder in der Wand: <style=cIsDamage>100 % Schaden</style> beim Einschlag, nach 0,45 Sekunden explodiert es für <style=cIsDamage>220 % Schaden</style> im Umkreis von 3,5 m (wächst mit Einklang). 7 Sekunden Abklingzeit.", SynthIcons.Make(20), 7f, 1, press: true, "SynthBlades")), Variant(Skill<BladeHammerCast>("SYNTH_HAMMER", "Klingenhammer", "Deine fünf Schwerter heben sich nacheinander über dich und schlagen abwechselnd links und rechts vor dir in den Boden, jedes ein Stück weiter vorne: je <style=cIsDamage>200 % Schaden</style> im Umkreis von 3 m (wächst mit Einklang). 6 Sekunden Abklingzeit.", SynthIcons.Make(25), 6f, 1, press: true, "SynthBlades"), SynthGoals.SchrittUnlock), Variant(Skill<BanishCircleCast>("SYNTH_BANISH", "Bannkreis", "Wirf eine Arkankugel an den Zielort. Deine Schwerter kreisen 3 Sekunden um sie, ziehen Gegner im Umkreis von 6 m heran und schneiden sie (<style=cIsDamage>80 % alle 0,5 s</style>), dann bricht der Kreis auf: <style=cIsDamage>300 % Schaden</style>. 8 Sekunden Abklingzeit.", SynthIcons.Make(24), 8f, 1, press: true, "SynthBlades"), SynthGoals.KaefigUnlock), Variant(Skill<MirrorBladeCast>("SYNTH_MIRROR", "Spiegelparade", "Kreuze für 0,4 Sekunden die beiden äußeren Schwerter vor dir. Wird ein Treffer geblockt, schlagen alle fünf Schwerter auf den Angreifer zurück: <style=cIsDamage>5 × 200 % Schaden</style>. Ohne Treffer schneidest du am Ende nach vorn (200 %). 5 Sekunden Abklingzeit.", SynthIcons.Make(19), 5f, 1, press: true, "SynthBlades"), SynthGoals.SpiegelUnlock));
		Family(component2.utility, Variant(Skill<BladeSwapThrow>("SYNTH_SWAP", "Klingentausch", "Wirf ein Schwert in Blickrichtung (bis 40 m). Es bleibt im ersten Gegner oder in der Wand stecken. Drücke innerhalb von 4 Sekunden erneut: Du tauschst den Platz mit ihm und schneidest alles im Umkreis von 5 m (<style=cIsDamage>300 % Schaden</style>). 6 Sekunden Abklingzeit ab dem Wurf.", SynthIcons.Make(26), 6f, 1, press: true, "Weapon")), Variant(Skill<BladeSurf>("SYNTH_SURF", "Schwertsurfen", "Umschalten: Surfe auf einem Schwert knapp über dem Boden mit <style=cIsUtility>+70 % Bewegungstempo</style>. Das Schwert ist rutschig: Kurven brauchen Zeit, Tempo baut sich langsam auf und ohne Eingabe bremst es ab. Beim Surfen ist nur M1 nutzbar. Kontakt verursacht <style=cIsDamage>120 % Schaden</style>, Proc 0,2; dasselbe Ziel höchstens alle 0,5 Sekunden. <style=cIsUtility>Springen hält dich in der Luft</style>: Jeder Sprung gibt Flugzeit. Solange sie reicht, gleitest du und steigst mit gehaltenem Sprung (bis 7 m, mehr mit Extrasprüngen); danach fällst du bis zur Landung. Du bleibst verwundbar. Nach Absteigen 3 Sekunden Abklingzeit.", SynthIcons.Make(21), 3f, 1, press: true, "SynthSurf"), BladeDancer.SurfUnlock), Variant(Skill<ArcaneEchoCast>("SYNTH_AECHO", "Arkanes Echo", "Hinterlasse an deiner Stelle für 4 Sekunden ein arkanes Echo und erhalte 2 Sekunden lang <style=cIsUtility>+60 % Bewegungstempo</style>. Das Echo wiederholt deine M1-Angriffe: Jeder Arkane Impuls und jeder Kreuzhieb kommt vom Echo noch einmal mit <style=cIsDamage>75 % Schaden</style>, auf dein Ziel gerichtet. Mehrere Echos können gleichzeitig stehen. 8 Sekunden Abklingzeit.", SynthIcons.Make(23), 8f, 1, press: true, "Body"), SynthGoals.FeralUnlock));
		Family(component2.special, Variant(Skill<BladeDomain>("SYNTH_DOMAIN", "Tausend Klingen", "Falte die Hände zum Gebet und lass " + 2.6f.ToString("0.#") + " Sekunden lang Schnitte durch die Luft fliegen, im Umkreis von <style=cIsUtility>" + 14f.ToString("0") + " Metern</style>. Du kannst dich dabei nicht bewegen, nicht springen und keine anderen Fähigkeiten nutzen, nur umschauen. Deine Schwerter wirbeln um dich, und <style=cIsDamage>jeder Gegner im Umkreis wird alle 0,08 Sekunden für 100 % Schaden geschnitten</style> (Proc 0,2). Danach bist du wieder frei.", SynthIcons.Make(12), 30f, 1, press: true, "SynthStars")), Variant(Skill<Starbreak>("SYNTH_SPECIAL", "Klingengericht", "Halten: Zielgebiet markieren. Loslassen: Ein riesiges Schwert kracht herab, vier Klingen schießen über Kreuz hinterher, dann bricht alles auf: <style=cIsDamage>1400 % Flächenschaden</style>, Proc 1,0, Radius 9,75 Meter, zieht leichte Gegner zur Mitte. Der Boden brennt danach 4 Sekunden violett (<style=cIsDamage>50 % alle 0,5 Sekunden</style>). 30 Sekunden Abklingzeit.", SpecialIcon, 30f, 1, press: true, "SynthStars"), SynthGoals.GerichtUnlock), Variant(Skill<TarnfeldCast>("SYNTH_VEIL", "Tarnfeld", "Halten: Zielgebiet markieren. Loslassen: Errichte für 10 Sekunden ein Tarnfeld mit 8 Metern Grundradius, vergrößert durch Einklang (bis +64 %). Verbündete darin sind unsichtbar. Angreifen deckt auf und verhindert für 1 Sekunde erneute Feldtarnung. Nach Verlassen hält die Tarnung 1,5 Sekunden nach. 30 Sekunden Abklingzeit.", SynthVeil.Icon, 30f, 1, press: true, "SynthStars"), SynthVeil.Unlock));
		NetworkStateMachine component3 = BodyPrefab.GetComponent<NetworkStateMachine>();
		EntityStateMachine[] components2 = BodyPrefab.GetComponents<EntityStateMachine>();
		foreach (EntityStateMachine val4 in components2)
		{
			val4.initialStateType = new SerializableEntityStateType((!(val4.customName == "Body")) ? typeof(Idle) : typeof(GenericCharacterMain));
			val4.mainStateType = val4.initialStateType;
		}
		FieldInfo field = typeof(NetworkStateMachine).GetField("stateMachines", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
		List<EntityStateMachine> list = new List<EntityStateMachine>((EntityStateMachine[])field.GetValue(component3));
		string[] array = new string[3] { "SynthBlades", "SynthStars", "SynthSurf" };
		foreach (string customName in array)
		{
			EntityStateMachine val5 = BodyPrefab.AddComponent<EntityStateMachine>();
			val5.customName = customName;
			val5.initialStateType = new SerializableEntityStateType(typeof(Idle));
			val5.mainStateType = val5.initialStateType;
			list.Add(val5);
		}
		field.SetValue(component3, list.ToArray());
		BodyPrefab.AddComponent<SynthController>();
		BodyPrefab.AddComponent<SynthDabInput>();
		BodyPrefab.AddComponent<SynthArsenal>();
		BodyPrefab.AddComponent<SynthRecall>();
		SynthModel.BuildWorld(BodyPrefab);
		ContentAddition.AddBody(BodyPrefab);
		DisplayPrefab = PrefabAPI.CreateEmptyPrefab("SynthDisplay", false);
		GameObject val6 = Object.Instantiate<GameObject>(((Component)BodyPrefab.GetComponent<ModelLocator>().modelTransform).gameObject, DisplayPrefab.transform, false);
		((Object)val6).name = "SynthDisplayModel";
		CharacterModel component4 = val6.GetComponent<CharacterModel>();
		if (Object.op_Implicit((Object)(object)component4))
		{
			component4.body = null;
			((Behaviour)component4).enabled = false;
		}
		Collider[] componentsInChildren2 = val6.GetComponentsInChildren<Collider>(true);
		foreach (Collider val7 in componentsInChildren2)
		{
			Object.DestroyImmediate((Object)(object)val7);
		}
		SynthModel component5 = val6.GetComponent<SynthModel>();
		component5.Display = true;
		Survivor = ScriptableObject.CreateInstance<SurvivorDef>();
		Survivor.cachedName = "Synth";
		Survivor.bodyPrefab = BodyPrefab;
		Survivor.displayPrefab = DisplayPrefab;
		Survivor.displayNameToken = "SYNTH_NAME";
		Survivor.descriptionToken = "SYNTH_DESCRIPTION";
		Survivor.outroFlavorToken = "SYNTH_OUTRO";
		Survivor.mainEndingEscapeFailureFlavorToken = "SYNTH_FAIL";
		Survivor.primaryColor = Burgundy;
		Survivor.desiredSortPosition = 50f;
		ContentAddition.AddSurvivorDef(Survivor);
		LanguageAPI.Add("SYNTH_NAME", "Synth");
		LanguageAPI.Add("SYNTH_SUBTITLE", "Die Klingensängerin");
		LanguageAPI.Add("SYNTH_DESCRIPTION", "Synth führt fünf schwebende Schwerter und wirft violette Arkanbolzen.\n\nTreffer mit <style=cIsDamage>Arkaner Impuls</style> bauen Einklang auf und machen all ihre Fähigkeiten größer. Die <style=cIsUtility>Klingenmeute</style> schickt die Schwerter stattdessen selbst auf die Jagd.\n\n<style=cIsUtility>Klingenwacht</style> fängt alle 10 Sekunden einen Treffer ab, aber sie hält wenig aus: Bleib in Bewegung.\n\n<style=cIsDamage>Klingengericht</style> und <style=cIsDamage>Tausend Klingen</style> sind ihre großen Finisher.");
		LanguageAPI.Add("SYNTH_OUTRO", "…und ihre Melodie klang zwischen den Sternen weiter.");
		LanguageAPI.Add("SYNTH_FAIL", "…und der letzte Ton verklang.");
		LanguageAPI.Add("SYNTH_SKIN_NAME", "Violetter Einklang");
		LanguageAPI.Add("SYNTH_BODY_NAME", "Synth");
		LanguageAPI.Add("SYNTH_BODY_LORE", "Vier Klingen schweben im Takt ihrer Hände.");
		GameObject val8 = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/CommandoMonsterMaster");
		if (Object.op_Implicit((Object)(object)val8))
		{
			GameObject val9 = PrefabAPI.InstantiateClone(val8, "SynthMonsterMaster", true);
			val9.GetComponent<CharacterMaster>().bodyPrefab = BodyPrefab;
			ContentAddition.AddMaster(val9);
		}
	}

	private static void BuildProjectiles()
	{
		Bolt = MakeBolt("SynthNightBolt", heavy: false);
		VolleyBolt = MakeBolt("SynthVolleyBolt", heavy: false);
		VolleyBolt.GetComponent<ProjectileController>().procCoefficient = 0.7f;
		HeavyBolt = MakeBolt("SynthImpaleBolt", heavy: true);
	}

	private static GameObject MakeBolt(string name, bool heavy)
	{
		GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/Arrow"), name, true);
		MonoBehaviour[] components = val.GetComponents<MonoBehaviour>();
		foreach (MonoBehaviour val2 in components)
		{
			string name2 = ((object)val2).GetType().Name;
			if (name2.Contains("Steer") || name2.Contains("TargetFinder") || name2 == "ProjectileTargetComponent" || name2.Contains("StickOnImpact") || name2.Contains("OverlapAttack"))
			{
				Object.DestroyImmediate((Object)(object)val2);
			}
		}
		ProjectileSimple val3 = val.GetComponent<ProjectileSimple>();
		if (!Object.op_Implicit((Object)(object)val3))
		{
			val3 = val.AddComponent<ProjectileSimple>();
		}
		val3.desiredForwardSpeed = ((!heavy) ? 140 : 100);
		val3.lifetime = 8f;
		val3.oscillate = false;
		Rigidbody component = val.GetComponent<Rigidbody>();
		if (Object.op_Implicit((Object)(object)component))
		{
			component.useGravity = false;
			component.collisionDetectionMode = (CollisionDetectionMode)2;
		}
		ProjectileController component2 = val.GetComponent<ProjectileController>();
		component2.procCoefficient = 1f;
		GameObject val4 = PrefabAPI.CreateEmptyPrefab(name + "Ghost", false);
		val4.AddComponent<ProjectileGhostController>();
		SynthGeometry.Bolt(val4.transform, heavy);
		component2.ghostPrefab = val4;
		component2.ghostPrefabAddress = null;
		AssetOrDirectReference<GameObject> val5 = new AssetOrDirectReference<GameObject>();
		val5.directRef = val4;
		typeof(ProjectileController).GetField("ghostAssetOrDirectReference", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).SetValue(component2, val5);
		ProjectileSingleTargetImpact val6 = val.GetComponent<ProjectileSingleTargetImpact>();
		if (!Object.op_Implicit((Object)(object)val6))
		{
			val6 = val.AddComponent<ProjectileSingleTargetImpact>();
		}
		val6.destroyOnWorld = true;
		val6.destroyWhenNotAlive = true;
		val.AddComponent<SynthProjectileMetadata>();
		ContentAddition.AddProjectile(val);
		return val;
	}

	private static void Damage(DamageReport report)
	{
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || report.damageInfo == null || report.damageInfo.rejected || report.damageDealt <= 0f || !Object.op_Implicit((Object)(object)report.attackerBody) || ((Object)report.attackerBody).name.IndexOf("SynthBody", StringComparison.Ordinal) < 0 || !Object.op_Implicit((Object)(object)report.victimBody))
		{
			return;
		}
		SynthProjectileMetadata synthProjectileMetadata = ((!Object.op_Implicit((Object)(object)report.damageInfo.inflictor)) ? null : report.damageInfo.inflictor.GetComponent<SynthProjectileMetadata>());
		if (Object.op_Implicit((Object)(object)synthProjectileMetadata))
		{
			SynthRecall component = ((Component)report.attackerBody).GetComponent<SynthRecall>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.Capture(report);
			}
		}
		if (!DamageAPI.HasModdedDamageType(report.damageInfo, PinDamage) || report.attackerTeamIndex == report.victimTeamIndex)
		{
			return;
		}
		CharacterMotor characterMotor = report.victimBody.characterMotor;
		if (Object.op_Implicit((Object)(object)characterMotor) && !report.victimBody.isChampion && characterMotor.mass <= 500f)
		{
			SynthWallPin synthWallPin = ((Component)report.victimBody).GetComponent<SynthWallPin>();
			if (!Object.op_Implicit((Object)(object)synthWallPin))
			{
				synthWallPin = ((Component)report.victimBody).gameObject.AddComponent<SynthWallPin>();
			}
			synthWallPin.Begin(report);
		}
	}

	public static bool IsSynth(CharacterBody body)
	{
		return Object.op_Implicit((Object)(object)body) && ((Object)body).name.StartsWith("SynthBody", StringComparison.Ordinal);
	}

	public static Ray Aim(CharacterBody body)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		if (SynthFirstPerson.TryAim(body, out var ray))
		{
			return ray;
		}
		return new Ray(body.inputBank.aimOrigin, body.inputBank.aimDirection);
	}
}
public sealed class SynthPrimarySkillDef : SkillDef
{
	public override bool IsReady(GenericSkill skill)
	{
		CharacterBody characterBody = skill.characterBody;
		if (Object.op_Implicit((Object)(object)characterBody) && Object.op_Implicit((Object)(object)skill.skillDef) && skill.skillDef.skillName == "SYNTH_SWORDS")
		{
			SynthArsenal component = ((Component)characterBody).GetComponent<SynthArsenal>();
			if (Object.op_Implicit((Object)(object)component) && component.FreeSwords() == 0)
			{
				return false;
			}
		}
		if (Object.op_Implicit((Object)(object)characterBody) && Object.op_Implicit((Object)(object)characterBody.inputBank) && Object.op_Implicit((Object)(object)characterBody.skillLocator))
		{
			InputBankTest inputBank = characterBody.inputBank;
			SkillLocator skillLocator = characterBody.skillLocator;
			if (inputBank.skill2.down && Object.op_Implicit((Object)(object)skillLocator.secondary) && skillLocator.secondary.stock > 0 && skillLocator.secondary.IsReady())
			{
				return false;
			}
			if (((ButtonState)(ref inputBank.skill4)).justPressed && Object.op_Implicit((Object)(object)skillLocator.special) && skillLocator.special.stock > 0 && skillLocator.special.IsReady())
			{
				return false;
			}
		}
		return ((SkillDef)this).IsReady(skill);
	}
}
public sealed class SynthController : MonoBehaviour
{
	private CharacterBody body;

	private bool wasCloaked;

	public int CloakSequence;

	public int NextHand;

	public bool LastAttackAmbush;

	public string Motion = "Idle";

	public float MotionStart;

	public float MotionDuration;

	public int MotionHand;

	public readonly float[] HandStart = new float[2] { -100f, -100f };

	public readonly float[] HandDuration = new float[2];

	public int BarrierGrants { get; private set; }

	private void Awake()
	{
		body = ((Component)this).GetComponent<CharacterBody>();
	}

	public bool BeginAttack()
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		bool flag = (LastAttackAmbush = Object.op_Implicit((Object)(object)body) && body.HasBuff(Buffs.Cloak));
		if (NetworkServer.active && flag)
		{
			if (!wasCloaked)
			{
				CloakSequence++;
			}
			body.ClearTimedBuffs(Buffs.Cloak);
			body.SetBuffCount(Buffs.Cloak.buffIndex, 0);
			GrantBarrier();
			wasCloaked = false;
		}
		return flag;
	}

	private void GrantBarrier()
	{
		if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
		{
			body.healthComponent.AddBarrier(body.maxHealth * 0.15f);
			BarrierGrants++;
		}
	}

	public void StartDive()
	{
		EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Weapon");
		if (Object.op_Implicit((Object)(object)val) && !(val.state is Idle))
		{
			val.SetNextStateToMain();
		}
	}

	public void Cloak()
	{
		if (NetworkServer.active && Object.op_Implicit((Object)(object)body))
		{
			if (!body.HasBuff(Buffs.Cloak))
			{
				CloakSequence++;
			}
			body.AddTimedBuff(Buffs.Cloak, 1.25f);
			wasCloaked = true;
		}
	}

	public void Animate(string motion, float duration, int hand = 0)
	{
		Motion = motion;
		MotionStart = Time.time;
		MotionDuration = Mathf.Max(0.01f, duration);
		MotionHand = hand;
		if (motion == "Shot")
		{
			HandStart[hand] = Time.time;
			HandDuration[hand] = duration;
		}
		else
		{
			HandDuration[0] = (HandDuration[1] = 0f);
		}
	}
}
public abstract class SynthAttack : BaseSkillState
{
	protected SynthController control;

	protected bool ambush;

	protected float duration;

	public override void OnEnter()
	{
		((BaseState)this).OnEnter();
		control = ((EntityState)this).GetComponent<SynthController>();
		ambush = control.BeginAttack();
		((EntityState)this).characterBody.isSprinting = false;
		((BaseState)this).StartAimMode(2f, false);
	}

	public override void FixedUpdate()
	{
		((EntityState)this).FixedUpdate();
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)((this is PrimaryBolt) ? 1 : 2);
	}

	protected void Sound(string name)
	{
		Util.PlaySound(name, ((EntityState)this).gameObject);
	}

	protected void Shoot(GameObject prefab, float coefficient, int hand, DamageSource source, bool pin = false, float yaw = 0f, float pitch = 0f)
	{
		//IL_0012: 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_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: 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_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		if (!((EntityState)this).isAuthority)
		{
			return;
		}
		Ray val = Plugin.Aim(((EntityState)this).characterBody);
		Vector3 val2 = ((Ray)(ref val)).origin + ((Ray)(ref val)).direction * 0.12f;
		Vector3 val3 = ((Ray)(ref val)).direction;
		if (SynthFirstPerson.TryEmission(((EntityState)this).characterBody, hand, out var position, out var direction))
		{
			val2 = position;
			val3 = direction;
		}
		else
		{
			Transform val4 = SynthModel.Find(((EntityState)this).characterBody.modelLocator.modelTransform, (hand != 0) ? "SynthCrossbowLeft" : "SynthCrossbowRight");
			if (Object.op_Implicit((Object)(object)val4))
			{
				Transform val5 = SynthModel.Find(val4, "LoadedBolt");
				val2 = val5.TransformPoint(new Vector3(0f, 0f, 0.22f));
				Vector3 point = ((Ray)(ref val)).GetPoint(600f);
				float num = 600f;
				Ray val6 = val;
				LayerIndex world = LayerIndex.world;
				int num2 = LayerMask.op_Implicit(((LayerIndex)(ref world)).mask);
				LayerIndex entityPrecise = LayerIndex.entityPrecise;
				RaycastHit[] array = Physics.RaycastAll(val6, 600f, num2 | LayerMask.op_Implicit(((LayerIndex)(ref entityPrecise)).mask), (QueryTriggerInteraction)2);
				for (int i = 0; i < array.Length; i++)
				{
					RaycastHit val7 = array[i];
					HurtBox component = ((Component)((RaycastHit)(ref val7)).collider).GetComponent<HurtBox>();
					if (!((Component)((RaycastHit)(ref val7)).collider).transform.IsChildOf(((Component)((EntityState)this).characterBody).transform) && (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.healthComponent) || !((Object)(object)((Component)component.healthComponent).gameObject == (Object)(object)((EntityState)this).gameObject)) && !(((RaycastHit)(ref val7)).distance >= num))
					{
						num = ((RaycastHit)(ref val7)).distance;
						point = ((RaycastHit)(ref val7)).point;
					}
				}
				Vector3 origin = ((Ray)(ref val)).origin;
				Vector3 val8 = val2;
				LayerIndex world2 = LayerIndex.world;
				RaycastHit val9 = default(RaycastHit);
				if (Physics.Linecast(origin, val8, ref val9, LayerMask.op_Implicit(((LayerIndex)(ref world2)).mask), (QueryTriggerInteraction)1))
				{
					val2 = ((RaycastHit)(ref val9)).point - ((Ray)(ref val)).direction * 0.03f;
				}
				val3 = point - val2;
				if (Vector3.Dot(val3, ((Ray)(ref val)).direction) < 0.05f)
				{
					val2 = ((Ray)(ref val)).origin + ((Ray)(ref val)).direction * 0.03f;
					val3 = point - val2;
				}
				if (((Vector3)(ref val3)).sqrMagnitude < 0.001f)
				{
					val3 = ((Ray)(ref val)).direction;
				}
				((Vector3)(ref val3)).Normalize();
			}
		}
		prefab = HunterKit.Choose(prefab, ((EntityState)this).characterBody);
		if (yaw != 0f || pitch != 0f)
		{
			val3 = Util.QuaternionSafeLookRotation(val3) * Quaternion.Euler(pitch, yaw, 0f) * Vector3.forward;
		}
		DamageTypeCombo value = new DamageTypeCombo
		{
			damageSource = source
		};
		if (HunterKit.Burning(((EntityState)this).characterBody))
		{
			value.damageType = (DamageType)(value.damageType | 0x80);
		}
		if (ambush)
		{
			DamageAPI.AddModdedDamageType(ref value, Plugin.AmbushDamage);
		}
		if (pin)
		{
			DamageAPI.AddModdedDamageType(ref value, Plugin.PinDamage);
		}
		ProjectileManager.instance.FireProjectile(new FireProjectileInfo
		{
			projectilePrefab = prefab,
			owner = ((EntityState)this).gameObject,
			position = val2,
			rotation = Util.QuaternionSafeLookRotation(val3),
			damage = ((BaseState)this).damageStat * coefficient,
			crit = ((BaseState)this).RollCrit(),
			force = 0f,
			damageTypeOverride = value
		});
		Sound("Play_huntress_m1_shoot");
	}
}
public sealed class PrimaryBolt : SynthAttack
{
	private bool fired;

	private bool receivedSide;

	private int side;

	public override void OnEnter()
	{
		base.OnEnter();
		duration = 0.14f / Mathf.Max(0.1f, ((BaseState)this).attackSpeedStat);
		if (!receivedSide)
		{
			side = control.NextHand++ % 2;
		}
		control.Animate("Shot", duration, side);
	}

	public override void FixedUpdate()
	{
		if (!fired && ((EntityState)this).fixedAge >= duration * 0.6f)
		{
			fired = true;
			Shoot(Plugin.Bolt, 0.7f, side, (DamageSource)1);
		}
		base.FixedUpdate();
	}

	public override void OnSerialize(NetworkWriter writer)
	{
		((BaseSkillState)this).OnSerialize(writer);
		writer.Write(side);
	}

	public override void OnDeserialize(NetworkReader reader)
	{
		((BaseSkillState)this).OnDeserialize(reader);
		side = reader.ReadInt32();
		receivedSide = true;
		if (Object.op_Implicit((Object)(object)control))
		{
			control.Animate("Shot", duration, side);
		}
	}
}
public sealed class TwinVolley : SynthAttack
{
	private bool fired;

	public override void OnEnter()
	{
		base.OnEnter();
		duration = 0.45f / Mathf.Max(0.1f, ((BaseState)this).attackSpeedStat);
		control.Animate("Volley", duration);
	}

	public override void FixedUpdate()
	{
		if (!fired && ((EntityState)this).fixedAge >= duration * 0.35f)
		{
			fired = true;
			Shoot(HunterKit.PiercingBolt, HunterBalance.PierceDamage, 0, (DamageSource)2);
			Shoot(HunterKit.PiercingBolt, HunterBalance.PierceDamage, 1, (DamageSource)2);
		}
		base.FixedUpdate();
	}
}
public sealed class NightBolt : SynthAttack
{
	private bool fired;

	private int hand;

	public override void OnEnter()
	{
		base.OnEnter();
		duration = 0.26f / Mathf.Max(0.1f, ((BaseState)this).attackSpeedStat);
		hand = control.NextHand++ % 2;
		control.Animate("Night", duration, hand);
	}

	public override void FixedUpdate()
	{
		if (!fired && ((EntityState)this).fixedAge >= duration * 0.2f)
		{
			fired = true;
			Shoot(Plugin.Bolt, 2.5f, hand, (DamageSource)2);
		}
		base.FixedUpdate();
	}

	public override void OnSerialize(NetworkWriter writer)
	{
		((BaseSkillState)this).OnSerialize(writer);
		writer.Write(hand);
	}

	public override void OnDeserialize(NetworkReader reader)
	{
		((BaseSkillState)this).OnDeserialize(reader);
		hand = reader.ReadInt32();
		if (Object.op_Implicit((Object)(object)control))
		{
			control.Animate("Night", duration, hand);
		}
	}
}
public sealed class Recall : SynthAttack
{
	public override void OnEnter()
	{
		base.OnEnter();
		duration = 0.45f;
		control.Animate("Recall", duration);
		if (((EntityState)this).isAuthority)
		{
			((EntityState)this).GetComponent<SynthRecall>().Request(ambush);
		}
		Sound("Play_huntress_R_snipe_shoot");
	}
}
public sealed class Impale : SynthAttack
{
	private bool fired;

	public override void OnEnter()
	{
		base.OnEnter();
		duration = 0.65f / Mathf.Max(0.1f, ((BaseState)this).attackSpeedStat);
		control.Animate("Impale", duration);
	}

	public override void FixedUpdate()
	{
		if (!fired && ((EntityState)this).fixedAge >= duration * 0.38f)
		{
			fired = true;
			Shoot(Plugin.HeavyBolt, 8f, 0, (DamageSource)8, pin: true);
		}
		base.FixedUpdate();
	}
}
public sealed class Dive : BaseSkillState
{
	private Vector3 direction;

	private SynthController control;

	private float duration = 0.2f;

	private float moved;

	public override void OnEnter()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		((BaseState)this).OnEnter();
		control = ((EntityState)this).GetComponent<SynthController>();
		control.StartDive();
		direction = ((EntityState)this).inputBank.moveVector;
		if (((Vector3)(ref direction)).sqrMagnitude < 0.01f)
		{
			Ray val = Plugin.Aim(((EntityState)this).characterBody);
			direction = -Vector3.ProjectOnPlane(((Ray)(ref val)).direction, Vector3.up);
		}
		Vector3 val2 = Vector3.ProjectOnPlane(direction, Vector3.up);
		direction = ((Vector3)(ref val2)).normalized;
		if (((Vector3)(ref direction)).sqrMagnitude < 0.1f)
		{
			direction = -((EntityState)this).characterDirection.forward;
		}
		control.Animate("Dive", duration + 0.15f);
		Util.PlaySound("Play_bandit2_shift_enter", ((EntityState)this).gameObject);
		((EntityState)this).characterBody.isSprinting = false;
	}

	public override void FixedUpdate()
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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)
		//IL_0078: 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)
		((EntityState)this).FixedUpdate();
		if (((EntityState)this).isAuthority)
		{
			float num = Mathf.Min(5f - moved, 5f / duration * ((EntityState)this).GetDeltaTime());
			((EntityState)this).characterMotor.velocity = new Vector3(0f, ((EntityState)this).characterMotor.velocity.y, 0f);
			CharacterMotor characterMotor = ((EntityState)this).characterMotor;
			characterMotor.rootMotion += direction * num;
			moved += num;
			if (((EntityState)this).fixedAge >= duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}
	}

	public override void OnExit()
	{
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && Object.op_Implicit((Object)(object)((EntityState)this).characterBody.healthComponent) && ((EntityState)this).characterBody.healthComponent.alive && Object.op_Implicit((Object)(object)control))
		{
			control.Cloak();
		}
		((EntityState)this).OnExit();
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)7;
	}

	public override void OnSerialize(NetworkWriter writer)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		((BaseSkillState)this).OnSerialize(writer);
		writer.Write(direction);
	}

	public override void OnDeserialize(NetworkReader reader)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		((BaseSkillState)this).OnDeserialize(reader);
		direction = reader.ReadVector3();
	}
}
public sealed class SynthProjectileMetadata : MonoBehaviour
{
	public int AmbushSequence = -1;

	private bool captured;

	public void Capture()
	{
		if (!captured && NetworkServer.active)
		{
			ProjectileController component = ((Component)this).GetComponent<ProjectileController>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.owner))
			{
				SynthController component2 = component.owner.GetComponent<SynthController>();
				AmbushSequence = ((!Object.op_Implicit((Object)(object)component2)) ? (-1) : component2.CloakSequence);
				captured = true;
			}
		}
	}

	private void FixedUpdate()
	{
		Capture();
	}
}
public sealed class SynthWallPin : MonoBehaviour
{
	private CharacterBody victim;

	private CharacterBody attacker;

	private Vector3 direction;

	private float remaining;

	private float damage;

	private bool crit;

	private bool active;

	public bool WallTriggered { get; private set; }

	public void Begin(DamageReport report)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: 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_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_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		victim = ((Component)this).GetComponent<CharacterBody>();
		attacker = report.attackerBody;
		Vector3 val = Vector3.ProjectOnPlane(report.damageInfo.position - attacker.corePosition, Vector3.up);
		direction = ((Vector3)(ref val)).normalized;
		if (((Vector3)(ref direction)).sqrMagnitude < 0.1f)
		{
			Vector3 val2 = Vector3.ProjectOnPlane(attacker.inputBank.aimDirection, Vector3.up);
			direction = ((Vector3)(ref val2)).normalized;
		}
		damage = attacker.damage * 4f;
		crit = report.damageInfo.crit;
		remaining = 0.4f;
		active = true;
		WallTriggered = false;
	}

	private void FixedUpdate()
	{
		//IL_0073: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: 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_0114: Expected O, but got Unknown
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || !active || !Object.op_Implicit((Object)(object)victim) || !victim.healthComponent.alive || !Object.op_Implicit((Object)(object)victim.characterMotor))
		{
			return;
		}
		float num = Mathf.Min(remaining, Time.fixedDeltaTime);
		CharacterMotor characterMotor = victim.characterMotor;
		Vector3 corePosition = victim.corePosition;
		float num2 = Mathf.Max(0.15f, victim.radius * 0.7f);
		Vector3 val = direction;
		float num3 = 20f * num + 0.18f;
		LayerIndex world = LayerIndex.world;
		RaycastHit val2 = default(RaycastHit);
		if (Physics.SphereCast(corePosition, num2, val, ref val2, num3, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1) && ((RaycastHit)(ref val2)).normal.y < 0.65f)
		{
			WallTriggered = true;
			active = false;
			characterMotor.velocity = new Vector3(0f, characterMotor.velocity.y, 0f);
			DamageInfo val3 = new DamageInfo();
			val3.attacker = ((!Object.op_Implicit((Object)(object)attacker)) ? null : ((Component)attacker).gameObject);
			val3.inflictor = ((!Object.op_Implicit((Object)(object)attacker)) ? null : ((Component)attacker).gameObject);
			val3.damage = damage;
			val3.crit = crit;
			val3.procCoefficient = 0f;
			val3.position = ((RaycastHit)(ref val2)).point;
			val3.damageType = new DamageTypeCombo
			{
				damageType = (DamageType)32,
				damageSource = (DamageSource)8
			};
			DamageInfo val4 = val3;
			victim.healthComponent.TakeDamage(val4);
			if (Object.op_Implicit((Object)(object)GlobalEventManager.instance))
			{
				GlobalEventManager.instance.OnHitEnemy(val4, ((Component)victim).gameObject);
				GlobalEventManager.instance.OnHitAll(val4, ((Component)victim).gameObject);
			}
		}
		else
		{
			characterMotor.velocity = direction * 20f + Vector3.up * characterMotor.velocity.y;
			remaining -= Time.fixedDeltaTime;
			if (remaining <= 0f)
			{
				active = false;
				characterMotor.velocity = new Vector3(0f, characterMotor.velocity.y, 0f);
			}
		}
	}
}
public static class SynthGeometry
{
	public static Material Template;

	private static Material cloth;

	private static Material dark;

	private static Material steel;

	private static Material trim;

	private static Material glow;

	public static Material Cloth => cloth ?? (cloth = Mat("SynthBurgundy", new Color(0.35f, 0.14f, 0.55f)));

	public static Material Dark => dark ?? (dark = Mat("SynthLeather", new Color(0.045f, 0.043f, 0.052f)));

	public static Material Steel => steel ?? (steel = Mat("SynthSteel", new Color(0.57f, 0.61f, 0.65f), emissive: false, 0.8f));

	public static Material Trim => trim ?? (trim = Mat("SynthAntiqueSilver", new Color(0.33f, 0.28f, 0.24f), emissive: false, 0.7f));

	public static Material Glow => glow ?? (glow = Mat("SynthViolet", Plugin.Accent, emissive: true));

	public static Material Mat(string name, Color color, bool emissive = false, float spec = 0.05f)
	{
		//IL_0014: 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_003f: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		Material val = ((!Object.op_Implicit((Object)(object)Template)) ? new Material(Shader.Find("Hopoo Games/Deferred/Standard") ?? Shader.Find("Standard")) : new Material(Template));
		((Object)val).name = name;
		if (val.HasProperty("_MainTex"))
		{
			val.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
		}
		if (val.HasProperty("_Color"))
		{
			val.SetColor("_Color", color);
		}
		if (val.HasProperty("_NormalTex"))
		{
			val.SetTexture("_NormalTex", (Texture)null);
		}
		if (val.HasProperty("_EmTex"))
		{
			val.SetTexture("_EmTex", (Texture)(object)((!emissive) ? Texture2D.blackTexture : Texture2D.whiteTexture));
		}
		if (val.HasProperty("_EmColor"))
		{
			val.SetColor("_EmColor", color);
		}
		if (val.HasProperty("_EmPower"))
		{
			val.SetFloat("_EmPower", (!emissive) ? 0f : 1.8f);
		}
		if (val.HasProperty("_SpecularStrength"))
		{
			val.SetFloat("_SpecularStrength", spec);
		}
		if (val.HasProperty("_SpecularExponent"))
		{
			val.SetFloat("_SpecularExponent", (float)((!(spec > 0.1f)) ? 2 : 15));
		}
		return val;
	}

	public static Transform Root(Transform parent, string name, Vector3 position, Quaternion rotation)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent, false);
		val.transform.localPosition = position;
		val.transform.localRotation = rotation;
		return val.transform;
	}

	public static MeshRenderer Mesh(Transform parent, string name, Vector3[] vertices, int[] triangles, Material material)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		Mesh val = new Mesh();
		((Object)val).name = name;
		val.vertices = vertices;
		val.triangles = triangles;
		Vector2[] array = (Vector2[])(object)new Vector2[vertices.Length];
		for (int i = 0; i < array.Length; i++)
		{
			ref Vector2 reference = ref array[i];
			reference = new Vector2(vertices[i].x, vertices[i].y);
		}
		val.uv = array;
		val.RecalculateNormals();
		val.RecalculateBounds();
		Transform val2 = Root(parent, name, Vector3.zero, Quaternion.identity);
		((Component)val2).gameObject.AddComponent<MeshFilter>().sharedMesh = val;
		MeshRenderer val3 = ((Component)val2).gameObject.AddComponent<MeshRenderer>();
		((Renderer)val3).sharedMaterial = material;
		((Renderer)val3).shadowCastingMode = (ShadowCastingMode)1;
		return val3;
	}

	public static Transform Box(Transform parent, string name, Vector3 center, Vector3 size, Material material, Quaternion rotation)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		Transform val = Root(parent, name, center, rotation);
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		int[,] array = new int[6, 4]
		{
			{ 0, 2, 3, 1 },
			{ 4, 5, 7, 6 },
			{ 0, 1, 5, 4 },
			{ 2, 6, 7, 3 },
			{ 0, 4, 6, 2 },
			{ 1, 3, 7, 5 }
		};
		Vector3[] array2 = (Vector3[])(object)new Vector3[8];
		for (int i = 0; i < 8; i++)
		{
			ref Vector3 reference = ref array2[i];
			reference = new Vector3(((i & 1) != 0) ? 0.5f : (-0.5f), ((i & 2) != 0) ? 0.5f : (-0.5f), ((i & 4) != 0) ? 0.5f : (-0.5f));
		}
		for (int j = 0; j < 6; j++)
		{
			int count = list.Count;
			for (int k = 0; k < 4; k++)
			{
				list.Add(Vector3.Scale(array2[array[j, k]], size));
			}
			list2.AddRange(new int[6]
			{
				count,
				count + 1,
				count + 2,
				count,
				count + 2,
				count + 3
			});
		}
		Mesh(val, name + "Geometry", list.ToArray(), list2.ToArray(), material);
		return val;
	}

	public static void Beam(Transform parent, string name, Vector3 a, Vector3 b, float width, float thickness, Material material)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: 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_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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)
		Box(parent, name, (a + b) * 0.5f, new Vector3(width, thickness, Vector3.Distance(a, b)), material, Quaternion.LookRotation(b - a));
	}

	public static MeshRenderer Loft(Transform parent, string name, Vector3[] centers, Vector2[] radii, int segments, Material material, bool diamond = false)
	{
		//IL_004d: 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_0084: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		for (int i = 0; i < centers.Length; i++)
		{
			for (int j = 0; j < segments; j++)
			{
				float num = ((float)j * 360f / (float)segments + ((!diamond) ? 22.5f : 0f)) * ((float)Math.PI / 180f);
				list.Add(centers[i] + new Vector3(Mathf.Cos(num) * radii[i].x, 0f, Mathf.Sin(num) * radii[i].y));
			}
		}
		for (int k = 0; k < centers.Length - 1; k++)
		{
			for (int l = 0; l < segments; l++)
			{
				int num2 = k * segments + l;
				int num3 = k * segments + (l + 1) % segments;
				int num4 = num2 + segments;
				int num5 = num3 + segments;
				list2.AddRange(new int[6] { num2, num4, num5, num2, num5, num3 });
			}
		}
		for (int m = 1; m < segments - 1; m++)
		{
			list2.AddRange(new int[3]
			{
				0,
				m + 1,
				m
			});
			int num6 = (centers.Length - 1) * segments;
			list2.AddRange(new int[3]
			{
				num6,
				num6 + m,
				num6 + m + 1
			});
		}
		return Mesh(parent, name, list.ToArray(), list2.ToArray(), material);
	}

	public static Transform Crossbow(Transform parent, string name)
	{
		return SynthCrossbow.Build(parent, name);
	}

	public static void Bolt(Transform root, bool heavy, bool emitTrail = true)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: 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_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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)
		//IL_008a: 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_00ad: 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_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_00e4: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: 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_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: 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)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		float num = ((!heavy) ? 1f : 1.35f);
		Box(root, "BoltShaft", Vector3.back * 0.15f * num, new Vector3(0.012f, 0.012f, 0.5f) * num, Steel, Quaternion.identity);
		Transform parent = Root(root, "BoltHead", new Vector3(0f, 0f, 0.13f) * num, Quaternion.Euler(90f, 0f, 0f));
		Loft(parent, "Head", (Vector3[])(object)new Vector3[2]
		{
			Vector3.zero,
			Vector3.up * 0.09f
		}, (Vector2[])(object)new Vector2[2]
		{
			new Vector2(0.035f, 0.012f),
			Vector2.zero
		}, 4, Steel, diamond: true);
		float[] array = new float[3] { 0f, 120f, 240f };
		foreach (float num2 in array)
		{
			Box(root, "Fletching", new Vector3(0f, 0.018f, -0.31f) * num, new Vector3(0.005f, 0.04f, 0.09f) * num, Cloth, Quaternion.Euler(0f, 0f, num2));
		}
		if (emitTrail)
		{
			TrailRenderer val = ((Component)root).gameObject.AddComponent<TrailRenderer>();
			val.time = 0.075f;
			val.startWidth = 0.022f * num;
			val.endWidth = 0f;
			((Renderer)val).sharedMaterial = Glow;
			val.startColor = new Color(0.7f, 0.55f, 0.95f, 0.5f);
			val.endColor = new Color(0.7f, 0.55f, 0.95f, 0f);
			val.minVertexDistance = 0.04f;
			((Renderer)val).shadowCastingMode = (ShadowCastingMode)0;
		}
	}

	public static void Hood(Transform parent)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: 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_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0352: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: 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_03b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_042a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0445: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0466: Unknown result type (might be due to invalid IL or missing references)
		//IL_046b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0481: Unknown result type (might be due to invalid IL or missing references)
		//IL_0486: Unknown result type (might be due to invalid IL or missing references)
		Transform parent2 = Root(parent, "SynthHood", Vector3.zero, Quaternion.identity);
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		float[] array = new float[5] { -0.18f, -0.06f, 0.11f, 0.25f, 0.31f };
		float[] array2 = new float[5] { 0.19f, 0.235f, 0.255f, 0.19f, 0.085f };
		float[] array3 = new float[5] { 0.15f, 0.22f, 0.235f, 0.19f, 0.085f };
		for (int i = 0; i < array.Length; i++)
		{
			for (int j = 0; j <= 16; j++)
			{
				float num = Mathf.Lerp(65f, 295f, (float)j / 16f) * ((float)Math.PI / 180f);
				list.Add(new Vector3(Mathf.Sin(num) * array2[i], array[i], Mathf.Cos(num) * array3[i]));
			}
		}
		for (int k = 0; k < array.Length - 1; k++)
		{
			for (int l = 0; l < 16; l++)
			{
				int num2 = k * 17 + l;
				int num3 = num2 + 1;
				int num4 = num2 + 16 + 1;
				int num5 = num4 + 1;
				list2.AddRange(new int[12]
				{
					num2, num4, num5, num2, num5, num3, num5, num4, num2, num3,
					num5, num2
				});
			}
		}
		Mesh(parent2, "HoodCloth", list.ToArray(), list2.ToArray(), Cloth);
		Mesh(parent2, "Brow", (Vector3[])(object)new Vector3[6]
		{
			new Vector3(-0.19f, 0.16f, 0.16f),
			new Vector3(0f, 0.215f, 0.29f),
			new Vector3(0.19f, 0.16f, 0.16f),
			new Vector3(-0.13f, 0.27f, 0.08f),
			new Vector3(0f, 0.31f, 0.14f),
			new Vector3(0.13f, 0.27f, 0.08f)
		}, new int[24]
		{
			0, 3, 4, 0, 4, 1, 1, 4, 5, 1,
			5, 2, 4, 3, 0, 1, 4, 0, 5, 4,
			1, 2, 5, 1
		}, Cloth);
		Loft(parent2, "Mask", (Vector3[])(object)new Vector3[4]
		{
			new Vector3(0f, -0.16f, 0.02f),
			new Vector3(0f, -0.08f, 0.025f),
			new Vector3(0f, 0.1f, 0.015f),
			new Vector3(0f, 0.16f, 0f)
		}, (Vector2[])(object)new Vector2[4]
		{
			new Vector2(0.1f, 0.1f),
			new Vector2(0.145f, 0.13f),
			new Vector2(0.145f, 0.13f),
			new Vector2(0.1f, 0.08f)
		}, 12, Dark);
		int[] array4 = new int[2] { -1, 1 };
		foreach (int num6 in array4)
		{
			Box(parent2, "EyeSlit", new Vector3((float)num6 * 0.062f, 0.07f, 0.175f), new Vector3(0.064f, 0.012f, 0.009f), Glow, Quaternion.Euler(0f, (float)(num6 * 12), (float)(num6 * -7)));
		}
		Loft(parent2, "Scarf", (Vector3[])(object)new Vector3[2]
		{
			new Vector3(0f, -0.2f, 0f),
			new Vector3(0f, -0.12f, 0f)
		}, (Vector2[])(object)new Vector2[2]
		{
			new Vector2(0.19f, 0.16f),
			new Vector2(0.18f, 0.15f)
		}, 12, Dark);
	}

	public static Transform Tail(Transform parent, string name, int side)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_00a4: 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_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: 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 = Root(parent, name, new Vector3((float)side * 0.17f, -0.02f, -0.11f), Quaternion.identity);
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		float[] array = new float[4] { 0f, -0.25f, -0.52f, -0.82f };
		for (int i = 0; i < 4; i++)
		{
			float num = (new float[4] { 0.16f, 0.18f, 0.2f, 0.13f })[i];
			float num2 = (float)(side * i) * 0.025f;
			float num3 = (float)(-i) * 0.045f;
			list.Add(new Vector3(num2 - num, array[i], num3));
			list.Add(new Vector3(num2, array[i] + 0.015f, num3 - 0.035f));
			list.Add(new Vector3(num2 + num, array[i], num3));
		}
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 2; k++)
			{
				int num4 = j * 3 + k;
				int num5 = num4 + 1;
				int num6 = num4 + 3;
				int num7 = num6 + 1;
				list2.AddRange(new int[12]
				{
					num4, num6, num7, num4, num7, num5, num7, num6, num4, num5,
					num7, num4
				});
			}
		}
		Mesh(val, "SplitCoatPanel", list.ToArray(), list2.ToArray(), Cloth);
		Beam(val, "CoatEdge", list[0], list[9], 0.012f, 0.006f, Trim);
		Beam(val, "CoatEdge", list[2], list[11], 0.012f, 0.006f, Trim);
		return val;
	}
}
[DefaultExecutionOrder(9000)]
public sealed class SynthModel : MonoBehaviour
{
	private Vector3 dabFace;

	private bool dabFaceKnown;

	public bool Display;

	private float armIk;

	private float scale;

	private float sprintW;

	private float airW;

	private Vector3 sr;

	private Vector3 sl;

	private Quaternion srr;

	private Quaternion slr;

	private bool smoothReady;

	public Transform RightCrossbow;

	public Transform LeftCrossbow;

	public Transform TailLeft;

	public Transform TailRight;

	private SynthArm right;

	private SynthArm left;

	private CharacterModel characterModel;

	private CharacterBody body;

	private SynthController control;

	private static readonly Dictionary<string, string> Alias = BuildAlias();

	private static Dictionary<string, string> reverse;

	private float surfWeight;

	private float domainWeight;

	private float feralWeight;

	public static float FeralPhase;

	private readonly Dictionary<Transform, Quaternion> legRest = new Dictionary<Transform, Quaternion>();

	private Transform meshNode;

	private Transform[] spine;

	private Quaternion[] spineBind;

	private static bool lateLogged;

	private static bool startLogged;

	private SynthCloth tailCloth;

	private float wag;

	private float nextNear;

	private bool near;

	public static Transform Find(Transform root, string name)
	{
		Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			if (((Object)val).name == name)
			{
				return val;
			}
		}
		if (Alias.TryGetValue(name, out var value))
		{
			Transform[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren2)
			{
				if (((Object)val2).name == value)
				{
					return val2;
				}
			}
		}
		return null;
	}

	private static Dictionary<string, string> BuildAlias()
	{
		Dictionary<string, string> dictionary = new Dictionary<string, string>();
		dictionary.Add("ROOT", "Root");
		dictionary.Add("base", "Root");
		dictionary.Add("pelvis", "Hips");
		dictionary.Add("stomach", "Spine1");
		dictionary.Add("chest", "Spine2");
		dictionary.Add("neck", "Neck");
		dictionary.Add("head", "Head");
		dictionary.Add("hat", "Head");
		Dictionary<string, string> dictionary2 = dictionary;
		string[] array = new string[2] { "l", "r" };
		foreach (string text in array)
		{
			string text2 = ((!(text == "l")) ? "R_" : "L_");
			dictionary2["clavicle." + text] = text2 + "Clav";
			dictionary2["upper_arm." + text] = text2 + "Upperarm";
			dictionary2["lower_arm." + text] = text2 + "Forearm";
			dictionary2["hand." + text] = text2 + "Hand";
			dictionary2["thigh." + text] = text2 + "Thigh";
			dictionary2["calf." + text] = text2 + "Shin";
			dictionary2["foot." + text] = text2 + "Foot";
			dictionary2["toe." + text] = text2 + "Toe";
			string[] array2 = new string[4] { "Index", "Middle", "Ring", "Pinky" };
			for (int j = 0; j < 4; j++)
			{
				for (int k = 1; k <= 3; k++)
				{
					dictionary2["finger" + (j + 1) + "." + k + "." + text] = text2 + array2[j] + "_0" + k;
				}
			}
			for (int l = 1; l <= 3; l++)
			{
				dictionary2["thumb." + l + "." + text] = text2 + "Thumb_0" + l;
			}
		}
		return dictionary2;
	}

	public static string Logical(string name)
	{
		if (reverse == null)
		{
			reverse = new Dictionary<string, string>();
			foreach (KeyValuePair<string, string> item in Alias)
			{
				if (!reverse.ContainsKey(item.Value))
				{
					reverse[item.Value] = item.Key;
				}
			}
		}
		string value;
		return (!reverse.TryGetValue(name, out value)) ? name : value;
	}

	public static bool IsBodyMesh(string name)
	{
		return name == "meshSeekerBody";
	}

	private static bool Hidden(string name)
	{
		return name.StartsWith("Bandit") || name == "meshSeekerGlass" || name == "meshSeekerCloth" || name.StartsWith("SeekerProps") || name.Contains("Lotus");
	}

	public static void BuildWorld(GameObject prefab)
	{
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Expected O, but got Unknown
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Expected O, but got Unknown
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0577: Unknown result type (might be due to invalid IL or missing references)
		//IL_0581: Unknown result type (might be due to invalid IL or missing references)
		//IL_0607: Unknown result type (might be due to invalid IL or missing references)
		//IL_0627: Unknown result type (might be due to invalid IL or missing references)
		//IL_0634: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_074e: Unknown result type (might be due to invalid IL or missing references)
		//IL_076b: Unknown result type (might be due to invalid IL or missing references)
		ModelLocator component = prefab.GetComponent<ModelLocator>();
		Transform modelTransform = component.modelTransform;
		((Object)modelTransform).name = "mdlSynth";
		ModelSkinController component2 = ((Component)modelTransform).GetComponent<ModelSkinController>();
		if (Object.op_Implicit((Object)(object)component2) && component2.skins.Length > 0)
		{
			LoadBaseSkin(component2.skins[0], modelTransform);
			Animator component3 = ((Component)modelTransform).GetComponent<Animator>();
			if (Object.op_Implicit((Object)(object)component3) && component2.animatorControllerRef != null)
			{
				component3.runtimeAnimatorController = component2.animatorControllerRef.WaitForCompletion();
			}
		}
		CharacterModel component4 = ((Component)modelTransform).GetComponent<CharacterModel>();
		Renderer[] componentsInChildren = ((Component)modelTransform).GetComponentsInChildren<Renderer>(true);
		Renderer[] array = componentsInChildren;
		foreach (Renderer val in array)
		{
			if (Object.op_Implicit((Object)(object)val.sharedMaterial))
			{
				SynthGeometry.Template = new Material(val.sharedMaterial);
				SynthBodyAsset.Plain(SynthGeometry.Template);
				break;
			}
		}
		Renderer[] array2 = componentsInChildren;
		foreach (Renderer val2 in array2)
		{
			if (Hidden(((Object)val2).name))
			{
				((Component)val2).gameObject.SetActive(false);
				continue;
			}
			if (IsBodyMesh(((Object)val2).name))
			{
				Transform val3 = ((Component)val2).transform;
				while (Object.op_Implicit((Object)(object)val3) && (Object)(object)val3 != (Object)(object)modelTransform)
				{
					((Component)val3).gameObject.SetActive(true);
					val3 = val3.parent;
				}
			}
			Material val4 = new Material(val2.sharedMaterial);
			((Object)val4).name = "Synth_" + ((Object)val2).name;
			SynthBodyAsset.Plain(val4);
			if (val2 is SkinnedMeshRenderer)
			{
				if (val4.HasProperty("_MainTex"))
				{
					val4.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
				}
				if (val4.HasProperty("_EmPower"))
				{
					val4.SetFloat("_EmPower", 0f);
				}
			}
			if (val4.HasProperty("_Color"))
			{
				val4.SetColor("_Color", ((Object)val2).name.Contains("Coat") ? new Color(0.3f, 0.045f, 0.095f) : ((!((Object)val2).name.Contains("Arms")) ? new Color(0.085f, 0.08f, 0.095f) : new Color(0.075f, 0.07f, 0.085f)));
			}
			val2.sharedMaterial = val4;
		}
		Renderer[] array3 = componentsInChildren;
		foreach (Renderer val5 in array3)
		{
			if (IsBodyMesh(((Object)val5).name))
			{
				SynthArmMesh.Prepare(val5);
			}
		}
		string[] array4 = new string[2] { "ArrowDisplay", "ClusterArrowDisplay" };
		foreach (string name in array4)
		{
			Transform val6 = Find(modelTransform, name);
			if (Object.op_Implicit((Object)(object)val6))
			{
				Renderer[] componentsInChildren2 = ((Component)val6).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val7 in componentsInChildren2)
				{
					Object.DestroyImmediate((Object)(object)val7);
				}
				((Component)val6).gameObject.SetActive(false);
			}
		}
		SynthModel synthModel = ((Component)modelTransform).gameObject.AddComponent<SynthModel>();
		synthModel.characterModel = component4;
		SynthBodyAsset.Build(modelTransform);
		SynthVisuals.Build(modelTransform);
		ItemDisplayFix.Apply(modelTransform, (string child, Vector3 pos, Vector3 bone) => (Vector3)(((!child.Contains("Chest") && !child.Contains("Stomach") && !child.Contains("Pelvis") && !(child == "Base")) || !(pos.z < bone.z - 0.04f)) ? Vector3.zero : new Vector3(0f, 0f, -0.1f)));
		SynthCloth synthCloth = ((Component)modelTransform).gameObject.AddComponent<SynthCloth>();
		synthCloth.Roots = new string[1] { "tail.0" };
		synthCloth.Stiffness = 0.045f;
		synthCloth.Gravity = 0.22f;
		synthCloth.Damping = 0.1f;
		synthCloth.TipLength = 0.12f;
		synthCloth.Wind = 0.002f;
		synthCloth.Colliders = new string[4] { "thigh.l", "calf.l", "thigh.r", "calf.r" };
		synthCloth.ColliderRadius = 0.09f;
		synthCloth.Thickness = 0.1f;
		SynthCloth synthCloth2 = ((Component)modelTransform).gameObject.AddComponent<SynthCloth>();
		synthCloth2.Roots = new string[1] { "pony.0" };
		synthCloth2.Stiffness = 0.04f;
		synthCloth2.Gravity = 0.45f;
		synthCloth2.Damping = 0.09f;
		synthCloth2.TipLength = 0.1f;
		synthCloth2.Colliders = new string[0];
		SynthCloth synthCloth3 = ((Component)modelTransform).gameObject.AddComponent<SynthCloth>();
		synthCloth3.Roots = SynthBodyAsset.CoatRoots.ToArray();
		synthCloth3.Colliders = new string[8] { "thigh.l", "calf.l", "calf.l", "foot.l", "thigh.r", "calf.r", "calf.r", "foot.r" };
		synthCloth3.TipLength = 0.25f;
		synthModel.RightCrossbow = SynthVisuals.Palm(Find(modelTransform, "hand.r"), "SynthCrossbowRight");
		synthModel.LeftCrossbow = SynthVisuals.Palm(Find(modelTransform, "hand.l"), "SynthCrossbowLeft");
		Transform[] array5 = (Transform[])(object)new Transform[2] { synthModel.RightCrossbow, synthModel.LeftCrossbow };
		foreach (Transform val8 in array5)
		{
			val8.localScale = Vector3.one * 0.8f;
		}
		AlignEquipment(modelTransform, synthModel.RightCrossbow, ".r", bow: true);
		AlignEquipment(modelTransform, synthModel.LeftCrossbow, ".l", bow: true);
		List<RendererInfo> list = new List<RendererInfo>();
		Renderer[] componentsInChildren3 = ((Component)modelTransform).GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val9 in componentsInChildren3)
		{
			if (!(val9 is ParticleSystemRenderer) && !Hidden(((Object)val9).name))
			{
				list.Add(new RendererInfo
				{
					renderer = val9,
					defaultMaterial = val9.sharedMaterial,
					defaultShadowCastingMode = (ShadowCastingMode)1,
					ignoreOverlays = false
				});
			}
		}
		component4.baseRendererInfos = list.ToArray();
		if (!Object.op_Implicit((Object)(object)component2))
		{
			return;
		}
		SkinDef val10 = ScriptableObject.CreateInstance<SkinDef>();
		((Object)val10).name = "SynthDefault";
		val10.nameToken = "SYNTH_SKIN_NAME";
		val10.icon = SynthIcons.Make(7);
		val10.rootObject = ((Component)modelTransform).gameObject;
		val10.baseSkins = (SkinDef[])(object)new SkinDef[0];
		SkinDefParams val11 = ScriptableObject.CreateInstance<SkinDefParams>();
		InitArrays(val11);
		val11.rendererInfos = component4.baseRendererInfos;
		List<MeshReplacement> list2 = new List<MeshReplacement>();
		RendererInfo[] baseRendererInfos = component4.baseRendererInfos;
		for (int num3 = 0; num3 < baseRendererInfos.Length; num3++)
		{
			RendererInfo val12 = baseRendererInfos[num3];
			Renderer renderer = val12.renderer;
			SkinnedMeshRenderer val13 = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null);
			MeshFilter component5 = ((Component)val12.renderer).GetComponent<MeshFilter>();
			Mesh val14 = (Object.op_Implicit((Object)(object)val13) ? val13.sharedMesh : ((!Object.op_Implicit((Object)(object)component5)) ? null : component5.sharedMesh));
			if (Object.op_Implicit((Object)(object)val14))
			{
				list2.Add(new MeshReplacement
				{
					renderer = val12.renderer,
					mesh = val14
				});
			}
		}
		val11.meshReplacements = list2.ToArray();
		val10.skinDefParams = val11;
		val10.optimizedSkinDefParams = val11;
		InitArrays(val10);
		component2.skins = (SkinDef[])(object)new SkinDef[1] { val10 };
		SynthSkins.Build(modelTransform, component2, component4, val10, InitArrays);
	}

	private static T Load<T>(AssetReferenceT<T> address, T direct) where T : Object
	{
		//IL_002d: 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)
		return Object.op_Implicit((Object)(object)direct) ? direct : ((address == null || !((AssetReference)address).RuntimeKeyIsValid()) ? ((T)(object)null) : Addressables.LoadAssetAsync<T>(((AssetReference)address).RuntimeKey).WaitForCompletion());
	}

	private static void LoadBaseSkin(SkinDef skin, Transform model)
	{
		//IL_003d: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		SkinDefParams val = Load<SkinDefParams>(skin.skinDefParamsAddress, skin.skinDefParams);
		if (!Object.op_Implicit((Object)(object)val))
		{
			throw new Exception("Bandit base skin data unavailable");
		}
		GameObjectActivation[] gameObjectActivations = val.gameObjectActivations;
		for (int i = 0; i < gameObjectActivations.Length; i++)
		{
			GameObjectActivation val2 = gameObjectActivations[i];
			if (Object.op_Implicit((Object)(object)val2.gameObject) && !val2.spawnPrefabOnModelObject)
			{
				Transform val3 = Find(model, ((Object)val2.gameObject).name);
				if (Object.op_Implicit((Object)(object)val3))
				{
					((Component)val3).gameObject.SetActive(val2.shouldActivate);
				}
			}
		}
		RendererInfo[] rendererInfos = val.rendererInfos;
		for (int j = 0; j < rendererInfos.Length; j++)
		{
			RendererInfo val4 = rendererInfos[j];
			if (!Object.op_Implicit((Object)(object)val4.renderer))
			{
				continue;
			}
			Transform val5 = Find(model, ((Object)val4.renderer).name);
			if (Object.op_Implicit((Object)(object)val5))
			{
				Renderer component = ((Component)val5).GetComponent<Renderer>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.sharedMaterial = Load<Material>(val4.defaultMaterialAddress, val4.defaultMaterial);
				}
			}
		}
		MeshReplacement[] meshReplacements = val.meshReplacements;
		for (int k = 0; k < meshReplacements.Length; k++)
		{
			MeshReplacement val6 = meshReplacements[k];
			if (!Object.op_Implicit((Object)(object)val6.renderer))
			{
				continue;
			}
			Transform val7 = Find(model, ((Object)val6.renderer).name);
			if (!Object.op_Implicit((Object)(object)val7))
			{
				continue;
			}
			Mesh sharedMesh = Load<Mesh>(val6.meshAddress, val6.mesh);
			SkinnedMeshRenderer component2 = ((Component)val7).GetComponent<SkinnedMeshRenderer>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.sharedMesh = sharedMesh;
				continue;
			}
			MeshFilter component3 = ((Component)val7).GetComponent<MeshFilter>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.sharedMesh = sharedMesh;
			}
		}
	}

	private static void InitArrays(object value)
	{
		FieldInfo[] fields = value.GetType().GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
		foreach (FieldInfo fieldInfo in fields)
		{
			if (!fieldInfo.IsStatic && fieldInfo.FieldType.IsArray && fieldInfo.GetValue(value) == null)
			{
				fieldInfo.SetValue(value, Array.CreateInstance(fieldInfo.FieldType.GetElementType(), 0));
			}
		}
	}

	private static Mesh WithoutHead(SkinnedMeshRenderer source)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		Mesh val = Object.Instantiate<Mesh>(source.sharedMesh);
		((Object)val).name = "SynthBodyBase";
		BoneWeight[] boneWeights = val.boneWeights;
		bool[] array = new bool[boneWeights.Length];
		for (int i = 0; i < boneWeights.Length; i++)
		{
			BoneWeight val2 = boneWeights[i];
			float num = 0f;
			KeyValuePair<int, float>[] array2 = new KeyValuePair<int, float>[4]
			{
				new KeyValuePair<int, float>(((BoneWeight)(ref val2)).boneIndex0, ((BoneWeight)(ref val2)).weight0),
				new KeyValuePair<int, float>(((BoneWeight)(ref val2)).boneIndex1, ((BoneWeight)(ref val2)).weight1),
				new KeyValuePair<int, float>(((BoneWeight)(ref val2)).boneIndex2, ((BoneWeight)(ref val2)).weight2),
				new KeyValuePair<int, float>(((BoneWeight)(ref val2)).boneIndex3, ((BoneWeight)(ref val2)).weight3)
			};
			for (int j = 0; j < array2.Length; j++)
			{
				KeyValuePair<int, float> keyValuePair = array2[j];
				if (keyValuePair.Key < source.bones.Length && Object.op_Implicit((Object)(object)source.bones[keyValuePair.Key]) && (((Object)source.bones[keyValuePair.Key]).name == "head" || ((Object)source.bones[keyValuePair.Key]).name == "hat"))
				{
					num += keyValuePair.Value;
				}
			}
			array[i] = num < 0.4f;
		}
		for (int k = 0; k < val.subMeshCount; k++)
		{
			int[] triangles = val.GetTriangles(k);
			List<int> list = new List<int>();
			for (int l = 0; l < triangles.Length; l += 3)
			{
				if (array[triangles[l]] && array[triangles[l + 1]] && array[triangles[l + 2]])
				{
					list.AddRange(new int[3]
					{
						triangles[l],
						triangles[l + 1],
						triangles[l + 2]
					});
				}
			}
			val.SetTriangles(list, k);
		}
		return val;
	}

	public static Quaternion GripFrame(Transform model, string side)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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_0059: 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_0062: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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_00ad: Unk