Decompiled source of Bibi Survivor v0.3.2

plugins/BibiSurvivor/BibiSurvivor.dll

Decompiled 15 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using HG.Reflection;
using KinematicCharacterController;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Networking;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BibiSurvivor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Bibi: a mobile ranged Risk of Rain 2 survivor.")]
[assembly: AssemblyFileVersion("0.3.1.0")]
[assembly: AssemblyInformationalVersion("0.3.1")]
[assembly: AssemblyProduct("BibiSurvivor")]
[assembly: AssemblyTitle("BibiSurvivor")]
[assembly: AssemblyVersion("0.3.1.0")]
namespace BibiSurvivor;

internal sealed class BibiAssets
{
	internal const string BundleFileName = "bibisurvivorassets";

	internal const string ModelPrefabName = "mdlBibi";

	private readonly string bundlePath;

	private readonly ManualLogSource log;

	private bool loadAttempted;

	private AssetBundle bundle;

	internal GameObject ModelPrefab { get; private set; }

	internal BibiAssets(string pluginDirectory, ManualLogSource log)
	{
		bundlePath = Path.Combine(pluginDirectory, "AssetBundles", "bibisurvivorassets");
		this.log = log;
	}

	internal IEnumerator LoadAsync()
	{
		if (loadAttempted)
		{
			yield break;
		}
		loadAttempted = true;
		if (!File.Exists(bundlePath))
		{
			log.LogError((object)("Required art bundle is missing. Expected: " + bundlePath + "."));
			yield break;
		}
		AssetBundleCreateRequest bundleRequest = BeginBundleLoad();
		if (bundleRequest == null)
		{
			yield break;
		}
		yield return bundleRequest;
		bundle = bundleRequest.assetBundle;
		if (!Object.op_Implicit((Object)(object)bundle))
		{
			log.LogError((object)("Could not load " + bundlePath + ". Build the bundle for Windows with the Unity version matching this game."));
			yield break;
		}
		string modelAssetPath = null;
		string[] allAssetNames = bundle.GetAllAssetNames();
		foreach (string text in allAssetNames)
		{
			bool num = string.Equals(text, "mdlBibi", StringComparison.OrdinalIgnoreCase);
			bool flag = string.Equals(Path.GetFileName(text), "mdlBibi.prefab", StringComparison.OrdinalIgnoreCase);
			if (num || flag)
			{
				if (modelAssetPath != null)
				{
					log.LogError((object)"The art bundle contains multiple mdlBibi model assets. Include exactly one model prefab.");
					yield break;
				}
				modelAssetPath = text;
			}
		}
		if (modelAssetPath == null)
		{
			log.LogError((object)"The art bundle does not contain the mdlBibi address or a mdlBibi.prefab asset. The FBX alone is not the required prefab.");
			yield break;
		}
		AssetBundleRequest modelRequest = bundle.LoadAssetAsync<GameObject>(modelAssetPath);
		yield return modelRequest;
		Object asset = modelRequest.asset;
		GameObject val = (GameObject)(object)((asset is GameObject) ? asset : null);
		if (!Object.op_Implicit((Object)(object)val))
		{
			log.LogError((object)("Could not deserialize " + modelAssetPath + " as a GameObject."));
			yield break;
		}
		Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
		if (componentsInChildren.Length == 0)
		{
			log.LogError((object)"mdlBibi has no renderers. Rebuild the art bundle with its mesh and materials.");
			yield break;
		}
		ModelPrefab = val;
		int num2 = val.GetComponentsInChildren<SkinnedMeshRenderer>(true).Length;
		bool flag2 = Object.op_Implicit((Object)(object)val.GetComponentInChildren<Animator>(true));
		log.LogInfo((object)string.Format("Validated {0}: {1} renderer(s), {2} skinned renderer(s), animator present: {3}.", "mdlBibi", componentsInChildren.Length, num2, flag2));
		if (num2 == 0 || !flag2)
		{
			log.LogWarning((object)"Model can be staged, but its rig/Animator still needs integration before it is playable.");
		}
	}

	private AssetBundleCreateRequest BeginBundleLoad()
	{
		try
		{
			return AssetBundle.LoadFromFileAsync(bundlePath);
		}
		catch (Exception ex)
		{
			log.LogError((object)("Failed to open the art bundle: " + ex.Message));
			return null;
		}
	}
}
internal static class BibiContent
{
	private static Transform prefabRoot;

	private const BindingFlags Fields = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

	public static GameObject BodyPrefab { get; private set; }

	public static SurvivorDef Survivor { get; private set; }

	internal static void Build(ContentPack pack, GameObject art)
	{
		//IL_0005: 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_0010: Expected O, but got Unknown
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: 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_01a1: 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_0415: Unknown result type (might be due to invalid IL or missing references)
		//IL_041a: Unknown result type (might be due to invalid IL or missing references)
		//IL_051a: Unknown result type (might be due to invalid IL or missing references)
		//IL_054d: Unknown result type (might be due to invalid IL or missing references)
		//IL_054f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0569: Unknown result type (might be due to invalid IL or missing references)
		//IL_057a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0676: Unknown result type (might be due to invalid IL or missing references)
		//IL_067b: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("ModdedPrefabs");
		Object.DontDestroyOnLoad((Object)val);
		val.SetActive(false);
		prefabRoot = val.transform;
		BibiNativeEffects.Build(pack, prefabRoot);
		GameObject val2 = LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody");
		if (!Object.op_Implicit((Object)(object)val2))
		{
			throw new InvalidOperationException("Commando body dependency was not available.");
		}
		BodyPrefab = PrefabAPI.InstantiateClone(val2, "BibiBody", false);
		CharacterBody component = BodyPrefab.GetComponent<CharacterBody>();
		ModelLocator component2 = BodyPrefab.GetComponent<ModelLocator>();
		Transform modelBaseTransform = component2.modelBaseTransform;
		Object.DestroyImmediate((Object)(object)((Component)component2.modelTransform).gameObject);
		GameObject val3 = Object.Instantiate<GameObject>(art, modelBaseTransform);
		((Object)val3).name = "mdlBibi";
		val3.transform.localPosition = Vector3.zero;
		val3.transform.localRotation = Quaternion.identity;
		val3.transform.localScale = Vector3.one;
		modelBaseTransform.localPosition = new Vector3(0f, -0.92f, 0f);
		component2.modelTransform = val3.transform;
		component.baseNameToken = "BIBI_NAME";
		component.subtitleNameToken = "BIBI_SUBTITLE";
		component.bodyFlags = (BodyFlags)16;
		component.baseMaxHealth = 110f;
		component.levelMaxHealth = 33f;
		component.baseRegen = 1f;
		component.levelRegen = 0.2f;
		component.baseDamage = 12f;
		component.levelDamage = 2.4f;
		component.baseMoveSpeed = 7.5f;
		component.baseAcceleration = 90f;
		component.baseJumpPower = 15f;
		component.baseArmor = 0f;
		component.baseAttackSpeed = 1f;
		component.levelAttackSpeed = 0f;
		component.bodyColor = new Color(0.15f, 0.55f, 1f);
		typeof(CharacterBody).GetField("_defaultCrosshairPrefab", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(component, LegacyResourcesAPI.Load<GameObject>("Prefabs/Crosshair/SimpleDotCrosshair"));
		component.preferredPodPrefab = null;
		component.portraitIcon = (Texture)(object)BibiIcons.Portrait.texture;
		CharacterDirection component3 = BodyPrefab.GetComponent<CharacterDirection>();
		component3.targetTransform = modelBaseTransform;
		component3.modelAnimator = val3.GetComponent<Animator>();
		component3.overrideAnimatorForwardTransform = null;
		component3.rootMotionAccumulator = null;
		component3.driveFromRootRotation = false;
		component3.turnSpeed = 720f;
		val3.GetComponent<Animator>().applyRootMotion = false;
		val3.GetComponent<Animator>().cullingMode = (AnimatorCullingMode)0;
		CharacterModel val4 = val3.AddComponent<CharacterModel>();
		val4.body = component;
		val4.autoPopulateLightInfos = true;
		val4.baseRendererInfos = SplitMaterials(val3, val2);
		SetUpHurtbox(component, val3);
		SetUpChildren(val3);
		val4.itemDisplayRuleSet = BibiItemDisplays.Build(val3, val2);
		SkinDefParams val5 = ScriptableObject.CreateInstance<SkinDefParams>();
		((Object)val5).name = "BibiDefaultSkinParams";
		val5.rendererInfos = val4.baseRendererInfos;
		SkinDef val6 = ScriptableObject.CreateInstance<SkinDef>();
		((Object)val6).name = "BibiDefaultSkin";
		val6.nameToken = "BIBI_SKIN";
		val6.rootObject = val3;
		val6.icon = BibiIcons.Portrait;
		val6.skinDefParams = val5;
		val3.AddComponent<ModelSkinController>().skins = (SkinDef[])(object)new SkinDef[1] { val6 };
		BodyPrefab.AddComponent<BibiCombatController>();
		BodyPrefab.AddComponent<BibiPresentation>();
		EntityStateMachine[] components = BodyPrefab.GetComponents<EntityStateMachine>();
		for (int i = 0; i < components.Length; i++)
		{
			Object.DestroyImmediate((Object)(object)components[i]);
		}
		EntityStateMachine[] array = (EntityStateMachine[])(object)new EntityStateMachine[5]
		{
			Machine("Body", typeof(GenericCharacterMain)),
			Machine("Weapon", typeof(Idle)),
			Machine("Pager", typeof(Idle)),
			Machine("Jet", typeof(Idle)),
			Machine("Strike", typeof(Idle))
		};
		typeof(NetworkStateMachine).GetField("stateMachines", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(BodyPrefab.GetComponent<NetworkStateMachine>(), array);
		component.vehicleIdleStateMachine = array.Skip(1).ToArray();
		CharacterDeathBehavior component4 = BodyPrefab.GetComponent<CharacterDeathBehavior>();
		component4.deathStateMachine = array[0];
		component4.idleStateMachine = array.Skip(1).ToArray();
		component4.deathState = new SerializableEntityStateType(typeof(GenericCharacterDeath));
		SetStateOnHurt component5 = BodyPrefab.GetComponent<SetStateOnHurt>();
		component5.targetStateMachine = array[0];
		component5.idleStateMachine = array.Skip(1).ToArray();
		GenericSkill[] components2 = BodyPrefab.GetComponents<GenericSkill>();
		for (int i = 0; i < components2.Length; i++)
		{
			Object.DestroyImmediate((Object)(object)components2[i]);
		}
		SkillLocator component6 = BodyPrefab.GetComponent<SkillLocator>();
		component6.primary = AddSkill(pack, "BEAM", typeof(GoyBeamState), "Weapon", 0f, 0, keyPress: false, 0);
		component6.secondary = AddSkill(pack, "PAGER", typeof(CallForwardingState), "Pager", 7f, 1, keyPress: true, 1);
		component6.utility = AddSkill(pack, "PODIUM", typeof(PressConferenceState), "Jet", 6f, 1, keyPress: true, 2);
		component6.special = AddSkill(pack, "STRIKE", typeof(BunkerBusterState), "Strike", 12f, 1, keyPress: true, 3);
		component6.passiveSkill = new PassiveSkill
		{
			enabled = true,
			skillNameToken = "BIBI_PASSIVE_NAME",
			skillDescriptionToken = "BIBI_PASSIVE_DESCRIPTION",
			icon = BibiIcons.Get(4)
		};
		GameObject val7 = PrefabAPI.InstantiateClone(val3, "BibiDisplay", false);
		val7.transform.localPosition = Vector3.zero;
		val7.transform.localRotation = Quaternion.identity;
		val7.GetComponent<CharacterModel>().body = null;
		HurtBox[] componentsInChildren = val7.GetComponentsInChildren<HurtBox>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
		}
		Collider[] componentsInChildren2 = val7.GetComponentsInChildren<Collider>(true);
		for (int i = 0; i < componentsInChildren2.Length; i++)
		{
			Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
		}
		HurtBoxGroup component7 = val7.GetComponent<HurtBoxGroup>();
		if (Object.op_Implicit((Object)(object)component7))
		{
			Object.DestroyImmediate((Object)(object)component7);
		}
		val7.AddComponent<BibiDisplayPose>();
		Survivor = ScriptableObject.CreateInstance<SurvivorDef>();
		Survivor.cachedName = "Bibi";
		Survivor.bodyPrefab = BodyPrefab;
		Survivor.displayPrefab = val7;
		Survivor.displayNameToken = "BIBI_NAME";
		Survivor.descriptionToken = "BIBI_DESCRIPTION";
		Survivor.outroFlavorToken = "BIBI_OUTRO";
		Survivor.mainEndingEscapeFailureFlavorToken = "BIBI_FAILURE";
		Survivor.primaryColor = component.bodyColor;
		Survivor.desiredSortPosition = 110f;
		pack.survivorDefs.Add((SurvivorDef[])(object)new SurvivorDef[1] { Survivor });
		GameObject val8 = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/CommandoMonsterMaster"), "BibiMonsterMaster", false);
		val8.GetComponent<CharacterMaster>().bodyPrefab = BodyPrefab;
		pack.masterPrefabs.Add((GameObject[])(object)new GameObject[1] { val8 });
		GameObject val9 = PodiumDecoy.CreatePrefab(art);
		pack.bodyPrefabs.Add((GameObject[])(object)new GameObject[2] { BodyPrefab, val9 });
		GameObject[] array2 = (GameObject[])(object)new GameObject[5]
		{
			BodyPrefab,
			val8,
			val9,
			BeeperCall.CreatePrefab(),
			BunkerStrike.CreatePrefab()
		};
		GameObject[] array3 = array2;
		for (int i = 0; i < array3.Length; i++)
		{
			PrepareNetworkPrefab(array3[i]);
		}
		pack.networkedObjectPrefabs.Add(array2);
		pack.entityStateTypes.Add(new Type[4]
		{
			typeof(GoyBeamState),
			typeof(CallForwardingState),
			typeof(PressConferenceState),
			typeof(BunkerBusterState)
		});
		BibiPlugin.Log.LogInfo((object)$"Bibi content built: {val4.baseRendererInfos.Length} material renderers, four independent skill state machines.");
	}

	private static EntityStateMachine Machine(string name, Type main)
	{
		//IL_0013: 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_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		EntityStateMachine obj = BodyPrefab.AddComponent<EntityStateMachine>();
		obj.customName = name;
		obj.initialStateType = new SerializableEntityStateType(main);
		obj.mainStateType = new SerializableEntityStateType(main);
		return obj;
	}

	private static GenericSkill AddSkill(ContentPack pack, string key, Type state, string machine, float recharge, int consume, bool keyPress, int icon)
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Expected O, but got Unknown
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		SkillDef val = (SkillDef)(object)((key == "PAGER") ? ScriptableObject.CreateInstance<CallForwardingSkillDef>() : ((CallForwardingSkillDef)(object)ScriptableObject.CreateInstance<SkillDef>()));
		((Object)val).name = "Bibi" + key;
		val.skillName = "Bibi" + key;
		val.skillNameToken = "BIBI_" + key + "_NAME";
		val.skillDescriptionToken = "BIBI_" + key + "_DESCRIPTION";
		val.activationState = new SerializableEntityStateType(state);
		val.activationStateMachineName = machine;
		val.baseMaxStock = 1;
		val.baseRechargeInterval = recharge;
		val.requiredStock = consume;
		val.stockToConsume = consume;
		val.rechargeStock = 1;
		val.fullRestockOnAssign = true;
		val.resetCooldownTimerOnUse = false;
		val.beginSkillCooldownOnSkillEnd = key == "STRIKE";
		val.mustKeyPress = keyPress;
		val.cancelSprintingOnActivation = false;
		val.canceledFromSprinting = false;
		val.interruptPriority = (InterruptPriority)1;
		val.icon = BibiIcons.Get(icon);
		val.keywordTokens = Array.Empty<string>();
		SkillFamily val2 = ScriptableObject.CreateInstance<SkillFamily>();
		((Object)val2).name = "Bibi" + key + "Family";
		Variant[] array = new Variant[1];
		Variant val3 = new Variant
		{
			skillDef = val
		};
		((Variant)(ref val3)).viewableNode = new Node(val.skillNameToken, false, (Node)null);
		array[0] = val3;
		val2.variants = (Variant[])(object)array;
		GenericSkill val4 = BodyPrefab.AddComponent<GenericSkill>();
		val4.skillName = key;
		typeof(GenericSkill).GetField("_skillFamily", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(val4, val2);
		pack.skillDefs.Add((SkillDef[])(object)new SkillDef[1] { val });
		pack.skillFamilies.Add((SkillFamily[])(object)new SkillFamily[1] { val2 });
		return val4;
	}

	private static void PrepareNetworkPrefab(GameObject prefab)
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		prefab.transform.SetParent(prefabRoot, false);
		NetworkIdentity component = prefab.GetComponent<NetworkIdentity>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			throw new InvalidOperationException("NetworkIdentity missing on " + ((Object)prefab).name);
		}
		using (MD5 mD = MD5.Create())
		{
			string text = string.Concat(from b in mD.ComputeHash(Encoding.UTF8.GetBytes("com.gal66.bibisurvivor:" + ((Object)prefab).name))
				select b.ToString("x2"));
			typeof(NetworkIdentity).GetField("m_AssetId", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(component, NetworkHash128.Parse(text));
		}
		prefab.SetActive(true);
	}

	private static RendererInfo[] SplitMaterials(GameObject model, GameObject sourceBody)
	{
		//IL_0005: 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_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_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Expected O, but got Unknown
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: 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)
		Shader val = Addressables.LoadAssetAsync<Shader>((object)"RoR2/Base/Shaders/HGStandard.shader").WaitForCompletion();
		if (!Object.op_Implicit((Object)(object)val))
		{
			throw new InvalidOperationException("RoR2 character shader failed to load.");
		}
		List<RendererInfo> list = new List<RendererInfo>();
		SkinnedMeshRenderer[] componentsInChildren = model.GetComponentsInChildren<SkinnedMeshRenderer>(true);
		foreach (SkinnedMeshRenderer val2 in componentsInChildren)
		{
			Mesh sharedMesh = val2.sharedMesh;
			for (int j = 0; j < sharedMesh.subMeshCount; j++)
			{
				if (sharedMesh.GetIndexCount(j) == 0)
				{
					continue;
				}
				GameObject val3 = new GameObject(((Object)val2).name + "_" + j);
				val3.transform.SetParent(((Component)val2).transform, false);
				SkinnedMeshRenderer val4 = val3.AddComponent<SkinnedMeshRenderer>();
				Mesh sharedMesh2 = ExtractMaterialMesh(sharedMesh, j);
				val4.sharedMesh = sharedMesh2;
				val4.bones = val2.bones;
				val4.rootBone = val2.rootBone;
				((Renderer)val4).localBounds = ((Renderer)val2).localBounds;
				val4.updateWhenOffscreen = true;
				Material val5 = ((Renderer)val2).sharedMaterials[j];
				Material val6 = new Material(val)
				{
					name = ((Object)val5).name,
					color = val5.color,
					mainTexture = (Texture)(Object.op_Implicit((Object)(object)val5.mainTexture) ? ((object)val5.mainTexture) : ((object)Texture2D.whiteTexture))
				};
				if (val6.HasProperty("_NormalStrength"))
				{
					val6.SetFloat("_NormalStrength", 0f);
				}
				if (val6.HasProperty("_SpecularStrength"))
				{
					val6.SetFloat("_SpecularStrength", 0.12f);
				}
				if (val6.HasProperty("_SpecularExponent"))
				{
					val6.SetFloat("_SpecularExponent", 5f);
				}
				bool flag = ((Object)val5).name.StartsWith("Suit_Lapel", StringComparison.Ordinal);
				if (((Object)val5).name.StartsWith("Suit_Charcoal", StringComparison.Ordinal) || flag)
				{
					val6.color = (flag ? new Color(0.22f, 0.24f, 0.27f) : new Color(0.17f, 0.19f, 0.22f));
					if (val6.HasProperty("_RampInfo"))
					{
						val6.SetFloat("_RampInfo", 1f);
					}
					if (val6.HasProperty("_Smoothness"))
					{
						val6.SetFloat("_Smoothness", flag ? 0.32f : 0.12f);
					}
					if (val6.HasProperty("_SpecularStrength"))
					{
						val6.SetFloat("_SpecularStrength", flag ? 0.22f : 0.07f);
					}
				}
				if (val6.HasProperty("_Cull"))
				{
					val6.SetFloat("_Cull", 0f);
				}
				((Renderer)val4).sharedMaterial = val6;
				list.Add(new RendererInfo
				{
					renderer = (Renderer)(object)val4,
					defaultMaterial = val6,
					defaultShadowCastingMode = (ShadowCastingMode)1,
					ignoreOverlays = false
				});
			}
			Object.DestroyImmediate((Object)(object)val2);
		}
		BibiPlugin.Log.LogInfo((object)$"Bibi character rendering: {list.Count} material renderers, {list.Sum((RendererInfo info) => ((SkinnedMeshRenderer)info.renderer).sharedMesh.vertexCount)} skinned vertices after material compaction.");
		return list.ToArray();
	}

	private static Mesh ExtractMaterialMesh(Mesh source, int submesh)
	{
		//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)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Expected O, but got Unknown
		int[] triangles = source.GetTriangles(submesh);
		int[] used = triangles.Distinct().ToArray();
		int[] array = new int[source.vertexCount];
		for (int i = 0; i < used.Length; i++)
		{
			array[used[i]] = i;
		}
		for (int j = 0; j < triangles.Length; j++)
		{
			triangles[j] = array[triangles[j]];
		}
		Mesh val = new Mesh
		{
			name = ((Object)source).name + "_" + submesh,
			indexFormat = (IndexFormat)(used.Length > 65535),
			vertices = Select<Vector3>(source.vertices),
			normals = Select<Vector3>(source.normals),
			tangents = Select<Vector4>(source.tangents),
			uv = Select<Vector2>(source.uv),
			uv2 = Select<Vector2>(source.uv2),
			colors = Select<Color>(source.colors),
			boneWeights = Select<BoneWeight>(source.boneWeights),
			bindposes = source.bindposes,
			triangles = triangles
		};
		val.RecalculateBounds();
		if (val.normals.Length == 0)
		{
			val.RecalculateNormals();
		}
		return val;
		T[] Select<T>(T[] values)
		{
			if (values.Length != source.vertexCount)
			{
				return Array.Empty<T>();
			}
			return used.Select((int num) => values[num]).ToArray();
		}
	}

	private static void SetUpHurtbox(CharacterBody body, GameObject model)
	{
		//IL_0005: 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_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("MainHurtbox");
		val.transform.SetParent(model.transform, false);
		val.transform.localPosition = new Vector3(0f, 1f, 0f);
		val.layer = LayerIndex.entityPrecise.intVal;
		CapsuleCollider obj = val.AddComponent<CapsuleCollider>();
		obj.radius = 0.3f;
		obj.height = 1.8f;
		((Collider)obj).isTrigger = false;
		HurtBox val2 = val.AddComponent<HurtBox>();
		HurtBoxGroup val3 = model.AddComponent<HurtBoxGroup>();
		val2.healthComponent = ((Component)body).GetComponent<HealthComponent>();
		val2.isBullseye = true;
		val2.isSniperTarget = true;
		val2.hurtBoxGroup = val3;
		val2.indexInGroup = 0;
		val3.hurtBoxes = (HurtBox[])(object)new HurtBox[1] { val2 };
		val3.mainHurtBox = val2;
		val3.bullseyeCount = 1;
	}

	private static void SetUpChildren(GameObject model)
	{
		//IL_00a3: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: 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_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		ChildLocator obj = model.AddComponent<ChildLocator>();
		Dictionary<string, Transform> bones = (from t in model.GetComponentsInChildren<Transform>(true)
			group t by ((Object)t).name).ToDictionary((IGrouping<string, Transform> g) => g.Key, (IGrouping<string, Transform> g) => g.First());
		NameTransformPair[] value = (NameTransformPair[])(object)new NameTransformPair[9]
		{
			Pair("Head", "head"),
			Pair("Chest", "chest"),
			Pair("Base", "base"),
			Pair("MainHurtbox", "MainHurtbox"),
			Pair("Muzzle", "hand.R"),
			Pair("MuzzleRight", "hand.R"),
			Pair("MuzzleLeft", "hand.L"),
			Pair("FootL", "foot.L"),
			Pair("FootR", "foot.R")
		};
		typeof(ChildLocator).GetField("transformPairs", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(obj, value);
		NameTransformPair Pair(string name, string bone)
		{
			//IL_0002: 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)
			Transform value2;
			return new NameTransformPair
			{
				name = name,
				transform = (bones.TryGetValue(bone, out value2) ? value2 : model.transform)
			};
		}
	}
}
internal sealed class BibiContentPackProvider : IContentPackProvider
{
	private readonly BibiAssets assets;

	private readonly ManualLogSource log;

	private readonly ContentPack content = new ContentPack();

	public string identifier => "com.gal66.bibisurvivor";

	internal BibiContentPackProvider(string pluginDirectory, ManualLogSource log)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		this.log = log;
		assets = new BibiAssets(pluginDirectory, log);
		typeof(ContentPack).GetProperty("identifier").SetValue(content, identifier);
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		yield return assets.LoadAsync();
		if (!Object.op_Implicit((Object)(object)assets.ModelPrefab))
		{
			throw new InvalidOperationException("Bibi model bundle is required.");
		}
		BibiContent.Build(content, assets.ModelPrefab);
		args.ReportProgress(1f);
	}

	public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
	{
		ContentPack.Copy(content, args.output);
		args.ReportProgress(1f);
		yield break;
	}

	public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
	{
		log.LogInfo((object)"Bibi survivor, four skills, passive and independent networked casts registered.");
		args.ReportProgress(1f);
		yield break;
	}
}
internal static class BibiLanguage
{
	internal static void Register()
	{
		LanguageAPI.Add("BIBI_NAME", "Bibi");
		LanguageAPI.Add("BIBI_SUBTITLE", "The Indispensable");
		LanguageAPI.Add("BIBI_SKIN", "State Business");
		LanguageAPI.Add("BIBI_DESCRIPTION", "Bibi is a mobile ranged survivor who remains remarkably composed while his calls escalate.<style=cSub>\n\nHold the palm beam for sustained on-hit damage.\nCall Forwarding works alone, or bursts faster under direct beam fire.\nLaunch from a podium and hold Jump while beaming to control your descent.\nMark a Red Line, then keep moving while the strike arrives.</style>");
		LanguageAPI.Add("BIBI_OUTRO", "...and so he left, declaring the briefing a complete success.");
		LanguageAPI.Add("BIBI_FAILURE", "...and so he remained, insisting the situation was under control.");
		LanguageAPI.Add("BIBI_BEAM_NAME", "Goy Beam");
		LanguageAPI.Add("BIBI_BEAM_DESCRIPTION", "Hold to fire a palm laser for <style=cIsDamage>55% damage per hit</style>, ramping from 35% to full power over <style=cIsUtility>0.6s</style>. Fires <style=cIsDamage>6 hits/s</style>, scaling with attack speed. Brief interruptions preserve charge.");
		LanguageAPI.Add("BIBI_PAGER_NAME", "Call Forwarding");
		LanguageAPI.Add("BIBI_PAGER_DESCRIPTION", "Attach an independent beeper to a target. It bursts <style=cIsDamage>4 times for 220% damage</style>, jumping between enemies. Direct palm-beam hits hasten its next burst. Against one enemy it stays and repeats.");
		LanguageAPI.Add("BIBI_PODIUM_NAME", "Emergency Press Conference");
		LanguageAPI.Add("BIBI_PODIUM_DESCRIPTION", "Launch upward and forward, preserving momentum. Leave a <style=cIsUtility>podium decoy for 6s</style> to distract nearby ordinary enemies. Extra stocks allow consecutive launches.");
		LanguageAPI.Add("BIBI_STRIKE_NAME", "Red Line: Bunker Buster");
		LanguageAPI.Add("BIBI_STRIKE_DESCRIPTION", "<style=cIsUtility>Hold</style> to aim at a surface or enemy position; <style=cIsUtility>release</style> to confirm. After 1.15s, a bunker buster deals <style=cIsDamage>2000% damage</style> in a 12m radius. Each confirmed cast calls an independent strike.");
		LanguageAPI.Add("BIBI_PASSIVE_NAME", "Never Steps Down");
		LanguageAPI.Add("BIBI_PASSIVE_DESCRIPTION", "While airborne, <style=cIsUtility>hold Jump while firing Goy Beam</style> to slow your descent. Release Jump to fall normally. This does not grant permanent flight.");
	}
}
[BepInPlugin("com.gal66.bibisurvivor", "Bibi Survivor", "0.3.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class BibiPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "com.gal66.bibisurvivor";

	public const string PluginName = "Bibi Survivor";

	public const string PluginVersion = "0.3.1";

	internal static ManualLogSource Log;

	private BibiContentPackProvider contentProvider;

	private void Awake()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		RoR2Application.isModded = true;
		NetworkModCompatibilityHelper.networkModList = NetworkModCompatibilityHelper.networkModList.Append("com.gal66.bibisurvivor;0.3.1");
		BibiLanguage.Register();
		string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		BibiIcons.LoadPortrait(directoryName);
		contentProvider = new BibiContentPackProvider(directoryName, ((BaseUnityPlugin)this).Logger);
		ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(AddContentPackProvider);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Bibi mobile ranged survivor loading.");
		if (Environment.GetEnvironmentVariable("BIBI_DEV_TESTS") == "1")
		{
			((Component)this).gameObject.AddComponent<BibiRuntimeChecks>();
		}
	}

	private void AddContentPackProvider(AddContentPackProviderDelegate addProvider)
	{
		addProvider.Invoke((IContentPackProvider)(object)contentProvider);
	}

	private void OnDestroy()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		ContentManager.collectContentPackProviders -= new CollectContentPackProvidersDelegate(AddContentPackProvider);
	}
}
public sealed class BeeperCall : NetworkBehaviour
{
	internal sealed class BeeperTargetSearch : BullseyeSearch
	{
		public BeeperTargetSearch()
		{
			base.maxThetaDot = 1.00001f;
		}
	}

	private static GameObject prefab;

	private GameObject ownerObject;

	private GameObject carrierObject;

	private CharacterBody ownerBody;

	private BibiCombatController ownerController;

	private TeamIndex ownerTeam;

	private BeeperBurstClock clock;

	private float burstTimer;

	private int burstsRemaining;

	private uint burstSequence;

	private Vector3 lastCarrierPosition;

	private Vector3 lastBurstPosition;

	private float syncTimer;

	private bool exhausted;

	private float retirementTime;

	private BeeperVisual visual;

	public HealthComponent CarrierHealth { get; private set; }

	public int BurstsRemaining
	{
		get
		{
			if (clock == null)
			{
				return burstsRemaining;
			}
			return clock.Remaining;
		}
	}

	public float SecondsUntilBurst
	{
		get
		{
			if (clock == null)
			{
				return burstTimer;
			}
			return clock.SecondsUntilBurst;
		}
	}

	public GameObject Owner => ownerObject;

	public Vector3 VisualAnchor
	{
		get
		{
			//IL_001d: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = (Object.op_Implicit((Object)(object)CarrierHealth) ? CarrierHealth.body : null);
			Vector3 carrierPosition = GetCarrierPosition();
			float num = carrierPosition.y + (Object.op_Implicit((Object)(object)val) ? Mathf.Clamp(val.radius, 0.6f, 4f) : 0.6f);
			Bounds bounds;
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.hurtBoxGroup) && val.hurtBoxGroup.hurtBoxes != null)
			{
				HurtBox[] hurtBoxes = val.hurtBoxGroup.hurtBoxes;
				foreach (HurtBox val2 in hurtBoxes)
				{
					if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.collider) && val2.collider.enabled)
					{
						float num2 = num;
						bounds = val2.collider.bounds;
						num = Mathf.Max(num2, ((Bounds)(ref bounds)).max.y);
					}
				}
			}
			else if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.mainHurtBox) && Object.op_Implicit((Object)(object)val.mainHurtBox.collider))
			{
				float num3 = num;
				bounds = val.mainHurtBox.collider.bounds;
				num = Mathf.Max(num3, ((Bounds)(ref bounds)).max.y);
			}
			carrierPosition.y = num + 0.12f;
			return carrierPosition;
		}
	}

	public GameObject Carrier => carrierObject;

	public static GameObject CreatePrefab()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		if (Object.op_Implicit((Object)(object)prefab))
		{
			return prefab;
		}
		prefab = new GameObject("BibiBeeperCall");
		prefab.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)prefab);
		prefab.AddComponent<NetworkIdentity>();
		prefab.AddComponent<BeeperCall>();
		return prefab;
	}

	public static BeeperCall Spawn(GameObject owner, HurtBox target)
	{
		//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_00aa: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)target) || !Object.op_Implicit((Object)(object)target.healthComponent) || !target.healthComponent.alive)
		{
			return null;
		}
		GameObject obj = Object.Instantiate<GameObject>(CreatePrefab());
		((Object)obj).name = "BibiBeeperCall(Clone)";
		BeeperCall component = obj.GetComponent<BeeperCall>();
		component.ownerObject = owner;
		component.ownerBody = owner.GetComponent<CharacterBody>();
		component.ownerController = owner.GetComponent<BibiCombatController>();
		component.ownerTeam = TeamComponent.GetObjectTeam(owner);
		component.burstsRemaining = 4;
		component.burstTimer = 1.2f;
		component.clock = new BeeperBurstClock();
		component.SetCarrier(target.healthComponent);
		obj.transform.position = component.lastCarrierPosition;
		obj.SetActive(true);
		if (Object.op_Implicit((Object)(object)component.ownerController))
		{
			component.ownerController.RegisterCall(component);
		}
		NetworkServer.Spawn(obj);
		return component;
	}

	public static HurtBox AcquireTarget(CharacterBody owner, Ray aim)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)owner))
		{
			return null;
		}
		BullseyeSearch obj = MakeSearch(owner, ((Ray)(ref aim)).origin, 90f);
		obj.searchDirection = ((Ray)(ref aim)).direction;
		obj.maxAngleFilter = 12f;
		obj.sortMode = (SortMode)2;
		obj.filterByLoS = true;
		obj.RefreshCandidates();
		return obj.GetResults().FirstOrDefault((Func<HurtBox, bool>)((HurtBox h) => Object.op_Implicit((Object)(object)h) && Object.op_Implicit((Object)(object)h.healthComponent) && h.healthComponent.alive));
	}

	private static BullseyeSearch MakeSearch(CharacterBody owner, Vector3 origin, float range)
	{
		//IL_000d: 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_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_004b: 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)
		BeeperTargetSearch obj = new BeeperTargetSearch
		{
			viewer = owner,
			searchOrigin = origin,
			searchDirection = Vector3.forward,
			maxDistanceFilter = range,
			minDistanceFilter = 0f
		};
		((BullseyeSearch)obj).maxAngleFilter = 180f;
		((BullseyeSearch)obj).filterByLoS = false;
		((BullseyeSearch)obj).filterByDistinctEntity = true;
		((BullseyeSearch)obj).sortMode = (SortMode)1;
		((BullseyeSearch)obj).teamMaskFilter = TeamMask.GetEnemyTeams(owner.teamComponent.teamIndex);
		return (BullseyeSearch)(object)obj;
	}

	private void Start()
	{
		if (!Application.isBatchMode)
		{
			visual = ((Component)this).gameObject.AddComponent<BeeperVisual>();
			visual.Initialize(this);
		}
	}

	private void SetCarrier(HealthComponent next)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		CarrierHealth = next;
		carrierObject = (Object.op_Implicit((Object)(object)next) ? ((Component)next).gameObject : null);
		if (Object.op_Implicit((Object)(object)next))
		{
			lastCarrierPosition = GetCarrierPosition();
		}
		((NetworkBehaviour)this).SetDirtyBit(1u);
	}

	private Vector3 GetCarrierPosition()
	{
		//IL_0025: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody val = (Object.op_Implicit((Object)(object)CarrierHealth) ? CarrierHealth.body : null);
		if (Object.op_Implicit((Object)(object)val))
		{
			return val.corePosition;
		}
		if (!Object.op_Implicit((Object)(object)carrierObject))
		{
			return lastCarrierPosition;
		}
		return carrierObject.transform.position;
	}

	public void AdvanceFromDirectBeam()
	{
		if (NetworkServer.active && !exhausted && clock != null && clock.Remaining > 0)
		{
			clock.AdvanceFromBeam();
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}
	}

	private void FixedUpdate()
	{
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active)
		{
			if (!exhausted)
			{
				burstTimer = Mathf.Max(0f, burstTimer - Time.fixedDeltaTime);
			}
			if (!Object.op_Implicit((Object)(object)CarrierHealth) && Object.op_Implicit((Object)(object)carrierObject))
			{
				CarrierHealth = carrierObject.GetComponent<HealthComponent>();
			}
			return;
		}
		float fixedDeltaTime = Time.fixedDeltaTime;
		if (exhausted)
		{
			retirementTime -= fixedDeltaTime;
			if (retirementTime <= 0f)
			{
				NetworkServer.Destroy(((Component)this).gameObject);
			}
			return;
		}
		clock?.AdvanceTime(fixedDeltaTime);
		if (!Object.op_Implicit((Object)(object)ownerBody) || !Object.op_Implicit((Object)(object)ownerBody.healthComponent) || !ownerBody.healthComponent.alive || clock == null || clock.HasExpired)
		{
			Retire();
			return;
		}
		if (Object.op_Implicit((Object)(object)CarrierHealth) && CarrierHealth.alive)
		{
			lastCarrierPosition = GetCarrierPosition();
		}
		else if (!Transfer(preferDifferent: true))
		{
			Retire();
			return;
		}
		while (clock.IsBurstDue && !exhausted)
		{
			Burst();
			if (clock.Remaining <= 0)
			{
				Retire();
				break;
			}
			if (!Transfer(preferDifferent: true))
			{
				Retire();
				break;
			}
		}
		syncTimer -= fixedDeltaTime;
		if (syncTimer <= 0f)
		{
			syncTimer = 0.1f;
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}
	}

	private bool Transfer(bool preferDifferent)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)ownerBody))
		{
			return false;
		}
		BullseyeSearch obj = MakeSearch(ownerBody, lastCarrierPosition, 28f);
		obj.RefreshCandidates();
		HurtBox val = obj.GetResults().FirstOrDefault((Func<HurtBox, bool>)((HurtBox h) => Object.op_Implicit((Object)(object)h) && Object.op_Implicit((Object)(object)h.healthComponent) && h.healthComponent.alive && (!preferDifferent || (Object)(object)h.healthComponent != (Object)(object)CarrierHealth)));
		if (Object.op_Implicit((Object)(object)val))
		{
			SetCarrier(val.healthComponent);
			return true;
		}
		if (Object.op_Implicit((Object)(object)CarrierHealth))
		{
			return CarrierHealth.alive;
		}
		return false;
	}

	private void Burst()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_0068: 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_0074: 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_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: 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_00ec: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		if (NetworkServer.active && Object.op_Implicit((Object)(object)CarrierHealth) && CarrierHealth.alive && clock.TrySpendBurst())
		{
			lastBurstPosition = GetCarrierPosition();
			burstSequence++;
			new BlastAttack
			{
				attacker = ownerObject,
				inflictor = ((Component)this).gameObject,
				teamIndex = ownerTeam,
				position = lastBurstPosition,
				radius = 5f,
				baseDamage = ownerBody.damage * 2.2f,
				baseForce = 45f,
				bonusForce = Vector3.zero,
				crit = Util.CheckRoll(ownerBody.crit, ownerBody.master),
				procCoefficient = 0.65f,
				falloffModel = (FalloffModel)0,
				damageType = new DamageTypeCombo
				{
					damageType = (DamageType)0,
					damageSource = (DamageSource)2
				},
				attackerFiltering = (AttackerFiltering)2,
				losType = (LoSType)1
			}.Fire();
			if (!Application.isBatchMode)
			{
				BeeperVisual.PlayBurst(lastBurstPosition);
			}
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}
	}

	private void Retire()
	{
		exhausted = true;
		retirementTime = 0.3f;
		if (Object.op_Implicit((Object)(object)ownerController))
		{
			ownerController.UnregisterCall(this);
		}
		((NetworkBehaviour)this).SetDirtyBit(1u);
	}

	private void OnDestroy()
	{
		if (Object.op_Implicit((Object)(object)ownerController))
		{
			ownerController.UnregisterCall(this);
		}
	}

	public override float GetNetworkSendInterval()
	{
		return 0.05f;
	}

	public override bool OnSerialize(NetworkWriter writer, bool initialState)
	{
		//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)
		writer.Write(ownerObject);
		writer.Write(carrierObject);
		writer.Write(lastCarrierPosition);
		writer.Write(lastBurstPosition);
		writer.Write(SecondsUntilBurst);
		writer.Write((byte)BurstsRemaining);
		writer.WritePackedUInt32(burstSequence);
		writer.Write(exhausted);
		return true;
	}

	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: 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_002b: 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)
		ownerObject = reader.ReadGameObject();
		carrierObject = reader.ReadGameObject();
		lastCarrierPosition = reader.ReadVector3();
		lastBurstPosition = reader.ReadVector3();
		burstTimer = reader.ReadSingle();
		burstsRemaining = reader.ReadByte();
		uint num = reader.ReadPackedUInt32();
		exhausted = reader.ReadBoolean();
		CarrierHealth = (Object.op_Implicit((Object)(object)carrierObject) ? carrierObject.GetComponent<HealthComponent>() : null);
		if (!initialState && num != burstSequence && !Application.isBatchMode)
		{
			BeeperVisual.PlayBurst(lastBurstPosition);
		}
		burstSequence = num;
	}
}
internal sealed class BeeperVisual : MonoBehaviour
{
	private static Material darkMaterial;

	private static Material glowMaterial;

	private static Material rimMaterial;

	private static Material screenMaterial;

	private static Material bezelMaterial;

	private static Mesh caseMesh;

	private static Material glyphMaterial;

	private static readonly Dictionary<int, Mesh> glyphMeshes = new Dictionary<int, Mesh>();

	private BeeperCall call;

	private Transform device;

	private Renderer screen;

	private MaterialPropertyBlock screenProperties;

	private Mesh screenGlyphs;

	private MeshFilter glyphFilter;

	private Transform countdown;

	private LineRenderer signal;

	private GameObject previousCarrier;

	private Vector3 hopStart;

	private float hopTime = 1f;

	private float hopAge = 1f;

	private float flashPhase;

	private float burstRecoil;

	private float ringCountdown;

	private int lastBudget = -1;

	internal Transform DeviceTransform => device;

	internal Renderer ScreenRenderer => screen;

	internal Camera ResolvedCamera { get; private set; }

	internal void Initialize(BeeperCall owner)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: 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)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: 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_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Expected O, but got Unknown
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Expected O, but got Unknown
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0343: Expected O, but got Unknown
		//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0448: Unknown result type (might be due to invalid IL or missing references)
		//IL_043f: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0459: Unknown result type (might be due to invalid IL or missing references)
		call = owner;
		EnsureResources();
		GameObject val = new GameObject("Hovering physical beeper");
		device = val.transform;
		device.SetParent(((Component)this).transform, false);
		GameObject val2 = new GameObject("Beveled pocket pager case");
		val2.transform.SetParent(device, false);
		val2.AddComponent<MeshFilter>().sharedMesh = caseMesh;
		MeshRenderer obj = val2.AddComponent<MeshRenderer>();
		((Renderer)obj).sharedMaterial = darkMaterial;
		((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)obj).receiveShadows = false;
		Box("Recessed LCD bezel", new Vector3(0.376f, 0.153f, 0.02f), new Vector3(0f, 0.036f, -0.065f), bezelMaterial);
		screen = Box("Flashing LCD screen", new Vector3(0.344f, 0.119f, 0.01f), new Vector3(0f, 0.039f, -0.08f), screenMaterial);
		Box("Left navigation key", new Vector3(0.046f, 0.027f, 0.018f), new Vector3(-0.115f, -0.085f, -0.069f), bezelMaterial);
		Box("Read message key", new Vector3(0.073f, 0.031f, 0.022f), new Vector3(0f, -0.085f, -0.072f), bezelMaterial);
		Box("Right navigation key", new Vector3(0.046f, 0.027f, 0.018f), new Vector3(0.115f, -0.085f, -0.069f), bezelMaterial);
		Box("Message status LED", new Vector3(0.016f, 0.008f, 0.008f), new Vector3(0.175f, 0.127f, -0.055f), rimMaterial);
		Box("Rear pocket clip", new Vector3(0.21f, 0.18f, 0.026f), new Vector3(0f, 0.013f, 0.084f), bezelMaterial);
		Box("Clip hinge", new Vector3(0.23f, 0.03f, 0.055f), new Vector3(0f, 0.104f, 0.067f), darkMaterial);
		Box("Countdown track", new Vector3(0.308f, 0.01f, 0.009f), new Vector3(0f, -0.001f, -0.088f), darkMaterial);
		countdown = ((Component)Box("Accelerating countdown charge", new Vector3(0.005f, 0.006f, 0.01f), new Vector3(-0.15f, -0.001f, -0.094f), rimMaterial)).transform;
		GameObject val3 = new GameObject("Readable pixel CALL and burst count");
		val3.transform.SetParent(device, false);
		val3.transform.localPosition = new Vector3(0f, 0f, -0.092f);
		glyphFilter = val3.AddComponent<MeshFilter>();
		MeshRenderer obj2 = val3.AddComponent<MeshRenderer>();
		((Renderer)obj2).sharedMaterial = glyphMaterial;
		((Renderer)obj2).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)obj2).receiveShadows = false;
		screenProperties = new MaterialPropertyBlock();
		GameObject val4 = new GameObject("Curved forwarding signal");
		val4.transform.SetParent(((Component)this).transform, false);
		signal = val4.AddComponent<LineRenderer>();
		((Renderer)signal).sharedMaterial = glowMaterial;
		signal.positionCount = 24;
		signal.startWidth = 0.013f;
		signal.endWidth = 0.04f;
		signal.useWorldSpace = true;
		((Renderer)signal).enabled = false;
		device.position = call.VisualAnchor;
		previousCarrier = call.Carrier;
		NetworkInstanceId netId = ((NetworkBehaviour)call).netId;
		flashPhase = (float)(((NetworkInstanceId)(ref netId)).Value % 11) / 11f;
		if (Object.op_Implicit((Object)(object)call.Owner))
		{
			CharacterBody component = call.Owner.GetComponent<CharacterBody>();
			hopStart = (Object.op_Implicit((Object)(object)component) ? component.corePosition : call.Owner.transform.position);
			device.position = hopStart;
			hopAge = 0f;
		}
	}

	private Renderer Box(string name, Vector3 size, Vector3 position, Material material)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
		((Object)obj).name = name;
		obj.transform.SetParent(device, false);
		obj.transform.localPosition = position;
		obj.transform.localScale = size;
		Collider component = obj.GetComponent<Collider>();
		component.enabled = false;
		Object.Destroy((Object)(object)component);
		Renderer component2 = obj.GetComponent<Renderer>();
		component2.sharedMaterial = material;
		component2.shadowCastingMode = (ShadowCastingMode)0;
		component2.receiveShadows = false;
		return component2;
	}

	private void LateUpdate()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: 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_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_022a: 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_02bb: 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_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: 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_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0509: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0411: Unknown result type (might be due to invalid IL or missing references)
		//IL_041e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0423: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0325: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_0382: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_050e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0516: Unknown result type (might be due to invalid IL or missing references)
		//IL_0528: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)call) || !Object.op_Implicit((Object)(object)device))
		{
			return;
		}
		if (call.BurstsRemaining <= 0)
		{
			((Component)device).gameObject.SetActive(false);
			((Renderer)signal).enabled = false;
			return;
		}
		ResolvedCamera = ResolveSceneCamera();
		Vector3 val = call.VisualAnchor;
		float num = 1.3f;
		NetworkInstanceId netId;
		if (Object.op_Implicit((Object)(object)ResolvedCamera))
		{
			Camera resolvedCamera = ResolvedCamera;
			float num2 = Vector3.Distance(((Component)resolvedCamera).transform.position, val);
			num = Mathf.Clamp((resolvedCamera.orthographic ? (2f * resolvedCamera.orthographicSize / (float)Mathf.Max(1, resolvedCamera.pixelHeight)) : (2f * num2 * Mathf.Tan(resolvedCamera.fieldOfView * (MathF.PI / 180f) * 0.5f) / (float)Mathf.Max(1, resolvedCamera.pixelHeight))) * 38f / 0.44f, 1.3f, 4.5f);
			netId = ((NetworkBehaviour)call).netId;
			float num3 = (float)(((NetworkInstanceId)(ref netId)).Value % 5) - 2f;
			val += ((Component)resolvedCamera).transform.right * (num3 * 0.43f * num);
			Vector3 val2 = val;
			Vector3 val3 = ((Component)resolvedCamera).transform.position - val;
			val = val2 + ((Vector3)(ref val3)).normalized * (0.3f * num);
		}
		Vector3 val4 = val;
		Vector3 up = Vector3.up;
		float num4 = 0.22f * num;
		netId = ((NetworkBehaviour)call).netId;
		val = val4 + up * (num4 + 0.08f * (float)(((NetworkInstanceId)(ref netId)).Value % 3));
		burstRecoil = Mathf.Max(0f, burstRecoil - Time.deltaTime * 7f);
		device.localScale = Vector3.one * num * (1f + burstRecoil * 0.12f);
		if ((Object)(object)previousCarrier != (Object)(object)call.Carrier)
		{
			previousCarrier = call.Carrier;
			hopStart = device.position;
			hopAge = 0f;
		}
		hopAge += Time.deltaTime;
		hopTime = Mathf.Clamp01(hopAge / 0.28f);
		Transform obj = device;
		Vector3 position;
		if (!(hopTime < 1f))
		{
			Vector3 val5 = val;
			Vector3 up2 = Vector3.up;
			float num5 = Time.time * 4f;
			netId = ((NetworkBehaviour)call).netId;
			position = val5 + up2 * (Mathf.Sin(num5 + (float)((NetworkInstanceId)(ref netId)).Value) * 0.06f);
		}
		else
		{
			position = Curve(hopStart, val, hopTime);
		}
		obj.position = position;
		((Renderer)signal).enabled = hopAge < 0.44f;
		if (((Renderer)signal).enabled)
		{
			float num6 = Mathf.Clamp01((hopAge - 0.16f) / 0.28f);
			for (int i = 0; i < signal.positionCount; i++)
			{
				signal.SetPosition(i, Curve(hopStart, val, Mathf.Lerp(num6, hopTime, (float)i / ((float)signal.positionCount - 1f))));
			}
			signal.startColor = new Color(0.14f, 0.55f, 1f, 0f);
			signal.endColor = new Color(0.65f, 0.9f, 1f, 0.9f * (1f - Mathf.Clamp01((hopAge - 0.28f) / 0.16f)));
		}
		if (Object.op_Implicit((Object)(object)ResolvedCamera))
		{
			Vector3 val6 = device.position - ((Component)ResolvedCamera).transform.position;
			if (((Vector3)(ref val6)).sqrMagnitude > 0.001f)
			{
				device.rotation = Quaternion.LookRotation(val6, ((Component)ResolvedCamera).transform.up);
			}
		}
		float num7 = 1f - Mathf.Clamp01(call.SecondsUntilBurst / 1.2f);
		float num8 = Mathf.Lerp(0.36f, 0.065f, num7 * num7);
		flashPhase = Mathf.Repeat(flashPhase + Time.deltaTime / num8, 1f);
		bool flag = flashPhase < 0.6f;
		float num9 = Mathf.Lerp(0.005f, 0.304f, num7);
		countdown.localScale = new Vector3(num9, 0.006f, 0.01f);
		countdown.localPosition = new Vector3(-0.152f + num9 * 0.5f, -0.001f, -0.094f);
		Color val7 = (flag ? new Color(0.22f, 0.57f, 0.51f) : new Color(0.08f, 0.22f, 0.2f));
		BibiEffectMaterials.Tint(screenProperties, val7);
		screenProperties.SetColor("_EmColor", val7);
		screenProperties.SetFloat("_EmPower", flag ? 1.2f : 0.4f);
		screen.SetPropertyBlock(screenProperties);
		if (lastBudget != call.BurstsRemaining)
		{
			if (lastBudget >= 0)
			{
				burstRecoil = 1f;
			}
			lastBudget = call.BurstsRemaining;
			UpdateScreenGlyphs(lastBudget);
		}
		ringCountdown -= Time.deltaTime;
		if (ringCountdown <= 0f)
		{
			ringCountdown += num8;
			BibiAudio.PagerRing(((Component)device).gameObject, num7);
		}
	}

	private Camera ResolveSceneCamera()
	{
		Camera val = null;
		Camera val2 = null;
		foreach (CameraRigController readOnlyInstances in CameraRigController.readOnlyInstancesList)
		{
			if (Object.op_Implicit((Object)(object)readOnlyInstances) && ((Behaviour)readOnlyInstances).isActiveAndEnabled && Object.op_Implicit((Object)(object)readOnlyInstances.sceneCam) && ((Behaviour)readOnlyInstances.sceneCam).isActiveAndEnabled)
			{
				if ((Object)(object)readOnlyInstances.target == (Object)(object)call.Owner && readOnlyInstances.localUserViewer != null)
				{
					return readOnlyInstances.sceneCam;
				}
				if (readOnlyInstances.localUserViewer != null)
				{
					val2 = readOnlyInstances.sceneCam;
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = readOnlyInstances.sceneCam;
				}
			}
		}
		if (!Object.op_Implicit((Object)(object)val2))
		{
			if (!Object.op_Implicit((Object)(object)val))
			{
				return Camera.main;
			}
			return val;
		}
		return val2;
	}

	private void UpdateScreenGlyphs(int budget)
	{
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		budget = Mathf.Clamp(budget, 0, 99);
		if (glyphMeshes.TryGetValue(budget, out screenGlyphs) && Object.op_Implicit((Object)(object)screenGlyphs))
		{
			glyphFilter.sharedMesh = screenGlyphs;
			return;
		}
		List<Vector3> vertices = new List<Vector3>();
		List<int> list = new List<int>();
		AddText("CALL", -0.154f, 0.08f, 0.012f, vertices, list);
		AddText(budget.ToString("00"), 0.052f, 0.08f, 0.014f, vertices, list);
		screenGlyphs = new Mesh
		{
			name = "Bibi shared pager display " + budget
		};
		screenGlyphs.SetVertices(vertices);
		screenGlyphs.SetTriangles(list, 0);
		screenGlyphs.RecalculateNormals();
		screenGlyphs.RecalculateBounds();
		glyphFilter.sharedMesh = screenGlyphs;
		glyphMeshes[budget] = screenGlyphs;
	}

	private static void AddText(string text, float x, float top, float cell, List<Vector3> vertices, List<int> triangles)
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < text.Length; i++)
		{
			string text2 = Glyph(text[i]);
			for (int j = 0; j < 5; j++)
			{
				for (int k = 0; k < 3; k++)
				{
					if (text2[j * 3 + k] == '1')
					{
						float num = x + (float)k * cell;
						float num2 = top - (float)j * cell;
						int count = vertices.Count;
						vertices.Add(new Vector3(num, num2, 0f));
						vertices.Add(new Vector3(num + cell * 0.87f, num2, 0f));
						vertices.Add(new Vector3(num + cell * 0.87f, num2 - cell * 0.87f, 0f));
						vertices.Add(new Vector3(num, num2 - cell * 0.87f, 0f));
						triangles.Add(count);
						triangles.Add(count + 1);
						triangles.Add(count + 2);
						triangles.Add(count);
						triangles.Add(count + 2);
						triangles.Add(count + 3);
					}
				}
			}
			x += cell * 4f;
		}
	}

	private static string Glyph(char character)
	{
		return character switch
		{
			'C' => "111100100100111", 
			'A' => "010101111101101", 
			'L' => "100100100100111", 
			'0' => "111101101101111", 
			'1' => "010110010010111", 
			'2' => "111001111100111", 
			'3' => "111001111001111", 
			'4' => "101101111001001", 
			'5' => "111100111001111", 
			'6' => "111100111101111", 
			'7' => "111001010010010", 
			'8' => "111101111101111", 
			'9' => "111101111001111", 
			_ => "000000000000000", 
		};
	}

	private static Vector3 Curve(Vector3 start, Vector3 end, float t)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		return Vector3.Lerp(start, end, t) + Vector3.up * (Mathf.Sin(t * MathF.PI) * Mathf.Min(4f, 0.8f + Vector3.Distance(start, end) * 0.15f));
	}

	private static void EnsureResources()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)glowMaterial))
		{
			glowMaterial = BibiEffectMaterials.Effect(Color.white, additive: true);
			((Object)glowMaterial).name = "Bibi blue-white pager signal";
			darkMaterial = BibiEffectMaterials.Solid(new Color(0.025f, 0.033f, 0.045f));
			((Object)darkMaterial).name = "Bibi charcoal pager shell";
			caseMesh = CreateCaseMesh();
			bezelMaterial = BibiEffectMaterials.Solid(new Color(0.08f, 0.1f, 0.12f));
			rimMaterial = BibiEffectMaterials.EmissiveSolid(new Color(0.15f, 0.65f, 1f), 1.1f);
			screenMaterial = BibiEffectMaterials.EmissiveSolid(new Color(0.22f, 0.57f, 0.51f), 1.2f);
			glyphMaterial = BibiEffectMaterials.Solid(new Color(0.009f, 0.018f, 0.023f));
		}
	}

	private static Mesh CreateCaseMesh()
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: 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_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: 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_0201: Expected O, but got Unknown
		List<Vector3> list = new List<Vector3>();
		List<int> list2 = new List<int>();
		float[] array = new float[4] { -0.06f, -0.039f, 0.041f, 0.06f };
		float[] array2 = new float[4] { 0.012f, 0f, 0f, 0.012f };
		for (int i = 0; i < 4; i++)
		{
			float num = 0.22f - array2[i];
			float num2 = 0.15f - array2[i];
			float num3 = 0.028f;
			list.Add(new Vector3(0f - num + num3, 0f - num2, array[i]));
			list.Add(new Vector3(num - num3, 0f - num2, array[i]));
			list.Add(new Vector3(num, 0f - num2 + num3, array[i]));
			list.Add(new Vector3(num, num2 - num3, array[i]));
			list.Add(new Vector3(num - num3, num2, array[i]));
			list.Add(new Vector3(0f - num + num3, num2, array[i]));
			list.Add(new Vector3(0f - num, num2 - num3, array[i]));
			list.Add(new Vector3(0f - num, 0f - num2 + num3, array[i]));
		}
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 8; k++)
			{
				int num4 = j * 8 + k;
				int num5 = j * 8 + (k + 1) % 8;
				list2.Add(num4);
				list2.Add(num5);
				list2.Add(num5 + 8);
				list2.Add(num4);
				list2.Add(num5 + 8);
				list2.Add(num4 + 8);
			}
		}
		for (int l = 1; l < 7; l++)
		{
			list2.Add(0);
			list2.Add(l + 1);
			list2.Add(l);
			list2.Add(24);
			list2.Add(24 + l);
			list2.Add(25 + l);
		}
		Mesh val = new Mesh
		{
			name = "Bibi shared beveled pager shell"
		};
		val.SetVertices(list);
		val.SetTriangles(list2, 0);
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
	}

	internal static void PlayBurst(Vector3 position)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		EnsureResources();
		BibiNativeEffects.PagerBurst(position);
		if (BeeperBurstVisual.ActiveCount < 32)
		{
			GameObject val = new GameObject("Beeper compact signal burst");
			val.transform.position = position;
			BibiAudio.PagerBurst(val);
			val.AddComponent<BeeperBurstVisual>().Initialize(glowMaterial);
		}
	}
}
internal sealed class BeeperBurstVisual : MonoBehaviour
{
	private LineRenderer ring;

	private LineRenderer cross;

	private LineRenderer[] arcs;

	private float age;

	internal static int ActiveCount { get; private set; }

	private void Awake()
	{
		ActiveCount++;
	}

	private void OnDestroy()
	{
		ActiveCount = Mathf.Max(0, ActiveCount - 1);
	}

	internal void Initialize(Material material)
	{
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: 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_0207: 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_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: 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_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: 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_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		ring = ((Component)this).gameObject.AddComponent<LineRenderer>();
		((Renderer)ring).sharedMaterial = material;
		ring.useWorldSpace = false;
		ring.loop = true;
		ring.positionCount = 32;
		LineRenderer obj = ring;
		float startWidth = (ring.endWidth = 0.1f);
		obj.startWidth = startWidth;
		for (int i = 0; i < 32; i++)
		{
			float num2 = MathF.PI * 2f * (float)i / 32f;
			ring.SetPosition(i, new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)));
		}
		GameObject val = new GameObject("Vertical signal flash");
		val.transform.SetParent(((Component)this).transform, false);
		cross = val.AddComponent<LineRenderer>();
		((Renderer)cross).sharedMaterial = material;
		cross.useWorldSpace = false;
		cross.positionCount = 2;
		cross.SetPosition(0, Vector3.down * 0.4f);
		cross.SetPosition(1, Vector3.up * 0.4f);
		LineRenderer obj2 = cross;
		startWidth = (cross.endWidth = 0.45f);
		obj2.startWidth = startWidth;
		arcs = (LineRenderer[])(object)new LineRenderer[5];
		for (int j = 0; j < arcs.Length; j++)
		{
			GameObject val2 = new GameObject("Short electrical burst arc");
			val2.transform.SetParent(((Component)this).transform, false);
			LineRenderer val3 = val2.AddComponent<LineRenderer>();
			((Renderer)val3).sharedMaterial = material;
			val3.useWorldSpace = false;
			val3.positionCount = 4;
			val3.startWidth = 0.045f;
			val3.endWidth = 0.008f;
			float num4 = (float)j * MathF.PI * 2f / (float)arcs.Length;
			Vector3 val4 = new Vector3(Mathf.Cos(num4), 0.2f + (float)(j % 2) * 0.4f, Mathf.Sin(num4));
			Vector3 normalized = ((Vector3)(ref val4)).normalized;
			val3.SetPosition(0, normalized * 0.12f);
			val3.SetPosition(1, normalized * 0.42f + Vector3.up * 0.12f);
			val3.SetPosition(2, normalized * 0.61f - Vector3.up * 0.1f);
			val3.SetPosition(3, normalized * 0.9f);
			arcs[j] = val3;
		}
	}

	private void Update()
	{
		//IL_0025: 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_005f: 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_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)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: 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_0098: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
		age += Time.deltaTime;
		float num = age / 0.3f;
		((Component)this).transform.localScale = Vector3.one * Mathf.Lerp(0.35f, 2.4f, 1f - Mathf.Pow(1f - Mathf.Clamp01(num), 2f));
		Color val = Color.Lerp(Color.white, new Color(0.15f, 0.6f, 1f, 0f), num);
		LineRenderer obj = ring;
		Color startColor = (ring.endColor = val);
		obj.startColor = startColor;
		LineRenderer obj2 = cross;
		startColor = (cross.endColor = val);
		obj2.startColor = startColor;
		LineRenderer[] array = arcs;
		foreach (LineRenderer obj3 in array)
		{
			startColor = (obj3.endColor = val);
			obj3.startColor = startColor;
		}
		if (num >= 1f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
public sealed class BibiCombatController : NetworkBehaviour
{
	private const short ReportHoverMessageType = 27458;

	private readonly List<BeeperCall> activeCalls = new List<BeeperCall>();

	private CharacterBody body;

	private float inactiveTime;

	private bool serverHover;

	private bool lastReportedHover;

	private bool hasBeamContact;

	private Vector3 beamContactPoint;

	private Vector3 beamContactNormal;

	private bool beamContactEnemy;

	private float beamContactTime = float.NegativeInfinity;

	private float nextContactSync;

	private float nextOpeningTick;

	public bool BeamActive { get; private set; }

	public bool IsHovering { get; private set; }

	public float Charge01 { get; private set; }

	public float BeamPower => Mathf.Lerp(0.35f, 1f, Charge01);

	public Ray BeamAimRay { get; private set; }

	public int ActiveCallCount => activeCalls.Count;

	public float BeamContactAgeSeconds => Time.time - beamContactTime;

	internal bool CanFireOpeningTick => Time.time >= nextOpeningTick;

	public bool TryGetBeamContact(out Vector3 point, out Vector3 normal, out bool enemy)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		point = beamContactPoint;
		normal = beamContactNormal;
		enemy = beamContactEnemy;
		if (BeamActive && hasBeamContact)
		{
			return BeamContactAgeSeconds < 0.4f;
		}
		return false;
	}

	internal void SetBeamContact(Vector3 point, Vector3 normal, bool enemy)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		hasBeamContact = true;
		beamContactPoint = point;
		beamContactNormal = normal;
		beamContactEnemy = enemy;
		beamContactTime = Time.time;
		DirtyContact();
	}

	internal void ClearBeamContact()
	{
		if (hasBeamContact)
		{
			hasBeamContact = false;
			DirtyContact();
		}
	}

	private void DirtyContact()
	{
		if (NetworkServer.active && !(Time.time < nextContactSync))
		{
			nextContactSync = Time.time + 0.1f;
			((NetworkBehaviour)this).SetDirtyBit(2u);
		}
	}

	internal void RecordBeamTick()
	{
		nextOpeningTick = Time.time + 1f / (6f * Mathf.Max(0.01f, body.attackSpeed));
	}

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

	public void SetBeamActive(bool active)
	{
		if (BeamActive && !active)
		{
			inactiveTime = 0f;
		}
		BeamActive = active;
		if (!active)
		{
			ClearBeamContact();
			IsHovering = false;
			if (NetworkServer.active)
			{
				SetServerHover(value: false);
			}
			if (Util.HasEffectiveAuthority(((Component)this).gameObject))
			{
				ReportHover(value: false);
			}
		}
	}

	public void SetBeamAimRay(Ray ray)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		BeamAimRay = ray;
	}

	private void FixedUpdate()
	{
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: 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_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		float fixedDeltaTime = Time.fixedDeltaTime;
		if (BeamActive)
		{
			Charge01 = Mathf.Min(1f, Charge01 + fixedDeltaTime / 0.6f);
		}
		else
		{
			inactiveTime += fixedDeltaTime;
			if (inactiveTime > 0.4f)
			{
				Charge01 = Mathf.Max(0f, Charge01 - fixedDeltaTime * 1.6f);
			}
		}
		CharacterMotor val = (Object.op_Implicit((Object)(object)body) ? body.characterMotor : null);
		InputBankTest val2 = (Object.op_Implicit((Object)(object)body) ? body.inputBank : null);
		if (!Util.HasEffectiveAuthority(((Component)this).gameObject))
		{
			IsHovering = BeamActive && serverHover && Object.op_Implicit((Object)(object)val) && !val.isGrounded;
			return;
		}
		IsHovering = BeamActive && Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2) && !val.isGrounded && val2.jump.down && val.velocity.y < 0f;
		ReportHover(IsHovering);
		if (IsHovering)
		{
			Vector3 velocity = val.velocity;
			float num = Mathf.Max(velocity.y, -2.8f);
			velocity.y = Mathf.Lerp(velocity.y, num, 1f - Mathf.Exp(-18f * fixedDeltaTime));
			val.velocity = velocity;
		}
	}

	private void ReportHover(bool value)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected O, but got Unknown
		if (NetworkServer.active)
		{
			SetServerHover(value);
			lastReportedHover = value;
		}
		else if (lastReportedHover != value && ClientScene.ready && ClientScene.readyConnection != null)
		{
			NetworkInstanceId netId = ((NetworkBehaviour)this).netId;
			if (((NetworkInstanceId)(ref netId)).Value != 0)
			{
				NetworkWriter val = new NetworkWriter();
				val.StartMessage((short)27458);
				val.Write(((Component)this).gameObject);
				val.Write(value);
				val.FinishMessage();
				ClientScene.readyConnection.SendWriter(val, QosChannelIndex.defaultReliable.intVal);
				lastReportedHover = value;
			}
		}
	}

	private void SetServerHover(bool value)
	{
		if (serverHover != value)
		{
			serverHover = value;
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}
	}

	[NetworkMessageHandler(msgType = 27458, server = true)]
	private static void HandleOwnerHover(NetworkMessage message)
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = message.reader.ReadGameObject();
		bool flag = message.reader.ReadBoolean();
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)val) || message.conn == null)
		{
			return;
		}
		NetworkIdentity component = val.GetComponent<NetworkIdentity>();
		if (Object.op_Implicit((Object)(object)component) && message.conn.clientOwnedObjects != null && message.conn.clientOwnedObjects.Contains(component.netId))
		{
			BibiCombatController component2 = val.GetComponent<BibiCombatController>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.SetServerHover(flag);
			}
		}
	}

	public override bool OnSerialize(NetworkWriter writer, bool initialState)
	{
		//IL_0035: 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)
		writer.Write(serverHover);
		writer.Write(hasBeamContact && BeamActive);
		if (hasBeamContact && BeamActive)
		{
			writer.Write(beamContactPoint);
			writer.Write(beamContactNormal);
			writer.Write(beamContactEnemy);
		}
		return true;
	}

	public override void OnDeserialize(NetworkReader reader, bool initialState)
	{
		//IL_0022: 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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		serverHover = reader.ReadBoolean();
		hasBeamContact = reader.ReadBoolean();
		if (hasBeamContact)
		{
			beamContactPoint = reader.ReadVector3();
			beamContactNormal = reader.ReadVector3();
			beamContactEnemy = reader.ReadBoolean();
			beamContactTime = Time.time;
		}
	}

	public override float GetNetworkSendInterval()
	{
		return 0.05f;
	}

	internal void RegisterCall(BeeperCall call)
	{
		if (Object.op_Implicit((Object)(object)call) && !activeCalls.Contains(call))
		{
			activeCalls.Add(call);
		}
	}

	internal void UnregisterCall(BeeperCall call)
	{
		activeCalls.Remove(call);
	}

	public void NotifyDirectBeamHit(HealthComponent victim)
	{
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)victim))
		{
			return;
		}
		for (int num = activeCalls.Count - 1; num >= 0; num--)
		{
			BeeperCall beeperCall = activeCalls[num];
			if (!Object.op_Implicit((Object)(object)beeperCall))
			{
				activeCalls.RemoveAt(num);
			}
			else if ((Object)(object)beeperCall.CarrierHealth == (Object)(object)victim)
			{
				beeperCall.AdvanceFromDirectBeam();
			}
		}
	}

	private void OnDisable()
	{
		BeamActive = false;
		IsHovering = false;
		hasBeamContact = false;
	}
}
public sealed class CallForwardingSkillDef : SkillDef
{
	public override bool CanExecute(GenericSkill skillSlot)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		if (!((SkillDef)this).CanExecute(skillSlot))
		{
			return false;
		}
		CharacterBody characterBody = skillSlot.characterBody;
		if (Object.op_Implicit((Object)(object)characterBody) && Object.op_Implicit((Object)(object)characterBody.inputBank))
		{
			return Object.op_Implicit((Object)(object)BeeperCall.AcquireTarget(characterBody, characterBody.inputBank.GetAimRay()));
		}
		return false;
	}
}
public sealed class CallForwardingState : BaseSkillState
{
	private Ray entryAim;

	private bool hasSerializedAim;

	private float duration;

	public override void OnEnter()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: 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)
		((BaseState)this).OnEnter();
		if (!hasSerializedAim)
		{
			entryAim = ((BaseState)this).GetAimRay();
		}
		duration = 0.16f / Mathf.Max(0.5f, ((BaseState)this).attackSpeedStat);
		((EntityState)this).GetComponent<BibiPresentation>()?.NotifyPagerCast();
		((EntityState)this).characterBody.SetAimTimer(0.3f);
		if (NetworkServer.active)
		{
			HurtBox val = BeeperCall.AcquireTarget(((EntityState)this).characterBody, entryAim);
			if (Object.op_Implicit((Object)(object)val))
			{
				BeeperCall.Spawn(((EntityState)this).gameObject, val);
			}
		}
	}

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

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

	public override void OnDeserialize(NetworkReader reader)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//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)
		((BaseSkillState)this).OnDeserialize(reader);
		entryAim = new Ray(reader.ReadVector3(), reader.ReadVector3());
		hasSerializedAim = true;
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)0;
	}
}
public static class CombatTuning
{
	public const float BeamTicksPerSecond = 6f;

	public const float BeamDamagePerTick = 0.55f;

	public const float BeamProcCoefficient = 0.35f;

	public const float BeamRange = 90f;

	public const float BeamRampSeconds = 0.6f;

	public const float BeamStartingPower = 0.35f;

	public const float BeamChargeGraceSeconds = 0.4f;

	public const float BeamChargeDecayPerSecond = 1.6f;

	public const float HoverDescentSpeed = 2.8f;

	public const float HoverBlendPerSecond = 18f;

	public const float BeeperAcquireRange = 90f;

	public const float BeeperAcquireAngle = 12f;

	public const float BeeperHopRange = 28f;

	public const float BeeperBurstDamage = 2.2f;

	public const float BeeperBurstRadius = 5f;

	public const float BeeperProcCoefficient = 0.65f;

	public const float BeeperBurstInterval = 1.2f;

	public const float BeeperLifetime = 9f;

	public const int BeeperBurstCount = 4;

	public const float BeeperBeamAdvanceSeconds = 0.055f;

	public const float PagerGestureSeconds = 0.16f;
}
internal struct BeamTickAccumulator
{
	private double fractionalTicks;

	public int Advance(float deltaTime, float attacksPerSecond)
	{
		if (deltaTime <= 0f || attacksPerSecond <= 0f || float.IsNaN(attacksPerSecond) || float.IsInfinity(attacksPerSecond))
		{
			return 0;
		}
		double num = (double)deltaTime * (double)attacksPerSecond;
		fractionalTicks += num;
		double num2 = 1E-06 * Math.Max(1.0, num);
		int num3 = (int)Math.Floor(fractionalTicks + num2);
		fractionalTicks = Math.Max(0.0, fractionalTicks - (double)num3);
		return num3;
	}
}
internal sealed class BeeperBurstClock
{
	public float Elapsed { get; private set; }

	public float SecondsUntilBurst { get; private set; } = 1.2f;

	public int Remaining { get; private set; } = 4;

	public bool HasExpired => Elapsed >= 9f;

	public bool IsBurstDue
	{
		get
		{
			if (!HasExpired && Remaining > 0)
			{
				return SecondsUntilBurst <= 0f;
			}
			return false;
		}
	}

	public void AdvanceTime(float deltaTime)
	{
		if (!(deltaTime <= 0f))
		{
			Elapsed += deltaTime;
			SecondsUntilBurst -= deltaTime;
		}
	}

	public void AdvanceFromBeam()
	{
		if (!HasExpired && Remaining > 0)
		{
			SecondsUntilBurst -= 0.055f;
		}
	}

	public bool TrySpendBurst()
	{
		if (!IsBurstDue)
		{
			return false;
		}
		int remaining = Remaining - 1;
		Remaining = remaining;
		SecondsUntilBurst += 1.2f;
		return true;
	}
}
public sealed class GoyBeamState : BaseSkillState
{
	private BibiCombatController controller;

	private BeamTickAccumulator ticks;

	private BulletAttack attack;

	private bool tickHit;

	public override void OnEnter()
	{
		//IL_003c: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_0082: 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_008f: 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)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Expected O, but got Unknown
		//IL_010e: Expecte