using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Video;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("XianglingKidnapperFox")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("XianglingKidnapperFox")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c70747a2-ad4c-4c28-ae4a-679dfb33db9c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace XianglingKidnapperFox;
[BepInPlugin("XianglingKidnapperFox", "GoblinKingShmeesXianglingKidnapperFox", "1.0.0")]
public class XianglingModBase : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("XianglingKidnapperFox");
private static XianglingModBase Instance;
public static ManualLogSource mls;
public static AssetBundle XianglingAssetBundle;
public static GameObject XianglingPrefab;
public static GameObject XianglingObject;
public static GameObject GuobaPrefab;
public static GameObject GuobaObject;
public static AudioClip soundXianglingHit;
public static AudioClip soundXianglingCloseCall1;
public static AudioClip soundXianglingCloseCall2;
public static AudioClip soundXianglingFarCall1;
public static AudioClip soundXianglingFarCall2;
public static AudioClip soundXianglingGrowl1;
public static AudioClip soundXianglingGrowl2;
public static AudioClip soundXianglingGrowl3;
public static AudioClip soundXianglingGrowl4;
public static AudioClip soundXianglingKill;
public static AudioClip soundXianglingShootTongue;
public static AudioClip soundXianglingSnarl;
public static AudioClip soundXianglingDie;
public static AudioClip soundXianglingStun;
public static TextAsset XiangText;
public static VideoClip XiangVideo;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = ((BaseUnityPlugin)this).Logger;
mls.LogInfo((object)"--=== XIANGLING MOD LOADED ===--");
harmony.PatchAll(typeof(XianglingModBase));
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "xiangling");
mls.LogDebug((object)text);
XianglingAssetBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)XianglingAssetBundle == (Object)null)
{
mls.LogError((object)"-Could not find Xiangling Assets-");
}
XianglingPrefab = XianglingAssetBundle.LoadAsset<GameObject>("Assets/PrefabInstance/Xiangling1.prefab");
GuobaPrefab = XianglingAssetBundle.LoadAsset<GameObject>("Assets/PrefabInstance/Guoba.prefab");
SkinnedMeshRenderer[] componentsInChildren = XianglingPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true);
SkinnedMeshRenderer[] array = componentsInChildren;
foreach (SkinnedMeshRenderer val in array)
{
((Component)val).gameObject.layer = LayerMask.NameToLayer("Enemies");
}
XiangVideo = XianglingAssetBundle.LoadAsset<VideoClip>("Assets/Terminal/XiangVideo.mp4");
XiangText = XianglingAssetBundle.LoadAsset<TextAsset>("Assets/Terminal/XiangText.txt");
}
private void Start()
{
soundXianglingHit = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingHit.ogg");
soundXianglingCloseCall1 = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingCC1.ogg");
soundXianglingCloseCall2 = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingCC2.ogg");
soundXianglingFarCall1 = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingFC1.ogg");
soundXianglingFarCall2 = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingFC2.ogg");
soundXianglingGrowl1 = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingGrowl1.ogg");
soundXianglingGrowl2 = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingGrowl2.ogg");
soundXianglingGrowl3 = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingGrowl3.ogg");
soundXianglingGrowl4 = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingGrowl4.ogg");
soundXianglingKill = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingKill.ogg");
soundXianglingShootTongue = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingShootTongue.ogg");
soundXianglingSnarl = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingSnarl.ogg");
soundXianglingDie = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingDie.ogg");
soundXianglingStun = XianglingAssetBundle.LoadAsset<AudioClip>("Assets/AudioClip/Xiangling/XianglingStun.ogg");
}
[HarmonyPatch(typeof(BushWolfEnemy), "Start")]
[HarmonyPostfix]
public static void PluginDetectBushWolf(BushWolfEnemy __instance)
{
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)((Component)__instance).transform.Find("AnimContainer")).gameObject;
if (!HasChildWithName(gameObject, "Xiangling1(Clone)") && !HasChildWithName(gameObject, "Guoba(Clone)"))
{
__instance.hitBushWolfSFX = soundXianglingHit;
__instance.callsClose[0] = soundXianglingCloseCall1;
__instance.callsClose[1] = soundXianglingCloseCall2;
__instance.callsFar[0] = soundXianglingFarCall1;
__instance.callsFar[1] = soundXianglingFarCall2;
__instance.growlSFX[0] = soundXianglingGrowl1;
__instance.growlSFX[1] = soundXianglingGrowl2;
__instance.growlSFX[2] = soundXianglingGrowl3;
__instance.growlSFX[3] = soundXianglingGrowl4;
__instance.killSFX = soundXianglingKill;
__instance.shootTongueSFX = soundXianglingShootTongue;
__instance.snarlSFX = soundXianglingSnarl;
__instance.tongueShootSFX = soundXianglingShootTongue;
((EnemyAI)__instance).dieSFX = soundXianglingDie;
((EnemyAI)__instance).enemyType.stunSFX = soundXianglingStun;
Transform parent = ((Component)__instance).transform.Find("AnimContainer");
Transform parent2 = ((Component)__instance).transform.Find("AnimContainer");
((Renderer)((Component)((Component)__instance).gameObject.transform.Find("Mesh").Find("BodyLOD0")).gameObject.GetComponent<SkinnedMeshRenderer>()).enabled = false;
((Renderer)((Component)((Component)__instance).gameObject.transform.Find("Mesh").Find("BodyLOD1")).gameObject.GetComponent<SkinnedMeshRenderer>()).enabled = false;
((Renderer)((Component)((Component)__instance).gameObject.transform.Find("Mesh").Find("BodyLOD2")).gameObject.GetComponent<SkinnedMeshRenderer>()).enabled = false;
((Renderer)((Component)((Component)__instance).gameObject.transform.Find("GameObject").Find("FrogTongue")).GetComponent<MeshRenderer>()).enabled = false;
((Renderer)((Component)((Component)__instance).gameObject.transform.Find("AnimContainer").Find("metarigContainer").Find("metarig")
.Find("Bone.001")
.Find("UpperChest")
.Find("Neck1")
.Find("Neck2")
.Find("Neck3")
.Find("Head")
.Find("PlayerHead")).GetComponent<MeshRenderer>()).enabled = false;
((Component)((Component)__instance).gameObject.transform.Find("ScanNode (1)")).gameObject.GetComponent<ScanNodeProperties>().headerText = "Xiangling";
XianglingObject = Object.Instantiate<GameObject>(XianglingPrefab);
XianglingObject.transform.SetParent(parent);
GuobaObject = Object.Instantiate<GameObject>(GuobaPrefab);
GuobaObject.transform.SetParent(parent2);
XianglingObject.AddComponent<EnemyAnimationEvent>();
XianglingObject.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
XianglingObject.transform.localPosition = new Vector3(0f, 0f, 0f);
GuobaObject.transform.localPosition = new Vector3(0f, 0f, 0f);
__instance.tongueStartPoint = ((Component)((Component)__instance).gameObject.transform.Find("AnimContainer").Find("Xiangling1(Clone)").Find("Armature")
.Find("全ての親")
.Find("センター")
.Find("センター2")
.Find("グルーブ")
.Find("グルーブ2")
.Find("腰")
.Find("上半身")
.Find("上半身2")
.Find("首")
.Find("頭")
.Find("舌1")
.Find("TongueStartPoint")).transform;
((EnemyAI)__instance).creatureAnimator = ((Component)XianglingObject.transform).GetComponent<Animator>();
}
}
[HarmonyPatch(typeof(BushWolfEnemy), "LateUpdate")]
[HarmonyPostfix]
public static void GuobaSize(BushWolfEnemy __instance)
{
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: 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)
GameObject gameObject = ((Component)((Component)__instance).transform.Find("AnimContainer")).gameObject;
if (HasChildWithName(gameObject, "Guoba(Clone)") || (Object)(object)__instance == (Object)null)
{
return;
}
Transform val = ((Component)__instance).transform.Find("AnimContainer").Find("Guoba(Clone)");
if ((Object)(object)val == (Object)null)
{
return;
}
bool activeSelf = ((Component)((Component)__instance).gameObject.transform.Find("GameObject")).gameObject.activeSelf;
((Component)val).gameObject.SetActive(activeSelf);
Vector3 val2 = (((Object)(object)val.parent != (Object)null) ? val.parent.lossyScale : Vector3.one);
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(10f, 10f, 10f);
Vector3 localScale = default(Vector3);
((Vector3)(ref localScale))..ctor(val3.x / val2.x, val3.y / val2.y, val3.z / val2.z);
val.localScale = localScale;
FieldInfo field = typeof(BushWolfEnemy).GetField("tongueTarget", BindingFlags.Instance | BindingFlags.NonPublic);
if (!(field == null))
{
Transform val4 = (Transform)field.GetValue(__instance);
if (!((Object)(object)val4 == (Object)null) && !((Object)(object)__instance.tongueStartPoint == (Object)null))
{
Vector3 val5 = __instance.tongueStartPoint.position - val4.position;
((Vector3)(ref val5)).Normalize();
Vector3 position = val4.position + val5 * 1f;
position.y -= 0.7f;
((Component)val).transform.position = position;
Vector3 val6 = val4.position - val.position;
((Component)val).transform.rotation = Quaternion.LookRotation(val6);
((Component)val).transform.Rotate(70f, 0f, 0f, (Space)1);
}
}
}
[HarmonyPatch(typeof(Terminal), "BeginUsingTerminal")]
[HarmonyPostfix]
public static void BeginUsingTerminalPatch(Terminal __instance)
{
__instance.terminalNodes.allKeywords[137].word = "xiangling";
__instance.enemyFiles[23].creatureName = "Xiangling";
__instance.enemyFiles[23].displayVideo = XiangVideo;
__instance.enemyFiles[23].displayText = XiangText.text;
}
private static bool HasChildWithName(GameObject parent, string childName)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
foreach (Transform item in parent.transform)
{
Transform val = item;
if (((Object)val).name == childName)
{
return true;
}
}
return false;
}
}