diff --git a/BoneSync.sln b/BoneSync.sln new file mode 100644 index 0000000..41c0a72 --- /dev/null +++ b/BoneSync.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34616.47 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoneSync", "BoneSync\BoneSync.csproj", "{C33921DC-5778-4EEC-A2D0-E0AE522CC701}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C33921DC-5778-4EEC-A2D0-E0AE522CC701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C33921DC-5778-4EEC-A2D0-E0AE522CC701}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C33921DC-5778-4EEC-A2D0-E0AE522CC701}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C33921DC-5778-4EEC-A2D0-E0AE522CC701}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1DEC2C55-48C4-4AD3-A203-AE46BDB62FF3} + EndGlobalSection +EndGlobal diff --git a/BoneSync/BoneSync.csproj b/BoneSync/BoneSync.csproj new file mode 100644 index 0000000..fc83336 --- /dev/null +++ b/BoneSync/BoneSync.csproj @@ -0,0 +1,61 @@ + + + + + Debug + AnyCPU + {C33921DC-5778-4EEC-A2D0-E0AE522CC701} + Library + Properties + BoneSync + BoneSync + v4.7.2 + 512 + true + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + ..\..\..\..\AppData\Roaming\r2modmanPlus-local\BONEWORKS\profiles\aaaa\MelonLoader\MelonLoader.dll + + + + + + + + + + + + + + + + + + + + + COPY "$(TargetPath)" "C:\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\Mods" + + \ No newline at end of file diff --git a/BoneSync/MelonLoaderMod.cs b/BoneSync/MelonLoaderMod.cs new file mode 100644 index 0000000..ae34664 --- /dev/null +++ b/BoneSync/MelonLoaderMod.cs @@ -0,0 +1,66 @@ +using MelonLoader; + +namespace BoneSync +{ + public static class BuildInfo + { + public const string Name = "BoneSync"; // Name of the Mod. (MUST BE SET) + public const string Author = null; // 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.0"; // Version of the Mod. (MUST BE SET) + public const string DownloadLink = null; // Download Link for the Mod. (Set as null if none) + } + + public class BoneSync : MelonMod + { + public override void OnApplicationStart() + { + MelonLogger.Msg("OnApplicationStart"); + } + + public override void OnSceneWasLoaded(int buildIndex, string sceneName) + { + MelonLogger.Msg("OnLevelWasLoaded: " + sceneName); + } + + public override void OnSceneWasInitialized(int buildIndex, string sceneName) + { + MelonLogger.Msg("OnLevelWasInitialized: " + sceneName); + } + + public override void OnSceneWasUnloaded(int buildIndex, string sceneName) + { + MelonLogger.Msg("OnLevelWasLoaded: " + sceneName); + } + + public override void OnUpdate() + { + MelonLogger.Msg("OnUpdate"); + } + + public override void OnFixedUpdate() + { + MelonLogger.Msg("OnFixedUpdate"); + } + + public override void OnLateUpdate() + { + MelonLogger.Msg("OnLateUpdate"); + } + + public override void OnGUI() + { + MelonLogger.Msg("OnGUI"); + } + + public override void OnApplicationQuit() + { + MelonLogger.Msg("OnApplicationQuit"); + } + + public override void OnPreferencesLoaded() + { + MelonLogger.Msg("OnPreferencesLoaded"); + } + } +} diff --git a/BoneSync/Networking/ByteEncoder.cs b/BoneSync/Networking/ByteEncoder.cs new file mode 100644 index 0000000..da5bcd5 --- /dev/null +++ b/BoneSync/Networking/ByteEncoder.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BoneSync.Networking +{ + internal class ByteEncoder + { + public List Data; + public ByteEncoder() + { + Data = new List(); + } + + public ByteEncoder(byte[] data) + { + Data = data.ToList(); + } + + public byte[] ToArray() + { + return Data.ToArray(); + } + + public void WriteByte(byte value) + { + Data.Add(value); + } + + public void WriteBytes(byte[] value) + { + Data.AddRange(value); + } + public byte[] ReadBytes(int count) + { + byte[] value = Data.GetRange(0, count).ToArray(); + Data.RemoveRange(0, count); + return value; + } + + public byte ReadByte() + { + byte value = Data[0]; + Data.RemoveAt(0); + return value; + } + + public void WriteInt(int value) + { + WriteBytes(BitConverter.GetBytes(value)); + } + + public int ReadInt() + { + return BitConverter.ToInt32(ReadBytes(sizeof(int)), 0); + } + + public void WriteLong(long value) + { + WriteBytes(BitConverter.GetBytes(value)); + } + + public long ReadLong() + { + return BitConverter.ToInt64(ReadBytes(sizeof(long)), 0); + } + + public void WriteFloat(float value) + { + WriteBytes(BitConverter.GetBytes(value)); + } + + public float ReadFloat() + { + return BitConverter.ToSingle(ReadBytes(sizeof(float)), 0); + } + + public void WriteDouble(double value) + { + WriteBytes(BitConverter.GetBytes(value)); + } + + public double ReadDouble() + { + return BitConverter.ToDouble(ReadBytes(sizeof(double)), 0); + } + + public void WriteString(string value) + { + byte[] bytes = Encoding.UTF8.GetBytes(value); + WriteInt(bytes.Length); + WriteBytes(bytes); + } + + public string ReadString() + { + int length = ReadInt(); + return Encoding.UTF8.GetString(ReadBytes(length)); + } + + } +} diff --git a/BoneSync/Networking/PacketBase.cs b/BoneSync/Networking/PacketBase.cs new file mode 100644 index 0000000..fc9c26f --- /dev/null +++ b/BoneSync/Networking/PacketBase.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace BoneSync.Networking +{ + public enum PacketType + { + LobbyInfo = 0, + } + internal struct PacketInfo + { + public int id; + public int senderId; + public int receiverId; + public PacketType packetType; + + public PacketInfo(int id, int senderId, int receiverId, PacketType packetType) + { + this.id = id; + this.senderId = senderId; + this.receiverId = receiverId; + this.packetType = packetType; + } + } + internal abstract class PacketBase + { + + public PacketInfo Info; + public ByteEncoder Encoder; + + public void OnReceive(byte[] bytes) + { + + } + + + private void ParseInfo() + { + Info = new PacketInfo(); + Info.id = Encoder.ReadInt(); + Info.senderId = Encoder.ReadInt(); + Info.receiverId = Encoder.ReadInt(); + Info.packetType = (PacketType)Encoder.ReadInt(); + } + + private void WriteInfo() + { + Encoder.WriteInt(Info.id); + Encoder.WriteInt(Info.senderId); + Encoder.WriteInt(Info.receiverId); + Encoder.WriteInt((int)Info.packetType); + } + + internal abstract void ParseData(); + internal abstract void WriteData(); + } +} diff --git a/BoneSync/Properties/AssemblyInfo.cs b/BoneSync/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e957f12 --- /dev/null +++ b/BoneSync/Properties/AssemblyInfo.cs @@ -0,0 +1,25 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; +using MelonLoader; + +[assembly: AssemblyTitle(BoneSync.BuildInfo.Name)] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany(BoneSync.BuildInfo.Company)] +[assembly: AssemblyProduct(BoneSync.BuildInfo.Name)] +[assembly: AssemblyCopyright("Created by " + BoneSync.BuildInfo.Author)] +[assembly: AssemblyTrademark(BoneSync.BuildInfo.Company)] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +//[assembly: Guid("")] +[assembly: AssemblyVersion(BoneSync.BuildInfo.Version)] +[assembly: AssemblyFileVersion(BoneSync.BuildInfo.Version)] +[assembly: NeutralResourcesLanguage("en")] +[assembly: MelonInfo(typeof(BoneSync.BoneSync), BoneSync.BuildInfo.Name, BoneSync.BuildInfo.Version, BoneSync.BuildInfo.Author, BoneSync.BuildInfo.DownloadLink)] + + +// Create and Setup a MelonModGame to mark a Mod as Universal or Compatible with specific Games. +// If no MelonModGameAttribute is found or any of the Values for any MelonModGame on the Mod is null or empty it will be assumed the Mod is Universal. +// Values for MelonModGame 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(null, null)] \ No newline at end of file