using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("canFart")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("canFart")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("093a27fc-e347-4e2d-b831-458af2e3a8f1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace canFart;
[BepInPlugin("CanFart_SlimeYuri", "CanFart", "1.0.0")]
public class CanFart : BaseUnityPlugin
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "CanFart_SlimeYuri";
public const string PLUGIN_NAME = "CanFart";
public const string PLUGIN_VERSION = "1.0.0";
}
[CompilerGenerated]
private sealed class <FartCoolDownCoroutine>d__10 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float cdDuration;
public CanFart <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FartCoolDownCoroutine>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this.isInCoolDown = true;
<>2__current = (object)new WaitForSeconds(cdDuration);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>4__this.isInCoolDown = false;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private ConfigEntry<bool> enableCd;
private ConfigEntry<float> cdDurationConfig;
private ConfigEntry<float> FartingForce;
private bool isInCoolDown;
public ConfigEntry<KeyCode> hotkey;
private static MethodInfo _spawnMethod;
private static MethodInfo _rpcMethod;
private static MethodInfo _GetBodypartRig;
internal static CanFart instance;
public void Start()
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
instance = this;
enableCd = ((BaseUnityPlugin)this).Config.Bind<bool>("放屁设置", "EnableCoolDown", true, "是否启用CD");
cdDurationConfig = ((BaseUnityPlugin)this).Config.Bind<float>("放屁设置", "CoolDownDuration", 2f, "CD时长(秒)");
FartingForce = ((BaseUnityPlugin)this).Config.Bind<float>("升空力度", "lift_off Force", 2000f, "float浮点数,Default:2000f,Recommnad:0f~8000f");
hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("快捷键", "hotkey", (KeyCode)102, "默认键位键盘C,改键位时复制上述支持的键位即可:The default key for the keyboard is C. When changing the key, you can copy the supported keys mentioned above.");
Harmony val = new Harmony("CanFart_SlimeYuri");
val.PatchAll();
_spawnMethod = AccessTools.Method(typeof(GameUtils), "SpawnResourceAtPositionNetworked", (Type[])null, (Type[])null);
_rpcMethod = AccessTools.Method(typeof(GameUtils), "RPC_SpawnResourceAtPosition", (Type[])null, (Type[])null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"CanFart 已启动!");
}
public void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(hotkey.Value) && !isInCoolDown)
{
Fart();
if (enableCd.Value)
{
((MonoBehaviour)this).StartCoroutine(FartCoolDownCoroutine(cdDurationConfig.Value));
}
}
}
[IteratorStateMachine(typeof(<FartCoolDownCoroutine>d__10))]
private IEnumerator FartCoolDownCoroutine(float cdDuration)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FartCoolDownCoroutine>d__10(0)
{
<>4__this = this,
cdDuration = cdDuration
};
}
public void Fart()
{
Character localCharacter = Character.localCharacter;
instance.TryFart(localCharacter);
}
public void TryFart(Character character)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Expected O, but got Unknown
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
try
{
GameUtils val = GameUtils.instance;
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"未找到GameUtils组件实例,无法执行放屁逻辑!");
return;
}
_spawnMethod.Invoke(val, new object[3]
{
"VFX_SporeExploExploEdibleSpawn",
character.Center,
(object)(RpcTarget)1
});
_rpcMethod.Invoke(val, new object[2] { "VFX_SporeExploExploEdibleSpawn_NoKnockback", character.Center });
_GetBodypartRig = AccessTools.Method(typeof(Character), "GetBodypartRig", new Type[1] { typeof(BodypartType) }, (Type[])null);
if ((Object)(object)character == (Object)null)
{
Debug.LogError((object)"TryFart: Character实例为空!");
return;
}
if (_GetBodypartRig == null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"未找到_GetBodypartRig");
}
Rigidbody val2 = (Rigidbody)_GetBodypartRig.Invoke(character, new object[1] { (object)(BodypartType)0 });
if ((Object)(object)val2 == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"未找到rig");
}
character.AddForceToBodyPart(val2, Vector3.zero, Vector3.up * FartingForce.Value);
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("放屁逻辑执行失败:" + ex.Message + "\n" + ex.StackTrace));
}
}
}