using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using Cupidon.Extensions;
using Cupidon.Patchs;
using Cupidon.Services;
using Cupidon.Unity;
using Fusion;
using Helpers.Collections;
using Microsoft.CodeAnalysis;
using On;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("Cupidon")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("Cupidon")]
[assembly: AssemblyTitle("Cupidon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 Cupidon
{
[BepInPlugin("fr.shepardeon.plugins.cupidon", "Cupidon", "1.1.0")]
[BepInProcess("Lycans.exe")]
public class CupidonPlugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "fr.shepardeon.plugins.cupidon";
public const string PLUGIN_AUTHOR = "Shepardeon";
public const string PLUGIN_NAME = "Cupidon";
public const string PLUGIN_VERSION = "1.1.0";
public static readonly Color LoverColor = new Color(0.83f, 0.09f, 0.63f);
internal static UIToggle? CupidonUI { get; set; }
internal static UIText? CupidonText { get; set; }
internal static NetworkObject? NetworkObject { get; set; }
internal static NetworkedCupidon? Cupidon
{
get
{
if ((Object)(object)NetworkObject == (Object)null)
{
return null;
}
return ((Component)NetworkObject).GetComponent<NetworkedCupidon>();
}
}
private void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
Log.Info("Initializing Cupidon...");
Log.Info("Registering language entries...");
LanguageService instance = LanguageService.Instance;
instance.AddEntry("CUPIDON_CUPIDON_MODE", "Activer les amoureux");
instance.AddEntry("CUPIDON_LOVERS_VICTORY", "Amoureux unis à vie");
instance.AddEntry("CUPIDON_LOVER_ALLY", "Amoureux : {0}");
instance.HookLocalization();
Log.Info("Hooking into game...");
GameManagerPatch.Hook();
GameSettingsUIPatch.Hook();
GameStatePatch.Hook();
LocalCameraHandlerPatch.Hook();
Log.Info("Initialization done!");
}
private void Start()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
Log.Info("Registering networked objetcs...");
GameObject val = new GameObject("NetworkCupidon");
val.AddComponent<NetworkObject>();
val.AddComponent<NetworkedCupidon>();
NetworkObjectService.Instance.RegisterNetworkObject(val, "fr.shepardeon.plugins.cupidon.NetworkCupidon");
Object.DontDestroyOnLoad((Object)(object)val);
}
private void OnDestroy()
{
GameManagerPatch.Unhook();
GameSettingsUIPatch.Unhook();
GameStatePatch.Unhook();
LocalCameraHandlerPatch.Unhook();
}
public static void UpdateLoverText(string loverName)
{
if (CupidonText != null)
{
CupidonText.LocalizeString.StringReference.Arguments = new object[1] { loverName };
CupidonText.LocalizeString.RefreshString();
}
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Cupidon";
public const string PLUGIN_NAME = "Cupidon";
public const string PLUGIN_VERSION = "1.1.0";
}
}
namespace Cupidon.Unity
{
[NetworkBehaviourWeaved(11)]
internal class NetworkedCupidon : NetworkBehaviour
{
[DefaultForProperty("CupidonMode", 0, 1)]
[SerializeField]
private bool _CupidonMode;
[DefaultForProperty("LoversWin", 1, 1)]
[SerializeField]
private bool _LoversWin;
[SerializeField]
[DefaultForProperty("CupidonLovers", 2, 9)]
private PlayerRef[] _CupidonLovers;
[Networked]
[NetworkedWeaved(0, 1)]
public unsafe bool CupidonMode
{
get
{
if (base.Ptr == null)
{
throw new InvalidOperationException("Error when accessing NetworkedCupidon.CupidonMode. Networked properties can only be accessed when Spawned() has been called.");
}
return ReadWriteUtilsForWeaver.ReadBoolean(base.Ptr);
}
private set
{
if (base.Ptr == null)
{
throw new InvalidOperationException("Error when accessing NetworkedCupidon.CupidonMode. Networked properties can only be accessed when Spawned() has been called.");
}
ReadWriteUtilsForWeaver.WriteBoolean(base.Ptr, value);
}
}
[NetworkedWeaved(1, 1)]
[Networked]
public unsafe bool LoversWin
{
get
{
if (base.Ptr == null)
{
throw new InvalidOperationException("Error when accessing NetworkedCupidon.LoversWin. Networked properties can only be accessed when Spawned() has been called.");
}
return ReadWriteUtilsForWeaver.ReadBoolean(base.Ptr + 1);
}
private set
{
if (base.Ptr == null)
{
throw new InvalidOperationException("Error when accessing NetworkedCupidon.LoversWin. Networked properties can only be accessed when Spawned() has been called.");
}
ReadWriteUtilsForWeaver.WriteBoolean(base.Ptr + 1, value);
}
}
[Networked]
[Capacity(2)]
[NetworkedWeaved(2, 9)]
public unsafe NetworkLinkedList<PlayerRef> CupidonLovers
{
get
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (base.Ptr == null)
{
throw new InvalidOperationException("Error when accessing NetworkedCupidon.CupidonLovers. Networked properties can only be accessed when Spawned() has been called.");
}
return new NetworkLinkedList<PlayerRef>((byte*)(base.Ptr + 2), 2, PlayerRefReaderWriter.GetInstance());
}
}
private void Awake()
{
Log.Debug("NetworkedObject Awake");
}
public override void Spawned()
{
Log.Debug("NetworkedObject Spawned");
if (((SimulationBehaviour)this).Runner.IsClient)
{
CupidonPlugin.NetworkObject = ((Component)this).GetComponent<NetworkObject>();
}
}
public void OnDestroy()
{
Log.Debug("NetworkedObject Destroyed");
}
public override void Despawned(NetworkRunner runner, bool hasState)
{
Log.Debug("NetworkedObject Despawned");
Object.Destroy((Object)(object)((Component)this).gameObject);
}
public void UpdateCupidonMode(bool value)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
if (((SimulationBehaviour)this).Runner.IsServer && (int)GameManager.State.Current == 1)
{
CupidonMode = value;
Log.Debug($"Cupidon value update: {CupidonMode}");
}
}
public void UpdateLoversWin(bool value)
{
if (((SimulationBehaviour)this).Runner.IsServer)
{
LoversWin = value;
}
}
public bool CheckLoversSameTeam()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Invalid comparison between Unknown and I4
if (!CupidonMode || CupidonLovers.Count == 0)
{
Log.Debug("Team check :");
Log.Debug($"CupidonMode {CupidonMode}");
Log.Debug($"Number of lovers {CupidonLovers.Count}");
return true;
}
List<PlayerController> list = PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController p) => p.IsLover())).ToList();
bool flag = (int)list[0].Role == 1;
bool flag2 = (int)list[1].Role == 1;
return flag == flag2;
}
public bool CheckLover(PlayerRef player)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
return CupidonLovers.Contains(player);
}
public void InitLovers()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (!CupidonMode || NetworkBool.op_Implicit(GameManager.Instance.BattleRoyale))
{
Log.Debug("Cupidon mode disabled, skipping selection");
return;
}
if (PlayerRegistry.Count < 2)
{
Log.Debug("Not enough player for Cupidon, skipping selection");
return;
}
Log.Debug("Selecting lovers...");
CollectionsUtil.ForEach<PlayerController>(PlayerRegistry.GetRandom(2), (Action<PlayerController>)delegate(PlayerController p)
{
p.SetLover();
});
}
public void AddLover(PlayerRef player)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (CupidonLovers.Contains(player))
{
Log.Warning("Tried to select the same player as lovers!");
}
else
{
CupidonLovers.Add(player);
}
}
public void ResetLovers()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
CupidonLovers.Clear();
}
public override void CopyBackingFieldsToState(bool firstTime)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
CupidonMode = _CupidonMode;
LoversWin = _LoversWin;
NetworkBehaviourUtils.InitializeNetworkList<PlayerRef>(CupidonLovers, _CupidonLovers, "CupidonLovers");
}
public override void CopyStateToBackingFields()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
_CupidonMode = CupidonMode;
_LoversWin = LoversWin;
NetworkBehaviourUtils.CopyFromNetworkList<PlayerRef>(CupidonLovers, ref _CupidonLovers);
}
}
[StructLayout(LayoutKind.Sequential, Size = 1)]
internal struct PlayerRefReaderWriter : IElementReaderWriter<PlayerRef>
{
public static IElementReaderWriter<PlayerRef> Instance;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe PlayerRef Read(byte* data, int index)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return (PlayerRef)data[index * 4];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe ref PlayerRef ReadRef(byte* data, int index)
{
return ref *(PlayerRef*)(data + index * 4);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void Write(byte* data, int index, PlayerRef val)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
System.Runtime.CompilerServices.Unsafe.Write(data + index * 4, val);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public int GetElementWordCount()
{
return 1;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IElementReaderWriter<PlayerRef> GetInstance()
{
if (Instance == null)
{
Instance = (IElementReaderWriter<PlayerRef>)(object)default(PlayerRefReaderWriter);
}
return Instance;
}
}
}
namespace Cupidon.Services
{
internal class LanguageService
{
private static LanguageService? _instance;
private readonly Dictionary<string, string> _translationDict = new Dictionary<string, string>();
public static LanguageService Instance
{
get
{
if (_instance == null)
{
_instance = new LanguageService();
}
return _instance;
}
}
private LanguageService()
{
}
public void AddEntry(string key, string value)
{
_translationDict[key] = value;
}
public void HookLocalization()
{
PopulateStringDatabase();
LocalizationSettings.SelectedLocaleChanged += SelectedLocaleChanged;
}
private void SelectedLocaleChanged(Locale locale)
{
PopulateStringDatabase();
}
private void PopulateStringDatabase()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
Log.Debug("Populating string database...");
StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("UI Text"), (Locale)null);
foreach (KeyValuePair<string, string> item in _translationDict)
{
((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry(item.Key, item.Value);
}
Log.Debug("Done!");
}
}
internal class NetworkObjectService
{
private static NetworkObjectService? _instance;
private Dictionary<string, NetworkPrefabId> _prefabs;
public static NetworkObjectService Instance
{
get
{
if (_instance == null)
{
_instance = new NetworkObjectService();
}
return _instance;
}
}
private NetworkObjectService()
{
_prefabs = new Dictionary<string, NetworkPrefabId>();
}
public void RegisterNetworkObject(GameObject prefab, string uniqueKey)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_0071: Expected O, but got Unknown
//IL_007c: 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_009d: Unknown result type (might be due to invalid IL or missing references)
if (_prefabs.ContainsKey(uniqueKey))
{
throw new InvalidOperationException("Key '" + uniqueKey + "' existed alreadly");
}
NetworkObject val = default(NetworkObject);
if (!prefab.TryGetComponent<NetworkObject>(ref val))
{
throw new MissingComponentException("Prefab is missing 'NetworkObject' component!");
}
val.NetworkedBehaviours = prefab.GetComponents<NetworkBehaviour>();
val.NetworkGuid = new NetworkObjectGuid(uniqueKey.ToGuid().ToString());
NetworkPrefabSourceStatic val2 = new NetworkPrefabSourceStatic
{
PrefabReference = val
};
NetworkPrefabId value = default(NetworkPrefabId);
if (!NetworkProjectConfig.Global.PrefabTable.TryAdd(val.NetworkGuid, (INetworkPrefabSource)(object)val2, ref value))
{
throw new ApplicationException("Could not add prefab to registered prefabs, was it already present?");
}
_prefabs.Add(uniqueKey, value);
}
public NetworkPrefabId GetNetworkObject(string uniqueKey)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if (_prefabs.TryGetValue(uniqueKey, out var value))
{
return value;
}
throw new KeyNotFoundException("No prefab registered with '" + uniqueKey + "' as identifier!");
}
}
internal class UIToggle
{
public GameObject ToggleGO { get; set; }
public LocalizeStringEvent LocalizeString { get; set; }
public Toggle UnityToggle { get; set; }
}
internal class UIText
{
public GameObject TextGO { get; set; }
public LocalizeStringEvent LocalizeString { get; set; }
public TextMeshProUGUI TMPText { get; set; }
}
internal class UIService
{
private static UIService? _instance;
public static UIService Instance
{
get
{
if (_instance == null)
{
_instance = new UIService();
}
return _instance;
}
}
private UIService()
{
}
public UIToggle AddToggleToGameSettings(string localizationEntry, UnityAction<bool> onValueChanged)
{
UIToggle? obj = CreateGameSettingsToggleClone() ?? throw new Exception("Could not create Toggle element");
obj.LocalizeString.SetEntry(localizationEntry);
((UnityEvent<bool>)(object)obj.UnityToggle.onValueChanged).AddListener(onValueChanged);
return obj;
}
public UIText AddTextToMainUI(string localizationEntry, Color? textColor = null)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
UIText? obj = CreateGameTextClone() ?? throw new Exception("Could not create Text element");
obj.LocalizeString.SetEntry(localizationEntry);
((Graphic)obj.TMPText).color = (Color)(((??)textColor) ?? Color.white);
return obj;
}
private UIToggle? CreateGameSettingsToggleClone()
{
Transform val = GameManager.Instance.gameUI.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/LayoutGroup/ShowAllySetting");
if ((Object)(object)val == (Object)null)
{
Log.Error("Could not get a Toggle copy to duplicate!");
return null;
}
Transform val2 = Object.Instantiate<Transform>(val, val.parent);
Transform obj = val2.Find("LayoutGroup/SettingNameText");
LocalizeStringEvent val3 = ((obj != null) ? ((Component)obj).GetComponent<LocalizeStringEvent>() : null);
Transform obj2 = val2.Find("LayoutGroup/ToggleContainer/Toggle");
Toggle val4 = ((obj2 != null) ? ((Component)obj2).GetComponent<Toggle>() : null);
if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null)
{
Log.Error("Copied object does not contains required text or toggle");
Object.Destroy((Object)(object)((Component)val2).gameObject);
return null;
}
for (int i = 0; i < ((UnityEventBase)val4.onValueChanged).GetPersistentEventCount(); i++)
{
((UnityEventBase)val4.onValueChanged).SetPersistentListenerState(i, (UnityEventCallState)0);
}
val4.SetIsOnWithoutNotify(false);
return new UIToggle
{
ToggleGO = ((Component)val2).gameObject,
LocalizeString = val3,
UnityToggle = val4
};
}
private UIText? CreateGameTextClone()
{
Transform val = ((Component)GameManager.Instance.gameUI).transform.Find("Canvas/Game/Role");
if ((Object)(object)val == (Object)null)
{
Log.Error("Could not get a Text copy to duplicate!");
return null;
}
Transform val2 = Object.Instantiate<Transform>(val, GameManager.Instance.gameUI.fixedMenu.transform);
LocalizeStringEvent component = ((Component)val2).GetComponent<LocalizeStringEvent>();
TextMeshProUGUI component2 = ((Component)val2).GetComponent<TextMeshProUGUI>();
if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
{
Log.Error("Copied object does not contains required text or localized string");
Object.Destroy((Object)(object)((Component)val2).gameObject);
return null;
}
return new UIText
{
TextGO = ((Component)val2).gameObject,
LocalizeString = component,
TMPText = component2
};
}
}
}
namespace Cupidon.Patchs
{
internal class GameManagerPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_Start <0>__GameManager_Start;
public static hook_Spawned <1>__GameManager_Spawned;
public static hook_CheckForEndGame <2>__GameManager_CheckForEndGame;
public static hook_Rpc_EndGame <3>__GameManager_Rpc_EndGame;
}
public static void Hook()
{
//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_001b: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0070: 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_007b: Expected O, but got Unknown
object obj = <>O.<0>__GameManager_Start;
if (obj == null)
{
hook_Start val = GameManager_Start;
<>O.<0>__GameManager_Start = val;
obj = (object)val;
}
GameManager.Start += (hook_Start)obj;
object obj2 = <>O.<1>__GameManager_Spawned;
if (obj2 == null)
{
hook_Spawned val2 = GameManager_Spawned;
<>O.<1>__GameManager_Spawned = val2;
obj2 = (object)val2;
}
GameManager.Spawned += (hook_Spawned)obj2;
object obj3 = <>O.<2>__GameManager_CheckForEndGame;
if (obj3 == null)
{
hook_CheckForEndGame val3 = GameManager_CheckForEndGame;
<>O.<2>__GameManager_CheckForEndGame = val3;
obj3 = (object)val3;
}
GameManager.CheckForEndGame += (hook_CheckForEndGame)obj3;
object obj4 = <>O.<3>__GameManager_Rpc_EndGame;
if (obj4 == null)
{
hook_Rpc_EndGame val4 = GameManager_Rpc_EndGame;
<>O.<3>__GameManager_Rpc_EndGame = val4;
obj4 = (object)val4;
}
GameManager.Rpc_EndGame += (hook_Rpc_EndGame)obj4;
}
public static void Unhook()
{
//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_001b: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0070: 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_007b: Expected O, but got Unknown
object obj = <>O.<0>__GameManager_Start;
if (obj == null)
{
hook_Start val = GameManager_Start;
<>O.<0>__GameManager_Start = val;
obj = (object)val;
}
GameManager.Start -= (hook_Start)obj;
object obj2 = <>O.<1>__GameManager_Spawned;
if (obj2 == null)
{
hook_Spawned val2 = GameManager_Spawned;
<>O.<1>__GameManager_Spawned = val2;
obj2 = (object)val2;
}
GameManager.Spawned -= (hook_Spawned)obj2;
object obj3 = <>O.<2>__GameManager_CheckForEndGame;
if (obj3 == null)
{
hook_CheckForEndGame val3 = GameManager_CheckForEndGame;
<>O.<2>__GameManager_CheckForEndGame = val3;
obj3 = (object)val3;
}
GameManager.CheckForEndGame -= (hook_CheckForEndGame)obj3;
object obj4 = <>O.<3>__GameManager_Rpc_EndGame;
if (obj4 == null)
{
hook_Rpc_EndGame val4 = GameManager_Rpc_EndGame;
<>O.<3>__GameManager_Rpc_EndGame = val4;
obj4 = (object)val4;
}
GameManager.Rpc_EndGame -= (hook_Rpc_EndGame)obj4;
}
private static void GameManager_Start(orig_Start orig, GameManager self)
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
CupidonPlugin.CupidonUI = UIService.Instance.AddToggleToGameSettings("CUPIDON_CUPIDON_MODE", delegate(bool value)
{
Log.Info((value ? "Enabled" : "Disabled") + " cupidon mode");
CupidonPlugin.Cupidon?.UpdateCupidonMode(value);
PlayerPrefs.SetInt("CUPIDON_GAME_SETTINGS_ENABLED", value ? 1 : 0);
});
CupidonPlugin.CupidonText = UIService.Instance.AddTextToMainUI("CUPIDON_LOVER_ALLY", CupidonPlugin.LoverColor);
CupidonPlugin.CupidonText.TextGO.transform.position = new Vector3(5f, 410f, 0f);
CupidonPlugin.CupidonText.TextGO.transform.localScale = new Vector3(0.75f, 0.75f, 1f);
CupidonPlugin.CupidonText.TextGO.SetActive(false);
}
private static void GameManager_Spawned(orig_Spawned orig, GameManager self)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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)
orig.Invoke(self);
if (!((SimulationBehaviour)self).Runner.SessionInfo.IsOpen)
{
return;
}
Log.Debug("Session is open.");
if (((SimulationBehaviour)self).Runner.IsServer)
{
Log.Debug("Retrieving network object...");
NetworkPrefabId networkObject = NetworkObjectService.Instance.GetNetworkObject("fr.shepardeon.plugins.cupidon.NetworkCupidon");
Log.Debug("Spawning networked object...");
CupidonPlugin.NetworkObject = ((SimulationBehaviour)self).Runner.Spawn(networkObject, (Vector3?)null, (Quaternion?)null, (PlayerRef?)null, (OnBeforeSpawned)null, (NetworkObjectPredictionKey?)null, true, (NetworkObject)null);
Log.Debug("Setting initial value...");
NetworkedCupidon? cupidon = CupidonPlugin.Cupidon;
if (cupidon != null)
{
UIToggle? cupidonUI = CupidonPlugin.CupidonUI;
cupidon.UpdateCupidonMode(cupidonUI != null && cupidonUI.UnityToggle.isOn);
}
}
}
private static void GameManager_CheckForEndGame(orig_CheckForEndGame orig, GameManager self)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Invalid comparison between Unknown and I4
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Invalid comparison between Unknown and I4
if ((Object)(object)CupidonPlugin.Cupidon == (Object)null || !CupidonPlugin.Cupidon.CupidonMode || NetworkBool.op_Implicit(self.BattleRoyale))
{
Log.Debug($"Cupidon null : {(Object)(object)CupidonPlugin.Cupidon == (Object)null}");
Log.Debug($"Cupidon mode : {CupidonPlugin.Cupidon?.CupidonMode ?? false}");
Log.Debug($"Battle royale : {self.BattleRoyale}");
orig.Invoke(self);
}
else
{
if (!NetworkBool.op_Implicit(self.IsStarted) || NetworkBool.op_Implicit(self.IsFinished))
{
return;
}
List<PlayerController> list = PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController p) => !NetworkBool.op_Implicit(p.IsDead))).ToList();
int num = list.Count((PlayerController p) => (int)p.Role == 1);
int num2 = list.Count((PlayerController p) => p.IsLover());
int num3 = list.Count((PlayerController p) => p.IsLover() && (int)p.Role == 1);
int num4 = list.Count - num;
int num5 = num2 - num3;
Log.Debug($"Num player alive {list.Count}");
Log.Debug($"Num lovers alive {num2}");
Log.Debug($"Num lovers same team {CupidonPlugin.Cupidon.CheckLoversSameTeam()}");
if (num2 == 2)
{
if (!CupidonPlugin.Cupidon.CheckLoversSameTeam())
{
if (num2 == list.Count)
{
CupidonPlugin.Cupidon.UpdateLoversWin(value: true);
GameManager.Rpc_EndGame(((SimulationBehaviour)self).Runner, false);
}
else if (num2 >= num4 - 1 && num == 1)
{
CupidonPlugin.Cupidon.UpdateLoversWin(value: true);
GameManager.Rpc_EndGame(((SimulationBehaviour)self).Runner, false);
}
}
else if (num == 0)
{
GameManager.Rpc_EndGame(((SimulationBehaviour)self).Runner, false);
}
else if (num4 == 0)
{
GameManager.Rpc_EndGame(((SimulationBehaviour)self).Runner, true);
}
else if (num >= num4 && (int)GameManager.State.Current == 4)
{
GameManager.Rpc_EndGame(((SimulationBehaviour)self).Runner, true);
}
}
else
{
num -= num3;
num4 -= num5;
if (num <= 0)
{
GameManager.Rpc_EndGame(((SimulationBehaviour)self).Runner, false);
}
else if (num4 <= 0)
{
GameManager.Rpc_EndGame(((SimulationBehaviour)self).Runner, true);
}
else if (num >= num4 && (int)GameManager.State.Current == 4)
{
GameManager.Rpc_EndGame(((SimulationBehaviour)self).Runner, true);
}
}
}
}
private unsafe static void GameManager_Rpc_EndGame(orig_Rpc_EndGame orig, NetworkRunner runner, bool wolfWin)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Invalid comparison between Unknown and I4
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Invalid comparison between Unknown and I4
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
Color villagerColor = GameUI.VillagerColor;
Color wolfColor = GameUI.WolfColor;
_ = CupidonPlugin.LoverColor;
if ((Object)(object)CupidonPlugin.Cupidon == (Object)null || !CupidonPlugin.Cupidon.CupidonMode || CupidonPlugin.Cupidon.CheckLoversSameTeam() || NetworkBool.op_Implicit(GameManager.Instance.BattleRoyale))
{
((Graphic)GameManager.Instance.gameUI.wolvesRecap).color = GameUI.WolfColor;
orig.Invoke(runner, wolfWin);
return;
}
if (NetworkBehaviourUtils.InvokeRpc)
{
NetworkBehaviourUtils.InvokeRpc = false;
}
else
{
if ((Object)(object)runner == (Object)null)
{
throw new ArgumentNullException("runner");
}
if ((int)runner.Stage == 4)
{
return;
}
if (runner.HasAnyActiveConnections())
{
int num = 8;
num += 4;
SimulationMessage* ptr = SimulationMessage.Allocate(runner.Simulation, num);
byte* data = SimulationMessage.GetData(ptr);
int num2 = RpcHeader.Write(RpcHeader.Create(NetworkBehaviourUtils.GetRpcStaticIndexOrThrow("System.Void GameManager::Rpc_EndGame(Fusion.NetworkRunner,System.Boolean)")), data);
ReadWriteUtilsForWeaver.WriteBoolean((int*)(data + num2), wolfWin);
num2 += 4;
((SimulationMessage)ptr).Offset = num2 * 8;
((SimulationMessage)ptr).SetStatic();
runner.SendRpc(ptr);
}
}
if (runner.IsServer)
{
GameManager.Instance.IsFinished = NetworkBool.op_Implicit(true);
PlayerRegistry.ForEach((Action<PlayerController>)delegate(PlayerController pObj)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
pObj.CanMove = NetworkBool.op_Implicit(false);
});
GameManager.State.Server_DelaySetState((EGameState)5, 3f);
}
if (!runner.IsPlayer)
{
return;
}
bool flag = PlayerController.Local.IsLover();
bool flag2 = (int)PlayerController.Local.Role == 1;
Color val;
string text;
string text3;
if (CupidonPlugin.Cupidon.LoversWin)
{
val = (flag ? villagerColor : wolfColor);
text = (flag ? "VICTORY" : "DEFEAT");
string text2 = string.Join(" / ", from x in PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController x) => x.IsLover()))
select x.PlayerData.Username);
((Graphic)GameManager.Instance.gameUI.wolvesRecap).color = CupidonPlugin.LoverColor;
text3 = "CUPIDON_LOVERS_VICTORY";
GameManager.Instance.gameUI.UpdateWolvesRecap(text2);
}
else
{
((Graphic)GameManager.Instance.gameUI.wolvesRecap).color = GameUI.WolfColor;
if (wolfWin)
{
val = ((!flag && flag2) ? villagerColor : wolfColor);
text = ((!flag && flag2) ? "VICTORY" : "DEFEAT");
}
else
{
val = ((!flag && !flag2) ? villagerColor : wolfColor);
text = ((!flag && !flag2) ? "VICTORY" : "DEFEAT");
}
text3 = (wolfWin ? "UI_WOLVES_WIN" : "UI_VILLAGERS_WIN");
}
AudioManager.Play(text, (MixerTarget)2, 0.5f, 1f);
GameManager.Instance.gameUI.UpdateTransitionText(text3, val);
GameManager.Instance.gameUI.ShowWolvesRecap(true);
GameManager.Instance.gameUI.StartFade(true);
}
}
internal class GameSettingsUIPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_Start <0>__GameSettingsUI_Start;
public static hook_ResetSettings <1>__GameSettingsUI_ResetSettings;
}
public static void Hook()
{
//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_001b: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
object obj = <>O.<0>__GameSettingsUI_Start;
if (obj == null)
{
hook_Start val = GameSettingsUI_Start;
<>O.<0>__GameSettingsUI_Start = val;
obj = (object)val;
}
GameSettingsUI.Start += (hook_Start)obj;
object obj2 = <>O.<1>__GameSettingsUI_ResetSettings;
if (obj2 == null)
{
hook_ResetSettings val2 = GameSettingsUI_ResetSettings;
<>O.<1>__GameSettingsUI_ResetSettings = val2;
obj2 = (object)val2;
}
GameSettingsUI.ResetSettings += (hook_ResetSettings)obj2;
}
public static void Unhook()
{
//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_001b: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
object obj = <>O.<0>__GameSettingsUI_Start;
if (obj == null)
{
hook_Start val = GameSettingsUI_Start;
<>O.<0>__GameSettingsUI_Start = val;
obj = (object)val;
}
GameSettingsUI.Start -= (hook_Start)obj;
object obj2 = <>O.<1>__GameSettingsUI_ResetSettings;
if (obj2 == null)
{
hook_ResetSettings val2 = GameSettingsUI_ResetSettings;
<>O.<1>__GameSettingsUI_ResetSettings = val2;
obj2 = (object)val2;
}
GameSettingsUI.ResetSettings -= (hook_ResetSettings)obj2;
}
private static void GameSettingsUI_Start(orig_Start orig, GameSettingsUI self)
{
orig.Invoke(self);
if (PlayerPrefs.HasKey("CUPIDON_GAME_SETTINGS_ENABLED"))
{
UIToggle? cupidonUI = CupidonPlugin.CupidonUI;
if (cupidonUI != null)
{
cupidonUI.UnityToggle.SetIsOnWithoutNotify(PlayerPrefs.GetInt("CUPIDON_GAME_SETTINGS_ENABLED") == 1);
}
}
}
private static void GameSettingsUI_ResetSettings(orig_ResetSettings orig, GameSettingsUI self)
{
orig.Invoke(self);
UIToggle cupidonUI = CupidonPlugin.CupidonUI;
if (cupidonUI != null)
{
cupidonUI.UnityToggle.isOn = false;
}
}
}
internal class GameStatePatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_Spawned <0>__GameState_Spawned;
}
public static void Hook()
{
//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_001b: Expected O, but got Unknown
object obj = <>O.<0>__GameState_Spawned;
if (obj == null)
{
hook_Spawned val = GameState_Spawned;
<>O.<0>__GameState_Spawned = val;
obj = (object)val;
}
GameState.Spawned += (hook_Spawned)obj;
}
public static void Unhook()
{
//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_001b: Expected O, but got Unknown
object obj = <>O.<0>__GameState_Spawned;
if (obj == null)
{
hook_Spawned val = GameState_Spawned;
<>O.<0>__GameState_Spawned = val;
obj = (object)val;
}
GameState.Spawned -= (hook_Spawned)obj;
}
private static void GameState_Spawned(orig_Spawned orig, GameState self)
{
GameState self2 = self;
orig.Invoke(self2);
Action<EGameState> onPregameEnter = self2.StateMachine[(EGameState)1].onEnter;
self2.StateMachine[(EGameState)1].onEnter = delegate(EGameState previousState)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
onPregameEnter(previousState);
if (((SimulationBehaviour)self2).Runner.IsPlayer && (int)previousState == 5)
{
UIText? cupidonText3 = CupidonPlugin.CupidonText;
if (cupidonText3 != null)
{
cupidonText3.TextGO.SetActive(false);
}
}
};
Action<EGameState> onPlayEnter = self2.StateMachine[(EGameState)2].onEnter;
self2.StateMachine[(EGameState)2].onEnter = delegate(EGameState previousState)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
//IL_0116: 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)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
if ((int)previousState == 1)
{
onPlayEnter(previousState);
if (((SimulationBehaviour)self2).Runner.IsServer)
{
CupidonPlugin.Cupidon?.ResetLovers();
CupidonPlugin.Cupidon?.UpdateLoversWin(value: false);
CupidonPlugin.Cupidon?.InitLovers();
}
if (((SimulationBehaviour)self2).Runner.IsPlayer)
{
PlayerController localPlayer = PlayerController.Local;
if ((Object)(object)localPlayer != (Object)null && localPlayer.IsLover())
{
CupidonPlugin.UpdateLoverText(((object)(from p in PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController p) => (Object)(object)p != (Object)(object)localPlayer && p.IsLover()))
select p.PlayerData.Username).FirstOrDefault()).ToString());
UIText? cupidonText = CupidonPlugin.CupidonText;
if (cupidonText != null)
{
cupidonText.TextGO.SetActive(true);
}
}
else
{
UIText? cupidonText2 = CupidonPlugin.CupidonText;
if (cupidonText2 != null)
{
cupidonText2.TextGO.SetActive(false);
}
}
}
}
else
{
onPlayEnter(previousState);
}
};
Action<EGameState> onMeetingEnter = self2.StateMachine[(EGameState)4].onEnter;
self2.StateMachine[(EGameState)4].onEnter = delegate(EGameState previousState)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
LoversSuicide(((SimulationBehaviour)self2).Runner);
onMeetingEnter(previousState);
};
Action<EGameState> onMeetingExit = self2.StateMachine[(EGameState)4].onExit;
self2.StateMachine[(EGameState)4].onExit = delegate(EGameState previousState)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
LoversSuicide(((SimulationBehaviour)self2).Runner);
onMeetingExit(previousState);
};
}
private static void LoversSuicide(NetworkRunner runner)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
PlayerController local = PlayerController.Local;
if (!NetworkBool.op_Implicit(local.IsDead) && local.IsLover() && PlayerRegistry.Any((Predicate<PlayerController>)((PlayerController p) => p.IsLover() && NetworkBool.op_Implicit(p.IsDead))))
{
GameManager.Rpc_BroadcastFollowSound(runner, NetworkString<_16>.op_Implicit("PUNCH"), ((Component)local).transform.position, 50f, 0.8f);
local.Rpc_Kill(PlayerRef.None);
GameManager.Rpc_DisplayDeadPlayers(runner);
}
}
}
internal class LocalCameraHandlerPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_SwitchPov <0>__LocalCameraHandler_SwitchPov;
}
public static void Hook()
{
//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_001b: Expected O, but got Unknown
object obj = <>O.<0>__LocalCameraHandler_SwitchPov;
if (obj == null)
{
hook_SwitchPov val = LocalCameraHandler_SwitchPov;
<>O.<0>__LocalCameraHandler_SwitchPov = val;
obj = (object)val;
}
LocalCameraHandler.SwitchPov += (hook_SwitchPov)obj;
}
public static void Unhook()
{
//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_001b: Expected O, but got Unknown
object obj = <>O.<0>__LocalCameraHandler_SwitchPov;
if (obj == null)
{
hook_SwitchPov val = LocalCameraHandler_SwitchPov;
<>O.<0>__LocalCameraHandler_SwitchPov = val;
obj = (object)val;
}
LocalCameraHandler.SwitchPov -= (hook_SwitchPov)obj;
}
private static void LocalCameraHandler_SwitchPov(orig_SwitchPov orig, LocalCameraHandler self, PlayerController spectatedPlayer)
{
//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)
LocalCameraHandler self2 = self;
orig.Invoke(self2, spectatedPlayer);
if ((Object)(object)self2.PovPlayer != (Object)null && self2.PovPlayer.IsLover())
{
CupidonPlugin.UpdateLoverText(((object)(from p in PlayerRegistry.Where((Predicate<PlayerController>)((PlayerController p) => (Object)(object)p != (Object)(object)self2.PovPlayer && p.IsLover()))
select p.PlayerData.Username).FirstOrDefault()).ToString());
UIText? cupidonText = CupidonPlugin.CupidonText;
if (cupidonText != null)
{
cupidonText.TextGO.SetActive(true);
}
}
else
{
UIText? cupidonText2 = CupidonPlugin.CupidonText;
if (cupidonText2 != null)
{
cupidonText2.TextGO.SetActive(false);
}
}
}
}
}
namespace Cupidon.Extensions
{
internal static class PlayerControllerExtensions
{
public static bool IsLover(this PlayerController? player)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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)
PlayerController player2 = player;
if ((Object)(object)CupidonPlugin.Cupidon == (Object)null || CupidonPlugin.Cupidon.CupidonLovers.Count == 0 || (Object)(object)player2 == (Object)null)
{
return false;
}
PlayerRef key = ((IEnumerable<KeyValuePair<PlayerRef, PlayerController>>)(object)PlayerRegistry.Instance.ObjectByRef).FirstOrDefault((KeyValuePair<PlayerRef, PlayerController> o) => (Object)(object)o.Value == (Object)(object)player2).Key;
return CupidonPlugin.Cupidon.CheckLover(key);
}
public static void SetLover(this PlayerController? player)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
PlayerController player2 = player;
if ((Object)(object)CupidonPlugin.Cupidon == (Object)null || CupidonPlugin.Cupidon.CupidonLovers.Count >= 2 || (Object)(object)player2 == (Object)null)
{
Log.Error("Tried to add a new user to lovers but there can be only Two!");
return;
}
PlayerRef key = ((IEnumerable<KeyValuePair<PlayerRef, PlayerController>>)(object)PlayerRegistry.Instance.ObjectByRef).FirstOrDefault((KeyValuePair<PlayerRef, PlayerController> o) => (Object)(object)o.Value == (Object)(object)player2).Key;
CupidonPlugin.Cupidon.AddLover(key);
Log.Debug($"Added {player2.PlayerData.Username} as lover");
}
}
internal static class StringExtensions
{
public static Guid ToGuid(this string value)
{
return new Guid(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(value)));
}
}
}