Add project files.

This commit is contained in:
Aaro Varis
2025-02-23 18:20:22 +02:00
parent 99796079b2
commit e28c3a4d44
6 changed files with 341 additions and 0 deletions

25
BoneSync.sln Normal file
View File

@@ -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

61
BoneSync/BoneSync.csproj Normal file
View File

@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C33921DC-5778-4EEC-A2D0-E0AE522CC701}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BoneSync</RootNamespace>
<AssemblyName>BoneSync</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="MelonLoader">
<HintPath>..\..\..\..\AppData\Roaming\r2modmanPlus-local\BONEWORKS\profiles\aaaa\MelonLoader\MelonLoader.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MelonLoaderMod.cs" />
<Compile Include="Networking\PacketBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Networking\ByteEncoder.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Networking\Packets\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>COPY "$(TargetPath)" "C:\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\Mods"</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@@ -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");
}
}
}

View File

@@ -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<byte> Data;
public ByteEncoder()
{
Data = new List<byte>();
}
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));
}
}
}

View File

@@ -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();
}
}

View File

@@ -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)]