using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FallingStaticObject;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyTemplate;
using LinkStatue;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LinkStatue")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds random Link Statue to any map.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+43206f0475d7dae18e393eaa115cfd192399712f")]
[assembly: AssemblyProduct("LinkStatue")]
[assembly: AssemblyTitle("LinkStatue")]
[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;
}
}
}
namespace LethalCompanyTemplate
{
[BepInPlugin("LinkStatue", "LinkStatue", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(GameNetworkManager))]
internal class GameNetworkManagerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch()
{
((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().AddNetworkPrefab(LinkPrefab);
}
}
private Harmony harmony = new Harmony("LinkStatue");
public static string AppRoot = Path.Combine(Paths.PluginPath, "MadCows-LinkStatue");
public static AssetBundle appAssets = null;
public static GameObject LinkPrefab;
public static Plugin _instance;
public static ManualLogSource TTLogger { get; set; }
private void Awake()
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
_instance = this;
TTLogger = Logger.CreateLogSource("Link Statue Mod");
loadBundle();
TTLogger.LogInfo((object)("Plugin LinkStatue is loaded! at " + AppRoot));
LinkPrefab = appAssets.LoadAsset<GameObject>("LinkStatue");
LinkPrefab.AddComponent<FallingObject>();
LinkPrefab.AddComponent<LinkStatueAI>();
LinkPrefab.transform.localScale = new Vector3(2f, 2f, 2f);
harmony.PatchAll(typeof(StartOfRoundPatch));
harmony.PatchAll(typeof(RoundManagerPatch));
harmony.PatchAll(typeof(GameNetworkManagerPatch));
}
private void loadBundle()
{
string path = Path.Combine(AppRoot, "myassetbundle");
byte[] array = File.ReadAllBytes(path);
AssetBundle val = AssetBundle.LoadFromMemory(array);
if ((Object)(object)val != (Object)null)
{
TTLogger.LogInfo((object)"YES THE BUNDLE WAS LOADED!");
appAssets = val;
}
else
{
Debug.LogError((object)"Failed to load the custom prefab.");
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LinkStatue";
public const string PLUGIN_NAME = "LinkStatue";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace LinkStatue
{
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch : MonoBehaviour
{
[HarmonyPatch("Start")]
[HarmonyPrefix]
private static void StartPatch(ref StartOfRound __instance)
{
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
[HarmonyPatch("GeneratedFloorPostProcessing")]
[HarmonyPrefix]
private static void GeneratedFloorPostProcessingPatch(ref RoundManager __instance)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsServer && (double)Random.value >= 0.5)
{
__instance.mapPropsContainer = GameObject.FindGameObjectWithTag("MapPropsContainer");
GameObject linkPrefab = Plugin.LinkPrefab;
Vector3 position = linkPrefab.transform.position;
position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(GameObject.Find("LevelGenerationRoot").transform.position, 100f, default(NavMeshHit));
Quaternion val = Quaternion.Euler(new Vector3(linkPrefab.transform.eulerAngles.x, RoundManager.Instance.YRotationThatFacesTheFarthestFromPosition(position, 25f, 6), linkPrefab.transform.eulerAngles.z));
GameObject val2 = Object.Instantiate<GameObject>(linkPrefab, position, val);
((Object)val2).name = "LINK_THE_HERO";
val2.GetComponent<NetworkObject>().Spawn(false);
val2.GetComponent<LinkStatueAI>().MoveStatueSpot();
}
}
[HarmonyPatch("UnloadSceneObjectsEarly")]
[HarmonyPrefix]
private static void UnloadSceneObjectsEarlyPatch(ref RoundManager __instance)
{
GameObject val = GameObject.Find("LINK_THE_HERO");
if (((NetworkBehaviour)__instance).IsServer && Object.op_Implicit((Object)(object)val))
{
val.GetComponent<NetworkObject>().Despawn(true);
}
}
}
internal class LinkStatueAI : NetworkBehaviour
{
private bool _hasBeenSeen = false;
private int _numOfEyesOnMe = 0;
private float _timeSeen = 0f;
public float teleportDelay = 20f;
public float teleportRange = 10f;
private float _teleTrueTime = 0f;
public float tooLonelyTimeDelay = 180f;
private float tooLonelyTime;
public void Start()
{
tooLonelyTime = Time.time + tooLonelyTimeDelay;
((MonoBehaviour)this).InvokeRepeating("CheckSitesSlow", 0f, 2f);
}
public void CheckSitesSlow()
{
if (((NetworkBehaviour)this).IsHost)
{
PlayerControllerB[] lineOfSightOfAny = GetLineOfSightOfAny();
_numOfEyesOnMe = lineOfSightOfAny.Length;
if (_numOfEyesOnMe > 0 && !_hasBeenSeen)
{
_hasBeenSeen = true;
_timeSeen = Time.time;
_teleTrueTime = Random.Range(teleportDelay - teleportRange, teleportDelay + teleportRange);
}
}
}
public void Update()
{
if (((NetworkBehaviour)this).IsServer && ((_hasBeenSeen && Time.time > _timeSeen + _teleTrueTime) || Time.time > tooLonelyTime))
{
if (GetLineOfSightOfAny().Length != 0)
{
_timeSeen = Time.time;
return;
}
tooLonelyTime = Time.time + tooLonelyTimeDelay;
MoveStatueSpot();
}
}
private void OnDestroy()
{
((MonoBehaviour)this).CancelInvoke();
}
public void MoveStatueSpot()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
Plugin.TTLogger.LogMessage((object)"Moving link statue to new Location.");
Vector3 position = ((Component)this).transform.position;
position = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(GameObject.Find("LevelGenerationRoot").transform.position, 100f, default(NavMeshHit));
((Component)this).transform.position = position;
((Component)this).transform.rotation = Quaternion.Euler(new Vector3(((Component)this).transform.eulerAngles.x, RoundManager.Instance.YRotationThatFacesTheFarthestFromPosition(position, 25f, 6), ((Component)this).transform.eulerAngles.z));
_hasBeenSeen = false;
}
public PlayerControllerB[] GetLineOfSightOfAny(float width = 45f, int range = 60, float proximityCheck = -1f)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
List<PlayerControllerB> list = new List<PlayerControllerB>(4);
for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
{
Vector3 position = ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform.position;
Vector3 position2 = ((Component)((Component)this).transform.Find("HeadPos")).transform.position;
Transform transform = ((Component)StartOfRound.Instance.allPlayerScripts[i].gameplayCamera).transform;
if (Vector3.Distance(((Component)this).transform.position, position) < (float)range && !Physics.Linecast(position2, position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
{
Vector3 val = position - position2;
Debug.Log((object)Vector3.Angle(transform.forward, val));
if (Vector3.Angle(-transform.forward, val) < width || Vector3.Distance(position2, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < proximityCheck)
{
Debug.Log((object)"Yes this player is looking at the statue");
list.Add(StartOfRound.Instance.allPlayerScripts[i]);
}
}
}
if (list.Count > 0)
{
return list.ToArray();
}
return Array.Empty<PlayerControllerB>();
}
}
}
namespace FallingStaticObject
{
internal class FallingObject : MonoBehaviour
{
public Vector3 targetFloorPosition;
private float fallTime;
public float verticalOffset = 0f;
private Vector3 startFallingPosition;
public void Start()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
startFallingPosition = ((Component)this).transform.position;
FallToGround();
}
public void Update()
{
if (fallTime < 1f)
{
FallWithCurve();
}
}
public void FallToGround(bool randomizePosition = false)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_0041: 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)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
fallTime = 0f;
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(((Component)this).transform.position, Vector3.down, ref val, 80f, 268437760, (QueryTriggerInteraction)1))
{
targetFloorPosition = ((RaycastHit)(ref val)).point + verticalOffset * Vector3.up;
if ((Object)(object)((Component)this).transform.parent != (Object)null)
{
targetFloorPosition = ((Component)this).transform.parent.InverseTransformPoint(targetFloorPosition);
}
}
else
{
targetFloorPosition = ((Component)this).transform.localPosition;
}
if (randomizePosition)
{
targetFloorPosition += new Vector3(Random.Range(-0.5f, 0.5f), 0f, Random.Range(-0.5f, 0.5f));
}
}
public virtual void FallWithCurve()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
float num = startFallingPosition.y - targetFloorPosition.y;
if (num > 5f)
{
((Component)this).transform.localPosition = Vector3.Lerp(startFallingPosition, targetFloorPosition, StartOfRound.Instance.objectFallToGroundCurveNoBounce.Evaluate(fallTime));
}
else
{
((Component)this).transform.localPosition = Vector3.Lerp(startFallingPosition, targetFloorPosition, StartOfRound.Instance.objectFallToGroundCurve.Evaluate(fallTime));
}
fallTime += Mathf.Abs(Time.deltaTime * 6f / num);
}
}
}