Decompiled source of Bronobi v1.0.1

UMM/BroMaker_Storage/Bronobi/Bronobi.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BroMakerLib;
using BroMakerLib.Abilities;
using BroMakerLib.Attributes;
using BroMakerLib.CustomObjects.Bros;
using BroMakerLib.Infos;
using BroMakerLib.Loggers;
using RocketLib;
using UnityEngine;
using World.Generation.MapGenV4;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Bronobi")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Bronobi")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b07fb4dd-0bc1-4b64-83ea-850bd5d8b914")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BronobiMod
{
	[HeroPreset(/*Could not decode attribute arguments.*/)]
	public class Bronobi : SwordHero
	{
		public BronobiForceWave forceWave;

		public MindControlWave mindControlforceWave;

		protected Texture2D _waveTexture;

		protected float _controlTime = 10f;

		public BronobiGhost Ghost;

		protected Texture2D ghostSprite;

		protected Vector3 _ghostSpawnOffset = new Vector3(0f, 16f);

		protected Texture originalGunSprite;

		protected Texture2D gunGrabSprite;

		protected Vector2 grabDistance = new Vector2(5f, 2f);

		protected Vector3 _grabOffset = new Vector3(1.5f, 0.1f, 0f);

		protected Mook _grabbedMook;

		protected float _grabbedMookControlTime = 5f;

		protected int _grabbedOriginalNum;

		protected float _grabBossTime = 1f;

		protected bool _grabbedBoss;

		protected Vector2Int _specialAnimationPosition = new Vector2Int(0, 9);

		protected float _specialAnimationRate = 0.0434f;

		protected AudioClip _forcePush;

		public void SetupGrabedUnit(Mook mook)
		{
			if (!((Object)(object)_grabbedMook != (Object)null))
			{
				_grabbedMook = mook;
				_grabbedOriginalNum = ((NetworkedUnit)_grabbedMook).playerNum;
				((NetworkedUnit)_grabbedMook).playerNum = ((NetworkedUnit)this).playerNum;
				((BroforceObject)_grabbedMook).X = ((BroforceObject)this).X + _grabOffset.x;
				((BroforceObject)_grabbedMook).Y = ((BroforceObject)this).Y + _grabOffset.y;
				((BroforceObject)_grabbedMook).xI = 0f;
				((BroforceObject)_grabbedMook).yI = 0f;
				Mook grabbedMook = _grabbedMook;
				if (Object.op_Implicit((Object)(object)((grabbedMook is AlienClimber) ? grabbedMook : null)))
				{
					((Mook)ObjectExtensions.As<AlienClimber>((object)_grabbedMook)).ForceClimbing(false, false, false);
				}
			}
		}

		public void UngrabMook(bool setPlayernum = true)
		{
			if (!((Object)(object)_grabbedMook == (Object)null))
			{
				if (setPlayernum && (ObjectExtensions.NotAs<MookArmouredGuy>((object)_grabbedMook) || ObjectExtensions.NotAs<BroBase>((object)ObjectExtensions.As<MookArmouredGuy>((object)_grabbedMook).pilotUnit)))
				{
					((NetworkedUnit)_grabbedMook).playerNum = _grabbedOriginalNum;
					_grabbedMook.firingPlayerNum = _grabbedOriginalNum;
				}
				SpriteSMExtensions.SetTexture(((TestVanDammeAnim)this).gunSprite, originalGunSprite);
				_grabbedMook = null;
				_grabbedBoss = false;
			}
		}

		public override void UIOptions()
		{
			Config.UI();
		}

		protected override void Awake()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((BroBase)this).meleeType = (MeleeType)5;
			((SwordHero)this).Awake();
			ghostSprite = ResourcesController.GetTexture(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "Bronobi_Ghost_anim.png");
			try
			{
				((TestVanDammeAnim)this).soundHolder.attackSounds = (AudioClip[])(object)new AudioClip[2]
				{
					ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "saber_swing_1.wav"),
					ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "saber_swing_2.wav")
				};
				((TestVanDammeAnim)this).soundHolder.hitSounds = (AudioClip[])(object)new AudioClip[4]
				{
					ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "saber_hit_0t.wav"),
					ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "saber_hit_1t.wav"),
					ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "saber_hit_2t.wav"),
					ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "saber_hit_3t.wav")
				};
				((TestVanDammeAnim)this).soundHolder.special2Sounds = ((TestVanDammeAnim)this).soundHolder.hitSounds;
				((TestVanDammeAnim)this).soundHolder.defendSounds = ((TestVanDammeAnim)this).soundHolder.hitSounds;
				((TestVanDammeAnim)this).soundHolder.special4Sounds = (AudioClip[])(object)new AudioClip[1] { ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "saber_hit_bullet.wav") };
				((TestVanDammeAnim)this).soundHolder.specialAttackSounds = (AudioClip[])(object)new AudioClip[3]
				{
					ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "force_1.wav"),
					ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "force_2.wav"),
					ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "force_3.wav")
				};
				_forcePush = ResourcesController.GetAudioClip(((CustomBroforceObjectInfo)((CustomHero)this).Info).path, "force_push.wav");
			}
			catch (Exception ex)
			{
				BMLogger.Log(ex, true);
			}
		}

		protected override void Start()
		{
			((CustomHero)this).Start();
			originalGunSprite = SpriteSMExtensions.GetTexture(((TestVanDammeAnim)this).gunSprite);
		}

		protected override void Update()
		{
			((BroBase)this).Update();
			if (!((Object)(object)_grabbedMook == (Object)null))
			{
				if (!((BroforceObject)_grabbedMook).IsAlive())
				{
					UngrabMook();
				}
				if (_grabbedBoss && (_grabBossTime -= Time.deltaTime) < 0f)
				{
					UngrabMook();
					return;
				}
				((BroforceObject)_grabbedMook).X = ((BroforceObject)this).X + _grabOffset.x * (float)((NetworkedUnit)this).Direction * 16f;
				((BroforceObject)_grabbedMook).Y = ((BroforceObject)this).Y + _grabOffset.y * 16f;
				((BroforceObject)_grabbedMook).xI = 0f;
				((BroforceObject)_grabbedMook).yI = 0f;
				((Unit)_grabbedMook).ForceFaceDirection(((NetworkedUnit)this).Direction);
			}
		}

		protected override void SetupThrownMookVelocity(out float XI, out float YI)
		{
			((BroBase)this).SetupThrownMookVelocity(ref XI, ref YI);
			XI *= 1.2f;
			YI *= 1.2f;
		}

		public override void Death(float xI, float yI, DamageObject damage)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			UngrabMook();
			((BroBase)this).Death(xI, yI, damage);
			if ((Object)(object)Ghost != (Object)null)
			{
				return;
			}
			try
			{
				Ghost = BronobiGhost.CreateAGhost(ghostSprite, ((BroforceObject)this).X, ((BroforceObject)this).Y, ((Renderer)((TestVanDammeAnim)this).Renderer).material, ((Component)this).gameObject.layer);
				((Component)Ghost).transform.parent = ((Component)this).transform.parent;
				((Component)Ghost).transform.localPosition = ((Component)this).transform.localPosition + _ghostSpawnOffset;
			}
			catch (Exception ex)
			{
				BMLogger.ExceptionLog((object)ex, true);
			}
		}

		protected override void PressHighFiveMelee(bool forceHighFive = false)
		{
			//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)
			if ((Object)(object)_grabbedMook != (Object)null)
			{
				if (!_grabbedBoss && (ObjectExtensions.NotAs<MookArmouredGuy>((object)_grabbedMook) || ObjectExtensions.NotAs<BroBase>((object)ObjectExtensions.As<MookArmouredGuy>((object)_grabbedMook).pilotUnit)))
				{
					float num = default(float);
					float num2 = default(float);
					((TestVanDammeAnim)this).SetupThrownMookVelocity(ref num, ref num2);
					_grabbedMook.isBeingThrown = true;
					((BroforceObject)_grabbedMook).xI = num;
					((BroforceObject)_grabbedMook).yI = num2;
					_grabbedMook.SetBackFlyingFrame(num, num2);
					((Component)_grabbedMook).transform.parent = ((Component)this).transform.parent;
					((TestVanDammeAnim)_grabbedMook).Reenable();
					_grabbedMook.StartFallingScream();
					((TestVanDammeAnim)_grabbedMook).EvaluateIsJumping();
					_grabbedMook.ThrowMook(false, ((NetworkedUnit)this).playerNum);
					((TestVanDammeAnim)this).sound.PlayAudioClip(_forcePush, Vector2.op_Implicit(((NetworkedUnit)this).XY), 0.7f, 1f, true, false, 0f, false, false);
				}
				UngrabMook();
			}
			else
			{
				((TestVanDammeAnim)this).PressHighFiveMelee(forceHighFive);
			}
		}

		protected override void StartMelee()
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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_01ce: Expected I4, but got Unknown
			((TestVanDammeAnim)this).counter = 0f;
			((BroBase)this).currentMeleeType = ((BroBase)this).meleeType;
			RaycastHit val = default(RaycastHit);
			if ((Physics.Raycast(new Vector3(((BroforceObject)this).X, ((BroforceObject)this).Y + 5f, 0f), Vector3.down, ref val, 16f, LayerMask.op_Implicit(((TestVanDammeAnim)this).platformLayer)) || Physics.Raycast(new Vector3(((BroforceObject)this).X + 4f, ((BroforceObject)this).Y + 5f, 0f), Vector3.down, ref val, 16f, LayerMask.op_Implicit(((TestVanDammeAnim)this).platformLayer)) || Physics.Raycast(new Vector3(((BroforceObject)this).X - 4f, ((BroforceObject)this).Y + 5f, 0f), Vector3.down, ref val, 16f, LayerMask.op_Implicit(((TestVanDammeAnim)this).platformLayer))) && (Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Animal>() != (Object)null)
			{
				((BroBase)this).currentMeleeType = (MeleeType)0;
			}
			else
			{
				Mook nearbyMook = Map.GetNearbyMook(grabDistance.x * 16f, grabDistance.y * 16f, ((BroforceObject)this).X, ((BroforceObject)this).Y, ((NetworkedUnit)this).Direction, false);
				if ((Object)(object)nearbyMook != (Object)null && ((Component)nearbyMook).gameObject.activeSelf && ((NetworkedUnit)nearbyMook).playerNum < 0)
				{
					SetupGrabedUnit(nearbyMook);
					SpriteSMExtensions.SetTexture(((TestVanDammeAnim)this).gunSprite, gunGrabSprite);
					if (BroMakerUtilities.IsBoss((Unit)(object)nearbyMook))
					{
						_grabbedBoss = true;
						_grabBossTime = 1f;
					}
					return;
				}
			}
			MeleeType currentMeleeType = ((BroBase)this).currentMeleeType;
			switch ((int)currentMeleeType)
			{
			case 0:
				((BroBase)this).StartKnifeMelee();
				break;
			case 1:
			case 15:
				((BroBase)this).StartPunch();
				break;
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:
			case 9:
			case 10:
			case 11:
			case 12:
			case 13:
			case 14:
				((BroBase)this).StartCustomMelee();
				break;
			}
		}

		protected override void FireWeapon(float x, float y, float xSpeed, float ySpeed)
		{
			if (Object.op_Implicit((Object)(object)_grabbedMook))
			{
				if (!_grabbedBoss && (ObjectExtensions.NotAs<MookArmouredGuy>((object)_grabbedMook) || ObjectExtensions.NotAs<BroBase>((object)ObjectExtensions.As<MookArmouredGuy>((object)_grabbedMook).pilotUnit)))
				{
					_grabbedMook.Gib();
				}
				UngrabMook();
			}
			else
			{
				((SwordHero)this).FireWeapon(x, y, xSpeed, ySpeed);
			}
		}

		protected override void UseSpecial()
		{
			if (Object.op_Implicit((Object)(object)_grabbedMook))
			{
				if (!Object.op_Implicit((Object)(object)ObjectExtensions.As<Satan>((object)_grabbedMook)) && !_grabbedBoss && (ObjectExtensions.NotAs<MookArmouredGuy>((object)_grabbedMook) || ObjectExtensions.NotAs<BroBase>((object)ObjectExtensions.As<MookArmouredGuy>((object)_grabbedMook).pilotUnit)))
				{
					ControlMook(_grabbedMook, _grabbedOriginalNum);
					UngrabMook(setPlayernum: false);
				}
				else
				{
					UngrabMook();
				}
			}
			else if (((TestVanDammeAnim)this).SpecialAmmo > 0)
			{
				((TestVanDammeAnim)this).PlaySpecialAttackSound(0.8f);
				int specialAmmo = ((TestVanDammeAnim)this).SpecialAmmo;
				((TestVanDammeAnim)this).SpecialAmmo = specialAmmo - 1;
				if (((NetworkObject)this).IsMine)
				{
					((TestVanDammeAnim)this).TriggerBroSpecialEvent();
					mindControlforceWave = MindControlWave.CreateMindControleWave((TestVanDammeAnim)(object)this, _waveTexture, _controlTime);
				}
				((TestVanDammeAnim)this).pressSpecialFacingDirection = 0;
			}
			else
			{
				HeroController.FlashSpecialAmmo(((NetworkedUnit)this).playerNum);
				((TestVanDammeAnim)this).ActivateGun();
			}
		}

		protected override void CalculateMovement()
		{
			if (((TestVanDammeAnim)this).usingSpecial && ((TestVanDammeAnim)this).SpecialAmmo > 0)
			{
				((BroforceObject)this).xI = 0f;
				((BroforceObject)this).yI = 0f;
			}
			else
			{
				((TestVanDammeAnim)this).CalculateMovement();
			}
		}

		protected override void AnimateSpecial()
		{
			((TestVanDammeAnim)this).SetSpriteOffset(0f, 0f);
			((TestVanDammeAnim)this).DeactivateGun();
			((TestVanDammeAnim)this).frameRate = _specialAnimationRate;
			int num = ((Vector2Int)(ref _specialAnimationPosition)).x + Mathf.Clamp(((Unit)this).frame, 0, 8);
			int y = ((Vector2Int)(ref _specialAnimationPosition)).y;
			((TestVanDammeAnim)this).sprite.SetLowerLeftPixel((float)(num * ((TestVanDammeAnim)this).spritePixelWidth), (float)(((TestVanDammeAnim)this).spritePixelHeight * y));
			if (((Unit)this).frame == 6)
			{
				((TestVanDammeAnim)this).UseSpecial();
			}
			if (((Unit)this).frame >= 8)
			{
				((Unit)this).frame = 0;
				((TestVanDammeAnim)this).usingSpecial = (((TestVanDammeAnim)this).usingPockettedSpecial = false);
				((TestVanDammeAnim)this).ActivateGun();
				((TestVanDammeAnim)this).ChangeFrame();
			}
		}

		protected virtual void ControlMook(Mook mook, int mookNum)
		{
			MindControlEffect mindControlEffect = ((Component)mook).gameObject.AddComponent<MindControlEffect>();
			mindControlEffect.Setup((TestVanDammeAnim)(object)this, mookNum, _controlTime);
		}
	}
	public class BronobiForceWave : FlameWallExplosion
	{
		public static void CallMethod(TestVanDammeAnim testVanDammeAnim)
		{
			//IL_0018: 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)
			BronobiForceWave bronobiForceWave = new GameObject("BronobiForceWave", new Type[1] { typeof(Transform) }).AddComponent<BronobiForceWave>();
			((Component)bronobiForceWave).transform.position = ((Component)testVanDammeAnim).transform.position;
			((FlameWallExplosion)bronobiForceWave).Setup(((NetworkedUnit)testVanDammeAnim).playerNum, (MonoBehaviour)(object)testVanDammeAnim, (DirectionEnum)1);
		}

		protected override void TryAssassinateUnits(float x, float y, int xRange, int yRange, int playerNum)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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)
			Mook nearbyMook = Map.GetNearbyMook((float)xRange, (float)yRange, x, y, ((int)base.forceDirection != 4) ? 1 : (-1), true);
			if (Object.op_Implicit((Object)(object)nearbyMook))
			{
				float num = Mathf.Sign(((Component)base.firedBy).transform.localScale.x) * 310f;
				MonoBehaviour firedBy = base.firedBy;
				float num2 = num + ((BroforceObject)((firedBy is TestVanDammeAnim) ? firedBy : null)).xI * 0.2f;
				MonoBehaviour firedBy2 = base.firedBy;
				float num3 = 220f + ((BroforceObject)((firedBy2 is TestVanDammeAnim) ? firedBy2 : null)).yI * 0.3f;
				((BroforceObject)nearbyMook).xI = num2;
				((BroforceObject)nearbyMook).yI = num3;
				nearbyMook.SetBackFlyingFrame(num2, num3);
				((Component)nearbyMook).transform.parent = ((Component)base.firedBy).transform.parent;
				((TestVanDammeAnim)nearbyMook).Reenable();
				nearbyMook.StartFallingScream();
				((TestVanDammeAnim)nearbyMook).EvaluateIsJumping();
				nearbyMook.ThrowMook(false, base.playerNum);
				((Unit)nearbyMook).Blind(10f);
			}
			int playerNum2 = base.playerNum;
			float num4 = ((BroforceObject)/*isinst with value type is only supported in some contexts*/).X + Mathf.Sign(((Component)this).transform.localScale.x) * 6f;
			MonoBehaviour firedBy3 = base.firedBy;
			Map.DeflectProjectiles((MonoBehaviour)(object)this, playerNum2, 16f, num4, ((BroforceObject)((firedBy3 is TestVanDammeAnim) ? firedBy3 : null)).Y + 6f, Mathf.Sign(((Component)this).transform.localScale.x) * 200f, true);
		}

		private void Awake()
		{
			try
			{
				base.assasinateUnits = true;
				base.damageDoodads = false;
				base.damageGround = false;
				base.damageUnits = false;
				base.knockUnits = false;
				base.blindUnits = false;
				base.maxCollumns = 32;
				base.maxRows = 3;
				base.rotateExplosionSprite = true;
				base.totalExplosions = 60;
				base.explosionRate = 0.04f;
			}
			catch (Exception arg)
			{
				BMLogger.Log($"[{typeof(BronobiForceWave)}] {arg}", (LogType)3, true);
			}
		}

		public void Setup(Texture2D texture)
		{
			try
			{
				base.lightExplosion = MindControlWave.GetForceWavePuff(texture);
				TestVanDammeAnim heroPrefab = HeroController.GetHeroPrefab((HeroType)35);
				MatildaTargettingWave matildaTargettingWavePrefab = ((TheBrofessional)((heroPrefab is TheBrofessional) ? heroPrefab : null)).matildaTargettingWavePrefab;
				base.flashBangSoundHolder = ((FlameWallExplosion)matildaTargettingWavePrefab).flashBangSoundHolder;
			}
			catch (Exception arg)
			{
				BMLogger.Log($"[{typeof(BronobiForceWave)}] {arg}", (LogType)3, true);
			}
		}
	}
	public enum GhostState
	{
		Starting,
		Idle,
		Gift,
		Leaving
	}
	public enum GhostGift
	{
		Life,
		Special,
		FlexPower,
		Pig,
		Perk,
		Pocketted,
		Drone
	}
	public class BronobiGhost : MonoBehaviour
	{
		private const int spawnAnimEndCol = 7;

		public Texture texture;

		public float X;

		public float Y;

		private GhostState state;

		private int row = 1;

		private int col = 1;

		private int spriteSize = 32;

		private float fps = 0.085f;

		private float time;

		private float giftRange = 30f;

		private int _giftedPlayer;

		private List<GhostGift> _gifts;

		protected int _nextBroRevive = -1;

		public SpriteSM Sprite { get; private set; }

		public static BronobiGhost CreateAGhost(Texture2D sprite, float X, float Y, Material mat, int layer)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			GameObject val = new GameObject("BronobiGhost", new Type[1] { typeof(MeshRenderer) });
			val.transform.position = new Vector3(X, Y, 0f);
			val.layer = layer;
			val.GetComponent<Renderer>().material = new Material(mat);
			val.GetComponent<Renderer>().material.SetTexture("_MainTex", (Texture)(object)sprite);
			BronobiGhost bronobiGhost = val.AddComponent<BronobiGhost>();
			bronobiGhost.Setup(X, Y);
			return bronobiGhost;
		}

		public void Setup(float X, float Y)
		{
			this.X = X;
			this.Y = Y;
		}

		private void Update()
		{
			time -= Time.deltaTime;
			if (time < 0f)
			{
				Animate();
				time = fps;
			}
			if (state == GhostState.Idle)
			{
				int actualNearestPlayer = HeroController.GetActualNearestPlayer(X, Y, giftRange, giftRange);
				if (actualNearestPlayer != -1 && HeroController.PlayerIsAlive(actualNearestPlayer) && DetermineGifts(actualNearestPlayer))
				{
					_giftedPlayer = actualNearestPlayer;
					state = GhostState.Gift;
					ForceAnimate();
				}
			}
		}

		private void Awake()
		{
			time = fps;
			Sprite = GameObjectExtensions.GetOrAddComponent<SpriteSM>(((Component)this).gameObject);
			Sprite.SetTextureDefaults();
			Sprite.SetPixelDimensions(spriteSize, spriteSize);
			((SpriteBase)Sprite).SetSize((float)spriteSize, (float)spriteSize);
			Sprite.SetLowerLeftPixel(0f, (float)spriteSize);
		}

		private void ForceAnimate()
		{
			time = fps;
			Animate();
		}

		private void Animate()
		{
			switch (state)
			{
			case GhostState.Starting:
				AnimateStarting();
				break;
			case GhostState.Idle:
				AnimateIdle();
				break;
			case GhostState.Gift:
				AnimateGift();
				break;
			case GhostState.Leaving:
				AnimateLeaving();
				break;
			}
		}

		private void AnimateStarting()
		{
			col++;
			Sprite.SetLowerLeftPixel((float)(col * spriteSize), (float)(row * spriteSize));
			if (col == 7)
			{
				state = GhostState.Idle;
			}
		}

		private void AnimateIdle()
		{
			if (col == 15)
			{
				col = 7;
			}
			else
			{
				col++;
			}
			Sprite.SetLowerLeftPixel((float)(col * spriteSize), (float)(row * spriteSize));
		}

		private void AnimateGift()
		{
			col++;
			if (col < 16)
			{
				col = 16;
			}
			Sprite.SetLowerLeftPixel((float)(col * spriteSize), (float)(row * spriteSize));
			if (col == 21)
			{
				Gift();
			}
			_ = col;
			_ = 23;
		}

		private bool DetermineGifts(int playerNum)
		{
			_gifts = new List<GhostGift>();
			TestVanDammeAnim character = HeroController.players[playerNum].character;
			if (Config.refillAmmos && character.SpecialAmmo < character.originalSpecialAmmo)
			{
				_gifts.Add(GhostGift.Special);
			}
			if (Config.giveFlexPower && !character.player.HasFlexPower())
			{
				_gifts.Add(GhostGift.FlexPower);
			}
			if (Config.givePockettedAmmo && IEnumerableExtensions.IsNullOrEmpty<PockettedSpecialAmmoType>((IEnumerable<PockettedSpecialAmmoType>)TestVanDammeAnimExtensions.AsBroBase(character).pockettedSpecialAmmo))
			{
				_gifts.Add(GhostGift.Pocketted);
			}
			if (Config.addLife && character.player.Lives < 4)
			{
				_gifts.Add(GhostGift.Life);
			}
			if (Config.useProcGen && ProcGenGameMode.UseProcGenRules)
			{
				_gifts.Add(GhostGift.Perk);
			}
			if (Config.spawnPig && Random.value > 0.2f)
			{
				_gifts.Add(GhostGift.Pig);
			}
			if (Config.spawnDrone)
			{
				_gifts.Add(GhostGift.Drone);
			}
			return IEnumerableExtensions.IsNotNullOrEmpty<GhostGift>((IEnumerable<GhostGift>)_gifts);
		}

		private int GetFirstPlayerDead()
		{
			if (HeroController.GetPlayersAliveCount() < 1)
			{
				return -1;
			}
			if (IEnumerableExtensions.IsNullOrEmpty<int>((IEnumerable<int>)HeroController.Instance.playerDeathOrder))
			{
				return -1;
			}
			int result = -1;
			while (HeroController.Instance.playerDeathOrder.Count != 0)
			{
				int num = HeroController.Instance.playerDeathOrder[0];
				HeroController.Instance.playerDeathOrder.RemoveAt(0);
				if ((Object)(object)HeroController.players[num] != (Object)null && HeroController.IsPlayerPlaying(num) && !HeroController.players[num].IsAlive())
				{
					result = num;
					break;
				}
			}
			return result;
		}

		private void Gift()
		{
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected I4, but got Unknown
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			if (_giftedPlayer == -1 || IEnumerableExtensions.IsNullOrEmpty<GhostGift>((IEnumerable<GhostGift>)_gifts))
			{
				return;
			}
			TestVanDammeAnim character = HeroController.players[_giftedPlayer].character;
			int index = Random.Range(0, _gifts.Count);
			switch (_gifts[index])
			{
			case GhostGift.Life:
				character.player.AddLife();
				break;
			case GhostGift.Special:
				character.AddSpecialAmmo();
				break;
			case GhostGift.Pig:
				MapController.SpawnTestVanDamme_Networked(Map.Instance.activeTheme.animals[0].GetComponent<TestVanDammeAnim>(), X, Y, 0f, 0f, false, false, false, false);
				break;
			case GhostGift.FlexPower:
			{
				Pickupable val3 = PickupableController.CreateGoldenPrizePickupable(X, Y, (PickupType)0);
				Registry.RegisterDeterminsiticGameObject(((Component)val3).gameObject);
				val3.Launch(X, Y, 0f, 0f);
				EffectsController.CreatePuffDisappearRingEffect(X, Y, 0f, 0f);
				break;
			}
			case GhostGift.Pocketted:
			{
				Pickupable val = null;
				PockettedSpecialAmmoType val2 = (PockettedSpecialAmmoType)Random.Range(2, 8);
				switch (val2 - 2)
				{
				case 1:
					val = PickupableController.CreateTimeSlowAmmoBox(X, Y);
					val.pickupType = (PickupType)3;
					break;
				case 2:
					val = PickupableController.CreateRCCarAmmoBox(X, Y);
					val.pickupType = (PickupType)2;
					break;
				case 0:
					val = PickupableController.CreateAirstrikeAmmoBox(X, Y);
					val.pickupType = (PickupType)4;
					break;
				case 3:
					val = PickupableController.CreateMechDropAmmoBox(X, Y);
					val.pickupType = (PickupType)5;
					break;
				case 4:
					val = PickupableController.CreateAlienPheromonesAmmoBox(X, Y);
					val.pickupType = (PickupType)6;
					break;
				default:
					val = PickupableController.CreateSteroidsAmmoBox(X, Y);
					val.pickupType = (PickupType)7;
					break;
				}
				val.Launch(X, Y, 0f, 100f);
				EffectsController.CreatePuffDisappearRingEffect(X, Y, 0f, 0f);
				break;
			}
			case GhostGift.Drone:
				HarmonyExtensions.CallMethod((object)character, "SpawnDrone", new object[0]);
				break;
			case GhostGift.Perk:
				break;
			}
		}

		private void AnimateLeaving()
		{
		}
	}
	internal static class Config
	{
		public static bool addLife = true;

		public static bool refillAmmos = true;

		public static bool givePockettedAmmo = true;

		public static bool giveFlexPower = true;

		public static bool respawnFriend = true;

		public static bool useProcGen = false;

		public static bool spawnDrone = false;

		public static bool spawnPig = false;

		public static SoundHolder CopySoundHolder(SoundHolder source)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			SoundHolder val = new SoundHolder();
			val.alienBurst = source.alienBurst;
			val.alternateMeleeHitSound = source.alternateMeleeHitSound;
			val.alternateMeleeHitSound2 = source.alternateMeleeHitSound2;
			val.attack2Sounds = source.attack2Sounds;
			val.attack3Sounds = source.attack3Sounds;
			val.attack4Sounds = source.attack4Sounds;
			val.attackSounds = source.attackSounds;
			val.attractSounds = source.attractSounds;
			val.bassDrop = source.bassDrop;
			val.bleedSounds = source.bleedSounds;
			val.burnSounds = source.burnSounds;
			val.chokeSounds = source.chokeSounds;
			val.confused = source.confused;
			val.dashSounds = source.dashSounds;
			val.deathGargleSounds = source.deathGargleSounds;
			val.defendSounds = source.deathGargleSounds;
			val.hitSounds = source.hitSounds;
			val.effortSounds = source.effortSounds;
			val.specialSounds = source.specialSounds;
			val.special2Sounds = source.special2Sounds;
			val.special3Sounds = source.special3Sounds;
			val.special4Sounds = source.special4Sounds;
			val.specialAttackSounds = source.specialAttackSounds;
			val.powerUp = source.powerUp;
			val.panic = source.panic;
			val.greeting = source.greeting;
			val.missSounds = source.missSounds;
			val.meleeHitSound = source.meleeHitSound;
			val.fallHitSound = source.fallHitSound;
			val.knockedSounds = source.knockedSounds;
			val.fizzleSounds = source.fizzleSounds;
			val.zappedSounds = source.zappedSounds;
			val.throwSounds = source.throwSounds;
			val.dismemberSounds = source.dismemberSounds;
			val.deathGargleSounds = source.deathGargleSounds;
			val.dizzieSounds = source.dizzieSounds;
			val.muffledScreams = source.muffledScreams;
			val.resurrectSounds = source.resurrectSounds;
			val.laughSounds = source.laughSounds;
			val.fallSounds = source.fallSounds;
			val.hurtSounds = source.hurtSounds;
			val.meleeHitTerrainSound = source.meleeHitTerrainSound;
			val.splashGunkSound = source.splashGunkSound;
			val.jetpackSound = source.jetpackSound;
			val.frozenGibSounds = source.frozenGibSounds;
			val.freezeScreamSounds = source.freezeScreamSounds;
			val.fartSounds = source.fartSounds;
			val.fartHugeSounds = source.fartHugeSounds;
			return val;
		}

		public static void UI()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			GUILayout.Label("Bronobi Ghost Gifts:", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("-- Some options may need additionals conditions --", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			addLife = GUILayout.Toggle(addLife, new GUIContent("Add Life"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
			refillAmmos = GUILayout.Toggle(refillAmmos, new GUIContent("Refill Special"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
			givePockettedAmmo = GUILayout.Toggle(givePockettedAmmo, new GUIContent("Give Pocketted Ammo"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
			giveFlexPower = GUILayout.Toggle(giveFlexPower, new GUIContent("Give Flex Power"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			spawnPig = GUILayout.Toggle(spawnPig, new GUIContent("Spawn Pig"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
			useProcGen = GUILayout.Toggle(useProcGen, new GUIContent("Proc Gen Items"), (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.EndHorizontal();
		}
	}
	public class MindControlEffect : MonoBehaviour
	{
		protected int _originalPlayerNum;

		public float timeBetwenEffects = 1f;

		protected float _counter;

		protected float _controlTime;

		protected Color _starColor = Color.cyan;

		protected static Texture2D[] _blindStars;

		protected Unit _nearestEnemy;

		protected int _rangeEnemySearch = 300;

		public Mook mook { get; protected set; }

		public TestVanDammeAnim MindController { get; protected set; }

		protected void Awake()
		{
			mook = ((Component)this).GetComponent<Mook>();
		}

		protected void Update()
		{
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Expected O, but got Unknown
			_controlTime -= Time.deltaTime;
			if ((Object)(object)mook == (Object)null || !((BroforceObject)mook).IsAlive() || _controlTime <= 0f)
			{
				StopControl();
				Object.Destroy((Object)(object)this);
				return;
			}
			_counter -= Time.deltaTime;
			if (_counter <= 0f)
			{
				RunEffect();
				_counter = timeBetwenEffects;
			}
			if (!((Object)(object)_nearestEnemy == (Object)null) && ((BroforceObject)_nearestEnemy).IsAlive())
			{
				return;
			}
			if ((Object)(object)_nearestEnemy != (Object)null && !((BroforceObject)_nearestEnemy).IsAlive())
			{
				((NetworkedUnit)mook).enemyAI.ClearActionQueue(true);
				((NetworkedUnit)mook).enemyAI.AddAction((EnemyActionType)20, 1f);
			}
			if (ObjectExtensions.NotAs<MookSuicide>((object)mook) && ObjectExtensions.NotAs<MookSuicideUndead>((object)mook) && HarmonyExtensions.CallMethod<bool>((object)((NetworkedUnit)mook).enemyAI, "CanSeeEnemyThisWay", new object[1] { ((NetworkedUnit)mook).Direction }))
			{
				((NetworkedUnit)mook).enemyAI.AddAction((EnemyActionType)1, 1f);
				return;
			}
			if (ObjectExtensions.NotAs<MookSuicide>((object)mook) && ObjectExtensions.NotAs<MookSuicideUndead>((object)mook) && HarmonyExtensions.CallMethod<bool>((object)((NetworkedUnit)mook).enemyAI, "CanSeeEnemyThisWay", new object[1] { -((NetworkedUnit)mook).Direction }))
			{
				((Unit)mook).ForceFaceDirection(-((NetworkedUnit)mook).Direction);
				((NetworkedUnit)mook).enemyAI.AddAction((EnemyActionType)1, 1f);
				return;
			}
			_nearestEnemy = Map.GetNearestUnit(-1, _rangeEnemySearch, ((BroforceObject)mook).X, ((BroforceObject)mook).Y, false);
			if ((Object)(object)_nearestEnemy == (Object)null)
			{
				_nearestEnemy = Map.GetNearestUnit(-2, _rangeEnemySearch, ((BroforceObject)mook).X, ((BroforceObject)mook).Y, false);
			}
			if ((Object)(object)_nearestEnemy != (Object)null)
			{
				((NetworkedUnit)mook).enemyAI.SetMentalState((MentalState)2);
				((NetworkedUnit)mook).enemyAI.AddAction((EnemyActionType)13, new GridPoint(_nearestEnemy.collumn + ((Random.value > 0.5f) ? 2 : (-2)), _nearestEnemy.row));
				((NetworkedUnit)mook).enemyAI.AddAction((EnemyActionType)1, ((NetworkedUnit)mook).enemyAI.attackTime);
			}
		}

		public void Setup(TestVanDammeAnim mindController, int originalPlayerNum, float controlTime)
		{
			MindController = mindController;
			_originalPlayerNum = originalPlayerNum;
			((NetworkedUnit)mook).playerNum = 10;
			mook.firingPlayerNum = 10;
			((NetworkedUnit)mook).enemyAI.ClearActionQueue(true);
			((NetworkedUnit)mook).enemyAI.SetMentalState((MentalState)0);
			_controlTime = controlTime;
			if (_blindStars != null)
			{
				return;
			}
			try
			{
				string path = ((CustomBroforceObjectInfo)ObjectExtensions.As<CustomHero>((object)mindController).Info).path;
				_blindStars = (Texture2D[])(object)new Texture2D[3]
				{
					ResourcesController.GetTexture(path, "blind_stars_white1.png"),
					ResourcesController.GetTexture(path, "blind_stars_white2.png"),
					ResourcesController.GetTexture(path, "blind_stars_white3.png")
				};
			}
			catch (Exception ex)
			{
				BMLogger.ExceptionLog((object)ex, true);
			}
		}

		protected virtual void RunEffect()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			PuffTwoLayer val = CreateBlindStar(((BroforceObject)mook).X + Random.value * 2f - 1f, ((BroforceObject)mook).Y + 6f + ((Unit)mook).height * 1.4f, 2f, 2f, 1f, 0f, 20f, ((Component)mook).transform);
			val.SetColor(_starColor);
		}

		protected PuffTwoLayer CreateBlindStar(float x, float y, float radius, float force, float count, float xI, float yI, Transform unitTransform)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)EffectsController.instance == (Object)null)
			{
				return null;
			}
			int i = 0;
			int num = 0;
			int num2 = 0;
			PuffTwoLayer val = null;
			for (; (float)i < count; i++)
			{
				num += 1 + Random.Range(0, 2);
				num2 = num % 3;
				PuffTwoLayer stunnedStars1Prefab;
				if (num2 == 0)
				{
					stunnedStars1Prefab = EffectsController.instance.stunnedStars1Prefab;
				}
				stunnedStars1Prefab = ((num2 != 1) ? EffectsController.instance.stunnedStars3Prefab : EffectsController.instance.stunnedStars2Prefab);
				val = CreatePuffTwoLayer(stunnedStars1Prefab, x, y, 0f, new Vector3(xI, yI, 0f));
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).transform.parent = unitTransform;
					if (IEnumerableExtensions.IsNotNullOrEmpty<Texture2D>((IEnumerable<Texture2D>)_blindStars))
					{
						((Renderer)((SpriteBase)val.spriteLayer1).MeshRenderer).material.mainTexture = (Texture)(object)_blindStars[num2];
						((Renderer)((SpriteBase)val.spriteLayer2).MeshRenderer).material.mainTexture = (Texture)(object)_blindStars[num2];
					}
				}
			}
			return val;
		}

		private PuffTwoLayer CreatePuffTwoLayer(PuffTwoLayer puffTwoLayer, float x, float y, float delay, Vector3 velocity)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			PuffTwoLayer val = Object.Instantiate<PuffTwoLayer>(puffTwoLayer, new Vector3(x, y, 0f), Quaternion.identity);
			if (velocity != Vector3.zero)
			{
				velocity.z = 0f;
				val.SetVelocity(velocity);
			}
			if (delay > 0f)
			{
				val.Delay(delay);
			}
			return val;
		}

		public void StopControl()
		{
			((NetworkedUnit)mook).playerNum = _originalPlayerNum;
			mook.firingPlayerNum = _originalPlayerNum;
			((NetworkedUnit)mook).enemyAI.ClearActionQueue(true);
			((NetworkedUnit)mook).enemyAI.AddAction((EnemyActionType)7, 0.2f);
			((NetworkedUnit)mook).enemyAI.AddAction((EnemyActionType)5, 1f);
			HarmonyExtensions.SetFieldValue<bool>((object)mook, "catchFriendlyBullets", false);
		}
	}
	public class MindControlWave : MatildaTargettingWave
	{
		private static Puff _forceWavePuff;

		protected float _controlTime = 2f;

		public TestVanDammeAnim Character
		{
			get
			{
				MonoBehaviour firedBy = ((FlameWallExplosion)this).firedBy;
				return (TestVanDammeAnim)(object)((firedBy is TestVanDammeAnim) ? firedBy : null);
			}
		}

		public static MindControlWave CreateMindControleWave(TestVanDammeAnim owner, Texture2D waveTexture, float controlTime)
		{
			//IL_0005: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			MindControlWave mindControlWave = new GameObject("MindControlWave").AddComponent<MindControlWave>();
			((Component)mindControlWave).transform.position = ((Component)owner).transform.position;
			mindControlWave.Setup(waveTexture, controlTime);
			DirectionEnum val = (DirectionEnum)1;
			if (owner.right || ((Component)owner).transform.localScale.x > 0f)
			{
				val = (DirectionEnum)5;
			}
			else if (owner.left || ((Component)owner).transform.localScale.x < 0f)
			{
				val = (DirectionEnum)4;
			}
			((FlameWallExplosion)mindControlWave).Setup(((NetworkedUnit)owner).playerNum, (MonoBehaviour)(object)owner, val);
			return mindControlWave;
		}

		public static Puff GetForceWavePuff(Texture2D texture)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			if ((Object)(object)_forceWavePuff != (Object)null)
			{
				return _forceWavePuff;
			}
			GameObject val = new GameObject("Bronobi_MindControlWave_Puff", new Type[3]
			{
				typeof(MeshFilter),
				typeof(MeshRenderer),
				typeof(SpriteSM)
			});
			TestVanDammeAnim heroPrefab = HeroController.GetHeroPrefab((HeroType)35);
			Puff lightExplosion = ((FlameWallExplosion)((TheBrofessional)((heroPrefab is TheBrofessional) ? heroPrefab : null)).matildaTargettingWavePrefab).lightExplosion;
			SpriteSM component = val.GetComponent<SpriteSM>();
			((SpriteBase)component).Copy((SpriteBase)(object)((Component)lightExplosion).GetComponent<SpriteSM>());
			_forceWavePuff = val.AddComponent<Puff>();
			_forceWavePuff.frameRate = lightExplosion.frameRate;
			_forceWavePuff.pauseFrame = lightExplosion.pauseFrame;
			((Component)_forceWavePuff).gameObject.layer = ((Component)lightExplosion).gameObject.layer;
			_forceWavePuff.spriteSize = lightExplosion.spriteSize;
			_forceWavePuff.frames = lightExplosion.frames;
			_forceWavePuff.rows = lightExplosion.rows;
			_forceWavePuff.loopStartFrame = lightExplosion.loopStartFrame;
			_forceWavePuff.loopEndFrame = lightExplosion.loopEndFrame;
			_forceWavePuff.numLoops = lightExplosion.numLoops;
			_forceWavePuff.requiresGroundBelow = lightExplosion.requiresGroundBelow;
			_forceWavePuff.pauseFrame = lightExplosion.pauseFrame;
			_forceWavePuff.pauseTime = lightExplosion.pauseTime;
			_forceWavePuff.useGravity = lightExplosion.useGravity;
			_forceWavePuff.gravityM = lightExplosion.gravityM;
			_forceWavePuff.correctRotation = lightExplosion.correctRotation;
			_forceWavePuff.useLightingMultiplier = lightExplosion.useLightingMultiplier;
			Material val2 = new Material(((Renderer)((Component)lightExplosion).GetComponent<MeshRenderer>()).material);
			MeshRenderer component2 = ((Component)_forceWavePuff).GetComponent<MeshRenderer>();
			val2.mainTexture = (Texture)(object)texture;
			if ((Object)(object)texture != (Object)null)
			{
				((Renderer)component2).material = val2;
			}
			return _forceWavePuff;
		}

		public void Setup(Texture2D wavePointTexture, float controlTime)
		{
			try
			{
				_controlTime = controlTime;
				((FlameWallExplosion)this).lightExplosion = GetForceWavePuff(wavePointTexture);
				TestVanDammeAnim heroPrefab = HeroController.GetHeroPrefab((HeroType)35);
				MatildaTargettingWave matildaTargettingWavePrefab = ((TheBrofessional)((heroPrefab is TheBrofessional) ? heroPrefab : null)).matildaTargettingWavePrefab;
				((FlameWallExplosion)this).flashBangSoundHolder = ((FlameWallExplosion)matildaTargettingWavePrefab).flashBangSoundHolder;
			}
			catch (Exception arg)
			{
				BMLogger.Log($"[{typeof(MindControlWave)}] {arg}", (LogType)3, true);
			}
		}

		protected virtual void Awake()
		{
			((FlameWallExplosion)this).assasinateUnits = true;
			((FlameWallExplosion)this).knockUnits = false;
			((FlameWallExplosion)this).blindUnits = false;
			((FlameWallExplosion)this).rotateExplosionSprite = true;
			((FlameWallExplosion)this).totalExplosions = 52;
			((FlameWallExplosion)this).explosionRate = 0.04f;
		}

		protected override void TryAssassinateUnits(float x, float y, int xRange, int yRange, int playerNum)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			Mook nearbyMook = Map.GetNearbyMook((float)xRange, (float)yRange, x, y, ((int)((FlameWallExplosion)this).forceDirection != 4) ? 1 : (-1), false);
			if ((Object)(object)nearbyMook != (Object)null && !ObjectExtensions.Is<Satan>((object)nearbyMook))
			{
				MindControlEffect mindControlEffect = ((Component)nearbyMook).gameObject.AddComponent<MindControlEffect>();
				mindControlEffect.Setup(Character, ((NetworkedUnit)nearbyMook).playerNum, BroMakerUtilities.IsBoss((Unit)(object)nearbyMook) ? (_controlTime / 4f) : _controlTime);
			}
		}
	}
}
namespace BronobiMod.Abilities
{
	[AbilityPreset("AutoReflect")]
	public class AutoReflect : CharacterAbility
	{
		public Vector2 positionOffset;

		public Vector2 radius = new Vector2(1f, 1f);

		public float fRadius = 16f;

		public float deflectForce = 200f;

		public Vector2 Position => new Vector2(((BroforceObject)((Ability<TestVanDammeAnim>)this).owner).X, ((BroforceObject)((Ability<TestVanDammeAnim>)this).owner).Y) + positionOffset;

		public override void All(string method, params object[] objects)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			switch (method)
			{
			case "Start":
				return;
			case "Awake":
				return;
			}
			Map.DeflectProjectiles((MonoBehaviour)(object)((Ability<TestVanDammeAnim>)this).owner, ((NetworkedUnit)((Ability<TestVanDammeAnim>)this).owner).playerNum, fRadius, ((BroforceObject)((Ability<TestVanDammeAnim>)this).owner).X + Mathf.Sign(((Component)((Ability<TestVanDammeAnim>)this).owner).transform.localScale.x) * positionOffset.x, ((BroforceObject)((Ability<TestVanDammeAnim>)this).owner).Y + positionOffset.y, Mathf.Sign(((Component)((Ability<TestVanDammeAnim>)this).owner).transform.localScale.x) * deflectForce, false);
		}

		public void ReverseProjectile(Projectile projectile)
		{
			projectile.playerNum = ((NetworkedUnit)((Ability<TestVanDammeAnim>)this).owner).playerNum;
			projectile.firedBy = (MonoBehaviour)(object)((Ability<TestVanDammeAnim>)this).owner;
			((BroforceObject)projectile).xI = ((BroforceObject)projectile).xI * -1f;
			((BroforceObject)projectile).yI = ((BroforceObject)projectile).yI * -1f;
		}

		public bool CanReverseProjectile(Projectile projectile)
		{
			//IL_0016: 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)
			if (((NetworkedUnit)((Ability<TestVanDammeAnim>)this).owner).playerNum == projectile.playerNum)
			{
				return false;
			}
			float num = Position.x - ((BroforceObject)projectile).X;
			if (Mathf.Abs(num) > radius.x)
			{
				return false;
			}
			float num2 = Position.y - ((BroforceObject)projectile).Y;
			if (Mathf.Abs(num2) > radius.y)
			{
				return false;
			}
			return true;
		}
	}
	[AbilityPreset("MindControlWave")]
	public class MindControlWaveAbility : CharacterAbility
	{
		public Texture2D waveTexture;

		public float controlTime = 10f;

		public override void All(string method, params object[] objects)
		{
			switch (method)
			{
			case "Start":
				return;
			case "Awake":
				return;
			}
			MindControlWave mindControlforceWave = MindControlWave.CreateMindControleWave(((Ability<TestVanDammeAnim>)this).owner, waveTexture, controlTime);
			if (Object.op_Implicit((Object)(object)(((Ability<TestVanDammeAnim>)this).owner as Bronobi)))
			{
				(((Ability<TestVanDammeAnim>)this).owner as Bronobi).mindControlforceWave = mindControlforceWave;
			}
		}
	}
	[AbilityPreset("ForceWave")]
	public class ForceWave : CharacterAbility
	{
		public Texture2D forceWaveTexture;

		public override void All(string method, params object[] objects)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			switch (method)
			{
			case "Start":
				return;
			case "Awake":
				return;
			}
			BronobiForceWave bronobiForceWave = new GameObject("BronobiForceWave").AddComponent<BronobiForceWave>();
			((Component)bronobiForceWave).transform.position = ((Component)((Ability<TestVanDammeAnim>)this).owner).transform.position;
			bronobiForceWave.Setup(forceWaveTexture);
			((FlameWallExplosion)bronobiForceWave).Setup(((NetworkedUnit)((Ability<TestVanDammeAnim>)this).owner).playerNum, (MonoBehaviour)(object)((Ability<TestVanDammeAnim>)this).owner, (DirectionEnum)1);
		}
	}
}