using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AwhDangit.Config;
using AwhDangit.Custom;
using AwhDangit.Patches;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCasino.Custom;
using LobbyCompatibility.Attributes;
using Microsoft.CodeAnalysis;
using StaticNetcodeLib;
using Unity.Netcode;
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("mrgrm7.LethalCasino")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("astridos2go.AwhDangit")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fe81c2084e4b89a8f3cc3395a5b779058a1b80a1")]
[assembly: AssemblyProduct("AwhDangit")]
[assembly: AssemblyTitle("astridos2go.AwhDangit")]
[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.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 AwhDangit
{
[BepInPlugin("astridos2go.AwhDangit", "AwhDangit", "1.0.0")]
[BepInDependency("BMX.LobbyCompatibility", "1.5.0")]
[BepInDependency("mrgrm7.LethalCasino", "1.1.0")]
[BepInDependency("com.sigurd.csync", "5.0.0")]
[BepInDependency("Xilophor.StaticNetcodeLib", "1.2.0")]
[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
public class AwhDangit : BaseUnityPlugin
{
public static AwhDangit Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
internal static AwhDangitConfig BoundConfig { get; private set; }
private void Awake()
{
Logger = Logger.CreateLogSource("astridos2go.AwhDangit");
Instance = this;
BoundConfig = new AwhDangitConfig(((BaseUnityPlugin)this).Config);
Patch();
Logger.LogInfo((object)"astridos2go.AwhDangit v1.0.0 has loaded!");
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("astridos2go.AwhDangit");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "astridos2go.AwhDangit";
public const string PLUGIN_NAME = "AwhDangit";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace AwhDangit.Patches
{
internal class BasePatch
{
internal static Dictionary<GrabbableObject, int> previousScrapValues = new Dictionary<GrabbableObject, int>();
internal static Dictionary<GrabbableObject, PlayerControllerB> scrapOwners = new Dictionary<GrabbableObject, PlayerControllerB>();
internal static PlayerControllerB? UpdateScrapValueFromRef(NetworkBehaviour gameInstance, NetworkBehaviourReference scrapRef)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
if (gameInstance != null && !gameInstance.IsServer && !gameInstance.IsHost)
{
return null;
}
GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(scrapRef);
if ((Object)(object)val == (Object)null || !previousScrapValues.ContainsKey(val))
{
return null;
}
return UpdateScrapValue(val);
}
internal static PlayerControllerB? UpdateScrapValue(GrabbableObject scrap, int? newScrapValue = null)
{
int num = newScrapValue ?? scrap.scrapValue;
scrapOwners.TryGetValue(scrap, out PlayerControllerB value);
if ((Object)(object)value == (Object)null)
{
return null;
}
GamblingProfitPlayerController gamblingProfitPlayerController = default(GamblingProfitPlayerController);
((Component)value).TryGetComponent<GamblingProfitPlayerController>(ref gamblingProfitPlayerController);
if ((Object)(object)gamblingProfitPlayerController == (Object)null)
{
return null;
}
int num2 = num - previousScrapValues[scrap];
gamblingProfitPlayerController.gambleProfit += num2;
AwhDangit.Logger.LogDebug((object)$"{value.playerUsername} made {num2} on {((Object)scrap).name}!");
AwhDangit.Logger.LogDebug((object)$"{value.playerUsername} has a net profit of {gamblingProfitPlayerController.gambleProfit}");
previousScrapValues.Remove(scrap);
scrapOwners.Remove(scrap);
return value;
}
internal static void StoreScrapInfoFromRefs(NetworkBehaviourReference playerRef, NetworkBehaviourReference scrapRef, string gameName)
{
//IL_0001: 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)
//IL_000d: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
GrabbableObject scrap = (GrabbableObject)NetworkBehaviourReference.op_Implicit(scrapRef);
PlayerControllerB player = (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef);
StoreScrapInfo(gameName, player, scrap);
}
internal static void StoreScrapInfo(string gameName, PlayerControllerB player, GrabbableObject scrap, int? value = null)
{
int num = value ?? scrap.scrapValue;
int value2;
bool flag = previousScrapValues.TryGetValue(scrap, out value2);
scrapOwners.TryGetValue(scrap, out PlayerControllerB value3);
if (!flag || value2 != num || !((Object)(object)value3 == (Object)(object)player))
{
AwhDangit.Logger.LogDebug((object)$"Setting previous scrap value of {((Object)scrap).name} to {num}");
previousScrapValues[scrap] = num;
AwhDangit.Logger.LogDebug((object)("Setting " + player.playerUsername + " as the owner of " + ((Object)scrap).name));
scrapOwners[scrap] = player;
int num2 = ((num != scrap.scrapValue) ? (num - scrap.scrapValue) : num);
AwhDangit.Logger.LogDebug((object)$"{player.playerUsername} just bet {num2} from {((Object)scrap).name} on {gameName}!");
}
}
internal static void CheckGamblingProfitsFromRefs(NetworkBehaviour gameInstance, NetworkBehaviourReference playerRef)
{
//IL_0001: 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)
//IL_000d: Expected O, but got Unknown
PlayerControllerB val = (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef);
GamblingProfitPlayerController gamblingProfitPlayerController = default(GamblingProfitPlayerController);
if (((Component)val).TryGetComponent<GamblingProfitPlayerController>(ref gamblingProfitPlayerController))
{
gamblingProfitPlayerController.CheckGamblingProfits(gameInstance);
}
}
}
[HarmonyPatch(typeof(Blackjack))]
internal class BlackjackPatch : BasePatch
{
[HarmonyPostfix]
[HarmonyPatch("UpdateScrapValueClientRpc")]
public static void UpdateScrapValuePostfix(Blackjack __instance, NetworkBehaviourReference item)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)"UpdateScrapValueClientRpc Postfix for Blackjack");
BasePatch.UpdateScrapValueFromRef((NetworkBehaviour)(object)__instance, item);
}
[HarmonyPostfix]
[HarmonyPatch("JoinGameServerRpc")]
public static void JoinGamePostfix(Blackjack __instance, NetworkBehaviourReference playerRef, int playerIdx)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
AwhDangit.Logger.LogDebug((object)"JoinGameServerRpc Postfix for Blackjack");
if (__instance != null && !((NetworkBehaviour)__instance).IsServer && !((NetworkBehaviour)__instance).IsHost)
{
return;
}
PlayerControllerB player = (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerRef);
foreach (GrabbableObject item in __instance.gambledScrap[playerIdx])
{
BasePatch.StoreScrapInfo("Blackjack", player, item);
}
}
[HarmonyPrefix]
[HarmonyPatch("GameFinished")]
public static void GameFinishedPrefix(Blackjack __instance, PlayerControllerB[] __state)
{
AwhDangit.Logger.LogDebug((object)"GameFinished Prefix for Blackjack");
AwhDangit.Logger.LogDebug((object)__instance.gamblingPlayers.Length);
}
[HarmonyPostfix]
[HarmonyPatch("GameFinished")]
public static void ProcessResultsPostfix(Blackjack __instance, PlayerControllerB[] __state)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)"ProcessResultsPostfix Postfix for Blackjack");
PlayerControllerB[] gamblingPlayers = __instance.gamblingPlayers;
foreach (PlayerControllerB val in gamblingPlayers)
{
if (!((Object)(object)val == (Object)null))
{
BasePatch.CheckGamblingProfitsFromRefs((NetworkBehaviour)(object)__instance, NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val));
}
}
}
}
public class ExplosionCaller
{
[CompilerGenerated]
private sealed class <DelayedExplosion>d__0 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayerControllerB player;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DelayedExplosion>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_008b: 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_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
AwhDangit.Logger.LogDebug((object)("Waiting 0.7f until explosion for player " + player.playerUsername));
<>2__current = (object)new WaitForSeconds(0.7f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
AwhDangit.Logger.LogDebug((object)("Spawning explosion on player " + player.playerUsername));
Landmine.SpawnExplosion(((Component)player).transform.position + Vector3.up, true, 2.5f, 2.7f, 50, 0f, (GameObject)null, false);
player.causeOfDeath = (CauseOfDeath)18;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[IteratorStateMachine(typeof(<DelayedExplosion>d__0))]
public static IEnumerator DelayedExplosion(PlayerControllerB player)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DelayedExplosion>d__0(0)
{
player = player
};
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
[HarmonyPrefix]
[HarmonyPatch("Awake")]
public static void Awake(PlayerControllerB __instance)
{
AwhDangit.Logger.LogDebug((object)("Attaching gambling profit player controller to " + __instance.playerUsername));
((Component)__instance).gameObject.AddComponent<GamblingProfitPlayerController>();
}
}
[HarmonyPatch(typeof(Roulette))]
internal class RoulettePatch : BasePatch
{
[HarmonyPrefix]
[HarmonyPatch("UpdateScrapValueClientRpc")]
public static void UpdateScrapValuePrefix(Roulette __instance, NetworkBehaviourReference item, int newValue)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
AwhDangit.Logger.LogDebug((object)"UpdateScrapValueClientRpc Prefix for Roulette");
if (newValue == 0)
{
GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(item);
if (((Object)val).name.Contains("ChipBag"))
{
BasePatch.UpdateScrapValue(val, newValue);
}
}
}
[HarmonyPostfix]
[HarmonyPatch("UpdateScrapValueClientRpc")]
public static void UpdateScrapValuePostfix(Roulette __instance, NetworkBehaviourReference item)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)"UpdateScrapValueClientRpc Postfix for Roulette");
BasePatch.UpdateScrapValueFromRef((NetworkBehaviour)(object)__instance, item);
}
[HarmonyPostfix]
[HarmonyPatch("PlaceBetServerRpc")]
public static void PlaceBetPostfix(Roulette __instance, NetworkBehaviourReference playerRef, NetworkBehaviourReference scrapRef)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)"PlaceBetServerRpc Postfix for Roulette");
BasePatch.StoreScrapInfoFromRefs(playerRef, scrapRef, "Roulette");
}
[HarmonyPostfix]
[HarmonyPatch("DisplayResultsClientRpc")]
public static void DisplayResultsPostfix(Roulette __instance, NetworkBehaviourReference playerRef)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)"DisplayResultsPostfix for Roulette");
BasePatch.CheckGamblingProfitsFromRefs((NetworkBehaviour)(object)__instance, playerRef);
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch : NetworkBehaviour
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
public static void AwakePatch(RoundManager __instance)
{
AwhDangit.Logger.LogDebug((object)"RoundManagerPatch just woke up!");
}
[HarmonyPrefix]
[HarmonyPatch("LoadNewLevelWait")]
public static void LoadNewLevelWaitPatch(RoundManager __instance)
{
AwhDangit.Logger.LogDebug((object)"Welcome back!");
if (AwhDangit.BoundConfig.ResetEachRound.Value)
{
ResetPlayerNetProfits(__instance);
}
}
[HarmonyPostfix]
[HarmonyPatch("DespawnPropsAtEndOfRound")]
public static void DespawnPropsAtEndOfRoundPatch(RoundManager __instance)
{
AwhDangit.Logger.LogDebug((object)"Come back soon!");
if (AwhDangit.BoundConfig.ResetEachRound.Value)
{
ResetPlayerNetProfits(__instance);
}
}
private static void ResetPlayerNetProfits(RoundManager __instance)
{
if (__instance.currentLevel.levelID != 3)
{
return;
}
AwhDangit.Logger.LogDebug((object)"Resetting gambling profits for all active players");
PlayerControllerB[] allPlayerScripts = __instance.playersManager.allPlayerScripts;
GamblingProfitPlayerController gamblingProfitPlayerController = default(GamblingProfitPlayerController);
foreach (PlayerControllerB val in allPlayerScripts)
{
((Component)val).TryGetComponent<GamblingProfitPlayerController>(ref gamblingProfitPlayerController);
if ((Object)(object)gamblingProfitPlayerController != (Object)null && gamblingProfitPlayerController.gambleProfit != 0)
{
AwhDangit.Logger.LogDebug((object)("Resetting gambling profit for player: " + val.playerUsername));
gamblingProfitPlayerController.gambleProfit = 0;
}
}
}
}
[StaticNetcode]
public static class RpcCaller
{
[ClientRpc]
public static void PlayerMustSufferClientRpc(NetworkBehaviourReference playerReference)
{
//IL_0001: 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)
//IL_000d: Expected O, but got Unknown
PlayerControllerB val = (PlayerControllerB)NetworkBehaviourReference.op_Implicit(playerReference);
AwhDangit.Logger.LogDebug((object)("PlayerMustSufferClientRpc called for " + val.playerUsername));
((MonoBehaviour)val).StartCoroutine(ExplosionCaller.DelayedExplosion(val));
}
[ServerRpc]
public static void PlayerMustSufferServerRpc(NetworkBehaviourReference playerReference)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
PlayerMustSufferClientRpc(playerReference);
}
}
[HarmonyPatch(typeof(SlotMachine))]
internal class SlotsPatch : BasePatch
{
[HarmonyPrefix]
[HarmonyPatch("UpdateScrapValueClientRpc")]
public static void UpdateScrapValuePrefix(Roulette __instance, NetworkBehaviourReference item, int newValue)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)"UpdateScrapValueClientRpc Prefix for Slots");
if (newValue == 0)
{
GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(item);
if (((Object)val).name.Contains("ChipBag"))
{
PlayerControllerB val2 = BasePatch.UpdateScrapValue(val, newValue);
BasePatch.CheckGamblingProfitsFromRefs((NetworkBehaviour)(object)__instance, NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val2));
}
}
}
[HarmonyPostfix]
[HarmonyPatch("UpdateScrapValueClientRpc")]
public static void UpdateScrapValuePostfix(SlotMachine __instance, NetworkBehaviourReference item)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)"UpdateScrapValueClientRpc Postfix for Slots");
PlayerControllerB val = BasePatch.UpdateScrapValueFromRef((NetworkBehaviour)(object)__instance, item);
if (!((Object)(object)val == (Object)null))
{
BasePatch.CheckGamblingProfitsFromRefs((NetworkBehaviour)(object)__instance, NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val));
}
}
[HarmonyPostfix]
[HarmonyPatch("StartGambleServerRpc")]
public static void StartGamblePostfix(SlotMachine __instance, NetworkBehaviourReference playerRef, NetworkBehaviourReference scrapRef)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)"StartGambleServerRpc Postfix for Slots");
BasePatch.StoreScrapInfoFromRefs(playerRef, scrapRef, "Slots");
}
}
[HarmonyPatch(typeof(TheWheel))]
internal class TheWheelPatch : BasePatch
{
[HarmonyPostfix]
[HarmonyPatch("UpdateScrapValueClientRpc")]
public static void UpdateScrapValuePostfix(TheWheel __instance, NetworkBehaviourReference item, int newValue, bool disablePoofsOnZero)
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)"UpdateScrapValueClientRpc Postfix for The Wheel");
if (disablePoofsOnZero)
{
AwhDangit.Logger.LogDebug((object)"Initial bet placed on The Wheel (initial price taken off scrap)");
GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(item);
PlayerControllerB playerHeldBy = val.playerHeldBy;
BasePatch.StoreScrapInfo("The Wheel", playerHeldBy, val, val.scrapValue + __instance.minimumItemValue);
return;
}
AwhDangit.Logger.LogDebug((object)"The Wheel Spin finished (applying any profit to scrap)");
PlayerControllerB val2 = BasePatch.UpdateScrapValueFromRef((NetworkBehaviour)(object)__instance, item);
if (!((Object)(object)val2 == (Object)null))
{
BasePatch.CheckGamblingProfitsFromRefs((NetworkBehaviour)(object)__instance, NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val2));
}
}
[HarmonyPrefix]
[HarmonyPatch("UpdateScrapValueClientRpc")]
public static void UpdateScrapValuePrefix(TheWheel __instance, NetworkBehaviourReference item, int newValue, bool disablePoofsOnZero)
{
//IL_0011: 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_001d: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (disablePoofsOnZero || newValue != 0)
{
return;
}
GrabbableObject val = (GrabbableObject)NetworkBehaviourReference.op_Implicit(item);
if (((Object)val).name.Contains("ChipBag"))
{
AwhDangit.Logger.LogDebug((object)"The Wheel Spin finished (applying any profit to scrap)");
PlayerControllerB val2 = BasePatch.UpdateScrapValue(val, newValue);
if (!((Object)(object)val2 == (Object)null))
{
BasePatch.CheckGamblingProfitsFromRefs((NetworkBehaviour)(object)__instance, NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val2));
}
}
}
}
}
namespace AwhDangit.Custom
{
internal class GamblingProfitPlayerController : NetworkBehaviour
{
public int gambleProfit = 0;
private PlayerControllerB player = null;
private void Start()
{
player = ((Component)this).GetComponent<PlayerControllerB>();
}
public void CheckGamblingProfits(NetworkBehaviour gameInstance)
{
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
AwhDangit.Logger.LogDebug((object)("Checking gambling profits for player " + player.playerUsername));
if (gambleProfit <= AwhDangit.BoundConfig.MaxLossAmount.Value)
{
TryShowWarning(gameInstance, "Uh oh!", "Time to pay for your debts...", isWarning: true);
AwhDangit.Logger.LogInfo((object)(player.playerUsername + " will be exploded for their debts"));
RpcCaller.PlayerMustSufferServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)player));
if (AwhDangit.BoundConfig.ResetWhenKilled.Value)
{
AwhDangit.Logger.LogDebug((object)(player.playerUsername + "'s debts will been forgiven in death"));
gambleProfit = 0;
}
}
}
private void TryShowWarning(NetworkBehaviour instance, string title, string message, bool isWarning = false)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
MethodInfo method = ((object)instance).GetType().GetMethod("ShowWarningMessageClientRpc");
if (!(method == null))
{
AwhDangit.Logger.LogDebug((object)("Showing warning message to " + player.playerUsername));
object[] parameters = new object[4]
{
NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)player),
title,
message,
isWarning
};
method.Invoke(instance, parameters);
}
}
}
}
namespace AwhDangit.Config
{
public class AwhDangitConfig : SyncedConfig2<AwhDangitConfig>
{
[SyncedEntryField]
public readonly SyncedEntry<int> MaxLossAmount;
[SyncedEntryField]
public readonly SyncedEntry<bool> ResetEachRound;
[SyncedEntryField]
public readonly SyncedEntry<bool> ResetWhenKilled;
public AwhDangitConfig(ConfigFile cfg)
: base("astridos2go.AwhDangit")
{
cfg.SaveOnConfigSet = false;
MaxLossAmount = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, "General", "MaxLossAmount", -100, "How much money a player has to be down at the Casino before facing consequences... (Setting this to a positive number may have unintended effects)");
ResetEachRound = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "General", "ResetEachRound", true, "Whether or not to forget players' gambling debts each time you leave the Company.");
ResetWhenKilled = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, "General", "ResetWhenPunished", true, "Whether or not to forgive a player's debts when they suffer consequences. (Useful if you have mods that allow reviving).");
ClearOrphanedEntries(cfg);
cfg.Save();
cfg.SaveOnConfigSet = true;
ConfigManager.Register<AwhDangitConfig>((SyncedConfig2<AwhDangitConfig>)(object)this);
}
private static void ClearOrphanedEntries(ConfigFile cfg)
{
PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries");
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg);
dictionary.Clear();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}