using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG.Reflection;
using On.RoR2;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using RoR2.UI;
using StageReport;
using TMPro;
using Unity;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace StageReport
{
public class ContentProvider : IContentPackProvider
{
public static ContentPack ContentPack = new ContentPack();
public static GameObject interactableTrackerPrefab;
public static GameObject stageReportPanelPrefab;
public string identifier => "Lawlzee.StageRecap.ContentProvider";
public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
{
ContentPack.identifier = identifier;
string directoryName = Path.GetDirectoryName(typeof(ContentProvider).Assembly.Location);
AssetBundle stageReportBundle = null;
yield return LoadAssetBundle(Path.Combine(directoryName, "stageRecap"), args.progressReceiver, delegate(AssetBundle assetBundle)
{
stageReportBundle = assetBundle;
});
yield return LoadAllAssetsAsync<InteractablesCollection>(stageReportBundle, args.progressReceiver, (Action<InteractablesCollection[]>)delegate(InteractablesCollection[] assets)
{
assets.First().Init();
});
yield return LoadAllAssetsAsync<GameObject>(stageReportBundle, args.progressReceiver, (Action<GameObject[]>)delegate(GameObject[] assets)
{
interactableTrackerPrefab = assets.First((GameObject a) => ((Object)a).name == "InteractableTracker");
stageReportPanelPrefab = assets.First((GameObject a) => ((Object)a).name == "StageReportPanel");
for (int i = 0; i < assets.Length; i++)
{
ClientScene.RegisterPrefab(assets[i]);
}
});
}
private IEnumerator LoadAssetBundle(string assetBundleFullPath, IProgress<float> progress, Action<AssetBundle> onAssetBundleLoaded)
{
AssetBundleCreateRequest assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(assetBundleFullPath);
while (!((AsyncOperation)assetBundleCreateRequest).isDone)
{
progress.Report(((AsyncOperation)assetBundleCreateRequest).progress);
yield return null;
}
onAssetBundleLoaded(assetBundleCreateRequest.assetBundle);
}
private static IEnumerator LoadAllAssetsAsync<T>(AssetBundle assetBundle, IProgress<float> progress, Action<T[]> onAssetsLoaded) where T : Object
{
AssetBundleRequest sceneDefsRequest = assetBundle.LoadAllAssetsAsync<T>();
while (!((AsyncOperation)sceneDefsRequest).isDone)
{
progress.Report(((AsyncOperation)sceneDefsRequest).progress);
yield return null;
}
onAssetsLoaded(sceneDefsRequest.allAssets.Cast<T>().ToArray());
}
public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
{
ContentPack.Copy(ContentPack, args.output);
args.ReportProgress(1f);
yield break;
}
public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
{
args.ReportProgress(1f);
yield break;
}
}
public static class ChestRevealerHooks
{
public static bool reportOpened;
private static bool _inRevealingContext;
public static void Init()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
RevealedObject.OnEnable += new hook_OnEnable(RevealedObject_OnEnable);
PingIndicator.GetInteractableIcon += new hook_GetInteractableIcon(PingIndicator_GetInteractableIcon);
}
private static void RevealedObject_OnEnable(orig_OnEnable orig, MonoBehaviour self)
{
Log.Debug("RevealedObject_OnEnable " + ((Object)self).name);
try
{
_inRevealingContext = reportOpened;
orig.Invoke(self);
}
finally
{
_inRevealingContext = false;
}
}
private static Sprite PingIndicator_GetInteractableIcon(orig_GetInteractableIcon orig, GameObject gameObject)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_00df: Unknown result type (might be due to invalid IL or missing references)
Log.Debug("PingIndicator_GetInteractableIcon " + ((Object)gameObject).name);
if (!_inRevealingContext)
{
Log.Debug("_inRevealingContext: false");
return orig.Invoke(gameObject);
}
NetworkIdentity component = gameObject.GetComponent<NetworkIdentity>();
if ((Object)(object)component == (Object)null)
{
Log.Debug("networkIdentity == null");
return orig.Invoke(gameObject);
}
NetworkInstanceId netId = component.netId;
int? num = InteractableHooks.FindInteractableIndex(((NetworkInstanceId)(ref netId)).Value);
if (!num.HasValue)
{
Log.Debug("index == null");
return orig.Invoke(gameObject);
}
InteractableType type = ((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables)[num.Value].type;
InteractableDef interactableDef = InteractablesCollection.instance[type];
return Sprite.Create(interactableDef.Texture, new Rect(0f, 0f, (float)((Texture)interactableDef.Texture).width, (float)((Texture)interactableDef.Texture).height), new Vector2(0.5f, 0.5f));
}
}
public static class InteractableHooks
{
public static void Init()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
PurchaseInteraction.PreStartClient += new hook_PreStartClient(PurchaseInteraction_PreStartClient);
PurchaseInteraction.OnDisable += new hook_OnDisable(PurchaseInteraction_OnDisable);
ShrineChanceBehavior.AddShrineStack += new hook_AddShrineStack(ShrineChanceBehavior_AddShrineStack);
MultiShopController.Start += new hook_Start(MultiShopController_Start);
MultiShopController.OnPurchase += new hook_OnPurchase(MultiShopController_OnPurchase);
BarrelInteraction.Start += new hook_Start(BarrelInteraction_Start);
BarrelInteraction.CoinDrop += new hook_CoinDrop(BarrelInteraction_CoinDrop);
ScrapperController.Start += new hook_Start(ScrapperController_Start);
CharacterBody.Start += new hook_Start(CharacterBody_Start);
CharacterDeathBehavior.OnDeath += new hook_OnDeath(CharacterDeathBehavior_OnDeath);
ShopTerminalBehavior.UpdatePickupDisplayAndAnimations += new hook_UpdatePickupDisplayAndAnimations(ShopTerminalBehavior_UpdatePickupDisplayAndAnimations);
}
private static void ShopTerminalBehavior_UpdatePickupDisplayAndAnimations(orig_UpdatePickupDisplayAndAnimations orig, ShopTerminalBehavior self)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (self.pickupIndex == PickupIndex.none)
{
return;
}
NetworkInstanceId netId = ((Component)self).GetComponent<NetworkIdentity>().netId;
int? num = FindInteractableIndex(((NetworkInstanceId)(ref netId)).Value);
if (num.HasValue)
{
TrackedInteractable trackedInteractable = ((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables)[num.Value];
if (InteractablesCollection.instance[trackedInteractable.type].unstackable)
{
ItemDef itemDef = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(self.pickupIndex).itemIndex);
trackedInteractable.itemIndex = itemDef.itemIndex;
((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables)[num.Value] = trackedInteractable;
}
}
}
private static void CharacterDeathBehavior_OnDeath(orig_OnDeath orig, CharacterDeathBehavior self)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (NetworkServer.active)
{
NetworkInstanceId netId = ((Component)self).GetComponent<NetworkIdentity>().netId;
SetCharges(((NetworkInstanceId)(ref netId)).Value, 0);
}
}
private static void CharacterBody_Start(orig_Start orig, CharacterBody self)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
orig.Invoke(self);
if (!TryRegistering("CharacterBody_Start", (NetworkBehaviour)(object)self, log: false))
{
return;
}
OnDisableEvent obj = ((Component)self).gameObject.AddComponent<OnDisableEvent>();
obj.action = new UnityEvent();
obj.action.AddListener((UnityAction)delegate
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
Log.Debug("CharacterBody_Disabled");
NetworkInstanceId netId = ((Component)self).GetComponent<NetworkIdentity>().netId;
int? num = FindInteractableIndex(((NetworkInstanceId)(ref netId)).Value);
if (num.HasValue)
{
Log.Debug("Removed");
((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables).RemoveAt(num.Value);
}
});
}
private static void ScrapperController_Start(orig_Start orig, ScrapperController self)
{
orig.Invoke(self);
TryRegistering("ScrapperController_Start", (NetworkBehaviour)(object)self);
}
private static void BarrelInteraction_CoinDrop(orig_CoinDrop orig, BarrelInteraction self)
{
//IL_002e: 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)
orig.Invoke(self);
Log.Debug("BarrelInteraction_Start " + ((Object)((Component)self).gameObject).name);
if (NetworkServer.active)
{
NetworkInstanceId netId = ((Component)self).GetComponent<NetworkIdentity>().netId;
SetCharges(((NetworkInstanceId)(ref netId)).Value, 0);
}
}
private static void BarrelInteraction_Start(orig_Start orig, BarrelInteraction self)
{
orig.Invoke(self);
TryRegistering("BarrelInteraction_Start", (NetworkBehaviour)(object)self);
}
private static void MultiShopController_Start(orig_Start orig, MultiShopController self)
{
orig.Invoke(self);
TryRegistering("MultiShopController_Start", (NetworkBehaviour)(object)self);
}
private static bool TryRegistering(string caller, NetworkBehaviour self, bool log = true)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
if (log)
{
Log.Debug(caller + " " + ((Object)((Component)self).gameObject).name);
}
if (NetworkServer.active)
{
InteractableDef byGameObjectName = InteractablesCollection.instance.GetByGameObjectName(((Object)((Component)self).gameObject).name);
if ((Object)(object)byGameObjectName == (Object)null)
{
if (log)
{
Log.Debug("interactableDef not found");
}
return false;
}
Log.Debug(byGameObjectName.type.ToString() + " found");
TrackedInteractable trackedInteractable = default(TrackedInteractable);
NetworkInstanceId netId = ((Component)self).GetComponent<NetworkIdentity>().netId;
trackedInteractable.netId = ((NetworkInstanceId)(ref netId)).Value;
trackedInteractable.type = byGameObjectName.type;
trackedInteractable.charges = byGameObjectName.charges;
TrackedInteractable trackedInteractable2 = trackedInteractable;
((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables).Add(trackedInteractable2);
return true;
}
return false;
}
private static void MultiShopController_OnPurchase(orig_OnPurchase orig, MultiShopController self, Interactor interactor, PurchaseInteraction purchaseInteraction)
{
//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)
orig.Invoke(self, interactor, purchaseInteraction);
Log.Debug("MultiShopController_OnPurchase " + ((Object)((Component)self).gameObject).name);
if (!NetworkServer.active)
{
return;
}
int num = 0;
GameObject[] terminalGameObjects = self._terminalGameObjects;
for (int i = 0; i < terminalGameObjects.Length; i++)
{
if (terminalGameObjects[i].GetComponent<PurchaseInteraction>().Networkavailable)
{
num++;
}
}
NetworkInstanceId netId = ((Component)self).GetComponent<NetworkIdentity>().netId;
SetCharges(((NetworkInstanceId)(ref netId)).Value, num);
}
private static void ShrineChanceBehavior_AddShrineStack(orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor activator)
{
//IL_002f: 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)
orig.Invoke(self, activator);
Log.Debug("ShrineChanceBehavior_AddShrineStack " + ((Object)((Component)self).gameObject).name);
if (NetworkServer.active)
{
NetworkInstanceId netId = ((Component)self).GetComponent<NetworkIdentity>().netId;
SetCharges(((NetworkInstanceId)(ref netId)).Value, self.maxPurchaseCount - self.successfulPurchaseCount);
}
}
private static void PurchaseInteraction_OnDisable(orig_OnDisable orig, PurchaseInteraction self)
{
//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)
orig.Invoke(self);
Log.Debug("PurchaseInteraction_OnDisable" + ((Object)((Component)self).gameObject).name);
if (!NetworkServer.active)
{
return;
}
if (((Object)((Component)self).gameObject).name.Contains("(Clone)"))
{
Log.Debug("Contains (Clone)");
return;
}
NetworkInstanceId netId = ((Component)self).GetComponent<NetworkIdentity>().netId;
int? num = FindInteractableIndex(((NetworkInstanceId)(ref netId)).Value);
if (num.HasValue)
{
Log.Debug("Removed");
((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables).RemoveAt(num.Value);
}
}
private static void PurchaseInteraction_PreStartClient(orig_PreStartClient orig, PurchaseInteraction self)
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
Log.Debug("PurchaseInteraction_PreStartClient " + ((Object)((Component)self).gameObject).name);
if (!NetworkServer.active)
{
return;
}
InteractableDef byGameObjectName = InteractablesCollection.instance.GetByGameObjectName(((Object)((Component)self).gameObject).name);
if ((Object)(object)byGameObjectName == (Object)null)
{
Log.Debug("interactableDef not found");
return;
}
Log.Debug(byGameObjectName.type.ToString() + " found");
int index = ((SyncListStruct<TrackedInteractable>)InteractableTracker.instance.trackedInteractables).Count;
TrackedInteractable trackedInteractable2 = default(TrackedInteractable);
NetworkInstanceId netId = ((Component)self).GetComponent<NetworkIdentity>().netId;
trackedInteractable2.netId = ((NetworkInstanceId)(ref netId)).Value;
trackedInteractable2.type = byGameObjectName.type;
trackedInteractable2.charges = byGameObjectName.charges;
TrackedInteractable trackedInteractable = trackedInteractable2;
((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables).Add(trackedInteractable);
if (byGameObjectName.charges != 1 && byGameObjectName.type != InteractableType.BloodShrine && byGameObjectName.type != InteractableType.WoodShrine)
{
Log.Debug("charges != 1");
return;
}
((UnityEvent<Interactor>)(object)self.onPurchase).AddListener((UnityAction<Interactor>)delegate
{
trackedInteractable.charges = Mathf.Max(0, trackedInteractable.charges - 1);
((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables)[index] = trackedInteractable;
});
}
public static int? FindInteractableIndex(uint netId)
{
return (from x in ((IEnumerable<TrackedInteractable>)InteractableTracker.instance.trackedInteractables).Select((TrackedInteractable x, int i) => (x.netId, i))
where x.netId == netId
select x.index).FirstOrDefault();
}
private static bool SetCharges(uint netId, int charges)
{
int? num = FindInteractableIndex(netId);
if (!num.HasValue)
{
Log.Debug("index == null. netId = " + netId);
return false;
}
TrackedInteractable trackedInteractable = ((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables)[num.Value];
trackedInteractable.charges = charges;
((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables)[num.Value] = trackedInteractable;
return true;
}
}
public static class RunHooks
{
public static void Init()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
PreGameController.Awake += new hook_Awake(PreGameController_Awake);
Run.AdvanceStage += new hook_AdvanceStage(Run_AdvanceStage);
SceneExitController.Begin += new hook_Begin(SceneExitController_Begin);
}
private static void Run_AdvanceStage(orig_AdvanceStage orig, Run self, SceneDef nextScene)
{
if (NetworkServer.active)
{
((SyncList<TrackedInteractable>)(object)InteractableTracker.instance.trackedInteractables).Clear();
}
orig.Invoke(self, nextScene);
}
private static void PreGameController_Awake(orig_Awake orig, PreGameController self)
{
orig.Invoke(self);
if (NetworkServer.active)
{
NetworkServer.Spawn(Object.Instantiate<GameObject>(ContentProvider.interactableTrackerPrefab));
}
}
private static void SceneExitController_Begin(orig_Begin orig, SceneExitController self)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
if ((int)self.exitState == 0)
{
InteractableTracker.instance.CallRpcShowRecap();
}
orig.Invoke(self);
}
}
[CreateAssetMenu(fileName = "InteractableDef", menuName = "StageReport/InteractableDef", order = 1)]
public class InteractableDef : ScriptableObject
{
public InteractableType type;
public string nameToken;
public Texture2D texture;
public string textureKey;
public int charges = 1;
[Range(0f, 100f)]
public int defaultScoreWeight;
public bool unstackable;
public string[] gameObjectNames;
private Texture2D _texture;
public Texture2D Texture
{
get
{
//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)
if (!((Object)(object)_texture == (Object)null))
{
return _texture;
}
return _texture = (((Object)(object)texture != (Object)null) ? texture : Addressables.LoadAssetAsync<Texture2D>((object)textureKey).WaitForCompletion());
}
}
public int score
{
get
{
if (!Application.isEditor)
{
return ModConfig.interactablesScore[type].Value;
}
return defaultScoreWeight;
}
}
}
[CreateAssetMenu(fileName = "InteractablesCollection", menuName = "StageReport/InteractablesCollection", order = 2)]
public class InteractablesCollection : ScriptableObject
{
public static InteractablesCollection instance;
private Dictionary<InteractableType, InteractableDef> _interactableByType;
private Dictionary<InteractableType, int> _interactableOrder;
private Dictionary<string, InteractableDef> _interactableByGameObjectName;
public InteractableDef[] interactables;
public InteractableDef this[InteractableType type] => _interactableByType[type];
public void Init()
{
instance = this;
_interactableByType = interactables.ToDictionary((InteractableDef x) => x.type);
_interactableOrder = interactables.Select((InteractableDef value, int index) => (value, index)).ToDictionary<(InteractableDef, int), InteractableType, int>(((InteractableDef value, int index) x) => x.value.type, ((InteractableDef value, int index) x) => x.index);
_interactableByGameObjectName = interactables.SelectMany((InteractableDef interactable) => interactable.gameObjectNames.Select((string name) => (interactable, name))).ToDictionary<(InteractableDef, string), string, InteractableDef>(((InteractableDef interactable, string name) x) => x.name, ((InteractableDef interactable, string name) x) => x.interactable);
}
public InteractableDef GetByGameObjectName(string name)
{
if (!_interactableByGameObjectName.TryGetValue(name, out var value))
{
return null;
}
return value;
}
public int GetOrder(InteractableType type)
{
return _interactableOrder[type];
}
}
[Serializable]
public struct TrackedInteractable : IEquatable<TrackedInteractable>
{
public InteractableType type;
public int charges;
public uint netId;
public ItemIndex itemIndex;
public bool Equals(TrackedInteractable other)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (type == other.type && charges == other.charges && netId == other.netId)
{
return itemIndex == other.itemIndex;
}
return false;
}
}
public class SyncListTrackedInteractable : SyncListStruct<TrackedInteractable>
{
public override void SerializeItem(NetworkWriter writer, TrackedInteractable item)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected I4, but got Unknown
writer.Write((int)item.type);
writer.WritePackedUInt32((uint)item.charges);
writer.WritePackedUInt32(item.netId);
writer.Write((int)item.itemIndex);
}
public override TrackedInteractable DeserializeItem(NetworkReader reader)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
TrackedInteractable result = default(TrackedInteractable);
result.type = (InteractableType)reader.ReadInt32();
result.charges = (int)reader.ReadPackedUInt32();
result.netId = reader.ReadPackedUInt32();
result.itemIndex = (ItemIndex)reader.ReadInt32();
return result;
}
}
public class InteractableTracker : NetworkBehaviour
{
public static InteractableTracker instance;
public SyncListTrackedInteractable trackedInteractables;
private static int kListtrackedInteractables;
private static int kRpcRpcShowRecap;
public void Awake()
{
instance = this;
Object.DontDestroyOnLoad((Object)(object)this);
((SyncList<TrackedInteractable>)(object)trackedInteractables).InitializeBehaviour((NetworkBehaviour)(object)this, kListtrackedInteractables);
}
public void OnDestroy()
{
instance = null;
}
[ClientRpc]
public void RpcShowRecap()
{
if (ModConfig.modEnabled.Value)
{
StageReportPanel.Show((IList<TrackedInteractable>)trackedInteractables);
}
}
public InteractableTracker()
{
trackedInteractables = new SyncListTrackedInteractable();
}
private void UNetVersion()
{
}
protected static void InvokeSyncListtrackedInteractables(NetworkBehaviour obj, NetworkReader reader)
{
if (!NetworkClient.active)
{
Debug.LogError((object)"SyncList trackedInteractables called on server.");
}
else
{
((SyncList<TrackedInteractable>)(object)((InteractableTracker)(object)obj).trackedInteractables).HandleMsg(reader);
}
}
protected static void InvokeRpcRpcShowRecap(NetworkBehaviour obj, NetworkReader reader)
{
if (!NetworkClient.active)
{
Debug.LogError((object)"RPC RpcShowRecap called on server.");
}
else
{
((InteractableTracker)(object)obj).RpcShowRecap();
}
}
public void CallRpcShowRecap()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkServer.active)
{
Debug.LogError((object)"RPC Function RpcShowRecap called on client.");
return;
}
NetworkWriter val = new NetworkWriter();
val.Write((short)0);
val.Write((short)2);
val.WritePackedUInt32((uint)kRpcRpcShowRecap);
val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcShowRecap");
}
static InteractableTracker()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
kRpcRpcShowRecap = -1110127644;
NetworkBehaviour.RegisterRpcDelegate(typeof(InteractableTracker), kRpcRpcShowRecap, new CmdDelegate(InvokeRpcRpcShowRecap));
kListtrackedInteractables = -1574685821;
NetworkBehaviour.RegisterSyncListDelegate(typeof(InteractableTracker), kListtrackedInteractables, new CmdDelegate(InvokeSyncListtrackedInteractables));
NetworkCRC.RegisterBehaviour("InteractableTracker", 0);
}
public override bool OnSerialize(NetworkWriter writer, bool forceAll)
{
if (forceAll)
{
GeneratedNetworkCode._WriteStructSyncListTrackedInteractable_None(writer, trackedInteractables);
return true;
}
bool flag = false;
if ((((NetworkBehaviour)this).syncVarDirtyBits & (true ? 1u : 0u)) != 0)
{
if (!flag)
{
writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
flag = true;
}
GeneratedNetworkCode._WriteStructSyncListTrackedInteractable_None(writer, trackedInteractables);
}
if (!flag)
{
writer.WritePackedUInt32(((NetworkBehaviour)this).syncVarDirtyBits);
}
return flag;
}
public override void OnDeserialize(NetworkReader reader, bool initialState)
{
if (initialState)
{
GeneratedNetworkCode._ReadStructSyncListTrackedInteractable_None(reader, trackedInteractables);
return;
}
int num = (int)reader.ReadPackedUInt32();
if (((uint)num & (true ? 1u : 0u)) != 0)
{
GeneratedNetworkCode._ReadStructSyncListTrackedInteractable_None(reader, trackedInteractables);
}
}
public override void PreStartClient()
{
}
}
public enum InteractableType
{
Chest,
DamageChest,
UtilityChest,
HealingChest,
WhiteMultishop,
LargeChest,
LargeDamageChest,
LargeUtilityChest,
LargeHealingChest,
GreenMultishop,
LegendaryChest,
RedMultishop,
AdaptiveChest,
EquipmentBarrel,
EquipmentMultishop,
Lockbox,
EncrustedCache,
CrashedMultishop,
CloakedChest,
LunarPod,
VoidCradle,
VoidPotential,
Barrel,
Stalk,
ChanceShrine,
BloodShrine,
CombatShrine,
MountainShrine,
WoodShrine,
OrderShrine,
GoldShrine,
GunnerDrone,
HealingDrone,
MissileDrone,
IcineratorDrone,
EquipmentDrone,
EmergencyDrone,
TCDrone,
GunnerTurret,
NewtAltar,
TimedSecurityChest,
AlloyVultureNest,
WhitePrinter,
GreenPrinter,
RedPrinter,
YellowPrinter,
Scapper,
CleansingPool,
VultureEgg,
ShippingRequestForm,
ShrineColossusAccess,
ShrineHalcyonite,
Geode
}
public static class Log
{
private static ManualLogSource _logSource;
public static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
public static void Debug(object data)
{
if (_logSource == null)
{
Debug.Log(data);
}
else
{
_logSource.LogDebug(data);
}
}
public static void Error(object data)
{
if (_logSource == null)
{
Debug.LogError(data);
}
else
{
_logSource.LogError(data);
}
}
public static void Fatal(object data)
{
if (_logSource == null)
{
Debug.LogError(data);
}
else
{
_logSource.LogFatal(data);
}
}
public static void Info(object data)
{
if (_logSource == null)
{
Debug.Log(data);
}
else
{
_logSource.LogInfo(data);
}
}
public static void Message(object data)
{
if (_logSource == null)
{
Debug.Log(data);
}
else
{
_logSource.LogMessage(data);
}
}
public static void Warning(object data)
{
if (_logSource == null)
{
Debug.LogWarning(data);
}
else
{
_logSource.LogWarning(data);
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Lawlzee.StageRecap", "StageRecap", "1.3.0")]
public class Main : BaseUnityPlugin
{
public const string PluginGUID = "Lawlzee.StageRecap";
public const string PluginAuthor = "Lawlzee";
public const string PluginName = "StageRecap";
public const string PluginVersion = "1.3.0";
public void Awake()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
Texture2D val = LoadTexture("icon.png");
ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f)));
ModSettingsManager.SetModDescription("At the end of each stage, StageRecap shows all the interactables on the stage and how many you’ve collected. This helps players improve at full looting stages.");
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
{
ModConfig.Init(((BaseUnityPlugin)this).Config);
});
RunHooks.Init();
InteractableHooks.Init();
ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(GiveToRoR2OurContentPackProviders);
}
private Texture2D LoadTexture(string name)
{
//IL_0002: 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_0028: Expected O, but got Unknown
//IL_002a: Expected O, but got Unknown
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), name)));
return val;
}
private void GiveToRoR2OurContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
{
addContentPackProvider.Invoke((IContentPackProvider)(object)new ContentProvider());
}
}
public static class ModConfig
{
public static ConfigEntry<bool> modEnabled;
public static ConfigEntry<bool> revealInteractableOnStageEnd;
public static Dictionary<InteractableType, ConfigEntry<bool>> visibleInteractables = new Dictionary<InteractableType, ConfigEntry<bool>>();
public static Dictionary<InteractableType, ConfigEntry<int>> interactablesScore = new Dictionary<InteractableType, ConfigEntry<int>>();
public static void Init(ConfigFile config)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Expected O, but got Unknown
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
modEnabled = config.Bind<bool>("Configuration", "Mod enabled", true, "Mod enabled");
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(modEnabled));
revealInteractableOnStageEnd = config.Bind<bool>("Configuration", "Reveal interactables on stage end", true, "When the stage recap is shown, the Radar Scanner effect is now activated to show missed interactables.");
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(revealInteractableOnStageEnd));
InteractableDef[] interactables = InteractablesCollection.instance.interactables;
foreach (InteractableDef interactableDef in interactables)
{
string text = string.Join(" ", ((IEnumerable<string>)interactableDef.nameToken.Split(' ')).Select((Func<string, string>)Language.GetString));
string text2 = NormaliseName(text);
ConfigEntry<bool> val = config.Bind<bool>("Visible", text2, true, "Is <style=cIsHealing>" + text + "</style> shown in the stage recap?");
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val));
visibleInteractables[interactableDef.type] = val;
ConfigEntry<int> val2 = config.Bind<int>("Score", text2, interactableDef.defaultScoreWeight, "How many points does <style=cIsHealing>" + text + "</style> add to the stage completion percentage?");
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(val2, new IntSliderConfig
{
min = 0,
max = 100
}));
interactablesScore[interactableDef.type] = val2;
}
static string NormaliseName(string name)
{
return Regex.Replace(name, "[=\\n\\t\\\\\"'\\[\\]]", "").Trim();
}
}
}
public class ProfilerLog : IDisposable
{
private readonly ProfilerLog _parent;
private readonly Stopwatch _stopwatch;
private readonly string _name;
private readonly int _depth;
public static ProfilerLog Current { get; private set; } = new ProfilerLog(null, null);
private ProfilerLog(ProfilerLog parent, string name)
{
_parent = parent;
_stopwatch = Stopwatch.StartNew();
_name = name;
_depth = (parent?._depth ?? 0) + 1;
}
public static void Reset()
{
while (Current._parent != null)
{
Current = Current._parent;
}
Current._stopwatch.Restart();
}
public static void Debug(object data)
{
Log.Debug(GetMessage(data));
Current._stopwatch.Restart();
}
public static void Error(object data)
{
Log.Error(GetMessage(data));
Current._stopwatch.Restart();
}
public static void Fatal(object data)
{
Log.Fatal(GetMessage(data));
Current._stopwatch.Restart();
}
public static void Info(object data)
{
Log.Info(GetMessage(data));
Current._stopwatch.Restart();
}
public static void Message(object data)
{
Log.Message(GetMessage(data));
Current._stopwatch.Restart();
}
public static void Warning(object data)
{
Log.Warning(GetMessage(data));
Current._stopwatch.Restart();
}
private static string GetMessage(object data)
{
return $"Profiler <{Current._depth}> {data}: {Current._stopwatch.Elapsed}";
}
public static ProfilerLog CreateScope(string name)
{
Current = new ProfilerLog(Current, name);
return Current;
}
public void Dispose()
{
Current = _parent;
Debug(_name);
}
}
public class SemanticVersion
{
public int Major;
public int Minor;
public int Patch;
public static SemanticVersion Parse(string version)
{
string[] array = version.Split('.');
return new SemanticVersion
{
Major = int.Parse(array[0]),
Minor = int.Parse(array[1]),
Patch = int.Parse(array[2])
};
}
public static bool operator <(SemanticVersion a, SemanticVersion b)
{
if (a.Major < b.Major)
{
return true;
}
if (a.Major > b.Major)
{
return false;
}
if (a.Minor < b.Minor)
{
return true;
}
if (a.Minor > b.Minor)
{
return false;
}
if (a.Patch < b.Patch)
{
return true;
}
return false;
}
public static bool operator >(SemanticVersion a, SemanticVersion b)
{
if (a.Major > b.Major)
{
return true;
}
if (a.Major < b.Major)
{
return false;
}
if (a.Minor > b.Minor)
{
return true;
}
if (a.Minor < b.Minor)
{
return false;
}
if (a.Patch > b.Patch)
{
return true;
}
return false;
}
public static bool operator ==(SemanticVersion a, SemanticVersion b)
{
if (a.Major == b.Major && a.Minor == b.Minor)
{
return a.Patch == b.Patch;
}
return false;
}
public static bool operator !=(SemanticVersion a, SemanticVersion b)
{
if (a.Major == b.Major && a.Minor == b.Minor)
{
return a.Patch != b.Patch;
}
return true;
}
public override bool Equals(object obj)
{
if (obj is SemanticVersion semanticVersion && Major == semanticVersion.Major && Minor == semanticVersion.Minor)
{
return Patch == semanticVersion.Patch;
}
return false;
}
public override int GetHashCode()
{
return ((-639545495 * -1521134295 + Major.GetHashCode()) * -1521134295 + Minor.GetHashCode()) * -1521134295 + Patch.GetHashCode();
}
}
public class StageReportPanel : MonoBehaviour
{
public string labelPrefabKey;
public string interactableIconPrefabKey;
public GameObject interactablePanel;
public GameObject printerItemIconPrefab;
public InteractablesCollection interactablesCollection;
public string stageLabelText;
public Vector3 stageLabelScale;
public Vector2 stageLabelPivot;
public Color stageLabelColor;
public int stageLabelFontSize;
public Texture2D numberRamp;
public Color noChargesColor;
public float interactableShowInitialDelay;
public float interactableShowDelay;
public static void Show(IList<TrackedInteractable> trackedInteractables)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
Transform val = (GameObject.Find("HUDSimple(Clone)") ?? GameObject.Find("RiskUI(Clone)")).transform.Find("MainContainer").Find("MainUIArea").Find("SpringCanvas");
Object.Instantiate<GameObject>(ContentProvider.stageReportPanelPrefab, val).GetComponent<StageReportPanel>().Render(trackedInteractables);
if (!Application.isEditor && ModConfig.revealInteractableOnStageEnd.Value)
{
GameObject obj = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Scanner/ChestScanner.prefab").WaitForCompletion(), ((Component)Camera.main).transform);
ChestRevealer component = obj.GetComponent<ChestRevealer>();
component.radius = float.MaxValue;
component.pulseTravelSpeed *= 2f;
OnDestroyCallback.AddCallback(obj, (Action<OnDestroyCallback>)delegate
{
ChestRevealerHooks.reportOpened = false;
});
ChestRevealerHooks.reportOpened = true;
}
}
public static void Toggle(IList<TrackedInteractable> trackedInteractables)
{
Transform obj = (GameObject.Find("HUDSimple(Clone)") ?? GameObject.Find("RiskUI(Clone)")).transform.Find("MainContainer").Find("MainUIArea").Find("SpringCanvas")
.Find("StageReportPanel(Clone)");
GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val);
}
else
{
Show(trackedInteractables);
}
}
public void Render(IList<TrackedInteractable> trackedInteractables)
{
//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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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)
GameObject obj = Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)labelPrefabKey).WaitForCompletion(), ((Component)this).transform);
RectTransform val = (RectTransform)obj.transform;
((Transform)val).localScale = stageLabelScale;
val.pivot = stageLabelPivot;
((Transform)val).SetAsFirstSibling();
HGTextMeshProUGUI component = obj.GetComponent<HGTextMeshProUGUI>();
((TMP_Text)component).text = stageLabelText;
((Graphic)component).color = stageLabelColor;
((TMP_Text)component).fontSize = stageLabelFontSize;
((MonoBehaviour)this).StartCoroutine(RenderInteractables(component, trackedInteractables));
}
private IEnumerator RenderInteractables(HGTextMeshProUGUI textMesh, IList<TrackedInteractable> trackedInteractables)
{
yield return (object)new WaitForSeconds(interactableShowInitialDelay);
GameObject interactableIconPrefab = Addressables.LoadAssetAsync<GameObject>((object)interactableIconPrefabKey).WaitForCompletion();
List<(InteractableType, ItemIndex, int, int, InteractableDef)> list = (from x in trackedInteractables
where Application.isEditor || ModConfig.visibleInteractables[x.type].Value
select (x, InteractablesCollection.instance[x.type]) into x
group x by (x.value.type, x.def.unstackable ? Guid.NewGuid() : Guid.Empty) into kvp
select (kvp.Key.type, kvp.First().value.itemIndex, kvp.Select(((TrackedInteractable value, InteractableDef def) x) => x.value.charges).Sum(), kvp.Count(), kvp.First().def) into x
orderby InteractablesCollection.instance.GetOrder(x.type)
select x).ToList();
float currentScore = 0f;
float total = (from x in list
where x.def.charges > 0
select x.def.score * x.count).Sum();
foreach (var item in list)
{
GameObject val = Object.Instantiate<GameObject>(interactableIconPrefab, interactablePanel.transform);
val.GetComponent<RawImage>().texture = (Texture)(object)item.Item5.Texture;
Transform child = val.transform.GetChild(0);
HGTextMeshProUGUI component = ((Component)child).GetComponent<HGTextMeshProUGUI>();
((Component)child).gameObject.SetActive(true);
if (item.Item5.unstackable)
{
((TMP_Text)component).text = "";
GameObject val2 = Object.Instantiate<GameObject>(printerItemIconPrefab, val.transform);
if (!Application.isEditor)
{
val2.GetComponent<RawImage>().texture = ItemCatalog.GetItemDef(item.Item2).pickupIconTexture;
}
}
else if (item.Item5.charges == 0)
{
((TMP_Text)component).text = item.Item4.ToString();
((Graphic)component).color = noChargesColor;
}
else
{
float num = 1f - (float)item.Item3 / ((float)item.Item5.charges * (float)item.Item4);
((Graphic)component).color = numberRamp.GetPixelBilinear(num, 0f);
currentScore += (float)item.Item5.score * ((float)item.Item4 - (float)item.Item3 / (float)item.Item5.charges);
((TMP_Text)component).text = $"{(float)item.Item4 - (float)item.Item3 / (float)item.Item5.charges:0.##}/{item.Item4}";
}
val.GetComponent<TooltipProvider>().titleToken = item.Item5.nameToken;
float num2 = ((total > 0f) ? (100f * Mathf.Clamp01(currentScore / total)) : 100f);
((TMP_Text)textMesh).text = $"{stageLabelText} - {Mathf.CeilToInt(num2)}%";
yield return (object)new WaitForSeconds(interactableShowDelay);
}
}
}
public class HudInstantier : MonoBehaviour
{
public GameObject stageReportPrefab;
public InteractablesCollection interactablesCollection;
public TrackedInteractable[] trackedInteractables;
private bool initalised;
private void Awake()
{
//IL_0022: 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)
if (Application.isPlaying)
{
interactablesCollection.Init();
ContentProvider.stageReportPanelPrefab = stageReportPrefab;
Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Core/Main Camera.prefab").WaitForCompletion());
}
}
private void Update()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
if (Application.isPlaying)
{
if (Input.GetKeyDown((KeyCode)286))
{
StageReportPanel.Toggle(trackedInteractables);
}
if (!initalised)
{
initalised = true;
Transform obj = GameObject.Find("HUDSimple(Clone)").transform.Find("MainContainer").Find("MainUIArea");
((Component)obj).gameObject.SetActive(true);
Transform val = obj.Find("SpringCanvas").Find("UpperRightCluster");
Object.Instantiate<GameObject>(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ClassicRun/ClassicRunInfoHudPanel.prefab").WaitForCompletion(), val);
StageReportPanel.Show(trackedInteractables);
}
}
}
}
[DefaultExecutionOrder(-100)]
public class ServerStarter : MonoBehaviour
{
public void Awake()
{
Log.Debug("Starting server");
((Component)this).GetComponent<NetworkManager>().StartHost();
Log.Debug("Server started: " + NetworkServer.active);
}
}
}
namespace Assets.StageReport
{
public static class Commands
{
[ConCommand(/*Could not decode attribute arguments.*/)]
public static void ToggleReport(ConCommandArgs args)
{
StageReportPanel.Toggle((IList<TrackedInteractable>)InteractableTracker.instance.trackedInteractables);
}
}
}
namespace Unity
{
[StructLayout(LayoutKind.Auto, CharSet = CharSet.Auto)]
public class GeneratedNetworkCode
{
public static void _ReadStructSyncListTrackedInteractable_None(NetworkReader reader, SyncListTrackedInteractable instance)
{
ushort num = reader.ReadUInt16();
((SyncList<TrackedInteractable>)(object)instance).Clear();
for (ushort num2 = 0; num2 < num; num2++)
{
((SyncListStruct<TrackedInteractable>)instance).AddInternal(instance.DeserializeItem(reader));
}
}
public static void _WriteStructSyncListTrackedInteractable_None(NetworkWriter writer, SyncListTrackedInteractable value)
{
ushort count = ((SyncListStruct<TrackedInteractable>)value).Count;
writer.Write(count);
for (ushort num = 0; num < count; num++)
{
value.SerializeItem(writer, ((SyncListStruct<TrackedInteractable>)value).GetItem((int)num));
}
}
}
}