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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
[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("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c574138cfea486cfa7104eae1a6f135c166daf8b")]
[assembly: AssemblyProduct("EmpressCursedShop")]
[assembly: AssemblyTitle("EmpressCursedShop")]
[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 CursedShop
{
public class CursedShopDirector : MonoBehaviourPunCallbacks
{
public enum CursedEvent
{
None,
RandomPurchases,
Tornado,
Poltergeist,
Buy1Get6Free,
Buy1OneDies,
HumanPrice,
Lockdown
}
public static CursedShopDirector Instance;
private static CursedEvent lastVisitEvent = CursedEvent.None;
public CursedEvent currentEvent = CursedEvent.None;
private List<PhysGrabObject> shopItems = new List<PhysGrabObject>();
private float timer = 0f;
private Vector3 shopCenterPosition;
private int humanTargetActorNumber = -1;
private int humanPriceValue = 0;
private bool humanSold = false;
private HashSet<int> processedItemIDs = new HashSet<int>();
private Coroutine messageCoroutine;
private GameObject lockdownBarrier;
private const string EVENT_PROP_KEY = "CursedShopEvent";
private const string EVENT_TIME_KEY = "CursedShopTime";
private const string HUMAN_TARGET_KEY = "CursedShopHumanTarget";
private const string HUMAN_PRICE_KEY = "CursedShopHumanPrice";
private static readonly FieldRef<ExtractionPoint, State> ep_currentState = AccessTools.FieldRefAccess<ExtractionPoint, State>("currentState");
private static readonly FieldRef<ExtractionPoint, bool> ep_tubeHit = AccessTools.FieldRefAccess<ExtractionPoint, bool>("tubeHit");
private void Awake()
{
Instance = this;
}
private void Start()
{
//IL_005e: 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_0074: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
//IL_009a: Expected O, but got Unknown
if ((Object)(object)RunManager.instance != (Object)null && (Object)(object)RunManager.instance.levelCurrent != (Object)null && RunManager.instance.levelCurrent.ResourcePath != "Shop")
{
Object.Destroy((Object)(object)this);
return;
}
CalculateShopCenter();
if (PhotonNetwork.IsMasterClient)
{
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)"CursedShopEvent", (object)0);
((Dictionary<object, object>)val).Add((object)"CursedShopHumanTarget", (object)(-1));
((Dictionary<object, object>)val).Add((object)"CursedShopHumanPrice", (object)0);
Hashtable val2 = val;
PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
((MonoBehaviour)this).StartCoroutine(PickEventRoutine());
}
else if (PhotonNetwork.CurrentRoom != null && ((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).ContainsKey((object)"CursedShopEvent") && (int)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties[(object)"CursedShopEvent"] != 0)
{
((MonoBehaviourPunCallbacks)this).OnRoomPropertiesUpdate(((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties);
}
}
public override void OnDisable()
{
((MonoBehaviourPunCallbacks)this).OnDisable();
CleanupEvent();
}
private void OnDestroy()
{
CleanupEvent();
}
private void CleanupEvent()
{
//IL_003e: 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)
if (messageCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(messageCoroutine);
}
if ((Object)(object)BigMessageUI.instance != (Object)null)
{
BigMessageUI.instance.BigMessage("", "", 0.1f, Color.white, Color.white);
}
if ((Object)(object)lockdownBarrier != (Object)null)
{
Object.Destroy((Object)(object)lockdownBarrier);
}
shopItems.Clear();
processedItemIDs.Clear();
currentEvent = CursedEvent.None;
humanSold = false;
}
private void CalculateShopCenter()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: 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)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ShopManager.instance == (Object)null || ShopManager.instance.itemVolumes == null)
{
shopCenterPosition = ((Component)this).transform.position + Vector3.up * 2f;
}
else if (ShopManager.instance.itemVolumes.Count > 0)
{
Vector3 val = Vector3.zero;
int num = 0;
foreach (ItemVolume itemVolume in ShopManager.instance.itemVolumes)
{
if ((Object)(object)itemVolume != (Object)null)
{
val += ((Component)itemVolume).transform.position;
num++;
}
}
if (num > 0)
{
shopCenterPosition = val / (float)num;
shopCenterPosition += Vector3.up * 1.5f;
}
else
{
shopCenterPosition = ((Component)this).transform.position + Vector3.up * 2f;
}
}
else
{
shopCenterPosition = ((Component)this).transform.position + Vector3.up * 2f;
}
}
private IEnumerator PickEventRoutine()
{
yield return (object)new WaitForSeconds(3f);
if ((Object)(object)this == (Object)null)
{
yield break;
}
int attempts = 0;
CursedEvent newEvent;
do
{
newEvent = (CursedEvent)Random.Range(1, 8);
attempts++;
}
while (newEvent == lastVisitEvent && attempts < 10);
lastVisitEvent = newEvent;
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)"CursedShopEvent", (object)(int)newEvent);
((Dictionary<object, object>)val).Add((object)"CursedShopTime", (object)PhotonNetwork.Time);
Hashtable props = val;
if (newEvent == CursedEvent.HumanPrice)
{
Player[] players = PhotonNetwork.PlayerList;
if (players.Length != 0)
{
Player target = players[Random.Range(0, players.Length)];
int price = Random.Range(5, 51);
((Dictionary<object, object>)(object)props).Add((object)"CursedShopHumanTarget", (object)target.ActorNumber);
((Dictionary<object, object>)(object)props).Add((object)"CursedShopHumanPrice", (object)price);
}
else
{
props[(object)"CursedShopEvent"] = 1;
}
}
PhotonNetwork.CurrentRoom.SetCustomProperties(props, (Hashtable)null, (WebFlags)null);
}
public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
{
if ((Object)(object)this == (Object)null || (Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent == (Object)null || RunManager.instance.levelCurrent.ResourcePath != "Shop")
{
return;
}
Hashtable customProperties = ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties;
if (!((Dictionary<object, object>)(object)customProperties).ContainsKey((object)"CursedShopEvent"))
{
return;
}
CursedEvent cursedEvent = (CursedEvent)customProperties[(object)"CursedShopEvent"];
if (cursedEvent == CursedEvent.None)
{
CleanupEvent();
return;
}
if (((Dictionary<object, object>)(object)customProperties).ContainsKey((object)"CursedShopHumanTarget"))
{
humanTargetActorNumber = (int)customProperties[(object)"CursedShopHumanTarget"];
}
if (((Dictionary<object, object>)(object)customProperties).ContainsKey((object)"CursedShopHumanPrice"))
{
humanPriceValue = (int)customProperties[(object)"CursedShopHumanPrice"];
}
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(InitializeEventRoutine(cursedEvent));
}
private IEnumerator InitializeEventRoutine(CursedEvent evt)
{
CleanupEvent();
currentEvent = evt;
PhysGrabObject[] allItems = Object.FindObjectsOfType<PhysGrabObject>();
PhysGrabObject[] array = allItems;
foreach (PhysGrabObject item in array)
{
if ((Object)(object)((Component)item).GetComponent<ValuableObject>() != (Object)null || (Object)(object)((Component)item).GetComponent<ItemAttributes>() != (Object)null)
{
shopItems.Add(item);
}
}
CalculateShopCenter();
string title = "SHOP EVENT";
string desc = "";
Color c1 = Color.red;
Color c2 = Color.yellow;
switch (currentEvent)
{
case CursedEvent.RandomPurchases:
desc = "RANDOM PURCHASES";
break;
case CursedEvent.Buy1Get6Free:
desc = "BUY 1 GET 6 FREE";
break;
case CursedEvent.Buy1OneDies:
desc = "BUYING KILLS A PLAYER";
break;
case CursedEvent.HumanPrice:
{
Player target = GetPlayerByActorNumber(humanTargetActorNumber);
string name = ((target != null) ? target.NickName : "UNKNOWN");
desc = $"SELL {name.ToUpper()} FOR ${humanPriceValue}K";
break;
}
case CursedEvent.Tornado:
desc = "INDOOR TORNADO ALERT";
break;
case CursedEvent.Poltergeist:
desc = "THE ITEMS ARE ANGRY";
break;
case CursedEvent.Lockdown:
ActivateLockdown();
currentEvent = CursedEvent.Tornado;
desc = "SECURITY LOCKDOWN";
break;
}
if (messageCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(messageCoroutine);
}
messageCoroutine = ((MonoBehaviour)this).StartCoroutine(ShowMessageRoutine(title, desc, 8f, c1, c2));
yield break;
}
private IEnumerator ShowMessageRoutine(string title, string subtitle, float duration, Color mainColor, Color flashColor)
{
//IL_0023: 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)
//IL_002b: 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)
float t = duration;
while (t > 0f)
{
if ((Object)(object)BigMessageUI.instance != (Object)null)
{
string fullText = title + ": " + subtitle;
BigMessageUI.instance.BigMessage(fullText, "", 30f, mainColor, flashColor);
}
t -= Time.deltaTime;
yield return null;
}
}
private void Update()
{
if ((Object)(object)RunManager.instance != (Object)null && (Object)(object)RunManager.instance.levelCurrent != (Object)null && RunManager.instance.levelCurrent.ResourcePath != "Shop")
{
Object.Destroy((Object)(object)this);
}
else if (PhotonNetwork.IsMasterClient && shopItems.Count > 0)
{
if (currentEvent == CursedEvent.Tornado)
{
DoTornadoLogic();
}
else if (currentEvent == CursedEvent.Poltergeist)
{
DoPoltergeistLogic();
}
else if (currentEvent == CursedEvent.HumanPrice)
{
CheckHumanPriceExtraction();
}
}
}
public void OnItemAddedToCart(ItemAttributes itemAttr)
{
//IL_0083: 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_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_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
if (!PhotonNetwork.IsMasterClient || (Object)(object)itemAttr == (Object)null)
{
return;
}
int instanceID = ((Object)((Component)itemAttr).gameObject).GetInstanceID();
if (processedItemIDs.Contains(instanceID))
{
return;
}
processedItemIDs.Add(instanceID);
if (currentEvent == CursedEvent.RandomPurchases)
{
Item randomItemDefinition = GetRandomItemDefinition();
if (!((Object)(object)randomItemDefinition != (Object)null))
{
return;
}
Vector3 position = ((Component)itemAttr).transform.position;
Quaternion rotation = ((Component)itemAttr).transform.rotation;
GameObject val = PhotonNetwork.InstantiateRoomObject(randomItemDefinition.prefab.ResourcePath, position, rotation, (byte)0, (object[])null);
if ((Object)(object)val != (Object)null)
{
processedItemIDs.Add(((Object)val).GetInstanceID());
PhysGrabObject component = val.GetComponent<PhysGrabObject>();
if ((Object)(object)component != (Object)null)
{
component.rb.velocity = Vector3.zero;
component.rb.angularVelocity = Vector3.zero;
}
}
PhotonNetwork.Destroy(((Component)itemAttr).gameObject);
}
else if (currentEvent == CursedEvent.Buy1Get6Free)
{
if (itemAttr.value == 0)
{
return;
}
Item val2 = FindItemDefinition(((Component)itemAttr).gameObject);
if (!((Object)(object)val2 != (Object)null))
{
return;
}
for (int i = 0; i < 6; i++)
{
Vector3 val3 = ((Component)itemAttr).transform.position + Vector3.up * (0.5f + (float)i * 0.2f);
GameObject val4 = PhotonNetwork.InstantiateRoomObject(val2.prefab.ResourcePath, val3, Random.rotation, (byte)0, (object[])null);
ItemAttributes component2 = val4.GetComponent<ItemAttributes>();
if (Object.op_Implicit((Object)(object)component2))
{
component2.value = 0;
((MonoBehaviour)this).StartCoroutine(SetFreeAfterDelay(component2));
}
}
}
else
{
if (currentEvent != CursedEvent.Buy1OneDies)
{
return;
}
List<PlayerAvatar> list = new List<PlayerAvatar>();
PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
foreach (PlayerAvatar val5 in array)
{
if (!val5.deadSet)
{
list.Add(val5);
}
}
if (list.Count > 0)
{
PlayerAvatar val6 = list[Random.Range(0, list.Count)];
PlayerHealth component3 = ((Component)val6).GetComponent<PlayerHealth>();
if ((Object)(object)component3 != (Object)null)
{
component3.photonView.RPC("HurtOtherRPC", (RpcTarget)0, new object[4]
{
100,
((Component)val6).transform.position,
false,
-1
});
}
if (messageCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(messageCoroutine);
}
messageCoroutine = ((MonoBehaviour)this).StartCoroutine(ShowMessageRoutine("SACRIFICE", val6.playerName + " died for this.", 4f, Color.red, Color.black));
}
}
}
private IEnumerator SetFreeAfterDelay(ItemAttributes attr)
{
yield return (object)new WaitForSeconds(0.2f);
if ((Object)(object)attr != (Object)null)
{
attr.value = 0;
}
}
private void CheckHumanPriceExtraction()
{
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
if (humanSold)
{
return;
}
PlayerAvatar val = null;
PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
foreach (PlayerAvatar val2 in array)
{
if (val2.photonView.Owner.ActorNumber == humanTargetActorNumber)
{
val = val2;
break;
}
}
if (!((Object)(object)val != (Object)null) || val.deadSet || !((Object)(object)ShopManager.instance.extractionPoint != (Object)null))
{
return;
}
ExtractionPoint component = ((Component)ShopManager.instance.extractionPoint).GetComponent<ExtractionPoint>();
if ((Object)(object)component != (Object)null && (int)ep_currentState.Invoke(component) == 6 && ep_tubeHit.Invoke(component))
{
float num = Vector3.Distance(((Component)val).transform.position, ((Component)component).transform.position);
if (val.RoomVolumeCheck.inExtractionPoint || num < 2.5f)
{
SellHuman(val);
}
}
}
private void SellHuman(PlayerAvatar player)
{
//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)
humanSold = true;
int num = SemiFunc.StatGetRunCurrency();
SemiFunc.StatSetRunCurrency(num + humanPriceValue);
if ((Object)(object)CurrencyUI.instance != (Object)null)
{
CurrencyUI.instance.FetchCurrency();
}
if (messageCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(messageCoroutine);
}
messageCoroutine = ((MonoBehaviour)this).StartCoroutine(ShowMessageRoutine("SOLD!", $"{player.playerName} WORTH ${humanPriceValue}K", 5f, Color.green, Color.yellow));
PhotonNetwork.CloseConnection(player.photonView.Owner);
}
private void ActivateLockdown()
{
//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_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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ShopManager.instance.extractionPoint != (Object)null)
{
lockdownBarrier = GameObject.CreatePrimitive((PrimitiveType)3);
((Object)lockdownBarrier).name = "LockdownBarrier";
lockdownBarrier.transform.position = ShopManager.instance.extractionPoint.position + Vector3.up * 1.5f;
lockdownBarrier.transform.localScale = new Vector3(4f, 4f, 1f);
lockdownBarrier.GetComponent<Renderer>().material.color = new Color(0.8f, 0f, 0f, 0.5f);
Object.Destroy((Object)(object)lockdownBarrier.GetComponent<BoxCollider>());
lockdownBarrier.AddComponent<BoxCollider>().size = Vector3.one;
}
}
private void DoTornadoLogic()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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_007f: 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)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
foreach (PhysGrabObject shopItem in shopItems)
{
if (!((Object)(object)shopItem == (Object)null) && !((Object)(object)shopItem.rb == (Object)null) && !shopItem.grabbed)
{
Vector3 val = shopCenterPosition - ((Component)shopItem).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
Vector3 val2 = Vector3.Cross(normalized, Vector3.up);
float num = Vector3.Distance(shopCenterPosition, ((Component)shopItem).transform.position);
if (num > 1f)
{
shopItem.rb.AddForce(normalized * 8f, (ForceMode)0);
}
shopItem.rb.AddForce(val2 * 15f, (ForceMode)0);
if (((Component)shopItem).transform.position.y < shopCenterPosition.y - 1f)
{
shopItem.rb.AddForce(Vector3.up * 6f, (ForceMode)0);
}
shopItem.rb.AddTorque(Random.insideUnitSphere * 2f);
}
}
}
private void DoPoltergeistLogic()
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
timer += Time.deltaTime;
if (timer < 0.1f)
{
return;
}
timer = 0f;
PlayerAvatar nearestPlayer = GetNearestPlayer();
if ((Object)(object)nearestPlayer == (Object)null)
{
return;
}
foreach (PhysGrabObject shopItem in shopItems)
{
if ((Object)(object)shopItem == (Object)null || (Object)(object)shopItem.rb == (Object)null || shopItem.grabbed)
{
continue;
}
float num = Vector3.Distance(((Component)shopItem).transform.position, ((Component)nearestPlayer).transform.position);
Vector3 val;
if (num > 1.5f)
{
val = ((Component)nearestPlayer).transform.position + Vector3.up - ((Component)shopItem).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
shopItem.rb.AddForce(normalized * 30f, (ForceMode)0);
continue;
}
val = shopItem.rb.velocity;
if (((Vector3)(ref val)).magnitude > 5f)
{
nearestPlayer.photonView.RPC("HurtOtherRPC", (RpcTarget)0, new object[4]
{
5,
((Component)shopItem).transform.position,
false,
-1
});
Rigidbody rb = shopItem.rb;
val = shopItem.rb.velocity;
rb.AddForce(-((Vector3)(ref val)).normalized * 10f, (ForceMode)1);
}
}
}
private Item GetRandomItemDefinition()
{
List<Item> list = new List<Item>();
if (ShopManager.instance.potentialItems != null)
{
list.AddRange(ShopManager.instance.potentialItems);
}
if (ShopManager.instance.potentialItemConsumables != null)
{
list.AddRange(ShopManager.instance.potentialItemConsumables);
}
if (ShopManager.instance.potentialItemUpgrades != null)
{
list.AddRange(ShopManager.instance.potentialItemUpgrades);
}
if (ShopManager.instance.potentialItemHealthPacks != null)
{
list.AddRange(ShopManager.instance.potentialItemHealthPacks);
}
if (list.Count == 0)
{
return null;
}
return list[Random.Range(0, list.Count)];
}
private Item FindItemDefinition(GameObject obj)
{
string text = ((Object)obj).name.Replace("(Clone)", "").Trim();
foreach (Item potentialItem in ShopManager.instance.potentialItems)
{
if (((Object)potentialItem.prefab.Prefab).name == text)
{
return potentialItem;
}
}
foreach (Item potentialItemConsumable in ShopManager.instance.potentialItemConsumables)
{
if (((Object)potentialItemConsumable.prefab.Prefab).name == text)
{
return potentialItemConsumable;
}
}
foreach (Item potentialItemUpgrade in ShopManager.instance.potentialItemUpgrades)
{
if (((Object)potentialItemUpgrade.prefab.Prefab).name == text)
{
return potentialItemUpgrade;
}
}
foreach (Item potentialItemHealthPack in ShopManager.instance.potentialItemHealthPacks)
{
if (((Object)potentialItemHealthPack.prefab.Prefab).name == text)
{
return potentialItemHealthPack;
}
}
return null;
}
private Player GetPlayerByActorNumber(int id)
{
Player[] playerList = PhotonNetwork.PlayerList;
foreach (Player val in playerList)
{
if (val.ActorNumber == id)
{
return val;
}
}
return null;
}
private PlayerAvatar GetNearestPlayer()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
PlayerAvatar result = null;
float num = float.MaxValue;
PlayerAvatar[] array2 = array;
foreach (PlayerAvatar val in array2)
{
if (!val.deadSet)
{
float num2 = Vector3.Distance(shopCenterPosition, ((Component)val).transform.position);
if (num2 < num)
{
num = num2;
result = val;
}
}
}
return result;
}
}
[BepInPlugin("com.omniscye.cursedshop", "Cursed Shop", "1.0.0")]
public class CursedShopPlugin : BaseUnityPlugin
{
private readonly Harmony _harmony = new Harmony("CursedShop");
internal Dictionary<string, ConfigEntry<bool>> boolConfigEntries = new Dictionary<string, ConfigEntry<bool>>();
internal static CursedShopPlugin Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
LoadConfig();
_harmony.PatchAll(typeof(ShopManagerPatch));
Logger.LogInfo((object)"Cursed Shop v1.0.0 loaded.");
}
private void LoadConfig()
{
string text = "Cursed Events";
boolConfigEntries.Add("Enable Cursed Events", ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Enable Events", true, "If true, shop may have random chaotic events."));
boolConfigEntries.Add("Force Event Always", ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Debug Force Event", false, "Forces an event every time for testing."));
}
}
[HarmonyPatch(typeof(ShopManager))]
internal static class ShopManagerPatch
{
private static readonly FieldRef<ShopManager, int> itemSpawnTargetAmount_ref = AccessTools.FieldRefAccess<ShopManager, int>("itemSpawnTargetAmount");
private static readonly FieldRef<ShopManager, int> itemConsumablesAmount_ref = AccessTools.FieldRefAccess<ShopManager, int>("itemConsumablesAmount");
private static readonly FieldRef<ShopManager, int> itemUpgradesAmount_ref = AccessTools.FieldRefAccess<ShopManager, int>("itemUpgradesAmount");
private static readonly FieldRef<ShopManager, int> itemHealthPacksAmount_ref = AccessTools.FieldRefAccess<ShopManager, int>("itemHealthPacksAmount");
[HarmonyPrefix]
[HarmonyPatch("Awake")]
private static void SetSpawnLimits(ShopManager __instance)
{
if (CursedShopPlugin.Instance.boolConfigEntries["Enable Cursed Events"].Value)
{
itemConsumablesAmount_ref.Invoke(__instance) = 50;
itemUpgradesAmount_ref.Invoke(__instance) = 50;
itemHealthPacksAmount_ref.Invoke(__instance) = 30;
itemSpawnTargetAmount_ref.Invoke(__instance) = 200;
}
}
[HarmonyPostfix]
[HarmonyPatch("ShopInitialize")]
private static void StartCursedEvent()
{
if (CursedShopPlugin.Instance.boolConfigEntries["Enable Cursed Events"].Value && (Object)(object)RunManager.instance != (Object)null && (Object)(object)RunManager.instance.levelCurrent != (Object)null && RunManager.instance.levelCurrent.ResourcePath == "Shop" && (Object)(object)((Component)ShopManager.instance).gameObject.GetComponent<CursedShopDirector>() == (Object)null)
{
((Component)ShopManager.instance).gameObject.AddComponent<CursedShopDirector>();
}
}
[HarmonyPostfix]
[HarmonyPatch("ShoppingListItemAdd")]
private static void OnItemAddedToCart(ItemAttributes item)
{
if ((Object)(object)CursedShopDirector.Instance != (Object)null)
{
CursedShopDirector.Instance.OnItemAddedToCart(item);
}
}
}
[HarmonyPatch(typeof(ExtractionPoint), "CancelExtraction")]
internal static class ExtractionPoint_CancelExtraction_Patch
{
private static bool Prefix(ref bool __result)
{
return true;
}
}
[HarmonyPatch(typeof(ExtractionPoint), "OnShopClick")]
internal static class ExtractionPoint_OnShopClick_Patch
{
private static bool Prefix(ExtractionPoint __instance)
{
return true;
}
}
}