using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Kanata
{
[BepInPlugin("4902.Katana", "Katana", "1.0.0")]
public class kyu : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("4902.Katana");
public static ManualLogSource mls;
private void Awake()
{
mls = Logger.CreateLogSource("Katana");
mls.LogInfo((object)"hei");
harmony.PatchAll();
}
}
}
namespace Kanata.Patches
{
[HarmonyPatch(typeof(GrabbableObject))]
internal class go
{
private static AudioClip[] audio = (AudioClip[])(object)new AudioClip[2];
private static Transform str;
[HarmonyPatch("Start")]
private static void Postfix(GrabbableObject __instance)
{
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: 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_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: 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_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Expected O, but got Unknown
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_0387: Unknown result type (might be due to invalid IL or missing references)
if (!(((Object)__instance.itemProperties).name == "Shovel"))
{
return;
}
if ((Object)(object)audio[0] == (Object)null)
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = (directoryName + "/4902-katana").Replace("\\", "/");
string path = directoryName + "\\4902-katana_icon.png";
kyu.mls.LogMessage((object)("Searching this filepath:" + text));
AssetBundle assetBundle = AssetBundle.LoadFromFileAsync(text).assetBundle;
__instance.itemProperties.toolTips = new string[1] { "Swing katana : [LMB]" };
Transform val = Object.Instantiate<Transform>(assetBundle.LoadAsset<Item>("katanaitem.asset").spawnPrefab.GetComponentsInChildren<Transform>()[1]);
Object.Instantiate<Transform>(val).SetParent(((Component)__instance).transform);
val.SetParent(__instance.itemProperties.spawnPrefab.transform);
Transform val2 = ((Component)__instance).GetComponentsInChildren<Transform>()[2];
Transform obj = val2;
Vector3 localPosition = (val.localPosition = new Vector3(0f, 0f, -0.6f));
obj.localPosition = localPosition;
Transform obj2 = val2;
Quaternion localRotation = (val.localRotation = new Quaternion(0.7071f, 0f, 0f, 0.7071f));
obj2.localRotation = localRotation;
Transform obj3 = val2;
localPosition = (val.localScale = new Vector3(0.4f, 0.4f, 0.4f));
obj3.localScale = localPosition;
str = val;
((Component)__instance.itemProperties.spawnPrefab.GetComponentsInChildren<Transform>()[1]).GetComponent<MeshFilter>().mesh = null;
((Component)((Component)__instance).GetComponentsInChildren<Transform>()[1]).GetComponent<MeshFilter>().mesh = null;
Texture2D val6 = new Texture2D(2, 2);
ImageConversion.LoadImage(val6, File.ReadAllBytes(path));
__instance.itemProperties.itemIcon = Sprite.Create(val6, __instance.itemProperties.itemIcon.rect, __instance.itemProperties.itemIcon.pivot);
audio = StartOfRound.Instance.allItemsList.itemsList.First((Item _) => ((Object)_).name == "Knife").spawnPrefab.GetComponent<KnifeItem>().hitSFX;
__instance.itemProperties.positionOffset = new Vector3(-0.19f, 0.03f, -0.44f);
__instance.itemProperties.rotationOffset = new Vector3(-30f, 200f, -4f);
}
else if (((Component)__instance).GetComponentsInChildren<Transform>().Length < 12)
{
Object.Instantiate<Transform>(str).SetParent(((Component)__instance).transform);
Transform val2 = ((Component)__instance).GetComponentsInChildren<Transform>()[2];
val2.localPosition = new Vector3(0f, 0f, -0.6f);
val2.localRotation = new Quaternion(0.7071f, 0f, 0f, 0.7071f);
val2.localScale = new Vector3(0.4f, 0.4f, 0.4f);
((Component)((Component)__instance).GetComponentsInChildren<Transform>()[1]).GetComponent<MeshFilter>().mesh = null;
}
if ((Object)(object)audio[0] != (Object)null)
{
BoxCollider component = ((Component)__instance).GetComponent<BoxCollider>();
component.center = new Vector3(0f, 0f, 0.4f);
component.size = new Vector3(0.214f, 0.2f, 2f);
((Component)__instance).GetComponent<Shovel>().hitSFX = audio;
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class sor
{
private static bool temp = false;
[HarmonyPatch("Awake")]
private static void Postfix()
{
if (!temp)
{
temp = true;
StartOfRound.Instance.allItemsList.itemsList.First((Item _) => ((Object)_).name == "Shovel").spawnPrefab.GetComponent<GrabbableObject>().itemProperties.itemName = "Katana";
}
}
}
[HarmonyPatch(typeof(Terminal))]
internal class t
{
private static bool temp = false;
[HarmonyPatch("Awake")]
private static void Postfix(Terminal __instance)
{
if (!temp)
{
temp = true;
TerminalKeyword val = __instance.terminalNodes.allKeywords.First((TerminalKeyword _) => _.word == "shovel");
val.word = "katana";
TerminalNode result = val.defaultVerb.compatibleNouns.First((CompatibleNoun _) => ((Object)_.result.terminalOptions[0].result).name == "buyShovel2").result;
result.displayText = result.displayText.Replace("shovels", "katanas");
result.terminalOptions[0].result.displayText = result.terminalOptions[0].result.displayText.Replace("shovels", "katanas");
}
}
}
}