Compare commits

...

87 Commits

Author SHA1 Message Date
6d3f9f8afb packet parsing optimisations 2026-02-17 16:35:20 +02:00
1fa8516ebe byte encoder 2026-02-17 15:33:20 +02:00
3dbe62a64d more sync fixes 2026-02-17 15:31:23 +02:00
Aaro Varis
6d7f9aa8c0 Optimize ByteEncoder.cs 2026-02-17 14:37:29 +02:00
671d8e4ad6 Rename isBlacklistedPool to IsBlacklistedPool; simplify transform check
Renamed PoolBlacklist.isBlacklistedPool to IsBlacklistedPool for C# naming consistency and updated all references. Simplified InPoolManagerTransform to check root object's name instead of path for improved reliability.
2026-01-13 17:43:23 +02:00
335df69fcd Refactor event patching and transport systems
- Convert TransportBase from abstract class to interface; replace BORADCAST_ID constant with BROADCAST_ID property in transport implementations.
- Update SteamTransport to implement the new interface and provide its own BROADCAST_ID.
- Refactor event patching: introduce UnityEventPatching to map proxy events to originals, and update UnityEventPatch<T> to use proxy events for patching.
- Ensure patched UnityEvents replace originals in SyncablePhysics, so all invocations go through patch logic.
- Improve robustness and maintainability of both networking and event patching systems.
2026-01-13 17:34:02 +02:00
54ec8da1fe invalid optimization test 2025-10-19 21:38:22 +03:00
f6f484549a idk whar i did 2025-07-24 00:25:01 +03:00
5f148bc86f update sync coroutine, holsters broken 2025-03-30 23:39:16 +03:00
b72add4e81 adjust sync 2025-03-30 15:45:22 +03:00
b9390bbf03 patch changes 2025-03-28 22:30:09 +02:00
f5ad619ed5 adjust how syncable cache works 2025-03-24 17:34:48 +02:00
Aaro Varis
8edfcff56f updated variable name 2025-03-24 17:29:41 +02:00
Aaro Varis
e29f0ebb70 maybe fixed static buttons 2025-03-24 17:27:46 +02:00
Aaro Varis
77a6101e08 playerscript changes 2025-03-24 13:03:13 +02:00
Aaro Varis
9a468564e8 mogging 2025-03-23 23:54:44 +02:00
Aaro Varis
b004b725f0 changes 2025-03-23 20:46:20 +02:00
Aaro Varis
ff52da9542 fix the broken :D 2025-03-23 20:19:39 +02:00
Aaro Varis
3d879a605d !BROKEN!!! 2025-03-23 19:59:59 +02:00
Aaro Varis
143505f762 debug log statements 2025-03-23 00:22:16 +02:00
21e44cc4c7 Pool patch stuff 2025-03-18 20:18:34 +02:00
ba6d71a2ec testing despawn patch 2025-03-17 16:55:01 +02:00
f06af0647d fix fix 2025-03-17 16:37:26 +02:00
253f29f5be fix button method patch 2025-03-17 16:37:09 +02:00
Aaro Varis
64b2005beb mm 2025-03-16 14:31:11 +02:00
Aaro Varis
922c33d4a1 Simple event queue for better experience 2025-03-16 13:25:25 +02:00
Aaro Varis
2f27e39610 disable some zone patches 2025-03-14 23:36:19 +02:00
Aaro Varis
104c52c183 Aaa 2025-03-14 21:30:03 +02:00
95cd554eb0 add oneshot event patch 2025-03-14 14:21:12 +02:00
f1f8f1cbcf scenemanager sync 2025-03-13 20:46:57 +02:00
1843410a4d local only trigger 2025-03-13 20:15:58 +02:00
3f359ed4ec logging fixes 2025-03-13 20:07:19 +02:00
632230b8b2 Button event sync and custom logger stuff 2025-03-13 20:02:38 +02:00
756deee097 tried to create a universal unity event hook 2025-03-12 18:35:16 +02:00
Aaro Varis
a7769147e3 build script stuff 2025-03-10 18:14:29 +02:00
Aaro Varis
3238fb7acf fuck 2025-03-10 18:03:13 +02:00
Aaro Varis
92ab39ed69 probs broke everything 2025-03-10 18:01:18 +02:00
Aaro Varis
f27e325526 . 2025-03-10 03:58:08 +02:00
Aaro Varis
a7dc4441a7 a 2025-03-10 03:51:36 +02:00
Aaro Varis
68aa949591 changed some zone patch stuff 2025-03-10 03:44:33 +02:00
Aaro Varis
a479fa8dd6 adjust plugsync reliability 2025-03-10 01:55:20 +02:00
Aaro Varis
52f3d57721 enable periodic plug sync 2025-03-10 01:54:50 +02:00
Aaro Varis
00f0a33a47 Fix stuff? 2025-03-10 01:54:27 +02:00
Aaro Varis
f9db5be09b zone patches 2025-03-09 23:15:51 +02:00
Aaro Varis
3b0c26a687 Packet catchup and scene indexes in packets 2025-03-09 22:32:47 +02:00
Aaro Varis
20a624fb0f AI Sync initial changes 2025-03-09 21:42:39 +02:00
Aaro Varis
adbd7f4704 mogus 2025-03-09 01:16:27 +02:00
Aaro Varis
eb66d0b089 remove the most spammy debug logs 2025-03-09 01:15:18 +02:00
Aaro Varis
a892e80068 more player sync stuff 2025-03-09 01:09:04 +02:00
Aaro Varis
7bc1b21098 Player sync styff 2025-03-08 22:36:48 +02:00
Aaro Varis
252f6ba49a Player Sync stuff 2025-03-08 17:45:29 +02:00
Aaro Varis
c0e912be87 more gun sync stuff 2025-03-08 00:16:26 +02:00
Aaro Varis
0030f68f99 Mag and gun sync fixes 2025-03-07 23:07:39 +02:00
Aaro Varis
28715ef80d holster sync fixes and gun sync fixes 2025-03-07 18:58:39 +02:00
54301cbf37 aaaaaa 2025-03-07 16:42:45 +02:00
84e3efe3e9 aaaa 2025-03-06 21:05:42 +02:00
2c8f1af97d sync fixes 2025-03-06 21:02:00 +02:00
44776c3499 Mag sync epicly working 2025-03-06 20:33:22 +02:00
5f0b1d40fb aaaaaa 2025-03-06 18:39:55 +02:00
2004f9cd0d Work on mag sync, broken af atm 2025-03-05 21:08:10 +02:00
4bd96e59bd PlugSync stuff 2025-03-05 15:35:18 +02:00
8c887ae0e4 Stuff Patches 2025-03-04 21:01:46 +02:00
03127bd810 Zone patches 2025-03-04 18:50:41 +02:00
7ab5f9779b AAAAAA 2025-03-04 15:09:34 +02:00
7b5b4b2744 aaaa 2025-03-03 21:01:50 +02:00
bc10f6b1b7 aaaaaaaa 2025-03-03 20:57:12 +02:00
e2e91ce513 update build event 2025-03-03 20:11:33 +02:00
51d7d81605 aaaaa 2025-03-03 20:10:39 +02:00
6402afc72b pool changes 2025-03-03 16:23:40 +02:00
Aaro Varis
c11256f9a1 aaa 2025-03-02 18:15:49 +02:00
Aaro Varis
9295ba43e3 Mogus 2025-03-02 18:12:35 +02:00
Aaro Varis
b7bd646520 loottable patches 2025-03-02 17:55:18 +02:00
Aaro Varis
7f266321db more sync stuff 2025-03-02 17:35:20 +02:00
Aaro Varis
fc744fd1ab network stuff 2025-03-02 11:45:15 +02:00
Aaro Varis
055ee44da5 Untested discard message 2025-03-02 01:42:55 +02:00
Aaro Varis
b485ab3259 Client spawning fix 2025-03-02 01:30:39 +02:00
Aaro Varis
76062e026e Ownership transfer and shit, and some pool stuff 2025-03-01 23:05:46 +02:00
Aaro Varis
061e7e6d8d Bunch of changes 2025-03-01 00:15:23 +02:00
d0eb7f89be Bunch more networking stuff 2025-02-28 14:35:14 +02:00
1dce1960f6 More Networking stuff 2025-02-28 12:20:55 +02:00
ff70bad234 Mogus 2025-02-28 11:13:16 +02:00
ee1b827c91 Basic object sync 2025-02-27 21:16:52 +02:00
43f6710697 progress 2025-02-27 16:26:04 +02:00
b721e2d25e I dont know what i am doing 2025-02-26 13:53:46 +02:00
c1c879c80c ll 2025-02-25 20:58:30 +02:00
b16c90f4e2 Stuff 2025-02-25 13:09:38 +02:00
da196057e5 update project 2025-02-25 13:09:03 +02:00
219 changed files with 6059 additions and 545 deletions

13
.idea/.idea.BoneSync/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/.idea.BoneSync.iml
/projectSettingsUpdater.xml
/modules.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

6
.idea/.idea.BoneSync/.idea/vcs.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@@ -5,8 +5,6 @@ VisualStudioVersion = 17.9.34616.47
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoneSync", "BoneSync\BoneSync.csproj", "{C33921DC-5778-4EEC-A2D0-E0AE522CC701}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoneSync", "BoneSync\BoneSync.csproj", "{C33921DC-5778-4EEC-A2D0-E0AE522CC701}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Facepunch.Steamworks.Win64", "Facepunch.Steamworks\Facepunch.Steamworks.Win64.csproj", "{FBEAD21F-E45E-4EC5-86A3-1FA6089E140D}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -17,10 +15,6 @@ Global
{C33921DC-5778-4EEC-A2D0-E0AE522CC701}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
{C33921DC-5778-4EEC-A2D0-E0AE522CC701}.Release|Any CPU.Build.0 = Release|Any CPU {C33921DC-5778-4EEC-A2D0-E0AE522CC701}.Release|Any CPU.Build.0 = Release|Any CPU
{FBEAD21F-E45E-4EC5-86A3-1FA6089E140D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FBEAD21F-E45E-4EC5-86A3-1FA6089E140D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FBEAD21F-E45E-4EC5-86A3-1FA6089E140D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FBEAD21F-E45E-4EC5-86A3-1FA6089E140D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.runner.visualstudio.3.0.2\build\net472\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.3.0.2\build\net472\xunit.runner.visualstudio.props')" />
<Import Project="..\packages\xunit.core.2.9.3\build\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.9.3\build\xunit.core.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -27,6 +25,7 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
@@ -36,43 +35,29 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit> <Prefer32Bit>false</Prefer32Bit>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="MelonLoader"> <Reference Include="0Harmony, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stationeers\MelonLoader\MelonLoader.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<Private>False</Private> <HintPath>A:\SteamLibrary\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\0Harmony.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Assembly-CSharp">
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll</HintPath> <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="Microsoft.TestPlatform.PlatformAbstractions, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="Il2Cppmscorlib">
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll</HintPath> <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\Il2Cppmscorlib.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> <Reference Include="MelonLoader, Version=0.5.4.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<Private>False</Private> <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\MelonLoader.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.3.8.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.3.8.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Runtime" /> <Reference Include="System.Runtime" />
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@@ -80,64 +65,258 @@
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> <Reference Include="UnhollowerBaseLib">
<SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnhollowerBaseLib.dll</HintPath>
<HintPath>..\..\..\..\.nuget\packages\xunit.abstractions\2.0.3\lib\net35\xunit.abstractions.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="xunit.assert, Version=2.9.3.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> <Reference Include="UnityEngine">
<SpecificVersion>False</SpecificVersion> <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnityEngine.dll</HintPath>
<HintPath>..\..\..\..\.nuget\packages\xunit.assert\2.9.3\lib\netstandard1.1\xunit.assert.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="xunit.core, Version=2.9.3.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> <Reference Include="UnityEngine.AnimationModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\.nuget\packages\xunit.extensibility.core\2.9.3\lib\net452\xunit.core.dll</HintPath> <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnityEngine.AnimationModule.dll</HintPath>
<Private>False</Private>
</Reference> </Reference>
<Reference Include="xunit.execution.desktop, Version=2.9.3.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> <Reference Include="UnityEngine.AssetBundleModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\.nuget\packages\xunit.extensibility.execution\2.9.3\lib\net452\xunit.execution.desktop.dll</HintPath> <HintPath>A:\SteamLibrary\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnityEngine.AssetBundleModule.dll</HintPath>
<Private>False</Private> </Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.PhysicsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnityEngine.PhysicsModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.TextRenderingModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnityEngine.TextRenderingModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnityEngine.UI.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIElementsModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnityEngine.UIElementsModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UIModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\MelonLoader\Managed\UnityEngine.UIModule.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Data\ByteEncoder.cs" />
<Compile Include="Data\Debugger.cs" />
<Compile Include="Data\EmebeddedAssetBundle.cs" />
<Compile Include="Data\PlayerScripts.cs" />
<Compile Include="Data\SpawnableManager.cs" />
<Compile Include="Data\Structs.cs" />
<Compile Include="Networking\Messages\AISyncMessage.cs" />
<Compile Include="Networking\Messages\DiscardSyncableMessage.cs" />
<Compile Include="Networking\Messages\GunSyncMessage.cs" />
<Compile Include="Networking\Messages\SceneChangeMessage.cs" />
<Compile Include="Patching\AIHealthPatches.cs" />
<Compile Include="Patching\ButtonTogglePatches.cs" />
<Compile Include="Patching\CartPatches.cs" />
<Compile Include="Patching\HolsterSlotPatches.cs" />
<Compile Include="Networking\Messages\MagazineSyncMessage.cs" />
<Compile Include="Networking\Messages\ObjectDamageMessage.cs" />
<Compile Include="Networking\Messages\ObjectSyncMessage.cs" />
<Compile Include="Networking\Messages\OwnershipTransferMessage.cs" />
<Compile Include="Networking\Messages\PlugSyncMessage.cs" />
<Compile Include="Networking\Messages\RegisterSyncableMessage.cs" />
<Compile Include="Networking\Messages\SimpleSyncableEventMessage.cs" />
<Compile Include="Patching\CallPatchedMethod.cs" />
<Compile Include="Patching\DebugPatches.cs" />
<Compile Include="Patching\GripPatches.cs" />
<Compile Include="Patching\GunPatches.cs" />
<Compile Include="Patching\InteractableHostPatches.cs" />
<Compile Include="Patching\ObjectHealthPatches.cs" />
<Compile Include="Patching\PlugPatches.cs" />
<Compile Include="Patching\PrefabSpawnerPatches.cs" />
<Compile Include="Patching\SceneManagerPatches.cs" />
<Compile Include="Patching\SkeletonHandPatches.cs" />
<Compile Include="Patching\UnityEventPatching.cs" />
<Compile Include="Patching\ZonePatches.cs" />
<Compile Include="Sync\Components\SyncableAI.cs" />
<Compile Include="Sync\Components\SyncableBase.cs" />
<Compile Include="Sync\Components\SyncableDamage.cs" />
<Compile Include="Sync\Components\SyncableNetworking.cs" />
<Compile Include="Sync\Components\SyncablePhysics.cs" />
<Compile Include="Sync\Components\SyncablePlugs.cs" />
<Compile Include="Sync\Components\SyncableProperties.cs" />
<Compile Include="Sync\ObjectSync.cs" />
<Compile Include="Sync\ObjectSyncCache.cs" />
<Compile Include="Facepunch.Steamworks\Callbacks\CallResult.cs" />
<Compile Include="Facepunch.Steamworks\Callbacks\ICallbackData.cs" />
<Compile Include="Facepunch.Steamworks\Classes\AuthTicket.cs" />
<Compile Include="Facepunch.Steamworks\Classes\Dispatch.cs" />
<Compile Include="Facepunch.Steamworks\Classes\SteamApi.cs" />
<Compile Include="Facepunch.Steamworks\Classes\SteamGameServer.cs" />
<Compile Include="Facepunch.Steamworks\Classes\SteamInternal.cs" />
<Compile Include="Facepunch.Steamworks\Enum\LeaderboardDisplay.cs" />
<Compile Include="Facepunch.Steamworks\Enum\LeaderboardSort.cs" />
<Compile Include="Facepunch.Steamworks\Enum\SendType.cs" />
<Compile Include="Facepunch.Steamworks\Generated\CustomEnums.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamAppList.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamApps.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamClient.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamController.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamFriends.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamGameSearch.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamGameServer.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamGameServerStats.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamHTMLSurface.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamHTTP.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamInput.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamInventory.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamMatchmaking.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamMatchmakingPingResponse.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamMatchmakingPlayersResponse.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamMatchmakingRulesResponse.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamMatchmakingServerListResponse.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamMatchmakingServers.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamMusic.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamMusicRemote.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamNetworking.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamNetworkingConnectionCustomSignaling.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamNetworkingCustomSignalingRecvContext.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamNetworkingSockets.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamNetworkingUtils.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamParentalSettings.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamParties.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamRemotePlay.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamRemoteStorage.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamScreenshots.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamTV.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamUGC.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamUser.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamUserStats.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamUtils.cs" />
<Compile Include="Facepunch.Steamworks\Generated\Interfaces\ISteamVideo.cs" />
<Compile Include="Facepunch.Steamworks\Generated\SteamCallbacks.cs" />
<Compile Include="Facepunch.Steamworks\Generated\SteamConstants.cs" />
<Compile Include="Facepunch.Steamworks\Generated\SteamEnums.cs" />
<Compile Include="Facepunch.Steamworks\Generated\SteamStructFunctions.cs" />
<Compile Include="Facepunch.Steamworks\Generated\SteamStructs.cs" />
<Compile Include="Facepunch.Steamworks\Generated\SteamTypes.cs" />
<Compile Include="Facepunch.Steamworks\Networking\Connection.cs" />
<Compile Include="Facepunch.Steamworks\Networking\ConnectionInfo.cs" />
<Compile Include="Facepunch.Steamworks\Networking\ConnectionManager.cs" />
<Compile Include="Facepunch.Steamworks\Networking\IConnectionManager.cs" />
<Compile Include="Facepunch.Steamworks\Networking\ISocketManager.cs" />
<Compile Include="Facepunch.Steamworks\Networking\NetAddress.cs" />
<Compile Include="Facepunch.Steamworks\Networking\NetDebugFunc.cs" />
<Compile Include="Facepunch.Steamworks\Networking\NetErrorMessage.cs" />
<Compile Include="Facepunch.Steamworks\Networking\NetIdentity.cs" />
<Compile Include="Facepunch.Steamworks\Networking\NetKeyValue.cs" />
<Compile Include="Facepunch.Steamworks\Networking\NetMsg.cs" />
<Compile Include="Facepunch.Steamworks\Networking\NetPingLocation.cs" />
<Compile Include="Facepunch.Steamworks\Networking\Socket.cs" />
<Compile Include="Facepunch.Steamworks\Networking\SocketManager.cs" />
<Compile Include="Facepunch.Steamworks\Networking\SteamDatagramRelayAuthTicket.cs" />
<Compile Include="Facepunch.Steamworks\ServerList\Base.cs" />
<Compile Include="Facepunch.Steamworks\ServerList\Favourites.cs" />
<Compile Include="Facepunch.Steamworks\ServerList\Friends.cs" />
<Compile Include="Facepunch.Steamworks\ServerList\History.cs" />
<Compile Include="Facepunch.Steamworks\ServerList\Internet.cs" />
<Compile Include="Facepunch.Steamworks\ServerList\IpList.cs" />
<Compile Include="Facepunch.Steamworks\ServerList\LocalNetwork.cs" />
<Compile Include="Facepunch.Steamworks\SteamApps.cs" />
<Compile Include="Facepunch.Steamworks\SteamClient.cs" />
<Compile Include="Facepunch.Steamworks\SteamFriends.cs" />
<Compile Include="Facepunch.Steamworks\SteamInput.cs" />
<Compile Include="Facepunch.Steamworks\SteamInventory.cs" />
<Compile Include="Facepunch.Steamworks\SteamMatchmaking.cs" />
<Compile Include="Facepunch.Steamworks\SteamMatchmakingServers.cs" />
<Compile Include="Facepunch.Steamworks\SteamMusic.cs" />
<Compile Include="Facepunch.Steamworks\SteamNetworking.cs" />
<Compile Include="Facepunch.Steamworks\SteamNetworkingSockets.cs" />
<Compile Include="Facepunch.Steamworks\SteamNetworkingUtils.cs" />
<Compile Include="Facepunch.Steamworks\SteamParental.cs" />
<Compile Include="Facepunch.Steamworks\SteamParties.cs" />
<Compile Include="Facepunch.Steamworks\SteamRemotePlay.cs" />
<Compile Include="Facepunch.Steamworks\SteamRemoteStorage.cs" />
<Compile Include="Facepunch.Steamworks\SteamScreenshots.cs" />
<Compile Include="Facepunch.Steamworks\SteamServer.cs" />
<Compile Include="Facepunch.Steamworks\SteamServerStats.cs" />
<Compile Include="Facepunch.Steamworks\SteamUgc.cs" />
<Compile Include="Facepunch.Steamworks\SteamUser.cs" />
<Compile Include="Facepunch.Steamworks\SteamUserStats.cs" />
<Compile Include="Facepunch.Steamworks\SteamUtils.cs" />
<Compile Include="Facepunch.Steamworks\SteamVideo.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Achievement.cs" />
<Compile Include="Facepunch.Steamworks\Structs\AppId.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Controller.cs" />
<Compile Include="Facepunch.Steamworks\Structs\DepotId.cs" />
<Compile Include="Facepunch.Steamworks\Structs\DlcInformation.cs" />
<Compile Include="Facepunch.Steamworks\Structs\DownloadProgress.cs" />
<Compile Include="Facepunch.Steamworks\Structs\DurationControl.cs" />
<Compile Include="Facepunch.Steamworks\Structs\FileDetails.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Friend.cs" />
<Compile Include="Facepunch.Steamworks\Structs\GameId.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Image.cs" />
<Compile Include="Facepunch.Steamworks\Structs\InventoryDef.cs" />
<Compile Include="Facepunch.Steamworks\Structs\InventoryItem.cs" />
<Compile Include="Facepunch.Steamworks\Structs\InventoryPurchaseResult.cs" />
<Compile Include="Facepunch.Steamworks\Structs\InventoryRecipe.cs" />
<Compile Include="Facepunch.Steamworks\Structs\InventoryResult.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Leaderboard.cs" />
<Compile Include="Facepunch.Steamworks\Structs\LeaderboardEntry.cs" />
<Compile Include="Facepunch.Steamworks\Structs\LeaderboardUpdate.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Lobby.cs" />
<Compile Include="Facepunch.Steamworks\Structs\LobbyQuery.cs" />
<Compile Include="Facepunch.Steamworks\Structs\MatchMakingKeyValuePair.cs" />
<Compile Include="Facepunch.Steamworks\Structs\NumericalFilter.cs" />
<Compile Include="Facepunch.Steamworks\Structs\OutgoingPacket.cs" />
<Compile Include="Facepunch.Steamworks\Structs\P2Packet.cs" />
<Compile Include="Facepunch.Steamworks\Structs\PartyBeacon.cs" />
<Compile Include="Facepunch.Steamworks\Structs\RemotePlaySession.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Screenshot.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Server.cs" />
<Compile Include="Facepunch.Steamworks\Structs\ServerInit.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Stat.cs" />
<Compile Include="Facepunch.Steamworks\Structs\SteamId.cs" />
<Compile Include="Facepunch.Steamworks\Structs\SteamIpAddress.cs" />
<Compile Include="Facepunch.Steamworks\Structs\SteamParamStringArray.cs" />
<Compile Include="Facepunch.Steamworks\Structs\Ugc.cs" />
<Compile Include="Facepunch.Steamworks\Structs\UgcEditor.cs" />
<Compile Include="Facepunch.Steamworks\Structs\UgcItem.cs" />
<Compile Include="Facepunch.Steamworks\Structs\UgcQuery.cs" />
<Compile Include="Facepunch.Steamworks\Structs\UgcResultPage.cs" />
<Compile Include="Facepunch.Steamworks\Structs\UserItemVote.cs" />
<Compile Include="Facepunch.Steamworks\Utility\Epoch.cs" />
<Compile Include="Facepunch.Steamworks\Utility\Helpers.cs" />
<Compile Include="Facepunch.Steamworks\Utility\Platform.cs" />
<Compile Include="Facepunch.Steamworks\Utility\SourceServerQuery.cs" />
<Compile Include="Facepunch.Steamworks\Utility\SteamInterface.cs" />
<Compile Include="Facepunch.Steamworks\Utility\Utf8String.cs" />
<Compile Include="Facepunch.Steamworks\Utility\Utility.cs" />
<Compile Include="MelonLoaderMod.cs" /> <Compile Include="MelonLoaderMod.cs" />
<Compile Include="Networking\LobbyManager\LobbyManager.cs" /> <Compile Include="Networking\LobbyManager\LobbyManager.cs" />
<Compile Include="Networking\LobbyManager\SteamLobbyManager.cs" /> <Compile Include="Networking\LobbyManager\SteamLobbyManager.cs" />
<Compile Include="Networking\Messages\LobbyInfoMessage.cs" /> <Compile Include="Networking\Messages\LobbyInfoMessage.cs" />
<Compile Include="Networking\Messages\NetworkMessage.cs" /> <Compile Include="Networking\NetworkMessage.cs" />
<Compile Include="Networking\Messages\PlayerSyncMessage.cs" />
<Compile Include="Networking\Packet.cs" /> <Compile Include="Networking\Packet.cs" />
<Compile Include="Networking\PacketTypes.cs" /> <Compile Include="Networking\PacketTypes.cs" />
<Compile Include="Networking\Transport\SteamTransport.cs" /> <Compile Include="Networking\Transport\SteamTransport.cs" />
<Compile Include="Networking\Transport\TransportBase.cs" /> <Compile Include="Networking\Transport\TransportBase.cs" />
<Compile Include="Patching\PoolPatches.cs" />
<Compile Include="Player\PlayerRig.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Networking\ByteEncoder.cs" /> <Compile Include="Sync\SceneSync.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<WCFMetadata Include="Connected Services\" /> <Content Include="Facepunch.Steamworks\LICENSE.txt" />
<EmbeddedResource Include="steam_api.dll" />
<EmbeddedResource Include="steam_api64.dll" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="packages.config" /> <EmbeddedResource Include="playerrep.eres" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\MSTest.Analyzers.3.8.2\analyzers\dotnet\cs\MSTest.Analyzers.CodeFixes.dll" />
<Analyzer Include="..\packages\MSTest.Analyzers.3.8.2\analyzers\dotnet\cs\MSTest.Analyzers.dll" />
<Analyzer Include="..\packages\xunit.analyzers.1.20.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
<Analyzer Include="..\packages\xunit.analyzers.1.20.0\analyzers\dotnet\cs\xunit.analyzers.fixes.dll" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup> <PropertyGroup>
<PostBuildEvent> <PostBuildEvent>xcopy /Y "$(TargetPath)" "A:\SteamLibrary\steamapps\common\BONEWORKS\BONEWORKS\Mods\"
</PostBuildEvent> xcopy /Y "$(TargetPath)" "C:\Program Files (x86)\Steam\steamapps\common\BONEWORKS\BONEWORKS\Mods\"</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.core.2.9.3\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.9.3\build\xunit.core.props'))" />
<Error Condition="!Exists('..\packages\xunit.core.2.9.3\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.9.3\build\xunit.core.targets'))" />
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.3.0.2\build\net472\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.3.0.2\build\net472\xunit.runner.visualstudio.props'))" />
</Target>
<Import Project="..\packages\xunit.core.2.9.3\build\xunit.core.targets" Condition="Exists('..\packages\xunit.core.2.9.3\build\xunit.core.targets')" />
</Project> </Project>

View File

@@ -0,0 +1,384 @@
using BoneSync.Networking.Messages;
using StressLevelZero;
using StressLevelZero.Combat;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace BoneSync.Data
{
public static class BitPacking
{
public static byte[] PackBits(bool[] bits)
{
int byteCount = bits.Length / 8;
if (bits.Length % 8 != 0)
{
byteCount++;
}
byte[] bytes = new byte[byteCount];
for (int i = 0; i < bits.Length; i++)
{
int byteIndex = i / 8;
int bitIndex = i % 8;
if (bits[i])
{
bytes[byteIndex] |= (byte)(1 << bitIndex);
}
}
return bytes;
}
public static bool[] UnpackBits(byte[] bytes, int bitCount)
{
bool[] bits = new bool[bitCount];
for (int i = 0; i < bitCount; i++)
{
int byteIndex = i / 8;
int bitIndex = i % 8;
bits[i] = (bytes[byteIndex] & (1 << bitIndex)) != 0;
}
return bits;
}
}
internal class ByteEncoder
{
private MemoryStream stream;
private BinaryWriter writer;
private BinaryReader reader;
private bool isWriting;
public ByteEncoder()
{
stream = new MemoryStream();
writer = new BinaryWriter(stream);
isWriting = true;
}
public ByteEncoder(byte[] data)
{
stream = new MemoryStream(data);
reader = new BinaryReader(stream);
isWriting = false;
}
public byte[] ToArray()
{
byte[] buf = stream.GetBuffer();
int start, len;
if (isWriting)
{
start = 0;
len = (int)stream.Length;
}
else
{
start = (int)stream.Position;
len = (int)stream.Length - start;
}
byte[] res = new byte[len];
Array.Copy(buf, start, res, 0, len);
return res;
}
public void SetBytes(byte[] data)
{
if (stream != null)
{
stream.Dispose();
}
stream = new MemoryStream(data);
reader = new BinaryReader(stream);
writer = null;
isWriting = false;
}
public void WriteByte(byte value)
{
writer.Write(value);
}
public void WriteBytes(byte[] value)
{
writer.Write(value);
}
public byte[] ReadBytes(int count)
{
byte[] value = reader.ReadBytes(count);
if (value.Length != count)
{
throw new Exception("Not enough data to read, expected " + count + " but only have " + value.Length);
}
return value;
}
public byte ReadByte()
{
return reader.ReadByte();
}
public void WriteBool(bool value)
{
WriteByte((byte)(value ? 1 : 0));
}
public bool ReadBool()
{
return ReadByte() == 1;
}
public void WriteInt(int value)
{
writer.Write(value);
}
public int ReadInt()
{
return reader.ReadInt32();
}
public void WriteLong(long value)
{
writer.Write(value);
}
public long ReadLong()
{
return reader.ReadInt64();
}
public void WriteFloat(float value)
{
writer.Write(value);
}
public float ReadFloat()
{
return reader.ReadSingle();
}
public void WriteUShort(ushort value)
{
writer.Write(value);
}
public ushort ReadUShort()
{
return reader.ReadUInt16();
}
public void WriteDouble(double value)
{
writer.Write(value);
}
public double ReadDouble()
{
return reader.ReadDouble();
}
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));
}
public void WriteULong(ulong value)
{
writer.Write(value);
}
public ulong ReadULong()
{
return reader.ReadUInt64();
}
public void WriteVector3(Vector3 value)
{
WriteFloat(value.x);
WriteFloat(value.y);
WriteFloat(value.z);
}
public Vector3 ReadVector3()
{
float x = ReadFloat();
float y = ReadFloat();
float z = ReadFloat();
return new Vector3(x, y, z);
}
public void WriteQuaternion(Quaternion value)
{
WriteVector3(value.eulerAngles);
}
public Quaternion ReadQuaternion()
{
Vector3 eulerAngles = ReadVector3();
return Quaternion.Euler(eulerAngles);
}
public void WriteSimpleTransform(SimpleSyncTransform value)
{
WriteVector3(value.position);
WriteQuaternion(value.rotation);
WriteBool(value.scale.HasValue);
if (value.scale.HasValue)
WriteVector3(value.scale.Value);
}
public SimpleSyncTransform ReadSimpleTransform()
{
Vector3 position = ReadVector3();
Quaternion rotation = ReadQuaternion();
bool hasScale = ReadBool();
Vector3? scale = null;
if (hasScale)
{
scale = ReadVector3();
}
return new SimpleSyncTransform()
{
position = position,
rotation = rotation,
scale = scale
};
}
public void WriteMatrix4x4(Matrix4x4 matrix)
{
for (int i = 0; i < 16; i++)
{
WriteFloat(matrix[i]);
}
}
public Matrix4x4 ReadMatrix4x4()
{
Matrix4x4 matrix = new Matrix4x4();
for (int i = 0; i < 16; i++)
{
matrix[i] = ReadFloat();
}
return matrix;
}
public void WriteBoolArray(bool[] array)
{
byte[] bytes = BitPacking.PackBits(array);
WriteByte((byte)bytes.Length);
WriteBytes(bytes);
}
public bool[] ReadBoolArray()
{
byte length = ReadByte();
byte[] bytes = ReadBytes(length);
return BitPacking.UnpackBits(bytes, length * 8);
}
public void WriteAmmoVariables(AmmoVariables ammoVariables)
{
WriteBool(ammoVariables.Tracer);
WriteFloat(ammoVariables.ProjectileMass);
WriteFloat(ammoVariables.ExitVelocity);
WriteFloat(ammoVariables.AttackDamage);
WriteByte((byte)ammoVariables.AttackType);
WriteByte((byte)ammoVariables.cartridgeType);
}
public AmmoVariables ReadAmmoVariables()
{
AmmoVariables ammoVariables = new AmmoVariables()
{
Tracer = ReadBool(),
ProjectileMass = ReadFloat(),
ExitVelocity = ReadFloat(),
AttackDamage = ReadFloat(),
AttackType = (AttackType)ReadByte(),
cartridgeType = (Cart)ReadByte()
};
return ammoVariables;
}
public void WriteMagazineData(MagazineData magazineData)
{
WriteByte((byte)magazineData.weight);
WriteByte((byte)magazineData.platform);
WriteUShort((byte)magazineData.cartridgeType);
BulletObject[] bulletObjects = magazineData.AmmoSlots;
WriteByte((byte)bulletObjects.Length);
for (int i = 0; i < bulletObjects.Length; i++)
{
WriteAmmoVariables(bulletObjects[i].ammoVariables);
}
}
public MagazineData ReadMagazineData()
{
MagazineData mag = new MagazineData();
mag.weight = (Weight)ReadByte();
mag.platform = (Platform)ReadByte();
mag.cartridgeType = (Cart)ReadUShort();
byte bulletCount = ReadByte();
mag.AmmoSlots = new BulletObject[bulletCount];
for (int i = 0; i < bulletCount; i++)
{
mag.AmmoSlots[i] = new BulletObject()
{
ammoVariables = ReadAmmoVariables()
};
}
return mag;
}
public void WriteCompressedFloat(float value)
{
value = Mathf.Clamp01(value);
int rounded = Mathf.FloorToInt(value * 255f);
WriteByte((byte)rounded);
}
public float ReadCompressedFloat()
{
return ReadByte() / 255f;
}
public void WriteFingerCurl(SimpleFingerCurl fingerCurl)
{
WriteCompressedFloat(fingerCurl.thumb);
WriteCompressedFloat(fingerCurl.index);
WriteCompressedFloat(fingerCurl.middle);
WriteCompressedFloat(fingerCurl.ring);
WriteCompressedFloat(fingerCurl.pinky);
}
public SimpleFingerCurl ReadFingerCurl()
{
SimpleFingerCurl fingerCurl = new SimpleFingerCurl()
{
thumb = ReadCompressedFloat(),
index = ReadCompressedFloat(),
middle = ReadCompressedFloat(),
ring = ReadCompressedFloat(),
pinky = ReadCompressedFloat()
};
return fingerCurl;
}
}
}

110
BoneSync/Data/Debugger.cs Normal file
View File

@@ -0,0 +1,110 @@
using MelonLoader;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
namespace BoneSync.Data
{
internal static class SyncLogger
{
private static string GetCleanCaller(string className, string methodName)
{
if (className.Contains("BoneSync"))
className = className.Replace("BoneSync.", "");
if (methodName.Contains("BoneSync"))
methodName = methodName.Replace("BoneSync.", "");
return $"{className}.{methodName}";
}
public static void Msg(string message, ConsoleColor color = ConsoleColor.White, int frame = 1)
{
StackTrace stackTrace = new StackTrace();
StackFrame stackFrame = stackTrace.GetFrame(frame);
MethodBase methodBase = stackFrame.GetMethod();
string methodName = methodBase.Name;
string className = methodBase.DeclaringType.Name;
string cleanCaller = GetCleanCaller(className, methodName);
MelonLogger.Msg(color, $"[{cleanCaller}] {message}");
}
public static void Warning(string message)
{
Msg(message, ConsoleColor.Yellow, 2);
}
public static void Error(string message)
{
Msg(message, ConsoleColor.Red, 2);
}
internal static void Debug(string v)
{
#if DEBUG
Msg($"[DEBUG] {v}", ConsoleColor.Gray, 2);
#endif
}
}
/*internal static class SyncDebugUI
{
public static Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
public static Text debugText;
public static void CreateUI()
{
if (debugText != null)
return;
GameObject canvas = new GameObject("BoneSyncDebugCanvas");
canvas.AddComponent<Canvas>();
canvas.AddComponent<CanvasScaler>();
canvas.AddComponent<GraphicRaycaster>();
canvas.GetComponent<Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
GameObject panel = new GameObject("BoneSyncDebugPanel");
panel.transform.SetParent(canvas.transform);
panel.AddComponent<CanvasRenderer>();
panel.AddComponent<Image>();
panel.GetComponent<Image>().color = new Color(0, 0, 0, 0.5f);
panel.GetComponent<RectTransform>().anchorMin = new Vector2(0, 0);
panel.GetComponent<RectTransform>().anchorMax = new Vector2(1, 1);
panel.GetComponent<RectTransform>().offsetMin = new Vector2(0, 0);
panel.GetComponent<RectTransform>().offsetMax = new Vector2(0, 0);
GameObject text = new GameObject("BoneSyncDebugText");
text.transform.SetParent(panel.transform);
text.AddComponent<RectTransform>();
text.AddComponent<Text>();
text.GetComponent<Text>().font = Font.CreateDynamicFontFromOSFont("Arial", 12);
text.GetComponent<Text>().color = Color.white;
text.GetComponent<Text>().alignment = TextAnchor.UpperLeft;
text.GetComponent<Text>().resizeTextForBestFit = true;
text.GetComponent<Text>().resizeTextMaxSize = 12;
text.GetComponent<Text>().resizeTextMinSize = 8;
text.GetComponent<Text>().text = "BoneSync Debug";
text.GetComponent<RectTransform>().anchorMin = new Vector2(0, 0);
text.GetComponent<RectTransform>().anchorMax = new Vector2(1, 1);
text.GetComponent<RectTransform>().offsetMin = new Vector2(0, 0);
text.GetComponent<RectTransform>().offsetMax = new Vector2(0, 0);
debugText = text.GetComponent<Text>();
}
public static void UpdateUI()
{
CreateUI();
StringBuilder sb = new StringBuilder();
foreach (var kvp in keyValuePairs)
{
sb.AppendLine($"{kvp.Key}: {kvp.Value}");
}
debugText.text = sb.ToString();
}
}*/
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using MelonLoader;
using UnityEngine;
namespace BoneSync.Data
{
public static class EmebeddedAssetBundle
{
// Credit to the "Entanglement" mod. The playerrep asset bundle is also by them.
public static AssetBundle LoadFromAssembly(string name)
{
Assembly assembly = Assembly.GetExecutingAssembly();
string[] manifestResources = assembly.GetManifestResourceNames();
if (manifestResources.Contains(name))
{
SyncLogger.Msg($"Loading embedded bundle data {name}...");
byte[] bytes;
using (Stream str = assembly.GetManifestResourceStream(name))
using (MemoryStream memoryStream = new MemoryStream())
{
str.CopyTo(memoryStream);
bytes = memoryStream.ToArray();
}
SyncLogger.Msg($"Loading bundle from data {name}, please be patient...");
AssetBundle temp = AssetBundle.LoadFromMemory(bytes);
SyncLogger.Msg($"Done!");
return temp;
}
SyncLogger.Warning($"Failed to load embedded bundle data {name}! Bundle not found.");
return null;
}
}
}

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MelonLoader;
using StressLevelZero.Interaction;
using StressLevelZero.Player;
using StressLevelZero.Rig;
using StressLevelZero.VRMK;
using UnhollowerBaseLib;
using UnityEngine;
namespace BoneSync.Data
{
// copied from Entanglement mod
public static class PlayerScripts
{
public static GameObject localPlayerGameObject;
public static RigManager playerRig;
public static PhysBody playerPhysBody;
public static Player_Health playerHealth;
public static PhysGrounder playerGrounder;
public static Hand playerLeftHand;
public static Hand playerRightHand;
public static bool reloadLevelOnDeath;
public static RuntimeAnimatorController playerAnimatorController;
public static Il2CppStringArray playerHandPoses = null;
public static void GetPlayerScripts()
{
if (playerRig != null)
return;
localPlayerGameObject = GameObject.Find("[RigManager (Default Brett)]");
playerRig = localPlayerGameObject.GetComponentInChildren<RigManager>();
playerHealth = playerRig.playerHealth;
reloadLevelOnDeath = playerHealth.reloadLevelOnDeath;
playerHealth.reloadLevelOnDeath = !BoneSync.IsConnected;
try
{
PhysicsRig physicsRig = playerRig.physicsRig;
playerPhysBody = physicsRig.physBody;
playerGrounder = playerPhysBody.physG;
playerLeftHand = physicsRig.leftHand;
playerRightHand = physicsRig.rightHand;
playerAnimatorController = playerRig.gameWorldSkeletonRig.characterAnimationManager.animator.runtimeAnimatorController;
} catch
{
SyncLogger.Warning("Failed to get physicsRig player scripts!");
}
}
public static void GetHandPoses()
{
// Checks if we already got the hand poses to prevent crashes
if (playerHandPoses == null)
CharacterAnimationManager.FetchHandPoseList(out playerHandPoses); // Lets hope this is constant!
}
}
}

View File

@@ -0,0 +1,84 @@
using BoneSync.Patching;
using MelonLoader;
using StressLevelZero.Data;
using StressLevelZero.Pool;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
using UnityEngine;
using UnityObject = UnityEngine.Object;
namespace BoneSync.Data
{
public static class SpawnableManager
{
private static Dictionary<string, SpawnableObject> _spawnableCache = new Dictionary<string, SpawnableObject>();
private static Dictionary<string, SpawnableObject> _spawnablePrefabNameCache = new Dictionary<string, SpawnableObject>();
public static void AddUnregisteredSpawnables()
{
Il2CppReferenceArray<UnityObject> foundSpawnables = UnityObject.FindObjectsOfTypeIncludingAssets(Il2CppType.Of<SpawnableObject>());
foreach (UnityObject obj in foundSpawnables)
{
SpawnableObject spawnable = obj.Cast<SpawnableObject>();
RegisterSpawnable(spawnable);
}
}
private static void _ClearCache()
{
_spawnableCache.Clear();
_spawnablePrefabNameCache.Clear();
}
public static void RegisterSpawnable(SpawnableObject spawnable)
{
if (!_spawnableCache.ContainsKey(spawnable?.title))
_spawnableCache.Add(spawnable?.title, spawnable);
if (spawnable?.prefab?.name != null && !_spawnablePrefabNameCache.ContainsKey(spawnable.prefab.name))
_spawnablePrefabNameCache.Add(spawnable.prefab.name, spawnable);
}
public static SpawnableObject GetSpawnable(string title)
{
if (_spawnableCache.ContainsKey(title))
return _spawnableCache[title];
return null;
}
public static SpawnableObject GetSpawnableByPrefabName(string prefabName)
{
if (_spawnablePrefabNameCache.ContainsKey(prefabName))
return _spawnablePrefabNameCache[prefabName];
return null;
}
public static Pool GetPool(SpawnableObject spawnable) {
PoolManager.RegisterPool(spawnable);
return PoolManager.GetPool(spawnable.title);
}
public static Poolee SpawnPoolee(SpawnableObject spawnableObject, Vector3 position, Quaternion rotation)
{
if (spawnableObject == null) return null;
Pool pool = GetPool(spawnableObject);
if (pool == null)
{
SyncLogger.Warning("Failed to find pool: " + spawnableObject.title);
return null;
}
Poolee poolee = CallPatchedMethods.InstantiatePoolee(pool, position, rotation, pool.Prefab.transform.localScale);
return poolee;
}
public static void Initialize()
{
_ClearCache();
AddUnregisteredSpawnables();
}
}
}

32
BoneSync/Data/Structs.cs Normal file
View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace BoneSync.Data
{
public static class SimpleTransformExtensions
{
public static void ApplySimpleTransform(this Transform transform, SimpleSyncTransform simpleTransform)
{
transform.position = simpleTransform.position;
transform.rotation = simpleTransform.rotation;
if (simpleTransform.scale.HasValue) transform.localScale = simpleTransform.scale.Value;
}
}
public struct SimpleSyncTransform
{
public Vector3 position;
public Quaternion rotation;
public Vector3? scale;
public SimpleSyncTransform(Transform transform, bool withScale = true)
{
position = transform.position;
rotation = transform.rotation;
scale = withScale ? transform.localScale : (Vector3?)null;
}
}
}

Some files were not shown because too many files have changed in this diff Show More