Decompiled source of barrel v0.2.1

plugins/barrel/barrel.dll

Decompiled 2 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameplayEntities;
using HarmonyLib;
using LLBML;
using LLBML.Math;
using LLBML.Networking;
using LLBML.States;
using LLBML.Utils;
using LLBT;
using LLBT.Tweaks;
using LLHandlers;
using Multiplayer;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("barrel (fr.glomzubuk.plugins.llb.barrel)")]
[assembly: AssemblyProduct("barrel")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.1.0")]
[module: UnverifiableCode]
namespace barrel;

[BepInPlugin("fr.glomzubuk.plugins.llb.barrel", "barrel", "0.2.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("LLBlaze.exe")]
public class barrel : BaseUnityPlugin
{
	public static BarrelTweak barrelTweak;

	public static barrel Instance { get; private set; }

	public static ManualLogSource Log { get; private set; }

	private void Awake()
	{
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		barrelTweak = new BarrelTweak();
		LLBTweaker.AddTweak((TweakBase)(object)barrelTweak);
		((BaseUnityPlugin)this).Logger.LogDebug((object)"Added barrel tweak");
	}
}
public class BarrelTweak : HarmonyTweak
{
	private int DEFAULT_MAX_COMMON_ITEMS = -1;

	internal readonly ConfigEntry<int> maxBarrel;

	internal readonly ConfigEntry<int> barrelSpawnInterval;

	private int gameStartTime = -1;

	public BarrelTweak()
		: base("barrel-tweak", "barrel", (Harmony)null)
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		DEFAULT_MAX_COMMON_ITEMS = ItemHandler.MAX_COMMON_ITEMS;
		barrelSpawnInterval = TweakBase.Config.Bind<int>(((TweakBase)this).ID, "barrelSpawnInterval", 5, new ConfigDescription("Time between barrel spawns in second.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 120), new object[0]));
		maxBarrel = TweakBase.Config.Bind<int>(((TweakBase)this).ID, "maxBarrels", 1, new ConfigDescription("Maximum amount of barrels on screen.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), new object[0]));
		((TweakBase)this).AddConfig((ConfigEntryBase)(object)barrelSpawnInterval);
		((TweakBase)this).AddConfig((ConfigEntryBase)(object)maxBarrel);
		((HarmonyTweak)this).AddPatchClass(typeof(barrel_Patches), false);
	}

	protected override void DoPatch()
	{
		((HarmonyTweak)this).DoPatch();
		ItemHandler.MAX_COMMON_ITEMS = maxBarrel.Value;
		ItemHandler.MAX_ITEMS = ItemHandler.MAX_COMMON_ITEMS + ItemHandler.MAX_CORPSE_ITEMS + ItemHandler.MAX_BOMB_ITEMS;
	}

	protected override void DoUnpatch()
	{
		((HarmonyTweak)this).DoUnpatch();
		ItemHandler.MAX_COMMON_ITEMS = DEFAULT_MAX_COMMON_ITEMS;
		ItemHandler.MAX_ITEMS = ItemHandler.MAX_COMMON_ITEMS + ItemHandler.MAX_CORPSE_ITEMS + ItemHandler.MAX_BOMB_ITEMS;
	}

	public override void FixedUpdate()
	{
		if ((EnumWrapper<JOFJHDJHJGI>)(object)GameStates.GetCurrent() == (EnumWrapper<JOFJHDJHJGI>)(object)GameState.GAME_INTRO)
		{
			gameStartTime = -1;
		}
	}

	public void OnFrameUpdate()
	{
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: 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)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Invalid comparison between Unknown and I4
		if (!((TweakBase)this).IsEnabled)
		{
			return;
		}
		GameState current = GameStates.GetCurrent();
		if (!((EnumWrapper<JOFJHDJHJGI>)(object)current == (EnumWrapper<JOFJHDJHJGI>)(object)GameState.GAME) && !((EnumWrapper<JOFJHDJHJGI>)(object)current == (EnumWrapper<JOFJHDJHJGI>)(object)GameState.GAME_PAUSE))
		{
			return;
		}
		BallEntity ball = BallApi.GetBall(0);
		if (gameStartTime == -1)
		{
			if (ball == null)
			{
				return;
			}
			BallData ballData = ((GetHitBallEntity)ball).ballData;
			if (ballData != null)
			{
				_ = ((BouncingData)ballData).ballState;
				if (true && (int)((BouncingData)((GetHitBallEntity)ball).ballData).ballState == 3)
				{
					gameStartTime = GameStatesGameUtils.currentFrame;
				}
			}
		}
		else
		{
			int num = GameStatesGameUtils.currentFrame - gameStartTime;
			int num2 = World.FPS * barrelSpawnInterval.Value;
			if (num % num2 == 0)
			{
				Vector2f.op_Implicit(World.instance.GetStageCenter());
				Vector2f val = Vector2f.op_Implicit(World.instance.stageMax);
				Vector2f val2 = Vector2f.op_Implicit(World.instance.stageMin);
				Floatf f = ControlledRandom.GetF(1, val2.x, val.x);
				ItemHandler.instance.SpawnItem((ItemType)0, Vector2f.op_Implicit(new Vector2f(f, val.y)));
			}
		}
	}
}
public static class barrel_Patches
{
	[HarmonyPatch(typeof(World), "FrameUpdate")]
	[HarmonyPrefix]
	public static bool FrameUpdate_Prefix()
	{
		if (NetworkApi.IsOnline && !Sync.isActive)
		{
			return true;
		}
		if (GameStatesGameUtils.currentFrame <= World.startHandlingFromFrame)
		{
			return true;
		}
		barrel.barrelTweak.OnFrameUpdate();
		return true;
	}
}
public static class PluginInfos
{
	public const string PLUGIN_NAME = "barrel";

	public const string PLUGIN_ID = "fr.glomzubuk.plugins.llb.barrel";

	public const string PLUGIN_VERSION = "0.2.1";
}