using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Bounce.Unmanaged;
using HarmonyLib;
using Miop.Consumer.Messages;
using Miop.Patches;
using RPCPlugin.Interfaces;
using RPCPlugin.RPC;
using TaleSpire.ContentManagement;
using TaleSpire.Modding;
using ZeroFormatter;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RForRotatePlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("D20ArmyKnife")]
[assembly: AssemblyProduct("RForRotatePlugin")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4e4deb5e-97f9-4901-bf67-6748a9c1229a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RPCPlugin.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
resourceMan = new ResourceManager("RpcConsumers.Properties.Resources", typeof(Resources).Assembly);
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal Resources()
{
}
}
}
namespace Miop
{
[BepInPlugin("org.HolloFox.mop.patch", "MOP (Mod IO Private Patch)", "1.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class MOPPlugin : BaseUnityPlugin
{
public const string Name = "MOP (Mod IO Private Patch)";
public const string Guid = "org.HolloFox.mop.patch";
public const string Version = "1.0.0.0";
internal static ManualLogSource InternalLogger;
public void Awake()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
InternalLogger = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"In Awake for MOP (Mod IO Private Patch)");
new Harmony("org.HolloFox.mop.patch").PatchAll();
}
}
}
namespace Miop.Patches
{
[HarmonyPatch("TaleSpire.Modding.ModManager,Bouncyrock.TaleSpire.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "OnInstanceSetup")]
internal class ModManagerPatch
{
internal static object instance;
public static void Postfix(object __instance)
{
instance = __instance;
}
public static void MaybeAddSubscription(ModInfo modInfo)
{
//IL_000a: 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_0031: Unknown result type (might be due to invalid IL or missing references)
MOPPlugin.InternalLogger.LogInfo((object)$"Triggering MaybeAddSubscription for {modInfo.Id}");
instance.CallMethod("MaybeAddSubscription", modInfo, null);
}
}
[HarmonyPatch(typeof(CommunityModsBrowserOwnedItem), "OnClicked")]
internal class CommunityModsBrowserOwnedItemOnClickedPatch
{
public static void Prefix(ref ModInfo ____modInfo)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if ((int)____modInfo.Kind == 4)
{
RPCInstance.SendMessage((RpcMessage)(object)new RespondModInfo
{
ModInfo = ____modInfo
}, (PhotonTargets)0);
}
}
}
public static class SysReflec
{
public static object CallMethod(this object o, string methodName, params object[] args)
{
MethodInfo method = o.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
return method?.Invoke(method.IsStatic ? null : o, args);
}
}
}
namespace Miop.Consumer
{
[InitOnLoad]
internal sealed class RespondModInfoConsumer : RpcConsumer<RespondModInfo>
{
private static readonly RespondModInfoConsumer instance;
private static readonly HashSet<NGuid> alreadyLooked;
public static RespondModInfoConsumer Instance => instance;
static RespondModInfoConsumer()
{
instance = new RespondModInfoConsumer();
alreadyLooked = new HashSet<NGuid>();
}
private RespondModInfoConsumer()
{
}
public override void Handle(RespondModInfo message)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//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_0018: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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_0062: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_00e2: 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)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
ModInfo modInfo = message.ModInfo;
NGuid id = modInfo.Id;
MOPPlugin.InternalLogger.LogMessage((object)$"Requested to fetch mini {id}");
if (alreadyLooked.Contains(id))
{
MOPPlugin.InternalLogger.LogMessage((object)$"{id} has already been searched, Skipping!");
return;
}
alreadyLooked.Add(id);
InternedPackId val = ContentManager.BrModIoPackIdFromModId(id);
MOPPlugin.InternalLogger.LogMessage((object)$"mod id provided {id}, {val}");
DbContentKind val2 = default(DbContentKind);
InternedContentAddress val3 = default(InternedContentAddress);
if (AssetDb.TryFindSoleSpawnableContentWithLock(val, ref val2, ref val3) && (int)val2 == 4)
{
MOPPlugin.InternalLogger.LogMessage((object)$"mod {id} Already Exits, Skipping Download");
return;
}
MOPPlugin.InternalLogger.LogMessage((object)"Does not exist, lets try finding it");
if (!((ModInfo)(ref modInfo)).IsValid)
{
MOPPlugin.InternalLogger.LogMessage((object)"Mod info received was invalid, will try again if new info provided");
alreadyLooked.Remove(id);
}
else
{
ModManagerPatch.MaybeAddSubscription(modInfo);
}
}
}
}
namespace Miop.Consumer.Messages
{
[ZeroFormattable]
public class RespondModInfo : RpcMessage
{
[Index(0)]
public virtual ushort ProviderIndex { get; set; }
[Index(1)]
public virtual string NId { get; set; }
[Index(2)]
public virtual string Name { get; set; }
[Index(3)]
public virtual string Summary { get; set; }
[Index(4)]
public virtual string Description { get; set; }
[Index(5)]
public virtual string ThumbnailUrl { get; set; }
[Index(6)]
public virtual string RepoUserName { get; set; }
[Index(7)]
public virtual string RepoModWebPageUrl { get; set; }
[Index(8)]
public virtual string ImageUrl { get; set; }
[Index(9)]
public virtual byte Kind { get; set; }
[Index(10)]
public virtual byte Status { get; set; }
[Index(11)]
public virtual ModVisibility ModVisibility { get; set; }
[Index(12)]
public virtual string ArchiveUrl { get; set; }
[Index(13)]
public virtual byte[] ArchiveMd5 { get; set; }
[Index(14)]
public virtual int ArchiveSize { get; set; }
[Index(15)]
public virtual DateTime UpdateDateTime { get; set; }
[Index(16)]
public virtual int UpVotes { get; set; }
[Index(17)]
public virtual int DownVotes { get; set; }
[IgnoreFormat]
public ModInfo ModInfo
{
get
{
//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)
//IL_0045: 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_0067: 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_008b: Unknown result type (might be due to invalid IL or missing references)
NGuid val = default(NGuid);
NGuid.TryParseHexString(NId, ref val);
return new ModInfo(new ProviderIndex(ProviderIndex), val, Name, (ModKind)Kind, (ModStatus)Status, Summary, Description, ThumbnailUrl, ImageUrl, ModVisibility, new ModArchiveInfo(ArchiveUrl, new MD5(ArchiveMd5), ArchiveSize, UpdateDateTime), true, RepoUserName, RepoModWebPageUrl, new ModVotes(UpVotes, DownVotes), (object)null);
}
set
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected I4, but got Unknown
//IL_003e: 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_0049: Expected I4, but got Unknown
//IL_004a: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
ProviderIndex = (ushort)((ProviderIndex)(ref value.ProviderIndex)).AsIndex;
NId = ((NGuid)(ref value.Id)).ToHexString();
Name = value.Name;
Kind = (byte)(int)value.Kind;
Status = (byte)(int)value.Status;
Summary = value.Summary;
Description = value.Description;
ThumbnailUrl = value.ThumbnailUrl;
ImageUrl = value.ImageUrl;
ModVisibility = value.ModVisibility;
ArchiveUrl = value.ArchiveInfo.ArchiveUrl;
ArchiveMd5 = ((MD5)(ref value.ArchiveInfo.ArchiveMd5)).ToArray();
ArchiveSize = value.ArchiveInfo.ArchiveSize;
UpdateDateTime = value.ArchiveInfo.UpdateDateTime;
RepoUserName = value.RepoUserName;
RepoModWebPageUrl = value.RepoModWebPageUrl;
UpVotes = value.RepoVotes.UpVotes;
DownVotes = value.RepoVotes.DownVotes;
}
}
public RespondModInfo()
{
}
public override byte[] Value()
{
return ZeroFormatterSerializer.Serialize<RespondModInfo>(this);
}
public RespondModInfo(byte[] data)
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
MOPPlugin.InternalLogger.LogInfo((object)$"Received {data.Length} bytes.");
RespondModInfo respondModInfo = ZeroFormatterSerializer.Deserialize<RespondModInfo>(data);
ProviderIndex = respondModInfo.ProviderIndex;
NId = respondModInfo.NId;
Name = respondModInfo.Name;
Summary = respondModInfo.Summary;
Description = respondModInfo.Description;
ThumbnailUrl = respondModInfo.ThumbnailUrl;
ImageUrl = respondModInfo.ImageUrl;
RepoUserName = respondModInfo.RepoUserName;
RepoModWebPageUrl = respondModInfo.RepoModWebPageUrl;
ImageUrl = respondModInfo.ImageUrl;
Kind = respondModInfo.Kind;
Status = respondModInfo.Status;
ModVisibility = respondModInfo.ModVisibility;
ArchiveUrl = respondModInfo.ArchiveUrl;
ArchiveMd5 = respondModInfo.ArchiveMd5;
ArchiveSize = respondModInfo.ArchiveSize;
UpdateDateTime = respondModInfo.UpdateDateTime;
UpVotes = respondModInfo.UpVotes;
DownVotes = respondModInfo.DownVotes;
}
}
}