using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using REPOLib.Modules;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("RepoCannon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RepoCannon")]
[assembly: AssemblyTitle("RepoCannon")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace RepoCannon
{
internal class BatteryUI_Patch
{
[HarmonyPatch(typeof(BatteryUI), "Update")]
[HarmonyPrefix]
public static bool Prefix(BatteryUI __instance)
{
try
{
PhysGrabObject component = ((Component)PhysGrabber.instance.grabbedObjectTransform).gameObject.GetComponent<PhysGrabObject>();
if (Object.op_Implicit((Object)(object)((Component)component).transform.Find("RepoCannon")))
{
((Component)component).GetComponent<ItemBattery>().OverrideBatteryShow(1.5f);
return false;
}
}
catch (Exception)
{
}
return true;
}
}
internal class CartPatch
{
[HarmonyPatch(typeof(PhysGrabCart), "Start")]
[HarmonyPostfix]
public static void Postfix(PhysGrabCart __instance)
{
if (Object.op_Implicit((Object)(object)((Component)__instance).transform.Find("RepoCannon")))
{
ItemGun component = ((Component)__instance).GetComponent<ItemGun>();
component.gunRecoilForce = Plugin.Recoil.Value;
component.cameraShakeMultiplier = Plugin.ScreenShake.Value;
component.batteryDrainFullBars = Plugin.BatteryDrain.Value;
component.shootCooldown = Plugin.FireRate.Value;
HurtCollider componentInChildren = ((Component)__instance).GetComponentInChildren<HurtCollider>(true);
componentInChildren.playerDamage = Plugin.PlayerDamage.Value;
componentInChildren.enemyDamage = Plugin.EnemyDamage.Value;
componentInChildren.enemyFreezeTime = 0f;
componentInChildren.enemyStunTime = 10f;
}
}
}
internal class ItemAttributesPatch
{
[HarmonyPatch(typeof(ItemAttributes), "Start")]
[HarmonyPrefix]
public static void Prefix(ItemAttributes __instance)
{
if (Object.op_Implicit((Object)(object)((Component)__instance).transform.Find("RepoCannon")))
{
((Component)__instance).GetComponent<ItemAttributes>().item.value.valueMin = Plugin.MinPrice.Value;
((Component)__instance).GetComponent<ItemAttributes>().item.value.valueMax = Plugin.MaxPrice.Value;
}
}
}
[BepInPlugin("Sai.Cannon", "Cannon", "0.8.6")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private static Plugin _instance;
private static Harmony _harmony;
private static AssetBundle cannonBundle;
private static Value CannonValue;
public static ManualLogSource log;
private bool _initialized;
internal static ConfigEntry<float> MinPrice;
internal static ConfigEntry<float> MaxPrice;
internal static ConfigEntry<float> FireRate;
internal static ConfigEntry<float> Recoil;
internal static ConfigEntry<float> ScreenShake;
internal static ConfigEntry<int> BatteryDrain;
internal static ConfigEntry<int> EnemyDamage;
internal static ConfigEntry<int> PlayerDamage;
internal static Plugin Instance
{
get
{
return _instance;
}
set
{
if ((Object)(object)_instance == (Object)null)
{
_instance = value;
}
else
{
Object.Destroy((Object)(object)value);
}
}
}
private void Awake()
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
_instance = this;
if (_harmony == null)
{
_harmony = new Harmony("Sai.Cannon");
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Sai_Cannon is loaded!");
((BaseUnityPlugin)this).Logger.LogInfo((object)"\n ____ _ _ _ _ _ ___ _ _ \n / ___| / \\ | \\ | | | \\ | | / _ \\ | \\ | |\n| | / _ \\ | \\| | | \\| | | | | | | \\| | \n| |___ _ / ___ \\ _ | |\\ | _ | |\\ | _| |_| |_ | |\\ | \n \\____|(_)/_/ \\_\\(_)|_| \\_|(_)|_| \\_|(_)\\___/(_)|_| \\_| v0.8.6");
_harmony.PatchAll(typeof(CartPatch));
_harmony.PatchAll(typeof(BatteryUI_Patch));
_harmony.PatchAll(typeof(ItemAttributesPatch));
cannonBundle = ExtractEmbeddedResource("RepoCannon.cannon");
GenerateConfig();
CannonValue = (Value)ScriptableObject.CreateInstance("Value");
LoadAssets();
}
private void GenerateConfig()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Expected O, but got Unknown
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Expected O, but got Unknown
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Expected O, but got Unknown
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Expected O, but got Unknown
MinPrice = ((BaseUnityPlugin)this).Config.Bind<float>("Pricing", "Minimum Price", 9500f, new ConfigDescription("The minimum price for the cannon(Not including scaling) | Default 9500", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150000f), Array.Empty<object>()));
MaxPrice = ((BaseUnityPlugin)this).Config.Bind<float>("Pricing", "Maximum Price", 12000f, new ConfigDescription("The maximum price for the cannon(Not including scaling) | Default 12000", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150000f), Array.Empty<object>()));
FireRate = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon", "Fire Rate", 2f, new ConfigDescription("The Fire Rate for the weapon | Default 2", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
Recoil = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon", "Recoil", 25f, new ConfigDescription("The amount of recoil for the weapon(Only noticable when fired from the side) | Default 25", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 25f), Array.Empty<object>()));
ScreenShake = ((BaseUnityPlugin)this).Config.Bind<float>("Weapon", "Screen Shake", 20f, new ConfigDescription("The amount the screen shakes after firing | Default 20", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
BatteryDrain = ((BaseUnityPlugin)this).Config.Bind<int>("Weapon", "Battery Drain", 2, new ConfigDescription("The amount the weapon drains from the battery when fired | Default 2", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
PlayerDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Damage", "Player Damage", 150, new ConfigDescription("The amount of damage dealt to the player | Default 150", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>()));
EnemyDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Damage", "Enemy Damage", 500, new ConfigDescription("The amount of damage dealt to enemies | Default 500", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2000), Array.Empty<object>()));
}
public AssetBundle ExtractEmbeddedResource(string resourceName)
{
if (string.IsNullOrEmpty(resourceName))
{
((BaseUnityPlugin)this).Logger.LogError((object)"Resource name is null or empty.");
return null;
}
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
if (stream == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Failed to find resource: " + resourceName));
return null;
}
AssetBundle val = AssetBundle.LoadFromStream(stream);
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load AssetBundle.");
return null;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"AssetBundle loaded successfully.");
return val;
}
private void LoadAssets()
{
Item val = cannonBundle.LoadAsset<Item>("Assets/REPO/Game/Resources/items/items/Item Cannon Cart.asset");
val.value = CannonValue;
Items.RegisterItem(val);
}
}
public static class PluginInfo
{
public const string PLUGIN_ID = "Sai_Cannon";
public const string PLUGIN_NAME = "Cannon";
public const string PLUGIN_VERSION = "0.8.6";
public const string PLUGIN_GUID = "Sai.Cannon";
}
}