using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HarmonyLib.Tools;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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 = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LCSplatBombGrenadeMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Replace the visuals and sounds of the Grenades with Bombs from Splatoon!")]
[assembly: AssemblyFileVersion("1.3.1.0")]
[assembly: AssemblyInformationalVersion("1.3.1")]
[assembly: AssemblyProduct("LCSplatBombGrenadeMod")]
[assembly: AssemblyTitle("LCSplatBombGrenadeMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace LCSplatBombGrenadeMod
{
public class Config
{
public static ConfigEntry<bool> SplatBombConfig;
public static ConfigEntry<bool> FizzyBombConfig;
public static ConfigEntry<bool> BurstBombConfig;
public Config(ConfigFile cfg)
{
SplatBombConfig = cfg.Bind<bool>("Customization", "Splat Bombs", true, "Set whether Splat Bombs replace Stun Grenades.");
FizzyBombConfig = cfg.Bind<bool>("Customization", "Fizzy Bombs", true, "Set whether Fizzy Bombs replace Homemade Flashbangs.");
BurstBombConfig = cfg.Bind<bool>("Customization", "Burst Bombs", true, "Set whether Burst Bombs replace Easter Eggs.");
}
public static void DisplayConfigs()
{
if (!SplatBombConfig.Value && !BurstBombConfig.Value && !FizzyBombConfig.Value)
{
Plugin.Logger.LogInfo((object)"Configs [Splat Bombs], [Fizzy Bombs], and [Burst Bombs] are all set to FALSE. :(");
return;
}
if (SplatBombConfig.Value)
{
Plugin.Logger.LogInfo((object)"Config [Splat Bombs] is set to TRUE. Splat Bombs will replace Stun Grenades.");
}
else
{
Plugin.Logger.LogInfo((object)"Config [Splat Bombs] is set to FALSE. Stun Grenades will not be replaced.");
}
if (FizzyBombConfig.Value)
{
Plugin.Logger.LogInfo((object)"Config [Fizzy Bombs] is set to TRUE. Fizzy Bombs will replace Homemade Flashbangs.");
}
else
{
Plugin.Logger.LogInfo((object)"Config [Fizzy Bombs] is set to FALSE. Homemade Flashbangs will not be replaced.");
}
if (BurstBombConfig.Value)
{
Plugin.Logger.LogInfo((object)"Config [Burst Bombs] is set to TRUE. Burst Bombs will replace Easter Eggs.");
}
else
{
Plugin.Logger.LogInfo((object)"Config [Burst Bombs] is set to FALSE. Easter Eggs will not be replaced.");
}
}
}
public class HarmonyPatches
{
[HarmonyPatch(typeof(StartOfRound), "Start")]
public class NewStartOfRoundStart
{
[HarmonyPrefix]
public static void Prefix(StartOfRound __instance)
{
if (SetStunGrenade && SetFlashbang && SetEasterEgg)
{
return;
}
if (!Config.SplatBombConfig.Value)
{
SetStunGrenade = true;
}
if (!Config.FizzyBombConfig.Value)
{
SetFlashbang = true;
}
if (!Config.BurstBombConfig.Value)
{
SetEasterEgg = true;
}
foreach (Item items in __instance.allItemsList.itemsList)
{
if (((Object)items).name == "StunGrenade" && Config.SplatBombConfig.Value)
{
Plugin.Logger.LogDebug((object)"Found stun grenade, setting item properties and terminal text to Splat Bomb...");
items.itemName = "Splat Bomb";
items.toolTips[0] = "Use Splat Bomb : [LMB]";
((Vector3)(ref items.positionOffset)).Set(-0.2f, 0.17f, 0.03f);
((Vector3)(ref items.rotationOffset)).Set(180f, -25f, 0f);
items.verticalOffset = 0.03f;
items.spawnPrefab.GetComponent<MeshFilter>().mesh = ((Component)Plugin.SplatBomb.transform.GetChild(0)).GetComponent<MeshFilter>().mesh;
((Component)items.spawnPrefab.transform.GetChild(0)).GetComponent<MeshFilter>().mesh = null;
StunGrenadeItem component = items.spawnPrefab.GetComponent<StunGrenadeItem>();
component.pullPinSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/SplatPullPinSFX.ogg");
component.explodeSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/SplatExplodeSFX.ogg");
((GrabbableObject)component).itemProperties.itemIcon = Plugin.SplatBombModAssets.LoadAsset<Sprite>("Assets/ItemIcon.png");
((GrabbableObject)component).itemProperties.grabSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/SplatGrabSFX.ogg");
((GrabbableObject)component).itemProperties.pocketSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/SplatPocketSFX.ogg");
((GrabbableObject)component).itemProperties.dropSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/SplatDropSFX.ogg");
component.stunGrenadeExplosion = Plugin.SplatBombModAssets.LoadAsset<GameObject>("Assets/SplatInk/GroundSplatters/SplatBombInkSplattersGround.prefab");
Plugin.SetSplatBombKeyword();
SetStunGrenade = true;
}
else if (((Object)items).name == "DiyFlashbang" && Config.FizzyBombConfig.Value)
{
Plugin.Logger.LogDebug((object)"Found DIYflashbang, setting item properties to Fizzy Bomb...");
items.itemName = "Fizzy Bomb";
items.toolTips[0] = "Use Fizzy Bomb : [LMB]";
((Vector3)(ref items.positionOffset)).Set(0.07f, 0.1f, -0.09f);
((Vector3)(ref items.restingRotation)).Set(0f, 0f, 270f);
items.verticalOffset = 0.08f;
((Component)items.spawnPrefab.transform.GetChild(0)).GetComponent<MeshFilter>().mesh = null;
items.spawnPrefab.GetComponentInChildren<ScanNodeProperties>().headerText = "Fizzy Bomb";
items.spawnPrefab.GetComponent<MeshFilter>().mesh = Plugin.FizzyBomb.GetComponent<MeshFilter>().mesh;
StunGrenadeItem component2 = items.spawnPrefab.GetComponent<StunGrenadeItem>();
component2.pullPinSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/FizzyPullPinSFX.ogg");
component2.explodeSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/FizzyExplodeSFX.ogg");
((GrabbableObject)component2).itemProperties.itemIcon = Plugin.SplatBombModAssets.LoadAsset<Sprite>("Assets/FizzyBombAssets/FizzyBombIcon.png");
((GrabbableObject)component2).itemProperties.grabSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/FizzyGrabSFX.ogg");
((GrabbableObject)component2).itemProperties.pocketSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/FizzyPocketSFX.ogg");
((GrabbableObject)component2).itemProperties.dropSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/FizzyDropSFX.ogg");
component2.stunGrenadeExplosion = Plugin.SplatBombModAssets.LoadAsset<GameObject>("Assets/SplatInk/GroundSplatters/SplatBombInkSplattersGround.prefab");
SetFlashbang = true;
}
else if (((Object)items).name == "EasterEgg" && Config.BurstBombConfig.Value)
{
Plugin.Logger.LogDebug((object)"found easter egg, setting item properties to Burst Bomb...");
items.itemName = "Burst Bomb";
((Vector3)(ref items.positionOffset)).Set(-0.03f, 0.08f, -0.09f);
((Vector3)(ref items.restingRotation)).Set(180f, 180f, 180f);
items.spawnPrefab.GetComponentInChildren<ScanNodeProperties>().headerText = "Burst Bomb";
items.spawnPrefab.GetComponent<MeshFilter>().mesh = Plugin.BurstBomb.GetComponent<MeshFilter>().mesh;
StunGrenadeItem component3 = items.spawnPrefab.GetComponent<StunGrenadeItem>();
component3.explodeSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/BurstExplodeSFX.ogg");
((GrabbableObject)component3).itemProperties.itemIcon = Plugin.SplatBombModAssets.LoadAsset<Sprite>("Assets/BurstBombAssets/BurstBombIcon.png");
((GrabbableObject)component3).itemProperties.grabSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/BurstGrabSFX.ogg");
((GrabbableObject)component3).itemProperties.pocketSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/BurstPocketSFX.ogg");
((GrabbableObject)component3).itemProperties.dropSFX = Plugin.SplatBombModAssets.LoadAsset<AudioClip>("Assets/SplatSounds/BurstDropSFX.ogg");
SetEasterEgg = true;
}
}
}
}
[HarmonyPatch(typeof(StunGrenadeItem), "Start")]
public class NewStunGrenadeStart
{
[HarmonyPostfix]
public static void Postfix(StunGrenadeItem __instance)
{
if (((Object)__instance).name == "StunGrenade(Clone)" && Config.SplatBombConfig.Value)
{
Object.Instantiate<GameObject>(Plugin.SplatBomb, ((Component)__instance).transform);
}
else if (((Object)__instance).name == "DiyFlashbang(Clone)" && Config.FizzyBombConfig.Value)
{
Object.Instantiate<GameObject>(Plugin.FizzyBomb, ((Component)__instance).transform);
}
else if (((Object)__instance).name == "EasterEgg(Clone)" && Config.BurstBombConfig.Value)
{
Object.Instantiate<GameObject>(Plugin.BurstBomb, ((Component)__instance).transform);
int num = 4;
if ((Object)(object)RoundManager.Instance != (Object)null && RoundManager.Instance.LevelRandom != null)
{
num = RoundManager.Instance.LevelRandom.Next(0, 9);
}
((Renderer)((Component)((Component)__instance).transform.GetChild(2)).GetComponent<MeshRenderer>()).material = Plugin.SplatBombModAssets.LoadAsset<Material>($"Assets/BurstBombAssets/BurstBombMaterials/BurstBombMaterial{num}.mat");
__instance.stunGrenadeExplosion = Plugin.SplatBombModAssets.LoadAsset<GameObject>($"Assets/SplatInk/GroundSplatters/BurstBomb/BurstBombInkSplatters{num}.prefab");
}
}
}
[HarmonyPatch(typeof(StunGrenadeItem), "SetControlTipForGrenade")]
public class NewStunGrenadeSetControlTip
{
[HarmonyPostfix]
public static void Postfix(StunGrenadeItem __instance)
{
if (((NetworkBehaviour)__instance).IsOwner)
{
if (((Object)((Component)__instance).gameObject).name == "StunGrenade(Clone)" && Config.SplatBombConfig.Value)
{
string[] array = (__instance.pinPulled ? new string[1] { "Throw Splat Bomb : [LMB]" } : new string[1] { "Activate Splat Bomb : [LMB] " });
HUDManager.Instance.ChangeControlTipMultiple(array, true, ((GrabbableObject)__instance).itemProperties);
}
else if (((Object)((Component)__instance).gameObject).name == "EasterEgg(Clone)" && Config.BurstBombConfig.Value)
{
string[] array2 = new string[1] { "Toss Burst Bomb : [LMB] " };
HUDManager.Instance.ChangeControlTipMultiple(array2, true, ((GrabbableObject)__instance).itemProperties);
}
else if (((Object)((Component)__instance).gameObject).name == "DiyFlashbang(Clone)" && Config.FizzyBombConfig.Value)
{
string[] array3 = new string[1] { "Use Fizzy Bomb : [LMB] " };
HUDManager.Instance.ChangeControlTipMultiple(array3, true, ((GrabbableObject)__instance).itemProperties);
}
}
}
}
[HarmonyPatch(typeof(StunGrenadeItem), "ExplodeStunGrenade")]
public class NewStunGrenadeExplode
{
[HarmonyPrefix]
public static void Prefix(StunGrenadeItem __instance)
{
object obj;
if (__instance == null)
{
obj = null;
}
else
{
GameObject gameObject = ((Component)__instance).gameObject;
obj = ((gameObject != null) ? ((Object)gameObject).name : null);
}
if ((string?)obj == "StunGrenade(Clone)" && Config.SplatBombConfig.Value)
{
((Renderer)((Component)((Component)__instance).transform.GetChild(2).GetChild(1)).GetComponent<MeshRenderer>()).material = Plugin.SplatBombEmptyMaterial;
}
}
}
public static bool SetStunGrenade;
public static bool SetFlashbang;
public static bool SetEasterEgg;
}
[BepInPlugin("LCSplatBombGrenadeMod", "LCSplatBombGrenadeMod", "1.3.1")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public string sAssemblyLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
public static AssetBundle SplatBombModAssets;
public static GameObject SplatBomb;
public static GameObject FizzyBomb;
public static GameObject BurstBomb;
public static Material SplatBombEmptyMaterial;
public static Config MyConfig { get; internal set; }
private void Awake()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin LCSplatBombGrenadeMod is loaded!");
Harmony val = new Harmony("LCSplatBombGrenadeMod");
val.PatchAll();
HarmonyFileLog.Enabled = false;
MyConfig = new Config(((BaseUnityPlugin)this).Config);
SplatBombModAssets = AssetBundle.LoadFromFile(Path.Combine(sAssemblyLocation, "splatbombmodassets"));
if ((Object)(object)SplatBombModAssets == (Object)null)
{
Logger.LogError((object)"Failed to load SplatBomb AssetBundle");
return;
}
Logger.LogInfo((object)"Loaded SplatBomb AssetBundle");
SplatBomb = SplatBombModAssets.LoadAsset<GameObject>("Assets/SplatBombPrefab.prefab");
SplatBombEmptyMaterial = SplatBombModAssets.LoadAsset<Material>("Assets/SplatBombAssets/EmptyMaterial.mat");
FizzyBomb = SplatBombModAssets.LoadAsset<GameObject>("Assets/FizzyBombAssets/FizzyBombPrefab.prefab");
BurstBomb = SplatBombModAssets.LoadAsset<GameObject>("Assets/BurstBombAssets/BurstBombPrefab.prefab");
Config.DisplayConfigs();
}
public static void SetSplatBombKeyword()
{
Terminal val = Object.FindObjectOfType<Terminal>();
TerminalKeyword val2 = null;
bool flag = false;
bool flag2 = false;
TerminalKeyword[] allKeywords = val.terminalNodes.allKeywords;
foreach (TerminalKeyword val3 in allKeywords)
{
if (((Object)val3).name == "StunGrenade")
{
val3.word = "splat";
flag = true;
}
else if (((Object)val3).name == "Buy")
{
val2 = val3;
flag2 = true;
}
if (flag && flag2)
{
break;
}
}
if ((Object)(object)val2 == (Object)null)
{
return;
}
TerminalNode val4 = null;
CompatibleNoun[] compatibleNouns = val2.compatibleNouns;
foreach (CompatibleNoun val5 in compatibleNouns)
{
if (((Object)val5.noun).name == "StunGrenade")
{
val4 = val5.result;
break;
}
}
if (!((Object)(object)val4 == (Object)null))
{
val4.displayText = "You have requested to order Splat Bombs. Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\n\n";
val4.terminalOptions[0].result.displayText = "Ordered [variableAmount] Splat Bombs. Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\n\nBooyah!\n\n";
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LCSplatBombGrenadeMod";
public const string PLUGIN_NAME = "LCSplatBombGrenadeMod";
public const string PLUGIN_VERSION = "1.3.1";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}