diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/DiscordRpc.cs b/DiscordRpc.cs new file mode 100644 index 0000000..030737d --- /dev/null +++ b/DiscordRpc.cs @@ -0,0 +1,227 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; + +/// +/// Credit to https://github.com/Slaynash +/// + +namespace DiscordRichPresense +{ + public class DiscordRpc + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void ReadyCallback(ref DiscordUser connectedUser); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void DisconnectedCallback(int errorCode, string message); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void ErrorCallback(int errorCode, string message); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void JoinCallback(string secret); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void SpectateCallback(string secret); + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void RequestCallback(ref DiscordUser request); + + public struct EventHandlers + { + public ReadyCallback readyCallback; + public DisconnectedCallback disconnectedCallback; + public ErrorCallback errorCallback; + public JoinCallback joinCallback; + public SpectateCallback spectateCallback; + public RequestCallback requestCallback; + } + + [Serializable, StructLayout(LayoutKind.Sequential)] + public struct RichPresenceStruct + { + public IntPtr state; /* max 128 bytes */ + public IntPtr details; /* max 128 bytes */ + public long startTimestamp; + public long endTimestamp; + public IntPtr largeImageKey; /* max 32 bytes */ + public IntPtr largeImageText; /* max 128 bytes */ + public IntPtr smallImageKey; /* max 32 bytes */ + public IntPtr smallImageText; /* max 128 bytes */ + public IntPtr partyId; /* max 128 bytes */ + public int partySize; + public int partyMax; + public IntPtr matchSecret; /* max 128 bytes */ + public IntPtr joinSecret; /* max 128 bytes */ + public IntPtr spectateSecret; /* max 128 bytes */ + public bool instance; + } + + [Serializable] + public struct DiscordUser + { + public string userId; + public string username; + public string discriminator; + public string avatar; + } + + public enum Reply + { + No = 0, + Yes = 1, + Ignore = 2 + } + + [DllImport("/PhasmodLoader/Dependencies/discord-rpc", EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)] + public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId); + + [DllImport("/PhasmodLoader/Dependencies/discord-rpc", EntryPoint = "Discord_Shutdown", CallingConvention = CallingConvention.Cdecl)] + public static extern void Shutdown(); + + [DllImport("/PhasmodLoader/Dependencies/discord-rpc", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)] + public static extern void RunCallbacks(); + + [DllImport("/PhasmodLoader/Dependencies/discord-rpc", EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)] + private static extern void UpdatePresenceNative(ref RichPresenceStruct presence); + + [DllImport("/PhasmodLoader/Dependencies/discord-rpc", EntryPoint = "Discord_ClearPresence", CallingConvention = CallingConvention.Cdecl)] + public static extern void ClearPresence(); + + [DllImport("/PhasmodLoader/Dependencies/discord-rpc", EntryPoint = "Discord_Respond", CallingConvention = CallingConvention.Cdecl)] + public static extern void Respond(string userId, Reply reply); + + [DllImport("/PhasmodLoader/Dependencies/discord-rpc", EntryPoint = "Discord_UpdateHandlers", CallingConvention = CallingConvention.Cdecl)] + public static extern void UpdateHandlers(ref EventHandlers handlers); + + public static void UpdatePresence(RichPresence presence) + { + var presencestruct = presence.GetStruct(); + UpdatePresenceNative(ref presencestruct); + presence.FreeMem(); + } + + public class RichPresence + { + private RichPresenceStruct _presence; + private readonly List _buffers = new List(10); + + public string state; /* max 128 bytes */ + public string details; /* max 128 bytes */ + public long startTimestamp; + public long endTimestamp; + public string largeImageKey; /* max 32 bytes */ + public string largeImageText; /* max 128 bytes */ + public string smallImageKey; /* max 32 bytes */ + public string smallImageText; /* max 128 bytes */ + public string partyId; /* max 128 bytes */ + public int partySize; + public int partyMax; + public string matchSecret; /* max 128 bytes */ + public string joinSecret; /* max 128 bytes */ + public string spectateSecret; /* max 128 bytes */ + public bool instance; + + /// + /// Get the reprensentation of this instance + /// + /// reprensentation of this instance + internal RichPresenceStruct GetStruct() + { + if (_buffers.Count > 0) + { + FreeMem(); + } + + _presence.state = StrToPtr(state, 128); + _presence.details = StrToPtr(details, 128); + _presence.startTimestamp = startTimestamp; + _presence.endTimestamp = endTimestamp; + _presence.largeImageKey = StrToPtr(largeImageKey, 32); + _presence.largeImageText = StrToPtr(largeImageText, 128); + _presence.smallImageKey = StrToPtr(smallImageKey, 32); + _presence.smallImageText = StrToPtr(smallImageText, 128); + _presence.partyId = StrToPtr(partyId, 128); + _presence.partySize = partySize; + _presence.partyMax = partyMax; + _presence.matchSecret = StrToPtr(matchSecret, 128); + _presence.joinSecret = StrToPtr(joinSecret, 128); + _presence.spectateSecret = StrToPtr(spectateSecret, 128); + _presence.instance = instance; + + return _presence; + } + + /// + /// Returns a pointer to a representation of the given string with a size of maxbytes + /// + /// String to convert + /// Max number of bytes to use + /// Pointer to the UTF-8 representation of + private IntPtr StrToPtr(string input, int maxbytes) + { + if (string.IsNullOrEmpty(input)) return IntPtr.Zero; + var convstr = StrClampBytes(input, maxbytes); + var convbytecnt = Encoding.UTF8.GetByteCount(convstr); + var buffer = Marshal.AllocHGlobal(convbytecnt); + _buffers.Add(buffer); + Marshal.Copy(Encoding.UTF8.GetBytes(convstr), 0, buffer, convbytecnt); + return buffer; + } + + /// + /// Convert string to UTF-8 and add null termination + /// + /// string to convert + /// UTF-8 representation of with added null termination + private static string StrToUtf8NullTerm(string toconv) + { + var str = toconv.Trim(); + var bytes = Encoding.Default.GetBytes(str); + if (bytes.Length > 0 && bytes[bytes.Length - 1] != 0) + { + str += "\0\0"; + } + return Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(str)); + } + + /// + /// Clamp the string to the given byte length preserving null termination + /// + /// string to clamp + /// max bytes the resulting string should have (including null termination) + /// null terminated string with a byte length less or equal to + private static string StrClampBytes(string toclamp, int maxbytes) + { + var str = StrToUtf8NullTerm(toclamp); + var strbytes = Encoding.UTF8.GetBytes(str); + + if (strbytes.Length <= maxbytes) + { + return str; + } + + var newstrbytes = new byte[] { }; + Array.Copy(strbytes, 0, newstrbytes, 0, maxbytes - 1); + newstrbytes[newstrbytes.Length - 1] = 0; + newstrbytes[newstrbytes.Length - 2] = 0; + + return Encoding.UTF8.GetString(newstrbytes); + } + + /// + /// Free the allocated memory for conversion to + /// + internal void FreeMem() + { + for (var i = _buffers.Count - 1; i >= 0; i--) + { + Marshal.FreeHGlobal(_buffers[i]); + _buffers.RemoveAt(i); + } + } + } + } +} \ No newline at end of file diff --git a/PhasmodHandler.csproj b/PhasmodHandler.csproj new file mode 100644 index 0000000..34f355d --- /dev/null +++ b/PhasmodHandler.csproj @@ -0,0 +1,310 @@ + + + + + Debug + AnyCPU + {D18A3585-0909-41F0-9576-A2CF6766F599} + Library + Properties + PhasmodHandler + PhasmodHandler + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\AntiCheat.dll + + + False + E:\SteamLibrary\steamapps\common\Phasmophobia - Copy\Phasmophobia_Data\Managed\Assembly-CSharp.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Boo.Lang.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Boo.Lang.Compiler.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Boo.Lang.Extensions.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Boo.Lang.Parser.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Boo.Lang.PatternMatching.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Boo.Lang.Useful.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\com.unity.multiplayer-hlapi.Runtime.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Commons.Xml.Relaxng.dll + + + False + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\cscompmgd.dll + + + + packages\DiscordRichPresence.1.0.150\lib\net35\DiscordRPC.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\I18N.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\I18N.CJK.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\I18N.MidEast.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\I18N.Other.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\I18N.Rare.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\I18N.West.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\IBM.Data.DB2.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Iced.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\ICSharpCode.SharpZipLib.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Il2CppMono.Security.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Il2Cppmscorlib.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Il2CppSystem.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Il2CppSystem.Configuration.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Il2CppSystem.Core.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Il2CppSystem.Diagnostics.StackTrace.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Il2CppSystem.Globalization.Extensions.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Il2CppSystem.IO.Compression.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Il2CppSystem.Xml.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\MelonLoader.ModHandler.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\MeshExtension.dll + + + packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Photon3Unity3D.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\PhotonChat.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\PhotonRealtime.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\PhotonUnityNetworking.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\PhotonUnityNetworking.Utilities.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\PhotonVoice.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\PhotonVoice.API.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\PhotonVoice.PUN.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\PhotonWebSocket.dll + + + + + + + + + + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnhollowerBaseLib.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnhollowerRuntimeLib.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Unity.Analytics.DataPrivacy.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Unity.InputSystem.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Unity.InputSystem.RebindingUI.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\Unity.Postprocessing.Runtime.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.AIModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.AndroidJNIModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.AnimationModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.AssetBundleModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.AudioModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.ClothModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.CoreModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.DirectorModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.GridModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.Il2CppAssetBundleManager.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.ImageConversionModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.IMGUIModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.InputLegacyModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.InputModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.JSONSerializeModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.ParticleSystemModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.Physics2DModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.PhysicsModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.SharedInternalsModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.SubsystemsModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.TerrainModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.TerrainPhysicsModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.TextRenderingModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.TilemapModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.UI.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.UIElementsModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.UIModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.UNETModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.UnityAnalyticsModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.UnityWebRequestModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.VFXModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.VideoModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.VRModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.WindModule.dll + + + E:\SteamLibrary\steamapps\common\Phasmophobia\PhasmodLoader\Managed\UnityEngine.XRModule.dll + + + + + + + + + + + + + \ No newline at end of file diff --git a/PhasmodHandler.sln b/PhasmodHandler.sln new file mode 100644 index 0000000..06b7810 --- /dev/null +++ b/PhasmodHandler.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30517.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhasmodHandler", "PhasmodHandler.csproj", "{D18A3585-0909-41F0-9576-A2CF6766F599}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D18A3585-0909-41F0-9576-A2CF6766F599}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D18A3585-0909-41F0-9576-A2CF6766F599}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D18A3585-0909-41F0-9576-A2CF6766F599}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D18A3585-0909-41F0-9576-A2CF6766F599}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {425E68C2-41EE-4A8E-9A1D-25AA941E4CDD} + EndGlobalSection +EndGlobal diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f8d9ce1 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +using System.Reflection; +using MelonLoader; + +[assembly: AssemblyTitle(Mod.BuildInfo.Description)] +[assembly: AssemblyDescription(Mod.BuildInfo.Description)] +[assembly: AssemblyCompany(Mod.BuildInfo.Company)] +[assembly: AssemblyProduct(Mod.BuildInfo.Name)] +[assembly: AssemblyCopyright("Created by " + Mod.BuildInfo.Author)] +[assembly: AssemblyTrademark(Mod.BuildInfo.Company)] +[assembly: AssemblyVersion(Mod.BuildInfo.Version)] +[assembly: AssemblyFileVersion(Mod.BuildInfo.Version)] +[assembly: MelonInfo(typeof(Mod.Mod), Mod.BuildInfo.Name, Mod.BuildInfo.Version, Mod.BuildInfo.Author, Mod.BuildInfo.DownloadLink)] + + +// Create and Setup a MelonGame to mark a Mod as Universal or Compatible with specific Games. +// If no MelonGameAttribute is found or any of the Values for any MelonGame on the Mod is null or empty it will be assumed the Mod is Universal. +// Values for MelonMame can be found in the Game's app.info file or printed at the top of every log directly beneath the Unity version. +[assembly: MelonGame("Kinetic Games", "Phasmophobia")] \ No newline at end of file diff --git a/main.cs b/main.cs new file mode 100644 index 0000000..8ea1c6b --- /dev/null +++ b/main.cs @@ -0,0 +1,165 @@ +using System; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Text; +using System.Runtime.InteropServices; +using MelonLoader; +using DiscordRichPresense; +using Harmony; +using UnityEngine.UI; +using UnityEngine; + +namespace Mod +{ + public static class BuildInfo + { + public const string Name = "PhasmodHandler"; // Name of the Mod. (MUST BE SET) + public const string Description = "Mod for handling specific Phasmophobia mods"; // Description for the Mod. (Set as null if none) + public const string Author = "seppdroid"; // Author of the Mod. (Set as null if none) + public const string Company = null; // Company that made the Mod. (Set as null if none) + public const string Version = "1.0.3"; // Version of the Mod. (MUST BE SET) + public const string DownloadLink = null; // Download Link for the Mod. (Set as null if none) + } + + public class Mod : MelonMod + { + private const string DiscordAppID = "767737509656002601"; + public static readonly DiscordRpc.RichPresence Presence = new DiscordRpc.RichPresence(); + + public override void OnApplicationStart() // Runs after Game Initialization. + { + var handlers = new DiscordRpc.EventHandlers(); + DiscordRpc.Initialize(DiscordAppID, ref handlers, false, string.Empty); + Presence.state = "Starting game..."; + Presence.details = "Playing PhasMODphobia"; + Presence.startTimestamp = default(long); + Presence.largeImageKey = "phasmod"; + Presence.largeImageText = "Phasmodphobia"; + Presence.smallImageKey = "phasmod"; + Presence.smallImageText = "phasmomod"; + DiscordRpc.UpdatePresence(Presence); + + MelonLogger.Log("[log] Phasmophobia Mod Handler has started"); + } + + public override void OnLevelIsLoading() // Runs when a Scene is Loading or when a Loading Screen is Shown. Currently only runs if the Mod is used in BONEWORKS. + { + MelonLogger.Log("[log] Loading level"); + } + + public override void OnLevelWasLoaded(int level) // Runs when a Scene has Loaded. + { + if (level == 1) + { + Presence.state = "In Main Menu Lobby"; + Presence.details = "Playing PhasMODphobia"; + Presence.largeImageKey = "lobby"; + Presence.largeImageText = "Phasmodphobia"; + Presence.smallImageKey = "phasmod"; + Presence.smallImageText = "phasmomod"; + DiscordRpc.UpdatePresence(Presence); + MelonLogger.Log("[log] RPC Status changed"); + + } + if (level == 2) + { + Presence.state = "In Tanglewood Street"; + Presence.details = "Playing PhasMODphobia"; + Presence.largeImageKey = "tanglewood"; + Presence.largeImageText = "Tanglewood Street House"; + Presence.smallImageKey = "phasmod"; + Presence.smallImageText = "phasmomod"; + DiscordRpc.UpdatePresence(Presence); + MelonLogger.Log("[log] RPC Status changed"); + } + if (level == 3) + { + Presence.state = "In Asylum"; + Presence.details = "Playing PhasMODphobia"; + Presence.largeImageKey = "asylum"; + Presence.largeImageText = "Asylum"; + Presence.smallImageKey = "phasmod"; + Presence.smallImageText = "phasmomod"; + DiscordRpc.UpdatePresence(Presence); + MelonLogger.Log("[log] RPC Status changed"); + } + if (level == 4) + { + Presence.state = "In Edgefield Street House"; + Presence.details = "Playing PhasMODphobia"; + Presence.largeImageKey = "streethouse"; + Presence.largeImageText = "Edgefield Street House"; + Presence.smallImageKey = "phasmod"; + Presence.smallImageText = "phasmomod"; + DiscordRpc.UpdatePresence(Presence); + MelonLogger.Log("[log] RPC Status changed"); + } + if (level == 5) + { + Presence.state = "In Ridgefield Road House"; + Presence.details = "Playing PhasMODphobia"; + Presence.largeImageKey = "ridgefield"; + Presence.largeImageText = "Ridgefield Road House"; + Presence.smallImageKey = "phasmod"; + Presence.smallImageText = "phasmomod"; + DiscordRpc.UpdatePresence(Presence); + MelonLogger.Log("[log] RPC Status changed"); + } + if (level == 6) + { + Presence.state = "In Brownstone Highschool"; + Presence.details = "Playing PhasMODphobia"; + Presence.largeImageKey = "brownstone"; + Presence.largeImageText = "Brownstone Highschool"; + Presence.smallImageKey = "phasmod"; + Presence.smallImageText = "phasmomod"; + DiscordRpc.UpdatePresence(Presence); + MelonLogger.Log("[log] RPC Status changed"); + } + if (level == 7) + { + Presence.state = "In Bleasdale Farmhouse"; + Presence.details = "Playing PhasMODphobia"; + Presence.largeImageKey = "bleasdale"; + Presence.largeImageText = "Bleasdale Farmhouse"; + Presence.smallImageKey = "phasmod"; + Presence.smallImageText = "phasmomod"; + DiscordRpc.UpdatePresence(Presence); + MelonLogger.Log("[log] RPC Status changed"); + } + if (level == 8) + { + Presence.state = "In Grafton Farmhouse"; + Presence.details = "Playing PhasMODphobia"; + Presence.largeImageKey = "grafton"; + Presence.largeImageText = "Grafton Farmhouse"; + Presence.smallImageKey = "phasmod"; + Presence.smallImageText = "phasmomod"; + DiscordRpc.UpdatePresence(Presence); + MelonLogger.Log("[log] RPC Status changed"); + } + // else and set an undefined level so you wont be in the main lobby if you play a map above 8? + + MelonLogger.Log("[log] loadedlevel: " + level.ToString()); + } + + public override void OnLevelWasInitialized(int level) // Runs when a Scene has Initialized. + { + MelonLogger.Log("[log] initlevel: " + level.ToString()); + + } + public override void OnUpdate() + { + DiscordRpc.RunCallbacks(); // for if we are going to handle invites... + } + + + + public override void OnApplicationQuit() // Runs when the Game is told to Close. + { + DiscordRpc.Shutdown(); + MelonLogger.Log("[log] Phasmophobia closed"); + } + } +} \ No newline at end of file diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..2f2eb90 --- /dev/null +++ b/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/patch.cs b/patch.cs new file mode 100644 index 0000000..7a270d7 --- /dev/null +++ b/patch.cs @@ -0,0 +1,16 @@ +using System; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Text; +using System.Runtime.InteropServices; +using MelonLoader; +using Harmony; +using UnityEngine.UI; +using UnityEngine; + +namespace PhasmodHandler +{ + // removed all this crap. + +}