using System;
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 BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("GameAssembly")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SBG-AutoSpectator")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("Auto Spectator")]
[assembly: AssemblyTitle("SBG-AutoSpectator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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 SpectatorCamera
{
[BepInPlugin("com.kingcox22.sbg.autospectator", "Auto Spectator", "1.3.4")]
public class SpectatorCameraPlugin : BaseUnityPlugin
{
private float _specTimer = 0f;
private ConfigEntry<float> _configUpdateInterval;
private void Awake()
{
_configUpdateInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Spectator", "Update Interval", 3f, "Seconds between camera updates.");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Auto Spectator 1.3.4 (Cinematic View) Loaded.");
}
private void Update()
{
if (NetworkClient.active)
{
_specTimer += Time.deltaTime;
if (_specTimer >= _configUpdateInterval.Value)
{
_specTimer = 0f;
MatchLeaderOfficially();
}
}
}
private void MatchLeaderOfficially()
{
PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
if ((Object)(object)localPlayerInfo == (Object)null || (Object)(object)localPlayerInfo.AsSpectator == (Object)null || !localPlayerInfo.AsSpectator.IsSpectating)
{
return;
}
PlayerSpectator asSpectator = localPlayerInfo.AsSpectator;
GolfHole mainHole = GolfHoleManager.MainHole;
Transform holeTrans = ((mainHole != null) ? ((Component)mainHole).transform : null);
if ((Object)(object)holeTrans == (Object)null)
{
return;
}
PlayerGolfer val = (from g in Object.FindObjectsOfType<PlayerGolfer>()
where (Object)(object)g != (Object)null && !((NetworkBehaviour)g).isLocalPlayer && ((Component)g).gameObject.activeInHierarchy
orderby Vector3.Distance(((Component)g).transform.position, holeTrans.position)
select g).FirstOrDefault();
if (!((Object)(object)val == (Object)null))
{
PlayerInfo component = ((Component)val).GetComponent<PlayerInfo>();
int num = 0;
while ((Object)(object)asSpectator.TargetPlayer != (Object)(object)component && num < 20)
{
asSpectator.CycleNextTarget(false);
num++;
}
}
}
private void LateUpdate()
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_009b: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
PlayerInfo localPlayerInfo = GameManager.LocalPlayerInfo;
if (!((Object)(object)localPlayerInfo == (Object)null) && !((Object)(object)localPlayerInfo.AsSpectator == (Object)null) && localPlayerInfo.AsSpectator.IsSpectating)
{
Transform target = localPlayerInfo.AsSpectator.Target;
GolfHole mainHole = GolfHoleManager.MainHole;
Transform val = ((mainHole != null) ? ((Component)mainHole).transform : null);
OrbitCameraModule val2 = default(OrbitCameraModule);
if (!((Object)(object)target == (Object)null) && !((Object)(object)val == (Object)null) && CameraModuleController.TryGetOrbitModule(ref val2))
{
Vector3 val3 = val.position - target.position;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
float yaw = Mathf.Atan2(normalized.x, normalized.z) * 57.29578f;
val2.SetYaw(yaw);
val2.SetPitch(15f);
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SBG-AutoSpectator";
public const string PLUGIN_NAME = "Auto Spectator";
public const string PLUGIN_VERSION = "1.1.1";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}