using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("PeakPropHunt")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bfdd906f192d313960a072f17b669fd9653f94f0")]
[assembly: AssemblyProduct("PEAK Prop Hunt")]
[assembly: AssemblyTitle("PeakPropHunt")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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;
}
}
}
[BepInPlugin("com.binston.prophunt", "PropHunt", "0.1.0")]
public class PropHunt : BaseUnityPlugin
{
internal static ManualLogSource Log;
public static ConfigEntry<float> ChainLength;
public static ConfigEntry<bool> PropHuntEnabled;
public static ConfigEntry<bool> EnableChainedTogether;
public static ConfigEntry<bool> EnableStaminaDrainAndFogAndStatusEffects;
private void Awake()
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"PropHunt loaded.");
ChainLength = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ChainLength", 5f, "Maximum chain length between players.");
EnableChainedTogether = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableChainedTogether", true, "Enable Chained Together mode.");
PropHuntEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PropHuntEnabled", false, "Enable Prop Hunt mode.");
EnableStaminaDrainAndFogAndStatusEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableStaminaDrainAndFogAndStatusEffects", true, "Enable stamina drain, fog movement, and status effects.");
Harmony val = new Harmony("com.binston.prophunt");
if (!EnableStaminaDrainAndFogAndStatusEffects.Value)
{
val.PatchAll(typeof(DisableEffectPatch));
}
val.PatchAll(typeof(PropHuntMod));
}
}
public static class DisableEffectPatch
{
[HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")]
[HarmonyPrefix]
public static bool PreventAllStatusEffects(STATUSTYPE statusType, float amount, CharacterAfflictions __instance)
{
return false;
}
[HarmonyPatch(typeof(Character), "UseStamina")]
[HarmonyPrefix]
public static bool StopStaminaDrain(float usage, Character __instance)
{
return false;
}
[HarmonyPatch(typeof(Fog), "Movement")]
[HarmonyPatch(typeof(OrbFogHandler), "Move")]
[HarmonyPatch(typeof(OrbFogHandler), "WaitToMove")]
[HarmonyPrefix]
public static bool StopFogMovementAndTimer()
{
return false;
}
}
[HarmonyPatch(typeof(Character), "Awake")]
public static class PropHuntMod
{
[HarmonyPostfix]
public static void AwakePatch(Character __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
if ((Object)((Component)__instance).GetComponent<PropHuntPatch>() == (Object)null)
{
((Component)__instance).gameObject.AddComponent<PropHuntPatch>();
PropHunt.Log.LogInfo((object)("PropHuntPatch added to: " + ((Object)__instance).name));
}
}
}
public class PropHuntPatch : MonoBehaviourPun
{
private static readonly HashSet<string> PropNames = new HashSet<string> { "luggagewagon (5)", "Flight Board (3)", "Mesh_CoconutGreen", "Apple Berry", "Jelly", "BushLeaves", "HomeShell_NoBandage", "Bugle" };
private Character character;
private CharacterMovement charMovement;
private List<GameObject> props;
private GameObject activeProp;
private int activePropIndex;
private bool propTransformDirty;
private DateTime lastPropTransformUpdate = DateTime.Now;
public static string GetObjectInfo(object o)
{
StringBuilder stringBuilder = new StringBuilder();
Type type = o.GetType();
stringBuilder.Append("Type: " + type.Name);
stringBuilder.Append("\r\n\r\nFields:");
FieldInfo[] fields = type.GetFields();
if (fields.Length != 0)
{
FieldInfo[] array = fields;
foreach (FieldInfo fieldInfo in array)
{
stringBuilder.Append("\r\n " + fieldInfo.ToString() + " = " + fieldInfo.GetValue(o));
}
}
else
{
stringBuilder.Append("\r\n None");
}
stringBuilder.Append("\r\n\r\nProperties:");
PropertyInfo[] properties = type.GetProperties();
if (properties.Length != 0)
{
PropertyInfo[] array2 = properties;
foreach (PropertyInfo propertyInfo in array2)
{
stringBuilder.Append("\r\n " + propertyInfo.ToString() + " = " + propertyInfo.GetValue(o, null));
}
}
else
{
stringBuilder.Append("\r\n None");
}
return stringBuilder.ToString();
}
public static void DisplayObjectInfo(object o)
{
string objectInfo = GetObjectInfo(o);
PropHunt.Log.LogInfo((object)objectInfo);
}
private void ApplyChainForce()
{
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Expected O, but got Unknown
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: 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_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
Character[] array = (from c in Object.FindObjectsByType<Character>((FindObjectsSortMode)0)
where (Object)(object)c != (Object)null && !Object.op_Implicit((Object)(object)c.Ghost) && !c.isBot && ((Behaviour)c).isActiveAndEnabled
select c).ToArray();
for (int i = 0; i < array.Length - 1; i++)
{
Transform val = ((IEnumerable<Transform>)((Component)array[i]).GetComponentsInChildren<Transform>()).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "Hip"));
Transform val2 = ((IEnumerable<Transform>)((Component)array[i + 1]).GetComponentsInChildren<Transform>()).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "Hip"));
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
{
continue;
}
float num = Vector3.Distance(val.position, val2.position);
if (num > PropHunt.ChainLength.Value)
{
Rigidbody component = ((Component)val).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
Vector3 val3 = val2.position - val.position;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float val4 = (num - PropHunt.ChainLength.Value) * 10f;
val4 = Math.Min(val4, 40f);
component.AddForce(normalized * val4, (ForceMode)2);
}
}
string text = $"ChainLine_{i}";
GameObject val5 = GameObject.Find(text);
LineRenderer val6;
if ((Object)(object)val5 == (Object)null)
{
val6 = new GameObject(text).AddComponent<LineRenderer>();
val6.positionCount = 2;
((Renderer)val6).material = new Material(Shader.Find("Sprites/Default"));
val6.startColor = new Color(0.36f, 0.22f, 0.09f);
val6.endColor = new Color(0.36f, 0.22f, 0.09f);
val6.startWidth = 0.1f;
val6.endWidth = 0.1f;
}
else
{
val6 = val5.GetComponent<LineRenderer>();
}
val6.SetPosition(0, val.position);
val6.SetPosition(1, val2.position);
}
}
private void Start()
{
character = ((Component)this).GetComponent<Character>();
charMovement = ((Component)this).GetComponent<CharacterMovement>();
props = new List<GameObject>();
}
public static void PrintTransformsRecursively(Transform transform, int depth)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
PropHunt.Log.LogInfo((object)$"{new string(' ', depth * 2)}{((Object)transform).name}: {transform.position}");
foreach (Transform item in transform)
{
PrintTransformsRecursively(item, depth + 1);
}
}
private Transform GetRealPlayerTransform()
{
return ((Component)this).transform.GetChild(0).GetChild(0).GetChild(0);
}
private GameObject CreatePropFromReferenceObject(GameObject referenceObject)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
GameObject obj = Object.Instantiate<GameObject>(referenceObject, new Vector3(0f, 0f, 0f), Quaternion.identity);
obj.transform.SetParent(GetRealPlayerTransform());
obj.transform.localPosition = Vector3.zero;
obj.transform.localScale = Vector3.one;
((Component)obj.GetComponentInChildren<Renderer>()).gameObject.SetActive(false);
return obj;
}
private void TryCreatePropsFromObjectsInScene()
{
if (props.Count > 0)
{
return;
}
HashSet<string> hashSet = new HashSet<string>();
GameObject[] array = Object.FindObjectsByType<GameObject>((FindObjectsSortMode)0);
foreach (GameObject val in array)
{
if (PropNames.Contains(((Object)val).name) && !hashSet.Contains(((Object)val).name))
{
hashSet.Add(((Object)val).name);
GameObject item = CreatePropFromReferenceObject(val);
props.Add(item);
PropHunt.Log.LogInfo((object)("Created prop from object: " + ((Object)val).name));
}
}
}
private void HidePlayer()
{
MeshRenderer[] componentsInChildren = ((Component)character).GetComponentsInChildren<MeshRenderer>(true);
foreach (MeshRenderer val in componentsInChildren)
{
if (!((Object)(object)((Component)val).gameObject == (Object)(object)activeProp))
{
((Renderer)val).enabled = false;
}
}
SkinnedMeshRenderer[] componentsInChildren2 = ((Component)character).GetComponentsInChildren<SkinnedMeshRenderer>(true);
foreach (SkinnedMeshRenderer val2 in componentsInChildren2)
{
if (!((Object)(object)((Component)val2).gameObject == (Object)(object)activeProp))
{
((Renderer)val2).enabled = false;
}
}
}
private void ShowPlayer()
{
MeshRenderer[] componentsInChildren = ((Component)character).GetComponentsInChildren<MeshRenderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Renderer)componentsInChildren[i]).enabled = true;
}
SkinnedMeshRenderer[] componentsInChildren2 = ((Component)character).GetComponentsInChildren<SkinnedMeshRenderer>(true);
for (int i = 0; i < componentsInChildren2.Length; i++)
{
((Renderer)componentsInChildren2[i]).enabled = true;
}
}
private void SetProp(string propName)
{
//IL_00d5: 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)
if ((Object)(object)activeProp != (Object)null)
{
((Component)activeProp.GetComponentInChildren<Renderer>()).gameObject.SetActive(false);
activeProp = null;
}
if (propName == "")
{
ShowPlayer();
return;
}
if (props.Count == 0)
{
PropHunt.Log.LogWarning((object)"No props available to toggle.");
return;
}
activeProp = props.Find((GameObject p) => ((Object)p).name == propName);
if ((Object)(object)activeProp == (Object)null)
{
PropHunt.Log.LogWarning((object)("Prop not found: " + propName));
return;
}
((Component)activeProp.GetComponentInChildren<Renderer>()).gameObject.SetActive(true);
activeProp.transform.localPosition = Vector3.zero;
activeProp.transform.localRotation = Quaternion.identity;
HidePlayer();
PropHunt.Log.LogInfo((object)("Toggled prop: " + ((Object)activeProp).name));
}
private void Update()
{
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: 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_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
if (PropHunt.EnableChainedTogether.Value && Time.timeSinceLevelLoad > 10f && character.IsLocal)
{
ApplyChainForce();
}
if (!PropHunt.PropHuntEnabled.Value)
{
return;
}
TryCreatePropsFromObjectsInScene();
((Component)((Component)character).transform.GetChild(0).GetChild(6).GetChild(3)).gameObject.SetActive(false);
if (!character.IsLocal)
{
return;
}
if (Input.GetKeyDown((KeyCode)111))
{
string text = "";
if ((Object)(object)activeProp == (Object)null && props.Count > 0)
{
activePropIndex = (activePropIndex + 1) % props.Count;
text = ((Object)props[activePropIndex]).name;
}
((MonoBehaviourPun)this).photonView.RPC("RpcSetProp", (RpcTarget)0, new object[1] { text });
propTransformDirty = true;
}
if ((Object)(object)activeProp != (Object)null)
{
Quaternion localRotation = activeProp.transform.localRotation;
Vector3 eulerAngles = ((Quaternion)(ref localRotation)).eulerAngles;
if (Input.GetKey((KeyCode)105))
{
eulerAngles.x += 5f;
}
if (Input.GetKey((KeyCode)107))
{
eulerAngles.x -= 5f;
}
if (Input.GetKey((KeyCode)106))
{
eulerAngles.y += 5f;
}
if (Input.GetKey((KeyCode)108))
{
eulerAngles.y -= 5f;
}
if (((Vector3)(ref eulerAngles)).magnitude > 0.001f)
{
propTransformDirty = true;
}
activeProp.transform.localRotation = Quaternion.Euler(eulerAngles.x, eulerAngles.y, eulerAngles.z);
}
if ((Object)(object)activeProp != (Object)null && propTransformDirty && DateTime.Now.Subtract(lastPropTransformUpdate).TotalSeconds > 0.10000000149011612)
{
((MonoBehaviourPun)this).photonView.RPC("RpcUpdatePropTransform", (RpcTarget)0, new object[2]
{
activeProp.transform.localPosition,
activeProp.transform.localRotation
});
lastPropTransformUpdate = DateTime.Now;
propTransformDirty = false;
}
}
[PunRPC]
public void RpcSetProp(string propName)
{
SetProp(propName);
}
[PunRPC]
public void RpcUpdatePropTransform(Vector3 position, Quaternion rotation)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)activeProp != (Object)null)
{
activeProp.transform.localPosition = position;
activeProp.transform.localRotation = rotation;
}
}
}
namespace PeakPropHunt
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "PeakPropHunt";
public const string PLUGIN_NAME = "PEAK Prop Hunt";
public const string PLUGIN_VERSION = "1.0.0";
}
}