Decompiled source of Lantern Peddler v1.1.0

LanternPeddler.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Collections;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

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

internal class Angel : NetworkBehaviour
{
	internal const int StDrift = 0;

	internal const int StApproach = 1;

	internal const int StOffer = 2;

	internal const int StChannel = 3;

	internal const int StReveal = 4;

	internal const int StProcession = 5;

	internal const int StAbundance = 6;

	internal const int StBow = 7;

	internal const int StStare = 8;

	internal const int StRecover = 9;

	internal const int OSalvation = 0;

	internal const int OFavor = 1;

	internal const int OProcession = 2;

	internal const int OAbundance = 3;

	internal const int OFailed = 4;

	internal static readonly string[] OutcomeNames = new string[6] { "Salvation", "Favor", "Procession", "Abundance", "Failed Ascension", "Transfiguration" };

	internal static readonly List<Angel> All = new List<Angel>();

	internal int State;

	internal int Target = -1;

	internal int Outcome = -1;

	internal bool Loose;

	private float _stateAt;

	private NavMeshAgent _agent;

	private int _rolled = -1;

	private int _lastVictim = -1;

	private float _nextScan;

	private float _nextRepath;

	private float _nextSync;

	private float _cooldownUntil;

	private float _recoverFor = 20f;

	private float _nextBell;

	private float _nextDoor;

	private int _fxStep;

	private Vector3 _stuckAt;

	private float _stuckSince;

	private static readonly Dictionary<int, float> Immune = new Dictionary<int, float>();

	private Transform _legL;

	private Transform _legR;

	private Quaternion _legLRest;

	private Quaternion _legRRest;

	private Transform _model;

	private Transform _body;

	private Transform _torso;

	private Transform _neck;

	private Transform _head;

	private Transform _halo;

	private Transform _haloSpin;

	private Transform _armL;

	private Transform _armR;

	private Transform _foreL;

	private Transform _foreR;

	private Transform _handL;

	private Transform _handR;

	private Transform _wingL;

	private Transform _wingR;

	private Quaternion _armLRest;

	private Quaternion _armRRest;

	private Quaternion _foreLRest;

	private Quaternion _foreRRest;

	private Quaternion _wingLRest;

	private Quaternion _wingRRest;

	private Quaternion _headRest;

	private Quaternion _torsoRest;

	private Light _haloLight;

	private float _haloLightBase = 600f;

	private Material _haloMat;

	private Color _haloEmit;

	private AudioSource _fx;

	private AudioSource _hum;

	private AudioSource _scrape;

	private float _haloAngle;

	private float _haloSpeed = 25f;

	private float _flashAt = -99f;

	private float _hitAt = -99f;

	private float _flicker = 1f;

	private float _nextFlicker;

	private Light _flashLight;

	private float _abundanceEnd;

	private static Item _saint;

	private static bool _saintLooked;

	private static readonly FieldInfo DoorOpened = AccessTools.Field(typeof(DoorLock), "isDoorOpened");

	private static DoorLock[] _doors = (DoorLock[])(object)new DoorLock[0];

	private static float _doorsAt = -99f;

	private static readonly HashSet<GrabbableObject> Copied = new HashSet<GrabbableObject>();

	private static readonly HashSet<GrabbableObject> Copies = new HashSet<GrabbableObject>();

	internal const int FxOffer = 1;

	internal const int FxGrab = 2;

	internal const int FxCeremony = 3;

	internal const int FxFlash = 4;

	internal const int FxTeleport = 5;

	internal const int FxClick = 6;

	internal const int FxDrop = 7;

	internal const int FxClunk = 8;

	internal const int FxRegister = 9;

	internal const int FxConfused = 10;

	internal const int FxBow = 11;

	internal const int FxHit = 12;

	internal const int FxLoose = 13;

	internal const int FxBell = 14;

	internal const int FxSlip = 15;

	private PlayerControllerB _holdingMe;

	private Vector3 _grabPos;

	private bool _crouched;

	private const int AbundanceShakes = 6;

	private float _shakeAt = -99f;

	private float _haloRingAt = -99f;

	private float _haloDeadUntil = -99f;

	private readonly List<Vector3> _trail = new List<Vector3>();

	internal static Angel LocalCaptor;

	private InputAction _interact;

	private float _hover;

	private float _speedSeen;

	private Vector3 _lastPos;

	private static bool _rolledToday;

	internal const int StSummon = 10;

	internal const int StCarry = 11;

	internal const int StFetch = 12;

	internal const int StDeliver = 13;

	internal const int OTransfig = 5;

	internal const int FxSwap = 20;

	internal const int FxSummon = 21;

	internal const int FxRevive = 22;

	internal const int FxDeliver = 23;

	internal int Aggro;

	private float _nextHoard = -1f;

	private float _nextDeathScan;

	private float _carryUntil;

	private GrabbableObject _fetchTarget;

	private GrabbableObject _carried;

	private static readonly HashSet<int> DeathsSeen = new HashSet<int>();

	private static Vector3? _entrance;

	private static GrabbableObject[] _loot = (GrabbableObject[])(object)new GrabbableObject[0];

	private static float _lootAt = -99f;

	private static readonly HashSet<GrabbableObject> Claimed = new HashSet<GrabbableObject>();

	internal float Elapsed => Time.time - _stateAt;

	internal float AggroK => (!Plugin.AngelHoardBolder.Value) ? 0f : Mathf.Clamp01((float)Aggro / 10f);

	private void Awake()
	{
		All.Add(this);
	}

	public override void OnDestroy()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		All.Remove(this);
		if ((Object)(object)_holdingMe != (Object)null)
		{
			ReleaseLocal();
		}
		DropCarriedLocal(((Component)this).transform.position);
		((NetworkBehaviour)this).OnDestroy();
	}

	public override void OnNetworkSpawn()
	{
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		((NetworkBehaviour)this).OnNetworkSpawn();
		_stateAt = Time.time;
		Build();
		if (((NetworkBehaviour)this).IsServer)
		{
			_agent = ((Component)this).gameObject.AddComponent<NavMeshAgent>();
			_agent.speed = 1.4f;
			_agent.acceleration = 8f;
			_agent.angularSpeed = 160f;
			_agent.radius = 0.35f;
			_agent.height = 2.6f;
			_agent.stoppingDistance = 0.2f;
			_agent.autoBraking = true;
			_agent.obstacleAvoidanceType = (ObstacleAvoidanceType)0;
			_agent.Warp(((Component)this).transform.position);
			_cooldownUntil = Time.time + 6f;
		}
	}

	private void Build()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: 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_00b7: 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_00e9: 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_011e: 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_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: 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_04ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0511: 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_0533: Unknown result type (might be due to invalid IL or missing references)
		//IL_0538: Unknown result type (might be due to invalid IL or missing references)
		//IL_0555: Unknown result type (might be due to invalid IL or missing references)
		//IL_055a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0577: Unknown result type (might be due to invalid IL or missing references)
		//IL_057c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0599: Unknown result type (might be due to invalid IL or missing references)
		//IL_059e: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_065d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0664: Expected O, but got Unknown
		//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0707: Unknown result type (might be due to invalid IL or missing references)
		//IL_078a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0791: Expected O, but got Unknown
		//IL_07ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f2: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Bundle.Spawn("enemy_angel", ((Component)this).transform);
		if ((Object)(object)val == (Object)null)
		{
			val = new GameObject("Model");
			val.transform.SetParent(((Component)this).transform, false);
			Transform transform = new GameObject("Body").transform;
			transform.SetParent(val.transform, false);
			Art.Box(transform, "Robe", new Vector3(0f, 1f, 0f), new Vector3(0.45f, 1.7f, 0.35f), new Color(0.8f, 0.79f, 0.74f));
			Transform transform2 = new GameObject("Torso").transform;
			transform2.SetParent(transform, false);
			transform2.localPosition = new Vector3(0f, 1.15f, 0f);
			Transform transform3 = new GameObject("Neck").transform;
			transform3.SetParent(transform2, false);
			transform3.localPosition = new Vector3(0f, 0.78f, 0f);
			Transform transform4 = new GameObject("Head").transform;
			transform4.SetParent(transform3, false);
			transform4.localPosition = new Vector3(0f, 0.24f, 0f);
			Art.Box(transform4, "Helmet", new Vector3(0f, 0.15f, 0f), new Vector3(0.36f, 0.42f, 0.34f), new Color(0.62f, 0.6f, 0.56f));
			Transform transform5 = new GameObject("Halo").transform;
			transform5.SetParent(transform4, false);
			transform5.localPosition = new Vector3(0f, 0.52f, 0f);
			Art.Box(transform5, "HaloRing", Vector3.zero, new Vector3(0.34f, 0.02f, 0.34f), new Color(1f, 0.9f, 0.6f));
		}
		_model = val.transform;
		Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
		foreach (Transform val2 in componentsInChildren)
		{
			switch (((Object)val2).name)
			{
			case "Body":
				_body = val2;
				break;
			case "Torso":
				_torso = val2;
				break;
			case "Neck":
				_neck = val2;
				break;
			case "Head":
				_head = val2;
				break;
			case "Halo":
				_halo = val2;
				break;
			case "HaloSpin":
				_haloSpin = val2;
				break;
			case "ArmL":
				_armL = val2;
				break;
			case "ArmR":
				_armR = val2;
				break;
			case "ForeL":
				_foreL = val2;
				break;
			case "ForeR":
				_foreR = val2;
				break;
			case "HandL":
				_handL = val2;
				break;
			case "HandR":
				_handR = val2;
				break;
			case "WingL":
				_wingL = val2;
				break;
			case "WingR":
				_wingR = val2;
				break;
			case "LegL":
				_legL = val2;
				break;
			case "LegR":
				_legR = val2;
				break;
			}
		}
		if ((Object)(object)_armL != (Object)null)
		{
			_armLRest = _armL.localRotation;
		}
		if ((Object)(object)_armR != (Object)null)
		{
			_armRRest = _armR.localRotation;
		}
		if ((Object)(object)_foreL != (Object)null)
		{
			_foreLRest = _foreL.localRotation;
		}
		if ((Object)(object)_foreR != (Object)null)
		{
			_foreRRest = _foreR.localRotation;
		}
		if ((Object)(object)_wingL != (Object)null)
		{
			_wingLRest = _wingL.localRotation;
		}
		if ((Object)(object)_wingR != (Object)null)
		{
			_wingRRest = _wingR.localRotation;
		}
		if ((Object)(object)_head != (Object)null)
		{
			_headRest = _head.localRotation;
		}
		if ((Object)(object)_legL != (Object)null)
		{
			_legLRest = _legL.localRotation;
		}
		if ((Object)(object)_legR != (Object)null)
		{
			_legRRest = _legR.localRotation;
		}
		if ((Object)(object)_torso != (Object)null)
		{
			_torsoRest = _torso.localRotation;
		}
		_haloLight = ((!((Object)(object)_halo != (Object)null)) ? null : ((Component)_halo).GetComponentInChildren<Light>(true));
		if ((Object)(object)_haloLight != (Object)null)
		{
			_haloLightBase = Mathf.Max(1f, _haloLight.intensity);
		}
		_haloMat = Bundle.GlowMat(_model, "HaloRing", out _haloEmit);
		GameObject val3 = new GameObject("AngelHit");
		val3.layer = 19;
		val3.transform.SetParent(((Component)this).transform, false);
		BoxCollider val4 = val3.AddComponent<BoxCollider>();
		((Collider)val4).isTrigger = true;
		val4.center = new Vector3(0f, 1.4f, 0f);
		val4.size = new Vector3(0.7f, 2.6f, 0.6f);
		val3.AddComponent<AngelHitBox>().Owner = this;
		ScanNodeProperties val5 = Plugin.AddScanNode(((Component)this).transform, "Angel", "It only wants to help.", 1, 1f);
		((Component)val5).transform.localPosition = new Vector3(0f, 2.1f, 0f);
		val5.maxRange = 30;
		_fx = ((Component)this).GetComponent<AudioSource>();
		Setup3D(_fx, 3f, 40f);
		_hum = Loop("Hum", "angel_hum", 1.5f, 16f, 2.6f);
		_scrape = Loop("Scrape", "angel_scrape", 3f, 30f, 0.2f);
		GameObject val6 = new GameObject("Flash");
		val6.transform.SetParent(((Component)this).transform, false);
		val6.transform.localPosition = new Vector3(0f, 2.2f, 0f);
		_flashLight = val6.AddComponent<Light>();
		_flashLight.type = (LightType)2;
		_flashLight.color = new Color(1f, 0.97f, 0.9f);
		_flashLight.range = 25f;
		_flashLight.intensity = 0f;
		((Behaviour)_flashLight).enabled = false;
	}

	private AudioSource Loop(string name, string clip, float min, float max, float y)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(((Component)this).transform, false);
		val.transform.localPosition = new Vector3(0f, y, 0f);
		AudioSource val2 = val.AddComponent<AudioSource>();
		Setup3D(val2, min, max);
		val2.clip = Bundle.Clip(clip);
		val2.loop = true;
		val2.volume = 0f;
		if ((Object)(object)val2.clip != (Object)null)
		{
			val2.Play();
		}
		return val2;
	}

	private static void Setup3D(AudioSource a, float min, float max)
	{
		a.playOnAwake = false;
		a.spatialBlend = 1f;
		a.dopplerLevel = 0f;
		a.rolloffMode = (AudioRolloffMode)1;
		a.minDistance = min;
		a.maxDistance = max;
		try
		{
			AudioMixerGroup val = ((!((Object)(object)SoundManager.Instance != (Object)null) || !((Object)(object)SoundManager.Instance.tempAudio1 != (Object)null)) ? null : SoundManager.Instance.tempAudio1.outputAudioMixerGroup);
			if ((Object)(object)val != (Object)null)
			{
				a.outputAudioMixerGroup = val;
			}
		}
		catch
		{
		}
	}

	internal static PlayerControllerB Player(int i)
	{
		StartOfRound instance = StartOfRound.Instance;
		return (!((Object)(object)instance != (Object)null) || i < 0 || i >= instance.allPlayerScripts.Length) ? null : instance.allPlayerScripts[i];
	}

	private static int IndexOf(PlayerControllerB p)
	{
		StartOfRound instance = StartOfRound.Instance;
		return (!((Object)(object)instance != (Object)null) || !((Object)(object)p != (Object)null)) ? (-1) : Array.IndexOf(instance.allPlayerScripts, p);
	}

	internal static bool Holds(int state)
	{
		return state == 3 || state == 4 || state == 5 || state == 6 || state == 11;
	}

	private void Update()
	{
		if (((NetworkBehaviour)this).IsServer)
		{
			Think();
		}
		Animate();
		Sounds();
		LocalVictim();
	}

	private void LateUpdate()
	{
		HoldVictimInPlace();
	}

	private void Think()
	{
		//IL_043a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0517: Unknown result type (might be due to invalid IL or missing references)
		//IL_0665: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0358: Unknown result type (might be due to invalid IL or missing references)
		//IL_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0371: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_agent == (Object)null || !_agent.isOnNavMesh)
		{
			return;
		}
		float time = Time.time;
		float elapsed = Elapsed;
		StartOfRound instance = StartOfRound.Instance;
		bool flag = (Object)(object)instance == (Object)null || instance.inShipPhase || instance.shipIsLeaving;
		PlayerControllerB val = Player(Target);
		if (Holds(State) && (flag || !Valid(val)))
		{
			Plugin.Log.LogInfo((object)("Angel: the blessing was cut short (" + ((!flag) ? "its charge is gone" : "the ship is leaving") + ")."));
			Release(grantImmunity: true);
			Recover(8f);
			return;
		}
		if (time >= _nextDoor)
		{
			_nextDoor = time + 0.25f;
			OpenDoorsAhead();
		}
		if (!flag && ThinkExtras(time))
		{
			return;
		}
		switch (State)
		{
		case 0:
			_agent.speed = 1.4f + 1f * AggroK;
			_agent.isStopped = false;
			if (!flag && TryHoard(time))
			{
				break;
			}
			if (!flag && time >= _nextScan && time >= _cooldownUntil)
			{
				_nextScan = time + 0.5f;
				int num = FindLonePlayer();
				if (num >= 0)
				{
					SetState(1, num);
					break;
				}
			}
			if (time >= _nextRepath || (!_agent.pathPending && _agent.remainingDistance < 0.5f))
			{
				_nextRepath = time + Random.Range(10f, 18f);
				Wander();
			}
			break;
		case 1:
		{
			if (!Valid(val) || IsImmune(Target) || !StillAlone(Target, 4f * (1f - 0.6f * AggroK)))
			{
				GiveUp();
				break;
			}
			float num3 = Flat(((Component)val).transform.position - ((Component)this).transform.position);
			if (num3 > 32f + 20f * AggroK)
			{
				GiveUp();
				break;
			}
			_agent.speed = 2.5f + 2.5f * AggroK;
			if (time >= _nextRepath)
			{
				_nextRepath = time + 0.3f;
				_agent.SetDestination(((Component)val).transform.position);
			}
			if (num3 < 4.5f)
			{
				SetState(2, Target);
				Net2.Fx(this, 1, Target);
			}
			break;
		}
		case 2:
		{
			if (!Valid(val) || IsImmune(Target))
			{
				GiveUp();
				break;
			}
			float num4 = Flat(((Component)val).transform.position - ((Component)this).transform.position);
			FaceTo(((Component)val).transform.position, 4f);
			_agent.speed = 1.6f + 1.6f * AggroK;
			if (time >= _nextRepath)
			{
				_nextRepath = time + 0.25f;
				_agent.SetDestination(((Component)val).transform.position);
			}
			if (elapsed >= 1.2f - 0.6f * AggroK && num4 < 1.45f)
			{
				Connect();
			}
			else if (elapsed > 9f || num4 > 10f + 6f * AggroK)
			{
				GiveUp();
			}
			break;
		}
		case 3:
			Stop();
			FaceTo(((Component)val).transform.position, 6f);
			if (elapsed >= Mathf.Max(0.5f, Plugin.AngelChannel.Value))
			{
				Outcome = _rolled;
				if (Outcome == 2)
				{
					StartProcession();
				}
				else if (Outcome == 3)
				{
					SetState(6, Target);
				}
				else
				{
					SetState(4, Target);
					Net2.Fx(this, 3, Outcome);
				}
				Plugin.Log.LogInfo((object)("Angel: " + val.playerUsername + " receives " + OutcomeNames[Outcome] + "."));
			}
			break;
		case 4:
			Stop();
			FaceTo(((Component)val).transform.position, 6f);
			if (_fxStep == 0 && elapsed >= 2.2f)
			{
				_fxStep = 1;
				Net2.Fx(this, 4, Outcome);
			}
			if (Outcome == 4)
			{
				if (_fxStep == 1 && elapsed >= 2.55f)
				{
					_fxStep = 2;
					Net2.Fx(this, 6, 0);
				}
				if (_fxStep == 2 && elapsed >= 2.75f)
				{
					_fxStep = 3;
					Net2.Fx(this, 7, Target);
					Release(grantImmunity: true);
					SetState(8, -1);
				}
			}
			else if (Outcome == 5)
			{
				if (_fxStep == 1 && elapsed >= 2.3f)
				{
					_fxStep = 2;
					Transfigure();
				}
			}
			else if (_fxStep == 1 && elapsed >= 2.3f)
			{
				_fxStep = 2;
				Net2.Fx(this, 5, Target * 2 + ((Outcome == 1) ? 1 : 0));
				Release(grantImmunity: true);
				Bow();
			}
			break;
		case 5:
			Procession(val, elapsed);
			break;
		case 6:
			Stop();
			FaceTo(((Component)val).transform.position, 6f);
			if (_fxStep < 6 && elapsed >= 0.45f + (float)_fxStep * 0.33f)
			{
				_fxStep++;
				Net2.Fx(this, 8, _fxStep);
				if (_fxStep == 6)
				{
					int num2 = Duplicate(val);
					Net2.Fx(this, (num2 <= 0) ? 10 : 9, num2);
					_abundanceEnd = elapsed + ((num2 <= 0) ? 2.4f : 1.2f);
				}
			}
			if (_fxStep >= 6 && elapsed >= _abundanceEnd)
			{
				Release(grantImmunity: true);
				Bow();
			}
			break;
		case 7:
			Stop();
			if (elapsed >= 1.8f)
			{
				Recover(Plugin.AngelRecovery.Value);
			}
			break;
		case 8:
			if (elapsed < 1.6f)
			{
				Stop();
			}
			else if (_fxStep == 0)
			{
				_fxStep = 1;
				_agent.isStopped = false;
				_agent.speed = 0.9f;
				_agent.updateRotation = false;
				BackAway(3f);
			}
			if (elapsed >= 3.2f)
			{
				_agent.updateRotation = true;
				Recover(Plugin.AngelRecovery.Value);
			}
			break;
		case 9:
			_agent.speed = 1.5f + 0.8f * AggroK;
			_agent.isStopped = false;
			if (elapsed >= _recoverFor)
			{
				SetState(0, -1);
			}
			else if (time >= _nextRepath)
			{
				_nextRepath = time + 12f;
				AwayFrom(_lastVictim);
			}
			break;
		default:
			ThinkMore(val, elapsed, time, flag);
			break;
		}
		if (time >= _nextSync)
		{
			Sync();
		}
	}

	private void Connect()
	{
		_rolled = Roll();
		_lastVictim = Target;
		SetState(3, Target);
		Net2.Fx(this, 2, Target);
	}

	internal static int Roll()
	{
		int num = Random.Range(0, 100);
		int num2 = 0;
		int[] array = Plugin.AngelChances();
		for (int i = 0; i < array.Length; i++)
		{
			num2 += array[i];
			if (num < num2)
			{
				return i;
			}
		}
		return 0;
	}

	private void GiveUp()
	{
		Recover(6f);
	}

	private void Bow()
	{
		SetState(7, Target);
		Net2.Fx(this, 11, 0);
	}

	private void Recover(float seconds)
	{
		_recoverFor = Mathf.Max(2f, seconds * (1f - 0.6f * AggroK));
		_cooldownUntil = Time.time + _recoverFor;
		Loose = false;
		if ((Object)(object)_agent != (Object)null && _agent.isOnNavMesh)
		{
			_agent.isStopped = false;
			_agent.updateRotation = true;
		}
		SetState(9, -1);
		_nextRepath = 0f;
	}

	private void Release(bool grantImmunity)
	{
		if (Target >= 0 && grantImmunity)
		{
			Immune[Target] = Time.time + Mathf.Max(0f, Plugin.AngelImmunity.Value);
		}
		if (Target >= 0 && grantImmunity && ((NetworkBehaviour)this).IsServer)
		{
			MaybeSaint(Player(Target));
		}
		Loose = false;
	}

	private void MaybeSaint(PlayerControllerB p)
	{
		//IL_0155: 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_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: 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_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)p == (Object)null || p.isPlayerDead || Random.Range(0, 100) >= Mathf.Clamp(Plugin.AngelSaintChance.Value, 0, 100))
			{
				return;
			}
			if (!_saintLooked)
			{
				_saintLooked = true;
				StartOfRound instance = StartOfRound.Instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.allItemsList != (Object)null)
				{
					foreach (Item items in instance.allItemsList.itemsList)
					{
						if ((Object)(object)items != (Object)null && (Object)(object)items.spawnPrefab != (Object)null && items.itemName != null && items.itemName.ToLowerInvariant().Contains("saint"))
						{
							_saint = items;
							break;
						}
					}
				}
				Plugin.Log.LogInfo((object)((!((Object)(object)_saint != (Object)null)) ? "Angel: no Saint die in this game (is Emergency Dice installed?)." : ("Angel: found the Saint die ('" + _saint.itemName + "').")));
			}
			if (!((Object)(object)_saint == (Object)null))
			{
				Vector3 at = ((Component)p).transform.position + ((Component)p).transform.forward * 0.6f + Vector3.up * 0.4f;
				Peddler.SpawnItem(_saint, at, p.isInsideFactory);
				Net2.Fx(this, 14, 0);
				Plugin.Log.LogInfo((object)("Angel: left " + p.playerUsername + " a Saint die."));
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("Angel Saint die: " + ex.Message));
		}
	}

	private void SetState(int st, int target)
	{
		State = st;
		Target = target;
		_stateAt = Time.time;
		_fxStep = 0;
		if (st == 5)
		{
			ResetTrail();
		}
		if (st != 4 && st != 5 && st != 6)
		{
			Outcome = -1;
		}
		Sync();
	}

	private void Sync()
	{
		_nextSync = Time.time + 0.35f;
		Net2.State(this);
	}

	internal void SetSynced(int st, int target, int outcome, bool loose, float elapsed)
	{
		bool flag = st != State || target != Target;
		if (flag)
		{
			_stateAt = Time.time - Mathf.Max(0f, elapsed);
		}
		State = st;
		Target = target;
		Outcome = outcome;
		Loose = loose;
		if (flag && st == 5)
		{
			ResetTrail();
		}
	}

	private void Stop()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		if (_agent.isOnNavMesh)
		{
			_agent.isStopped = true;
			_agent.velocity = Vector3.zero;
		}
	}

	private void FaceTo(Vector3 at, float speed)
	{
		//IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: 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_0040: 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)
		Vector3 val = at - ((Component)this).transform.position;
		val.y = 0f;
		if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
		{
			((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(val), Time.deltaTime * speed);
		}
	}

	private static float Flat(Vector3 v)
	{
		v.y = 0f;
		return ((Vector3)(ref v)).magnitude;
	}

	private static bool Valid(PlayerControllerB p)
	{
		return (Object)(object)p != (Object)null && p.isPlayerControlled && !p.isPlayerDead && p.isInsideFactory;
	}

	private static bool IsImmune(int i)
	{
		float value;
		return Immune.TryGetValue(i, out value) && Time.time < value;
	}

	private bool TakenByAnother(int i)
	{
		foreach (Angel item in All)
		{
			if ((Object)(object)item != (Object)null && (Object)(object)item != (Object)(object)this && item.Target == i)
			{
				return true;
			}
		}
		return false;
	}

	private static bool StillAlone(int i, float radius)
	{
		//IL_006f: 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)
		PlayerControllerB val = Player(i);
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)val == (Object)null || (Object)(object)instance == (Object)null)
		{
			return false;
		}
		PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
		foreach (PlayerControllerB val2 in allPlayerScripts)
		{
			if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)val && val2.isPlayerControlled && !val2.isPlayerDead && Vector3.Distance(((Component)val2).transform.position, ((Component)val).transform.position) < radius)
			{
				return false;
			}
		}
		return true;
	}

	private int FindLonePlayer()
	{
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return -1;
		}
		int result = -1;
		float num = 38f + 20f * AggroK;
		for (int i = 0; i < instance.allPlayerScripts.Length; i++)
		{
			PlayerControllerB val = instance.allPlayerScripts[i];
			if (Valid(val) && !IsImmune(i) && !val.isClimbingLadder && !TakenByAnother(i))
			{
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				if (!(num2 > num) && StillAlone(i, Mathf.Max(2f, Plugin.AngelLoneRadius.Value * (1f - 0.6f * AggroK))) && (!(num2 > 9f + 6f * AggroK) || CanSee(val, 32f + 20f * AggroK)))
				{
					num = num2;
					result = i;
				}
			}
		}
		return result;
	}

	private bool CanSee(PlayerControllerB p, float range)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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)
		Vector3 val = ((Component)this).transform.position + Vector3.up * 2.2f;
		Vector3 position = ((Component)p.gameplayCamera).transform.position;
		if (Vector3.Distance(val, position) > range)
		{
			return false;
		}
		return !Physics.Linecast(val, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
	}

	private void Wander()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		GameObject[] array = Peddler.Nodes(outside: false);
		for (int i = 0; i < 10; i++)
		{
			if (array.Length <= 0)
			{
				break;
			}
			GameObject val = array[Random.Range(0, array.Length)];
			if (!((Object)(object)val == (Object)null))
			{
				float num = Vector3.Distance(val.transform.position, ((Component)this).transform.position);
				if (!(num < 8f) && !(num > 45f) && TryPath(val.transform.position))
				{
					break;
				}
			}
		}
	}

	private void AwayFrom(int who)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB val = Player(who);
		if ((Object)(object)val == (Object)null)
		{
			Wander();
			return;
		}
		GameObject[] array = Peddler.Nodes(outside: false);
		for (int i = 0; i < 12; i++)
		{
			if (array.Length <= 0)
			{
				break;
			}
			GameObject val2 = array[Random.Range(0, array.Length)];
			if (!((Object)(object)val2 == (Object)null) && !(Vector3.Distance(val2.transform.position, ((Component)val).transform.position) < 18f) && !(Vector3.Distance(val2.transform.position, ((Component)this).transform.position) > 50f) && TryPath(val2.transform.position))
			{
				return;
			}
		}
		Wander();
	}

	private void BackAway(float metres)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = ((Component)this).transform.position - ((Component)this).transform.forward * metres;
		NavMeshHit val2 = default(NavMeshHit);
		if (NavMesh.SamplePosition(val, ref val2, 1.5f, -1))
		{
			_agent.SetDestination(((NavMeshHit)(ref val2)).position);
		}
	}

	private bool TryPath(Vector3 to)
	{
		//IL_0000: 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_001b: Expected O, but got Unknown
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		NavMeshHit val = default(NavMeshHit);
		if (!NavMesh.SamplePosition(to, ref val, 3f, -1))
		{
			return false;
		}
		NavMeshPath val2 = new NavMeshPath();
		if (!_agent.CalculatePath(((NavMeshHit)(ref val)).position, val2) || (int)val2.status != 0)
		{
			return false;
		}
		_agent.SetPath(val2);
		return true;
	}

	private void OpenDoorsAhead()
	{
		//IL_0054: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//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_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)
		if (State == 3 || State == 4 || State == 6)
		{
			return;
		}
		if (Time.time - _doorsAt > 10f)
		{
			_doors = Object.FindObjectsOfType<DoorLock>();
			_doorsAt = Time.time;
		}
		Vector3 val = ((Component)this).transform.position + ((Component)this).transform.forward * 0.9f + Vector3.up;
		DoorLock[] doors = _doors;
		foreach (DoorLock val2 in doors)
		{
			if ((Object)(object)val2 == (Object)null || val2.isLocked || Vector3.Distance(((Component)val2).transform.position, val) > 1.9f)
			{
				continue;
			}
			try
			{
				if (!(DoorOpened != null) || !(bool)DoorOpened.GetValue(val2))
				{
					val2.OpenDoorAsEnemyServerRpc();
				}
			}
			catch
			{
			}
		}
	}

	private void StartProcession()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		SetState(5, Target);
		_agent.isStopped = false;
		_agent.speed = 1.9f;
		_stuckAt = ((Component)this).transform.position;
		_stuckSince = Time.time;
		_nextBell = Time.time + Random.Range(1.5f, 3.5f);
		ProcessionLeg();
	}

	private void ProcessionLeg()
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		GameObject[] array = Peddler.Nodes(outside: false);
		EntranceTeleport[] array2 = Object.FindObjectsOfType<EntranceTeleport>();
		for (int i = 0; i < 20; i++)
		{
			if (array.Length <= 0)
			{
				break;
			}
			GameObject val = array[Random.Range(0, array.Length)];
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			Vector3 position = val.transform.position;
			float num = Vector3.Distance(position, ((Component)this).transform.position);
			if (num < 10f || num > 40f)
			{
				continue;
			}
			bool flag = false;
			EntranceTeleport[] array3 = array2;
			foreach (EntranceTeleport val2 in array3)
			{
				if ((Object)(object)val2 != (Object)null && Vector3.Distance(((Component)val2).transform.position, position) < 10f)
				{
					flag = true;
					break;
				}
			}
			if (!flag && TryPath(position))
			{
				return;
			}
		}
		Wander();
	}

	private void Procession(PlayerControllerB v, float e)
	{
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		float time = Time.time;
		_agent.isStopped = false;
		_agent.speed = 1.9f;
		if (!_agent.pathPending && _agent.remainingDistance < 0.8f)
		{
			ProcessionLeg();
		}
		float num = Mathf.Max(3f, Plugin.AngelLoosenEvery.Value);
		float num2 = Mathf.Clamp(Plugin.AngelLoosenWindow.Value, 0.3f, num - 0.5f);
		bool flag = e >= num && e % num < num2;
		if (flag != Loose)
		{
			Loose = flag;
			if (flag)
			{
				Net2.Fx(this, 13, Target);
			}
			Sync();
		}
		if (time >= _nextBell)
		{
			_nextBell = time + Random.Range(2.5f, 6f);
			Net2.Fx(this, 14, 0);
		}
		if (Vector3.Distance(((Component)this).transform.position, _stuckAt) > 0.6f)
		{
			_stuckAt = ((Component)this).transform.position;
			_stuckSince = time;
		}
		else if (time - _stuckSince > 4f)
		{
			Plugin.Log.LogInfo((object)"Angel: stuck mid-procession; it sets its charge down.");
			Release(grantImmunity: true);
			Bow();
			return;
		}
		if (e >= Mathf.Clamp(Plugin.AngelProcessionSeconds.Value, 5f, 600f))
		{
			Release(grantImmunity: true);
			Bow();
		}
	}

	internal void TryBreakFree(int who)
	{
		if (((NetworkBehaviour)this).IsServer && State == 5 && who == Target && Loose)
		{
			Plugin.Log.LogInfo((object)"Angel: its charge slipped free.");
			Net2.Fx(this, 15, Target);
			Release(grantImmunity: true);
			Recover(Plugin.AngelRecovery.Value);
		}
	}

	internal static bool Eligible(GrabbableObject g)
	{
		if ((Object)(object)g == (Object)null || (Object)(object)g.itemProperties == (Object)null || !g.itemProperties.isScrap || g.scrapValue <= 0)
		{
			return false;
		}
		if (Copied.Contains(g) || Copies.Contains(g))
		{
			return false;
		}
		if (g is RagdollGrabbableObject || g is KeyItem || g is PeddlerRemains)
		{
			return false;
		}
		if (((Component)g).GetComponentsInChildren<GrabbableObject>(true).Length > 1)
		{
			return false;
		}
		string name = ((object)g).GetType().Name;
		if (name.IndexOf("Bag", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Container", StringComparison.OrdinalIgnoreCase) >= 0)
		{
			return false;
		}
		if (!Plugin.AngelDupeWeapons.Value)
		{
			if (g is ShotgunItem || g is KnifeItem || g is Shovel || g is GunAmmo || g.itemProperties.isDefensiveWeapon)
			{
				return false;
			}
			if (name.IndexOf("Gun", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Weapon", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Longwatch", StringComparison.Ordinal) >= 0 || name.IndexOf("Crossbow", StringComparison.Ordinal) >= 0)
			{
				return false;
			}
		}
		string[] array = (Plugin.AngelDupeExclude.Value ?? string.Empty).Split(new char[1] { ',' });
		foreach (string text in array)
		{
			if (text.Trim().Length > 0 && string.Equals(text.Trim(), g.itemProperties.itemName, StringComparison.OrdinalIgnoreCase))
			{
				return false;
			}
		}
		return true;
	}

	private int Duplicate(PlayerControllerB p)
	{
		//IL_00a9: 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)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)p == (Object)null || p.ItemSlots == null)
		{
			return 0;
		}
		List<GrabbableObject> list = new List<GrabbableObject>();
		GrabbableObject[] itemSlots = p.ItemSlots;
		foreach (GrabbableObject val in itemSlots)
		{
			if (Eligible(val) && !list.Contains(val))
			{
				list.Add(val);
			}
		}
		int num = 0;
		for (int j = 0; j < list.Count; j++)
		{
			GrabbableObject val2 = list[j];
			try
			{
				Copied.Add(val2);
				float num2 = (float)j / (float)Mathf.Max(1, list.Count) * (float)Math.PI * 2f + Random.value;
				Vector3 val3 = ((Component)p).transform.position + new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * Random.Range(0.35f, 0.8f) + Vector3.up * 1.1f;
				Transform val4 = ((!((Object)(object)RoundManager.Instance != (Object)null)) ? null : RoundManager.Instance.spawnedScrapContainer);
				GameObject val5 = Object.Instantiate<GameObject>(val2.itemProperties.spawnPrefab, val3, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), val4);
				GrabbableObject component = val5.GetComponent<GrabbableObject>();
				if ((Object)(object)component != (Object)null)
				{
					component.fallTime = 0f;
					component.isInFactory = p.isInsideFactory;
					Copies.Add(component);
				}
				NetworkObject component2 = val5.GetComponent<NetworkObject>();
				component2.Spawn(false);
				if ((Object)(object)component != (Object)null)
				{
					component.SetScrapValue(val2.scrapValue);
					try
					{
						RoundManager.Instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(component2) }, new int[1] { val2.scrapValue });
					}
					catch
					{
					}
				}
				num++;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Angel: couldn't copy " + val2.itemProperties.itemName + ": " + ex.Message));
			}
		}
		Copied.RemoveWhere((GrabbableObject x) => (Object)(object)x == (Object)null);
		Copies.RemoveWhere((GrabbableObject x) => (Object)(object)x == (Object)null);
		Plugin.Log.LogInfo((object)("Angel: shook " + num + " copied scrap item(s) out of " + p.playerUsername + "."));
		return num;
	}

	internal void Struck(string how)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		if (!((NetworkBehaviour)this).IsServer)
		{
			return;
		}
		Net2.Fx(this, 12, 0);
		if ((Object)(object)_carried != (Object)null)
		{
			DropCarried(((Component)this).transform.position + ((Component)this).transform.forward * 0.5f);
			if (State == 12 || State == 13)
			{
				SetState(0, -1);
			}
		}
		if (Holds(State) || State == 2 || State == 1)
		{
			bool flag = Holds(State);
			Plugin.Log.LogInfo((object)("Angel: " + how + " - it lets go."));
			if (flag)
			{
				Release(grantImmunity: true);
			}
			Recover(Mathf.Max(8f, Plugin.AngelRecovery.Value));
		}
	}

	internal static void StunAround(Vector3 at, float radius)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		Angel[] array = All.ToArray();
		foreach (Angel angel in array)
		{
			if ((Object)(object)angel != (Object)null && ((NetworkBehaviour)angel).IsServer && Vector3.Distance(((Component)angel).transform.position + Vector3.up, at) < radius)
			{
				angel.Struck("stunned");
			}
		}
	}

	internal void OnFx(int fx, int arg)
	{
		float num = Mathf.Clamp(Plugin.Volume.Value, 0f, 2f) * Mathf.Clamp(Plugin.AngelVolume.Value, 0f, 2f);
		PlayerControllerB local = Peddler.Local;
		switch (fx)
		{
		case 1:
			Play("angel_offer", 0.9f, num);
			if ((Object)(object)local != (Object)null && (Object)(object)Player(arg) == (Object)(object)local && (Object)(object)HUDManager.Instance != (Object)null)
			{
				try
				{
					HUDManager.Instance.DisplayTip("???", "It opens its arms to you.", false, false, "LC_Tip1");
					break;
				}
				catch
				{
					break;
				}
			}
			break;
		case 2:
			Play("angel_grab", 1f, num);
			break;
		case 3:
			if (arg == 1)
			{
				Play("angel_bow", 0.9f, num);
				_fx.pitch = 1.12f;
				_fx.PlayOneShot(Bundle.Clip("angel_ceremony"), num);
			}
			else
			{
				Play("angel_ceremony", 1f, num);
			}
			break;
		case 4:
			Play("angel_flash", 1f, num);
			_flashAt = Time.time;
			break;
		case 6:
			Play("angel_click", 1f, num);
			_haloDeadUntil = Time.time + 2.5f;
			break;
		case 11:
			Play("angel_bow", 0.8f, num);
			break;
		case 8:
			_fx.pitch = Random.Range(0.92f, 1.06f);
			_fx.PlayOneShot(Bundle.Clip("angel_clunk"), num);
			_fx.pitch = 1f;
			_shakeAt = Time.time;
			if ((Object)(object)local != (Object)null && (Object)(object)Player(Target) == (Object)(object)local)
			{
				try
				{
					HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
					break;
				}
				catch
				{
					break;
				}
			}
			break;
		case 9:
			Play("angel_register", 1f, num);
			_haloSpeed = -720f;
			break;
		case 10:
			Play("angel_confused", 0.8f, num);
			break;
		case 12:
			Play("angel_hit", 1f, num);
			_hitAt = Time.time;
			break;
		case 13:
			Play("angel_loose", 1f, num);
			break;
		case 15:
			Play("angel_hit", 0.6f, num);
			break;
		case 14:
			_fx.pitch = Random.Range(0.85f, 1.1f);
			_fx.PlayOneShot(Bundle.Clip("angel_bell"), 0.9f * num);
			_fx.pitch = 1f;
			_haloRingAt = Time.time;
			break;
		case 5:
			Teleported(Player(arg / 2), (arg & 1) == 1);
			break;
		case 20:
		case 21:
		case 22:
		case 23:
			OnFxMore(fx, arg, num);
			break;
		case 7:
		{
			PlayerControllerB val = Player(arg);
			if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)local)
			{
				ReleaseLocal();
				try
				{
					val.fallValue = 0f;
					val.fallValueUncapped = 0f;
					val.DropAllHeldItemsAndSyncNonexact();
					break;
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Angel drop: " + ex.Message));
					break;
				}
			}
			break;
		}
		case 16:
		case 17:
		case 18:
		case 19:
			break;
		}
	}

	private void Play(string clip, float v, float vol)
	{
		AudioClip val = Bundle.Clip(clip);
		if (!((Object)(object)val == (Object)null) && !((Object)(object)_fx == (Object)null))
		{
			_fx.pitch = 1f;
			_fx.PlayOneShot(val, v * vol);
		}
	}

	private void Teleported(PlayerControllerB p, bool keep)
	{
		//IL_00ea: 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)
		if ((Object)(object)p == (Object)null)
		{
			return;
		}
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		Transform val = (((Object)(object)instance.middleOfShipNode != (Object)null) ? instance.middleOfShipNode : ((instance.playerSpawnPositions == null || instance.playerSpawnPositions.Length <= 0) ? null : instance.playerSpawnPositions[0]));
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		if ((Object)(object)p == (Object)(object)Peddler.Local)
		{
			ReleaseLocal();
			try
			{
				if (!keep)
				{
					p.DropAllHeldItemsAndSyncNonexact();
				}
				p.fallValue = 0f;
				p.fallValueUncapped = 0f;
				Teleport.To(p, val.position, inside: false, elevator: true, shipRoom: true);
				return;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Angel teleport: " + ex.Message));
				return;
			}
		}
		if (keep)
		{
			try
			{
				Teleport.To(p, val.position, inside: false, elevator: true, shipRoom: true);
				return;
			}
			catch
			{
				return;
			}
		}
		p.isInsideFactory = false;
		p.isInElevator = true;
		p.isInHangarShipRoom = true;
	}

	private void LocalVictim()
	{
		//IL_004e: 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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		if (_trail.Count == 0 || Vector3.Distance(_trail[_trail.Count - 1], ((Component)this).transform.position) > 0.12f)
		{
			_trail.Add(((Component)this).transform.position);
			if (_trail.Count > 120)
			{
				_trail.RemoveAt(0);
			}
		}
		PlayerControllerB local = Peddler.Local;
		bool flag = (Object)(object)local != (Object)null && Holds(State) && (Object)(object)Player(Target) == (Object)(object)local && !local.isPlayerDead && local.isPlayerControlled;
		if (flag && (Object)(object)_holdingMe == (Object)null)
		{
			_holdingMe = local;
			LocalCaptor = this;
			_grabPos = ((Component)local).transform.position;
			local.disableMoveInput = true;
			local.disableInteract = true;
		}
		else if (!flag && (Object)(object)_holdingMe != (Object)null)
		{
			ReleaseLocal();
		}
		if ((Object)(object)_holdingMe == (Object)null)
		{
			return;
		}
		if (State == 5 && !_crouched)
		{
			_crouched = true;
			try
			{
				if (!local.isCrouching)
				{
					local.Crouch(true);
				}
			}
			catch
			{
			}
		}
		if (State != 5 || !Loose)
		{
			return;
		}
		try
		{
			if (_interact == null && (Object)(object)IngamePlayerSettings.Instance != (Object)null)
			{
				_interact = IngamePlayerSettings.Instance.playerInput.actions.FindAction("Interact", false);
			}
			if (_interact != null && _interact.WasPressedThisFrame())
			{
				Net2.Free(this);
			}
		}
		catch
		{
		}
	}

	private void HoldVictimInPlace()
	{
		//IL_0032: 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_00a2: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: 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_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: 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_01fd: 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_0207: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB holdingMe = _holdingMe;
		if ((Object)(object)holdingMe == (Object)null)
		{
			return;
		}
		if (holdingMe.isPlayerDead || !holdingMe.isPlayerControlled)
		{
			ReleaseLocal();
			return;
		}
		Vector3 val = _grabPos;
		float elapsed = Elapsed;
		if (State == 4 && Outcome == 4)
		{
			val += Vector3.up * 0.5f * Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.3f, 2.1f, elapsed));
		}
		else if (State == 6)
		{
			val += Vector3.up * 0.3f * Mathf.Clamp01(elapsed / 0.4f);
			float num = Mathf.Clamp01(1f - (Time.time - _shakeAt) / 0.38f);
			if (_fxStep >= 1 && _fxStep < 6)
			{
				num = Mathf.Max(num, 0.45f);
			}
			val += (((Component)this).transform.right * Mathf.Sin(Time.time * 74f) * 0.14f + Vector3.up * Mathf.Abs(Mathf.Sin(Time.time * 61f)) * 0.2f + ((Component)this).transform.forward * Mathf.Sin(Time.time * 53f) * 0.05f) * num;
		}
		else if (State == 5)
		{
			val = TrailPoint(1.35f);
		}
		else if (State == 11)
		{
			val = ((Component)this).transform.position + ((Component)this).transform.forward * 0.4f + Vector3.up * 0.35f;
		}
		((Component)holdingMe).transform.position = val;
		holdingMe.fallValue = 0f;
		holdingMe.fallValueUncapped = 0f;
		try
		{
			Physics.SyncTransforms();
		}
		catch
		{
		}
	}

	private void ResetTrail()
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		_trail.Clear();
		PlayerControllerB val = Player(Target);
		if ((Object)(object)val != (Object)null)
		{
			_trail.Add(((Component)val).transform.position);
		}
		_trail.Add(((Component)this).transform.position);
	}

	private Vector3 TrailPoint(float back)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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_009a: 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)
		Vector3 val = ((Component)this).transform.position;
		float num = back;
		for (int num2 = _trail.Count - 1; num2 >= 0; num2--)
		{
			float num3 = Vector3.Distance(val, _trail[num2]);
			if (num3 >= num)
			{
				return Vector3.Lerp(val, _trail[num2], num / Mathf.Max(num3, 0.0001f));
			}
			num -= num3;
			val = _trail[num2];
		}
		return (_trail.Count <= 0) ? _grabPos : _trail[0];
	}

	private void ReleaseLocal()
	{
		PlayerControllerB holdingMe = _holdingMe;
		_holdingMe = null;
		if ((Object)(object)LocalCaptor == (Object)(object)this)
		{
			LocalCaptor = null;
		}
		if ((Object)(object)holdingMe == (Object)null)
		{
			return;
		}
		holdingMe.disableMoveInput = false;
		holdingMe.disableInteract = false;
		holdingMe.fallValue = 0f;
		holdingMe.fallValueUncapped = 0f;
		if (!_crouched)
		{
			return;
		}
		_crouched = false;
		try
		{
			if (holdingMe.isCrouching)
			{
				holdingMe.Crouch(false);
			}
		}
		catch
		{
		}
	}

	private void OnGUI()
	{
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: 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_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Expected O, but got Unknown
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: 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_0109: 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)
		float num = 1f - (Time.time - _flashAt) / 1.4f;
		PlayerControllerB local = Peddler.Local;
		if (num > 0f && (Object)(object)local != (Object)null && (Object)(object)local.gameplayCamera != (Object)null)
		{
			Vector3 position = ((Component)local.gameplayCamera).transform.position;
			Vector3 val = ((Component)this).transform.position + Vector3.up * 2f;
			float num2 = Vector3.Distance(position, val);
			if ((num2 < 22f && !Physics.Linecast(position, val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) || num2 < 3f)
			{
				GUI.color = new Color(1f, 0.98f, 0.92f, Mathf.Clamp01(num * 1.6f) * Mathf.Clamp01(1.2f - num2 / 22f));
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture);
				GUI.color = Color.white;
			}
		}
		if (!((Object)(object)_holdingMe != (Object)null) || State != 5 || !Loose)
		{
			return;
		}
		GUIStyle val2 = new GUIStyle(GUI.skin.label);
		val2.fontSize = Mathf.RoundToInt((float)Screen.height * 0.03f);
		val2.alignment = (TextAnchor)4;
		val2.fontStyle = (FontStyle)1;
		GUIStyle val3 = val2;
		val3.normal.textColor = new Color(1f, 0.92f, 0.6f);
		string text = "E";
		try
		{
			if (_interact != null)
			{
				text = InputActionRebindingExtensions.GetBindingDisplayString(_interact, 0, (DisplayStringOptions)0);
			}
		}
		catch
		{
		}
		GUI.Label(new Rect(0f, (float)Screen.height * 0.62f, (float)Screen.width, (float)Screen.height * 0.08f), "Its grip loosens - [" + text + "] to break free", val3);
	}

	private void Animate()
	{
		//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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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_0120: 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_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: 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_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0343: Unknown result type (might be due to invalid IL or missing references)
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034a: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_037a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_0399: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_050f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0511: Unknown result type (might be due to invalid IL or missing references)
		//IL_0871: Unknown result type (might be due to invalid IL or missing references)
		//IL_0882: Unknown result type (might be due to invalid IL or missing references)
		//IL_0889: Unknown result type (might be due to invalid IL or missing references)
		//IL_088e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0890: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a08: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a0d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a12: Unknown result type (might be due to invalid IL or missing references)
		//IL_06df: Unknown result type (might be due to invalid IL or missing references)
		//IL_0710: Unknown result type (might be due to invalid IL or missing references)
		//IL_0715: Unknown result type (might be due to invalid IL or missing references)
		//IL_071a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a31: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a37: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a3c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a3e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a43: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a4a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a77: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a7c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a7e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a83: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0abc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0abe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ac3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0af1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0af7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0afc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0afe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b03: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b0a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b5f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b64: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b66: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b6b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b70: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b31: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b37: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b3c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b3e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b43: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b54: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c62: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c67: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c75: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c9c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ca2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cb7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cbc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cc3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cf0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d05: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d0a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d11: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bd5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bda: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bdf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bfd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c09: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c19: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c1e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c23: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c39: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c3e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c43: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dcb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ed7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0eeb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ef6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0efb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f23: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f37: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f42: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f69: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f6e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f70: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f77: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_model == (Object)null)
		{
			return;
		}
		if (Time.deltaTime > 0f)
		{
			Vector3 val = ((Component)this).transform.position - _lastPos;
			val.y = 0f;
			_speedSeen = Mathf.Lerp(_speedSeen, ((Vector3)(ref val)).magnitude / Time.deltaTime, Time.deltaTime * 4f);
		}
		_lastPos = ((Component)this).transform.position;
		float time = Time.time;
		float deltaTime = Time.deltaTime;
		float elapsed = Elapsed;
		float num = Mathf.Clamp01(deltaTime * 5f);
		PlayerControllerB val2 = Player(Target);
		_hover = Mathf.Lerp(_hover, (State != 7 && State != 8) ? 0.09f : 0.03f, num);
		if ((Object)(object)_body != (Object)null)
		{
			_body.localPosition = new Vector3(0f, _hover + Mathf.Sin(time * 1.3f) * 0.04f, 0f);
		}
		float num2 = Mathf.Clamp(_speedSeen, 0f, 3f);
		if ((Object)(object)_legL != (Object)null)
		{
			_legL.localRotation = _legLRest * Quaternion.Euler((0f - num2) * 6f + Mathf.Sin(time * 1.3f + 0.6f) * 3f, 0f, Mathf.Sin(time * 0.9f) * 2f);
		}
		if ((Object)(object)_legR != (Object)null)
		{
			_legR.localRotation = _legRRest * Quaternion.Euler((0f - num2) * 6f + Mathf.Sin(time * 1.3f + 1.4f) * 3f, 0f, Mathf.Sin(time * 0.9f + 1f) * 2f);
		}
		Vector3 val3 = default(Vector3);
		((Vector3)(ref val3))..ctor(-10f, 0f, -4f);
		Vector3 val4 = default(Vector3);
		((Vector3)(ref val4))..ctor(-10f, 0f, 4f);
		Vector3 val5 = default(Vector3);
		((Vector3)(ref val5))..ctor(-58f, 38f, 0f);
		Vector3 val6 = default(Vector3);
		((Vector3)(ref val6))..ctor(-58f, -38f, 0f);
		Vector3 zero = Vector3.zero;
		Vector3 val7 = default(Vector3);
		((Vector3)(ref val7))..ctor(Mathf.Sin(time * 0.8f) * 1.2f, 0f, 0f);
		float num3 = 0f;
		float num4 = Mathf.Sin(time * 0.9f) * 3f;
		switch (State)
		{
		case 1:
			((Vector3)(ref zero))..ctor(6f, 0f, -8f);
			break;
		case 2:
		{
			float num5 = Mathf.SmoothStep(0f, 1f, elapsed / 0.9f);
			val3 = Vector3.Lerp(val3, new Vector3(-50f, 0f, -52f), num5);
			val4 = Vector3.Lerp(val4, new Vector3(-50f, 0f, 52f), num5);
			val5 = Vector3.Lerp(val5, new Vector3(-18f, 0f, 0f), num5);
			val6 = Vector3.Lerp(val6, new Vector3(-18f, 0f, 0f), num5);
			((Vector3)(ref zero))..ctor(10f, 0f, -16f * num5);
			val7.x += 4f * num5;
			num3 = -0.25f * num5;
			break;
		}
		case 3:
			((Vector3)(ref val3))..ctor(-72f, 0f, -18f);
			((Vector3)(ref val4))..ctor(-72f, 0f, 18f);
			((Vector3)(ref val5))..ctor(-42f, 30f, 0f);
			((Vector3)(ref val6))..ctor(-42f, -30f, 0f);
			((Vector3)(ref zero))..ctor(22f, 0f, -10f);
			val7.x += 10f;
			num3 = 0.35f * Mathf.Clamp01(elapsed / 2.5f);
			break;
		case 4:
		{
			float num8 = Mathf.SmoothStep(0f, 1f, elapsed / 1.2f);
			val3 = Vector3.Lerp(new Vector3(-72f, 0f, -18f), new Vector3(-165f, 0f, -14f), num8);
			val4 = Vector3.Lerp(new Vector3(-72f, 0f, 18f), new Vector3(-165f, 0f, 14f), num8);
			((Vector3)(ref val6))..ctor(-8f, 0f, 0f);
			val5 = val6;
			((Vector3)(ref zero))..ctor(-28f * num8, 0f, 0f);
			num3 = Mathf.Clamp01(elapsed / 0.8f);
			if (Outcome == 4 && elapsed > 2.55f)
			{
				num3 = 0.6f;
				((Vector3)(ref val3))..ctor(-150f, 0f, -20f);
				((Vector3)(ref val4))..ctor(-150f, 0f, 20f);
			}
			break;
		}
		case 5:
			((Vector3)(ref val4))..ctor(32f, 0f, 10f);
			((Vector3)(ref val6))..ctor(-10f, 0f, 0f);
			((Vector3)(ref val3))..ctor(-82f, 0f, -24f);
			((Vector3)(ref val5))..ctor(-12f, 0f, 0f);
			((Vector3)(ref zero))..ctor(-6f, 0f, 0f);
			val7.x += 6f;
			if (Loose)
			{
				((Vector3)(ref val4))..ctor(24f, 0f, 16f);
				((Vector3)(ref val6))..ctor(-30f, 0f, 0f);
			}
			break;
		case 6:
		{
			((Vector3)(ref val3))..ctor(-80f, 0f, -16f);
			((Vector3)(ref val4))..ctor(-80f, 0f, 16f);
			((Vector3)(ref val5))..ctor(-30f, 25f, 0f);
			((Vector3)(ref val6))..ctor(-30f, -25f, 0f);
			float num7 = Mathf.Clamp01(1f - (time - _shakeAt) / 0.38f);
			if (_fxStep >= 1 && _fxStep < 6)
			{
				num7 = Mathf.Max(num7, 0.45f);
			}
			val7 += new Vector3(Mathf.Sin(time * 74f) * 9f * num7, 0f, Mathf.Sin(time * 61f) * 7f * num7);
			((Vector3)(ref zero))..ctor(30f, 0f, 0f);
			if (_fxStep >= 6 || elapsed > 2.6f)
			{
				((Vector3)(ref zero))..ctor(42f, 0f, Mathf.Sin(time * 1.1f) * 10f);
			}
			break;
		}
		case 7:
			val7.x += 28f * Mathf.Sin(Mathf.Clamp01(elapsed / 1.6f) * (float)Math.PI);
			((Vector3)(ref zero))..ctor(20f, 0f, 0f);
			break;
		case 8:
			((Vector3)(ref val3))..ctor(-62f, 0f, -6f);
			((Vector3)(ref val4))..ctor(-62f, 0f, 6f);
			((Vector3)(ref val5))..ctor(-48f, 60f, 0f);
			((Vector3)(ref val6))..ctor(-48f, -60f, 0f);
			((Vector3)(ref zero))..ctor(40f, 0f, Mathf.Sin(time * 0.7f) * 6f);
			num3 = 0.15f;
			break;
		case 9:
			((Vector3)(ref zero))..ctor(14f, 0f, 0f);
			break;
		case 10:
		{
			float num6 = Mathf.SmoothStep(0f, 1f, elapsed / 0.8f);
			val3 = Vector3.Lerp(val3, new Vector3(-150f, 0f, -30f), num6);
			val4 = Vector3.Lerp(val4, new Vector3(-150f, 0f, 30f), num6);
			((Vector3)(ref val6))..ctor(-10f, 0f, 0f);
			val5 = val6;
			((Vector3)(ref zero))..ctor(-24f * num6, 0f, 0f);
			num3 = -0.3f * num6;
			break;
		}
		case 11:
			((Vector3)(ref val3))..ctor(-62f, 0f, -12f);
			((Vector3)(ref val4))..ctor(-62f, 0f, 12f);
			((Vector3)(ref val5))..ctor(-55f, 35f, 0f);
			((Vector3)(ref val6))..ctor(-55f, -35f, 0f);
			((Vector3)(ref zero))..ctor(26f, 0f, 0f);
			val7.x += 8f;
			num3 = 0.2f;
			break;
		case 12:
		case 13:
			((Vector3)(ref zero))..ctor(18f, 0f, 0f);
			if ((Object)(object)_carried != (Object)null)
			{
				((Vector3)(ref val4))..ctor(-48f, 0f, 14f);
				((Vector3)(ref val6))..ctor(-35f, -10f, 0f);
			}
			break;
		}
		float num9 = Mathf.Clamp01(1f - (time - _hitAt) / 0.4f);
		val7 += new Vector3(-14f * num9, 0f, 8f * num9);
		if ((Object)(object)_armL != (Object)null)
		{
			_armL.localRotation = Quaternion.Slerp(_armL.localRotation, _armLRest * Quaternion.Euler(val3), num);
		}
		if ((Object)(object)_armR != (Object)null)
		{
			_armR.localRotation = Quaternion.Slerp(_armR.localRotation, _armRRest * Quaternion.Euler(val4), num);
		}
		if ((Object)(object)_foreL != (Object)null)
		{
			_foreL.localRotation = Quaternion.Slerp(_foreL.localRotation, _foreLRest * Quaternion.Euler(val5), num);
		}
		if ((Object)(object)_foreR != (Object)null)
		{
			_foreR.localRotation = Quaternion.Slerp(_foreR.localRotation, _foreRRest * Quaternion.Euler(val6), num);
		}
		if ((Object)(object)_torso != (Object)null)
		{
			_torso.localRotation = Quaternion.Slerp(_torso.localRotation, _torsoRest * Quaternion.Euler(val7), Mathf.Clamp01(deltaTime * 8f));
		}
		Quaternion val8 = _headRest * Quaternion.Euler(zero);
		if ((Object)(object)_head != (Object)null && (Object)(object)val2 != (Object)null && (State == 1 || State == 2) && (Object)(object)_head.parent != (Object)null)
		{
			Vector3 val9 = ((Component)val2.gameplayCamera).transform.position - _head.position;
			if (((Vector3)(ref val9)).sqrMagnitude > 0.01f)
			{
				val8 = Quaternion.Inverse(_head.parent.rotation) * Quaternion.LookRotation(((Vector3)(ref val9)).normalized, _head.parent.up) * Quaternion.Euler(0f, 0f, zero.z);
			}
		}
		if ((Object)(object)_head != (Object)null)
		{
			_head.localRotation = Quaternion.Slerp(_head.localRotation, val8, Mathf.Clamp01(deltaTime * 3f));
		}
		if ((Object)(object)_wingL != (Object)null)
		{
			_wingL.localRotation = Quaternion.Slerp(_wingL.localRotation, _wingLRest * Quaternion.Euler(0f, (0f - num3) * 75f, num4), num);
		}
		if ((Object)(object)_wingR != (Object)null)
		{
			_wingR.localRotation = Quaternion.Slerp(_wingR.localRotation, _wingRRest * Quaternion.Euler(0f, num3 * 75f, 0f - num4), num);
		}
		_haloSpeed = Mathf.MoveTowards(_haloSpeed, 25f, deltaTime * 300f);
		_haloAngle += _haloSpeed * deltaTime;
		Transform val10 = ((!((Object)(object)_haloSpin != (Object)null)) ? _halo : _haloSpin);
		if ((Object)(object)val10 != (Object)null)
		{
			float num10 = Mathf.Clamp01(1f - (time - _haloRingAt) / 0.8f);
			val10.localRotation = Quaternion.Euler(Mathf.Sin(time * 30f) * 10f * num10, _haloAngle, Mathf.Sin(time * 23f) * 8f * num10);
		}
		if (time >= _nextFlicker)
		{
			_nextFlicker = time + Random.Range(0.03f, 0.12f);
			_flicker = ((!(Random.value < 0.08f)) ? Random.Range(0.85f, 1.05f) : Random.Range(0.05f, 0.4f));
		}
		float num11 = _flicker;
		if (State == 4)
		{
			num11 *= 1f + 4f * Mathf.Clamp01(elapsed / 2.2f);
		}
		if (time < _haloDeadUntil)
		{
			num11 = 0.05f;
		}
		if (time - _hitAt < 0.6f)
		{
			num11 *= Random.value;
		}
		if (Outcome == 1 && State == 4)
		{
			num11 *= 1.3f;
		}
		if ((Object)(object)_haloLight != (Object)null)
		{
			_haloLight.intensity = _haloLightBase * num11;
		}
		Color val11 = Color.Lerp(Color.white, new Color(1.4f, 0.35f, 0.25f), AggroK);
		if ((Object)(object)_haloLight != (Object)null)
		{
			_haloLight.color = Color.Lerp(new Color(1f, 0.88f, 0.55f), new Color(1f, 0.3f, 0.2f), AggroK);
		}
		if ((Object)(object)_haloMat != (Object)null)
		{
			try
			{
				_haloMat.SetColor("_EmissiveColor", _haloEmit * val11 * num11);
			}
			catch
			{
			}
		}
		float num12 = 1f - (time - _flashAt) / 0.9f;
		if ((Object)(object)_flashLight != (Object)null)
		{
			((Behaviour)_flashLight).enabled = num12 > 0f;
			if (num12 > 0f)
			{
				_flashLight.intensity = 400000f * num12 * num12;
			}
		}
	}

	private void Sounds()
	{
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: 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_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Clamp(Plugin.Volume.Value, 0f, 2f) * Mathf.Clamp(Plugin.AngelVolume.Value, 0f, 2f);
		if ((Object)(object)_hum != (Object)null)
		{
			float num2 = ((!(Time.time < _haloDeadUntil)) ? (0.55f * _flicker) : 0f) * ((State != 4) ? 1f : 1.6f);
			_hum.volume = Mathf.MoveTowards(_hum.volume, num2 * num, Time.deltaTime * 4f);
			_hum.pitch = ((State != 4) ? 1f : (1f + Elapsed * 0.08f));
		}
		if (!((Object)(object)_scrape != (Object)null))
		{
			return;
		}
		float num3 = 0f;
		if (State == 5)
		{
			float num4;
			if ((Object)(object)_agent != (Object)null)
			{
				Vector3 velocity = _agent.velocity;
				num4 = ((Vector3)(ref velocity)).magnitude;
			}
			else
			{
				num4 = 1.9f;
			}
			float num5 = num4;
			num3 = 0.85f * Mathf.Clamp01(num5 / 1.2f + 0.3f);
			PlayerControllerB val = Player(Target);
			if ((Object)(object)val != (Object)null)
			{
				((Component)_scrape).transform.position = ((Component)val).transform.position + Vector3.up * 0.2f;
			}
		}
		_scrape.volume = Mathf.MoveTowards(_scrape.volume, num3 * num, Time.deltaTime * 3f);
	}

	internal static void NewDay()
	{
		_rolledToday = false;
		Immune.Clear();
		DeathsSeen.Clear();
		_entrance = null;
	}

	internal static void RollToday()
	{
		if (_rolledToday)
		{
			return;
		}
		_rolledToday = true;
		if (Plugin.AngelEnabled.Value)
		{
			if (Random.Range(0, 100) >= Mathf.Clamp(Plugin.AngelChance.Value, 0, 100))
			{
				Plugin.Log.LogInfo((object)"No angel today.");
				return;
			}
			float num = Random.Range(Mathf.Max(0f, Plugin.AngelDelayMin.Value), Mathf.Max(Plugin.AngelDelayMin.Value, Plugin.AngelDelayMax.Value));
			Plugin.Log.LogInfo((object)("An angel will descend in " + Mathf.RoundToInt(num) + " s."));
			TradeMenu.Runner.StartCoroutine(SpawnLater(num));
		}
	}

	private static IEnumerator SpawnLater(float delay)
	{
		yield return (object)new WaitForSeconds(delay);
		StartOfRound sor = StartOfRound.Instance;
		if (!((Object)(object)sor == (Object)null) && !sor.inShipPhase && !sor.shipIsLeaving && !((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsServer)
		{
			SpawnInside();
		}
	}

	internal static Angel SpawnInside()
	{
		//IL_0017: 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_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: 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)
		GameObject[] array = Peddler.Nodes(outside: false);
		if (array.Length == 0)
		{
			return null;
		}
		StartOfRound instance = StartOfRound.Instance;
		Vector3 at = Vector3.zero;
		float num = -1f;
		for (int i = 0; i < 30; i++)
		{
			GameObject val = array[Random.Range(0, array.Length)];
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			float num2 = 999f;
			PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if ((Object)(object)val2 != (Object)null && val2.isPlayerControlled && !val2.isPlayerDead && val2.isInsideFactory)
				{
					num2 = Mathf.Min(num2, Vector3.Distance(((Component)val2).transform.position, val.transform.position));
				}
			}
			if (!(num2 < 20f))
			{
				float num3 = Mathf.Min(num2, 60f) + Random.value * 5f;
				if (num3 > num)
				{
					num = num3;
					at = val.transform.position;
				}
			}
		}
		return (!(num < 0f)) ? SpawnAt(at) : null;
	}

	internal static Angel SpawnAt(Vector3 at)
	{
		//IL_0000: 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_003a: Unknown result type (might be due to invalid IL or missing references)
		NavMeshHit val = default(NavMeshHit);
		if (!NavMesh.SamplePosition(at, ref val, 4f, -1))
		{
			return null;
		}
		GameObject val2 = Object.Instantiate<GameObject>(Plugin.AngelPrefab, ((NavMeshHit)(ref val)).position, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f));
		val2.GetComponent<NetworkObject>().Spawn(true);
		Plugin.Log.LogInfo((object)"An angel has descended into the facility.");
		return val2.GetComponent<Angel>();
	}

	internal static void DespawnAll()
	{
		Angel[] array = All.ToArray();
		foreach (Angel angel in array)
		{
			try
			{
				if ((Object)(object)angel != (Object)null && ((NetworkBehaviour)angel).IsSpawned)
				{
					((NetworkBehaviour)angel).NetworkObject.Despawn(true);
				}
			}
			catch
			{
			}
		}
	}

	internal static void Patch(Harmony h)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		HarmonyMethod val = new HarmonyMethod(typeof(Angel), "BlockWhileHeld", (Type[])null);
		string[] array = new string[3] { "ActivateItem_performed", "ItemSecondaryUse_performed", "ItemTertiaryUse_performed" };
		foreach (string text in array)
		{
			MethodInfo methodInfo = AccessTools.Method(typeof(PlayerControllerB), text, (Type[])null, (Type[])null);
			if (methodInfo != null)
			{
				h.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}
		MethodInfo methodInfo2 = AccessTools.Method(typeof(StunGrenadeItem), "StunExplosion", (Type[])null, (Type[])null);
		if (methodInfo2 != null)
		{
			MethodInfo methodInfo3 = methodInfo2;
			HarmonyMethod val2 = new HarmonyMethod(typeof(Angel), "AfterStun", (Type[])null);
			h.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
	}

	private static bool BlockWhileHeld(PlayerControllerB __instance)
	{
		return !((Object)(object)LocalCaptor != (Object)null) || !((Object)(object)LocalCaptor._holdingMe == (Object)(object)__instance);
	}

	private static void AfterStun(Vector3 explosionPosition)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer)
			{
				StunAround(explosionPosition, 9f);
			}
		}
		catch
		{
		}
	}

	private bool ThinkExtras(float now)
	{
		if (_nextHoard < 0f)
		{
			_nextHoard = now + Mathf.Max(5f, Plugin.AngelHoardSeconds.Value);
		}
		if (now >= _nextDeathScan)
		{
			_nextDeathScan = now + 0.5f;
			if (ScanForTheDead())
			{
				return true;
			}
		}
		return false;
	}

	private void ThinkMore(PlayerControllerB v, float e, float now, bool roundOver)
	{
		switch (State)
		{
		case 10:
			Summoning(e);
			break;
		case 11:
			Carrying(v, e, now);
			break;
		case 12:
			Fetching(now);
			break;
		case 13:
			Delivering(now);
			break;
		default:
			SetState(0, -1);
			break;
		}
	}

	private void Transfigure()
	{
		StartOfRound instance = StartOfRound.Instance;
		List<int> list = new List<int>();
		for (int i = 0; i < instance.allPlayerScripts.Length; i++)
		{
			PlayerControllerB val = instance.allPlayerScripts[i];
			if (i != Target && !((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead && !val.inTerminalMenu && !val.isClimbingLadder && !val.inSpecialInteractAnimation)
			{
				list.Add(i);
			}
		}
		if (list.Count == 0)
		{
			Net2.Fx(this, 10, 0);
			Release(grantImmunity: true);
			Bow();
			return;
		}
		int num = list[Random.Range(0, list.Count)];
		Plugin.Log.LogInfo((object)("Angel: Transfiguration - " + Player(Target).playerUsername + " and " + Player(num).playerUsername + " swap places."));
		Net2.Fx(this, 20, Target * 64 + num);
		Release(grantImmunity: true);
		Immune[num] = Time.time + Mathf.Max(0f, Plugin.AngelImmunity.Value);
		Bow();
	}

	private void SwapPlaces(PlayerControllerB a, PlayerControllerB b)
	{
		//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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)a == (Object)null || (Object)(object)b == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)a).transform.position;
		Vector3 position2 = ((Component)b).transform.position;
		bool isInsideFactory = a.isInsideFactory;
		bool isInElevator = a.isInElevator;
		bool isInHangarShipRoom = a.isInHangarShipRoom;
		bool isInsideFactory2 = b.isInsideFactory;
		bool isInElevator2 = b.isInElevator;
		bool isInHangarShipRoom2 = b.isInHangarShipRoom;
		PlayerControllerB local = Peddler.Local;
		try
		{
			if ((Object)(object)local == (Object)(object)a)
			{
				ReleaseLocal();
				a.fallValue = 0f;
				a.fallValueUncapped = 0f;
				Teleport.To(a, position2, isInsideFactory2, isInElevator2, isInHangarShipRoom2);
			}
			else
			{
				a.isInsideFactory = isInsideFactory2;
				a.isInElevator = isInElevator2;
				a.isInHangarShipRoom = isInHangarShipRoom2;
			}
			if ((Object)(object)local == (Object)(object)b)
			{
				b.fallValue = 0f;
				b.fallValueUncapped = 0f;
				Teleport.To(b, position, isInsideFactory, isInElevator, isInHangarShipRoom);
			}
			else
			{
				b.isInsideFactory = isInsideFactory;
				b.isInElevator = isInElevator;
				b.isInHangarShipRoom = isInHangarShipRoom;
			}
			if ((Object)(object)local == (Object)(object)a || (Object)(object)local == (Object)(object)b)
			{
				try
				{
					HUDManager.Instance.DisplayTip("Transfiguration", "You are somewhere else. Someone else is where you were.", false, false, "LC_Tip1");
					return;
				}
				catch
				{
					return;
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("Angel swap: " + ex.Message));
		}
	}

	private bool ScanForTheDead()
	{
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return false;
		}
		for (int i = 0; i < instance.allPlayerScripts.Length; i++)
		{
			PlayerControllerB val = instance.allPlayerScripts[i];
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			if (!val.isPlayerDead)
			{
				DeathsSeen.Remove(i);
			}
			else
			{
				if (DeathsSeen.Contains(i) || (Object)(object)val.deadBody == (Object)null)
				{
					continue;
				}
				DeathsSeen.Add(i);
				if (Plugin.AngelReviveEnabled.Value)
				{
					if (Random.Range(0, 100) >= Mathf.Clamp(Plugin.AngelReviveChance.Value, 0, 100))
					{
						Plugin.Log.LogInfo((object)("Angel: it does not come for " + val.playerUsername + "."));
					}
					else if (!Free())
					{
						Plugin.Log.LogInfo((object)("Angel: busy - " + val.playerUsername + " stays dead."));
					}
					else if (BodyCanBeClaimed(val.deadBody))
					{
						BeginSummon(i);
						return true;
					}
				}
			}
		}
		return false;
	}

	private bool Free()
	{
		return State == 0 || State == 9 || State == 12 || State == 13 || State == 1 || State == 2;
	}

	private static bool BodyCanBeClaimed(DeadBodyInfo body)
	{
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)body == (Object)null || body.deactivated || body.isInShip || body.parentedToShip)
		{
			return false;
		}
		if ((Object)(object)body.grabBodyObject != (Object)null && body.grabBodyObject.isHeld)
		{
			return false;
		}
		return ((body.bodyParts == null || body.bodyParts.Length <= 0 || !((Object)(object)body.bodyParts[0] != (Object)null)) ? ((Component)body).transform.position : body.bodyParts[0].position).y < -80f;
	}

	private void BeginSummon(int who)
	{
		//IL_0018: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_carried != (Object)null)
		{
			DropCarried(((Component)this).transform.position + ((Component)this).transform.forward * 0.5f);
		}
		Plugin.Log.LogInfo((object)("Angel: it raises its arms and calls " + Player(who).playerUsername + "'s body to it."));
		SetState(10, who);
		Stop();
		Net2.Fx(this, 21, who);
		try
		{
			DeadBodyInfo deadBody = Player(who).deadBody;
			if ((Object)(object)deadBody != (Object)null && (Object)(object)deadBody.grabBodyObject != (Object)null && (Object)(object)((NetworkBehaviour)deadBody.grabBodyObject).NetworkObject != (Object)null && ((NetworkBehaviour)deadBody.grabBodyObject).NetworkObject.IsSpawned)
			{
				((NetworkBehaviour)deadBody.grabBodyObject).NetworkObject.Despawn(true);
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("Angel: couldn't remove the body item: " + ex.Message));
		}
	}

	private void Summoning(float e)
	{
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		Stop();
		PlayerControllerB val = Player(Target);
		if ((Object)(object)val == (Object)null || !val.isPlayerDead)
		{
			Recover(4f);
		}
		else if (_fxStep == 0 && e >= 1.6f)
		{
			_fxStep = 1;
			Net2.Fx(this, 22, Target);
			SetState(11, Target);
			_carryUntil = Time.time + Mathf.Clamp(Plugin.AngelCarrySeconds.Value, 3f, 120f);
			_stuckAt = ((Component)this).transform.position;
			_stuckSince = Time.time;
			CarryLeg();
		}
	}

	private void Carrying(PlayerControllerB v, float e, float now)
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		_agent.isStopped = false;
		_agent.speed = Mathf.Clamp(Plugin.AngelCarrySpeed.Value, 1f, 8f);
		if (!_agent.pathPending && _agent.remainingDistance < 1f)
		{
			CarryLeg();
		}
		if (Vector3.Distance(((Component)this).transform.position, _stuckAt) > 0.6f)
		{
			_stuckAt = ((Component)this).transform.position;
			_stuckSince = now;
		}
		else if (now - _stuckSince > 4f)
		{
			Release(grantImmunity: true);
			Bow();
			return;
		}
		if (now >= _carryUntil)
		{
			Plugin.Log.LogInfo((object)("Angel: it sets " + v.playerUsername + " down, gently."));
			Release(grantImmunity: true);
			Bow();
		}
	}

	private void CarryLeg()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		GameObject[] array = Peddler.Nodes(outside: false);
		StartOfRound instance = StartOfRound.Instance;
		Vector3 to = Vector3.zero;
		float num = -1f;
		for (int i = 0; i < 24; i++)
		{
			if (array.Length <= 0)
			{
				break;
			}
			GameObject val = array[Random.Range(0, array.Length)];
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			Vector3 position = val.transform.position;
			float num2 = Vector3.Distance(position, ((Component)this).transform.position);
			if (num2 < 12f || num2 > 55f)
			{
				continue;
			}
			float num3 = 999f;
			for (int j = 0; j < instance.allPlayerScripts.Length; j++)
			{
				PlayerControllerB val2 = instance.allPlayerScripts[j];
				if (j != Target && !((Object)(object)val2 == (Object)null) && val2.isPlayerControlled && !val2.isPlayerDead)
				{
					num3 = Mathf.Min(num3, Vector3.Distance(((Component)val2).transform.position, position));
				}
			}
			float num4 = Mathf.Min(num3, 80f) + Random.value * 6f;
			if (num4 > num)
			{
				num = num4;
				to = position;
			}
		}
		if (num < 0f || !TryPath(to))
		{
			Wander();
		}
	}

	internal static void ReviveLocal(PlayerControllerB p, Vector3 at)
	{
		//IL_000e: 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 r