using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MyceliumNetworking;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("DontTrip")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Makes you Randomly Trip if you Sprint")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0")]
[assembly: AssemblyProduct("DontTrip")]
[assembly: AssemblyTitle("DontTrip")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.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 DontTrip
{
[BepInPlugin("DontTrip", "DontTrip", "1.3.0")]
[BepInProcess("Content Warning.exe")]
public class DontTrip : BaseUnityPlugin
{
public static DontTrip instance;
public static readonly Harmony harmony = new Harmony("DontTrip");
public static ConfigEntry<float> Duration { get; set; }
public static ConfigEntry<float> ChanceToTrip { get; set; }
public static ConfigEntry<float> DamageAmount { get; set; }
public static ConfigEntry<bool> DoesDamage { get; set; }
public static ConfigEntry<bool> DropItem { get; set; }
private void Awake()
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
instance = this;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin DontTrip is loaded!");
Duration = ((BaseUnityPlugin)this).Config.Bind<float>("DontTrip", "Duration of ragdoll", 2f, "The amount of time to ragdoll for");
ChanceToTrip = ((BaseUnityPlugin)this).Config.Bind<float>("DontTrip", "Tripping Chance", 5f, new ConfigDescription("The Chance to Trip in percent 0-100", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
DamageAmount = ((BaseUnityPlugin)this).Config.Bind<float>("DontTrip", "Damage Amount", 5f, "The Damage to Take on Tripping");
DoesDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("DontTrip", "Does Damage", true, "If True you get Damage on Tripping");
DropItem = ((BaseUnityPlugin)this).Config.Bind<bool>("DontTrip", "Drop Item", true, "If True you drop Item on Tripping");
harmony.PatchAll();
}
}
[HarmonyPatch(typeof(Player))]
public static class PlayerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Start(Player __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
if (__instance.IsLocal && !((Object)((Component)__instance).gameObject.GetComponent<Tripper>() != (Object)null))
{
Tripper tripper = ((Component)__instance).gameObject.AddComponent<Tripper>();
tripper.player = __instance;
}
}
}
public class Tripper : MonoBehaviour
{
private float maxTimerTime = 5f;
private float TimerTime = 0f;
private Vector3 TripForce;
private float Duration;
private float Chance;
private float DamageAmount;
private bool DoesDamage;
private bool DropItem;
private const uint modId = 817816524u;
public Player player { get; set; }
private void Awake()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
TripForce = Vector3.forward;
MyceliumNetwork.RegisterLobbyDataKey("K_Duration");
MyceliumNetwork.RegisterLobbyDataKey("K_Chance");
MyceliumNetwork.RegisterLobbyDataKey("K_DamageAmount");
MyceliumNetwork.RegisterLobbyDataKey("K_DoesDamage");
MyceliumNetwork.RegisterLobbyDataKey("K_DropItem");
}
private void Start()
{
MyceliumNetwork.RegisterNetworkObject((object)this, 817816524u, 0);
LocalInit();
if (player.refs.view.IsMine)
{
if (MyceliumNetwork.IsHost)
{
MyceliumNetwork.SetLobbyData("K_Duration", (object)DontTrip.Duration.Value);
MyceliumNetwork.SetLobbyData("K_Chance", (object)DontTrip.ChanceToTrip.Value);
MyceliumNetwork.SetLobbyData("K_DamageAmount", (object)DontTrip.DamageAmount.Value);
MyceliumNetwork.SetLobbyData("K_DoesDamage", (object)DontTrip.DoesDamage.Value);
MyceliumNetwork.SetLobbyData("K_DropItem", (object)DontTrip.DropItem.Value);
}
else
{
Duration = MyceliumNetwork.GetLobbyData<float>("K_Duration");
Chance = MyceliumNetwork.GetLobbyData<float>("K_Chance");
DamageAmount = MyceliumNetwork.GetLobbyData<float>("K_DamageAmount");
DoesDamage = MyceliumNetwork.GetLobbyData<bool>("K_DoesDamage");
DropItem = MyceliumNetwork.GetLobbyData<bool>("K_DropItem");
}
}
}
private void LocalInit()
{
Duration = DontTrip.Duration.Value;
Chance = DontTrip.ChanceToTrip.Value;
DoesDamage = DontTrip.DoesDamage.Value;
DropItem = DontTrip.DropItem.Value;
if (DoesDamage)
{
DamageAmount = DontTrip.DamageAmount.Value;
}
else
{
DamageAmount = 0f;
}
}
public void Update()
{
if (!player.data.dead)
{
Timer();
}
}
private void Timer()
{
if (TimerTime >= maxTimerTime)
{
if (player.data.isSprinting && player.data.fallTime <= 0f)
{
CheckTrip();
}
ResetTimer();
}
else
{
TimerTime += Time.deltaTime;
}
}
private void ResetTimer()
{
TimerTime = 0f;
}
private void CheckTrip()
{
float num = Random.Range(0, 100);
if (num < Chance)
{
MakeTrip();
}
}
private void MakeTrip()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
player.CallTakeDamageAndAddForceAndFall(DamageAmount, TripForce, Duration);
if (DropItem)
{
player.refs.items.DropItem(player.data.selectedItemSlot, false);
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "DontTrip";
public const string PLUGIN_NAME = "DontTrip";
public const string PLUGIN_VERSION = "1.3.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}