gg.easy.airship 0.1.2148 → 0.1.2149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/Easy.Airship.Editor.asmdef +2 -1
- package/Runtime/Code/Airship/Resources/Scripts/Editor/Airship.Airship.Editor.asmdef +2 -1
- package/Runtime/Code/Airship/Resources/Scripts/MeshCombiner.cs +3 -1
- package/Runtime/Code/Airship/Resources/Scripts/MeshCopy.cs +15 -10
- package/Runtime/Code/AirshipConst.cs +2 -2
- package/Runtime/Code/Bootstrap/ServerBootstrap.cs +1 -1
- package/Runtime/Code/Bundles/Airship.Bundles.asmdef +2 -1
- package/Runtime/Code/Crc32/Crc32Algorithm.cs +192 -0
- package/Runtime/Code/Crc32/Crc32Algorithm.cs.meta +3 -0
- package/Runtime/Code/Crc32/LICENSE +21 -0
- package/Runtime/Code/Crc32/LICENSE.meta +3 -0
- package/Runtime/Code/Crc32/SafeProxy.cs +76 -0
- package/Runtime/Code/Crc32/SafeProxy.cs.meta +3 -0
- package/Runtime/Code/Crc32.meta +3 -0
- package/Runtime/Code/Luau/Airship.LuauCore.asmdef +1 -0
- package/Runtime/Code/Luau/AirshipComponent.cs +13 -4
- package/Runtime/Code/Luau/AirshipComponentTriggerEvents.cs +20 -0
- package/Runtime/Code/Luau/AirshipComponentTriggerEvents.cs.meta +2 -0
- package/Runtime/Code/Luau/BinaryBlob.cs +100 -6
- package/Runtime/Code/Luau/LuauCompiler.cs +1 -1
- package/Runtime/Code/Luau/LuauCoreCallbacks.cs +2 -0
- package/Runtime/Code/Luau/LuauMetadata.cs +4 -1
- package/Runtime/Code/Luau/LuauScript.cs +4 -0
- package/Runtime/Code/Luau/ReflectionList.cs +1 -0
- package/Runtime/Code/LuauAPI/AirshipBehaviourHelper.cs +16 -2
- package/Runtime/Code/LuauAPI/GameObjectAPI.cs +15 -5
- package/Runtime/Code/LuauAPI/SplineContainerAPI.cs +9 -0
- package/Runtime/Code/LuauAPI/SplineContainerAPI.cs.meta +2 -0
- package/Runtime/Code/Managers/CanvasDistanceManager.cs +49 -0
- package/Runtime/Code/Managers/CanvasDistanceManager.cs.meta +3 -0
- package/Runtime/Code/Misc/CanvasDistanceCondition.cs +15 -15
- package/Runtime/Code/Network/Simulation/AirshipNetworkedObject.cs +9 -9
- package/Runtime/Code/Network/Simulation/AirshipSimulationManager.cs +78 -79
- package/Runtime/Code/Network/Simulation/History.cs +70 -54
- package/Runtime/Code/Network/Simulation/ObserveableHistory.cs +241 -0
- package/Runtime/Code/Network/Simulation/ObserveableHistory.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/AirshipNetworkedStateManager.cs +284 -177
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovement.cs +10 -9
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovementDiff.cs +7 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovementDiff.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestMovementState.cs +4 -4
- package/Runtime/Code/Network/StateSystem/Implementations/TestMovementSystem/TestNetworkedStateManager.cs +26 -7
- package/Runtime/Code/Network/StateSystem/NetworkedStateSystem.cs +8 -8
- package/Runtime/Code/Network/StateSystem/Structures/InputCommand.cs +4 -4
- package/Runtime/Code/Network/StateSystem/Structures/StateDiff.cs +24 -0
- package/Runtime/Code/Network/StateSystem/Structures/StateDiff.cs.meta +3 -0
- package/Runtime/Code/Network/StateSystem/Structures/StateSnapshot.cs +30 -4
- package/Runtime/Code/Player/Accessories/AccessoryComponent.cs +7 -4
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterMovement.cs +34 -24
- package/Runtime/Code/Player/Character/MovementSystems/Character/CharacterNetworkedStateManager.cs +29 -10
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures/CharacterInputData.cs +50 -1
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures/CharacterSnapshotData.cs +243 -54
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures/CharacterStateDiff.cs +31 -0
- package/Runtime/Code/Player/Character/MovementSystems/Character/Structures/CharacterStateDiff.cs.meta +3 -0
- package/Runtime/Code/PoolManager/Airship.PoolManager.asmdef +2 -1
- package/Runtime/Code/PoolManager/PoolManager.cs +1 -1
- package/Runtime/Code/TSCodeGen/Editor/CsToTs/CsToTs.asmdef +3 -1
- package/Runtime/Code/TSCodeGen/TypeGenerator.cs +4 -0
- package/Runtime/Code/Util/BitUtil.cs +22 -0
- package/Runtime/Code/Util/BitUtil.cs.meta +3 -0
- package/Runtime/Code/Util/NetworkSerializationUtil.cs +40 -0
- package/Runtime/Code/Util/NetworkSerializationUtil.cs.meta +3 -0
- package/Runtime/Code/VoxelWorld/Editor/Airship.VoxelWorld.Editor.asmdef +2 -1
- package/Runtime/Plugins/Android/libLuauPlugin.so +0 -0
- package/Runtime/Plugins/Linux/libLuauPlugin.so +0 -0
- package/Runtime/Plugins/Mac/LuauPlugin.bundle/Contents/MacOS/LuauPlugin +0 -0
- package/Runtime/Plugins/Windows/x64/LuauPlugin.dll +0 -0
- package/Runtime/Plugins/Windows/x64/LuauPlugin.pdb +0 -0
- package/Runtime/Plugins/iOS/LuauPluginIos.a +0 -0
- package/Runtime/Prefabs/Network.prefab +1 -1
- package/Runtime/Scenes/CoreScene.unity +283 -260
- package/ThirdParty/Graphy - Ultimate Stats Monitor/Editor/Tayx.Graphy.Editor.asmdef +4 -1
- package/ThirdParty/Graphy - Ultimate Stats Monitor/Runtime/Tayx.Graphy.asmdef +2 -1
- package/ThirdParty/Mirror/Components/NetworkStatistics.cs +12 -7
- package/ThirdParty/Mirror/Core/NetworkManager.cs +3 -0
- package/package.json +1 -1
|
@@ -66,7 +66,8 @@
|
|
|
66
66
|
"GUID:6e5063adab271564ba0098a06a8cebda",
|
|
67
67
|
"GUID:3b5390adca4e2bb4791cb930316d6f3e",
|
|
68
68
|
"GUID:725ee7191c021de4dbf9269590ded755",
|
|
69
|
-
"GUID:2a0340569ab0e1245a38e0d6c7b2529b"
|
|
69
|
+
"GUID:2a0340569ab0e1245a38e0d6c7b2529b",
|
|
70
|
+
"GUID:befe48b9a36afc04ea625c93daad910e"
|
|
70
71
|
],
|
|
71
72
|
"includePlatforms": [
|
|
72
73
|
"Editor"
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
"GUID:3b5390adca4e2bb4791cb930316d6f3e",
|
|
59
59
|
"GUID:725ee7191c021de4dbf9269590ded755",
|
|
60
60
|
"GUID:77ccaf49895b0d64e87cd4b4faf83c49",
|
|
61
|
-
"GUID:2a0340569ab0e1245a38e0d6c7b2529b"
|
|
61
|
+
"GUID:2a0340569ab0e1245a38e0d6c7b2529b",
|
|
62
|
+
"GUID:befe48b9a36afc04ea625c93daad910e"
|
|
62
63
|
],
|
|
63
64
|
"includePlatforms": [
|
|
64
65
|
"Editor"
|
|
@@ -402,12 +402,14 @@ namespace Airship {
|
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
+
var isClient = RunCore.IsClient();
|
|
406
|
+
|
|
405
407
|
// Copy the materials to the renderer
|
|
406
408
|
Material[] finalMaterials = new Material[finalSkinnedMeshCopy.subMeshes.Count];
|
|
407
409
|
for (int i = 0; i < finalSkinnedMeshCopy.subMeshes.Count; i++) {
|
|
408
410
|
finalMaterials[i] = finalSkinnedMeshCopy.subMeshes[i].material;
|
|
409
411
|
|
|
410
|
-
if (!finalMaterials[i].shader.isSupported) {
|
|
412
|
+
if (isClient && !finalMaterials[i].shader.isSupported) {
|
|
411
413
|
finalMaterials[i].shader = Shader.Find("Universal Render Pipeline/Lit");
|
|
412
414
|
}
|
|
413
415
|
// finalMaterials[i].shader = 1(finalMaterials[i].shader.name);
|
|
@@ -239,19 +239,22 @@ namespace Code.Airship.Resources.Scripts {
|
|
|
239
239
|
|
|
240
240
|
// int instancePropertyID = Shader.PropertyToID("_BaseColor");
|
|
241
241
|
|
|
242
|
+
bool isClient = RunCore.IsClient();
|
|
242
243
|
for (int i = 0; i < mesh.subMeshCount; i++) {
|
|
243
244
|
SubMesh subMesh = new();
|
|
244
245
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
246
|
+
if (isClient) {
|
|
247
|
+
Material mat = null;
|
|
248
|
+
if (i < materials.Length) {
|
|
249
|
+
mat = materials[i];
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
//default material
|
|
253
|
+
mat = new Material(Shader.Find("Universal Render Pipeline/Lit"));
|
|
254
|
+
}
|
|
255
|
+
subMesh.material = mat;
|
|
252
256
|
}
|
|
253
|
-
|
|
254
|
-
|
|
257
|
+
|
|
255
258
|
//id if the material is batchable
|
|
256
259
|
|
|
257
260
|
/*
|
|
@@ -781,9 +784,11 @@ namespace Code.Airship.Resources.Scripts {
|
|
|
781
784
|
|
|
782
785
|
}
|
|
783
786
|
|
|
787
|
+
var isClient = RunCore.IsClient();
|
|
788
|
+
|
|
784
789
|
for (int i = 0; i < source.subMeshes.Count; i++) {
|
|
785
790
|
SubMesh sourceMesh = source.subMeshes[i];
|
|
786
|
-
if (sourceMesh.material == null) {
|
|
791
|
+
if (isClient && sourceMesh.material == null) {
|
|
787
792
|
sourceMesh.material = new Material(Shader.Find("Universal Render Pipeline/Lit"));
|
|
788
793
|
}
|
|
789
794
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// ReSharper disable InconsistentNaming
|
|
2
2
|
namespace Code {
|
|
3
3
|
public static class AirshipConst {
|
|
4
|
-
public const int playerVersion =
|
|
4
|
+
public const int playerVersion = 11;
|
|
5
5
|
|
|
6
6
|
/// <summary>
|
|
7
7
|
/// The server will kick clients that have a playerVersion lower than this value.
|
|
8
8
|
/// </summary>
|
|
9
|
-
public const int minAcceptedPlayerVersionOnServer =
|
|
9
|
+
public const int minAcceptedPlayerVersionOnServer = 11;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -257,7 +257,7 @@ public class ServerBootstrap : MonoBehaviour
|
|
|
257
257
|
if (this.allocatedByAgones) return;
|
|
258
258
|
var annotations = server.ObjectMeta.Annotations;
|
|
259
259
|
if (annotations.ContainsKey("GameId") && annotations.ContainsKey("JWT") && annotations.ContainsKey("RequiredPackages")) {
|
|
260
|
-
Debug.Log($"[Agones]: Server will run game {annotations["GameId"]} with (Assets v{annotations["GameAssetVersion"]}) and (Code v{annotations["GameCodeVersion"]})");
|
|
260
|
+
Debug.Log($"[Agones]: Server {annotations["ServerId"]} will run game {annotations["GameId"]} with (Assets v{annotations["GameAssetVersion"]}) and (Code v{annotations["GameCodeVersion"]})");
|
|
261
261
|
this.allocatedByAgones = true;
|
|
262
262
|
startupConfig.GameBundleId = annotations["GameId"];
|
|
263
263
|
startupConfig.GameAssetVersion = annotations["GameAssetVersion"];
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"GUID:30817c1a0e6d646d99c048fc403f5979",
|
|
20
20
|
"GUID:ec266f293c0b4f6c9d06847488a52a0c",
|
|
21
21
|
"GUID:325984b52e4128546bc7558552f8b1d2",
|
|
22
|
-
"GUID:72872094b21c16e48b631b2224833d49"
|
|
22
|
+
"GUID:72872094b21c16e48b631b2224833d49",
|
|
23
|
+
"GUID:befe48b9a36afc04ea625c93daad910e"
|
|
23
24
|
],
|
|
24
25
|
"includePlatforms": [],
|
|
25
26
|
"excludePlatforms": [],
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Security.Cryptography;
|
|
3
|
+
|
|
4
|
+
namespace Force.Crc32
|
|
5
|
+
{
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Implementation of CRC-32.
|
|
8
|
+
/// This class supports several convenient static methods returning the CRC as UInt32.
|
|
9
|
+
/// </summary>
|
|
10
|
+
public class Crc32Algorithm : HashAlgorithm
|
|
11
|
+
{
|
|
12
|
+
private uint _currentCrc;
|
|
13
|
+
|
|
14
|
+
private readonly bool _isBigEndian = true;
|
|
15
|
+
|
|
16
|
+
/// <summary>
|
|
17
|
+
/// Initializes a new instance of the <see cref="Crc32Algorithm"/> class.
|
|
18
|
+
/// </summary>
|
|
19
|
+
public Crc32Algorithm()
|
|
20
|
+
{
|
|
21
|
+
#if !NETCORE13
|
|
22
|
+
HashSizeValue = 32;
|
|
23
|
+
#endif
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// Initializes a new instance of the <see cref="Crc32Algorithm"/> class.
|
|
28
|
+
/// </summary>
|
|
29
|
+
/// <param name="isBigEndian">Should return bytes result as big endian or little endian</param>
|
|
30
|
+
// Crc32 by dariogriffo uses big endian, so, we need to be compatible and return big endian as default
|
|
31
|
+
public Crc32Algorithm(bool isBigEndian = true)
|
|
32
|
+
: this()
|
|
33
|
+
{
|
|
34
|
+
_isBigEndian = isBigEndian;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// Computes CRC-32 from multiple buffers.
|
|
39
|
+
/// Call this method multiple times to chain multiple buffers.
|
|
40
|
+
/// </summary>
|
|
41
|
+
/// <param name="initial">
|
|
42
|
+
/// Initial CRC value for the algorithm. It is zero for the first buffer.
|
|
43
|
+
/// Subsequent buffers should have their initial value set to CRC value returned by previous call to this method.
|
|
44
|
+
/// </param>
|
|
45
|
+
/// <param name="input">Input buffer with data to be checksummed.</param>
|
|
46
|
+
/// <param name="offset">Offset of the input data within the buffer.</param>
|
|
47
|
+
/// <param name="length">Length of the input data in the buffer.</param>
|
|
48
|
+
/// <returns>Accumulated CRC-32 of all buffers processed so far.</returns>
|
|
49
|
+
public static uint Append(uint initial, byte[] input, int offset, int length)
|
|
50
|
+
{
|
|
51
|
+
if (input == null)
|
|
52
|
+
throw new ArgumentNullException("input");
|
|
53
|
+
if (offset < 0 || length < 0 || offset + length > input.Length)
|
|
54
|
+
throw new ArgumentOutOfRangeException("length");
|
|
55
|
+
return AppendInternal(initial, input, offset, length);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/// <summary>
|
|
59
|
+
/// Computes CRC-32 from multiple buffers.
|
|
60
|
+
/// Call this method multiple times to chain multiple buffers.
|
|
61
|
+
/// </summary>
|
|
62
|
+
/// <param name="initial">
|
|
63
|
+
/// Initial CRC value for the algorithm. It is zero for the first buffer.
|
|
64
|
+
/// Subsequent buffers should have their initial value set to CRC value returned by previous call to this method.
|
|
65
|
+
/// </param>
|
|
66
|
+
/// <param name="input">Input buffer containing data to be checksummed.</param>
|
|
67
|
+
/// <returns>Accumulated CRC-32 of all buffers processed so far.</returns>
|
|
68
|
+
public static uint Append(uint initial, byte[] input)
|
|
69
|
+
{
|
|
70
|
+
if (input == null)
|
|
71
|
+
throw new ArgumentNullException();
|
|
72
|
+
return AppendInternal(initial, input, 0, input.Length);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/// <summary>
|
|
76
|
+
/// Computes CRC-32 from input buffer.
|
|
77
|
+
/// </summary>
|
|
78
|
+
/// <param name="input">Input buffer with data to be checksummed.</param>
|
|
79
|
+
/// <param name="offset">Offset of the input data within the buffer.</param>
|
|
80
|
+
/// <param name="length">Length of the input data in the buffer.</param>
|
|
81
|
+
/// <returns>CRC-32 of the data in the buffer.</returns>
|
|
82
|
+
public static uint Compute(byte[] input, int offset, int length)
|
|
83
|
+
{
|
|
84
|
+
return Append(0, input, offset, length);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// <summary>
|
|
88
|
+
/// Computes CRC-32 from input buffer.
|
|
89
|
+
/// </summary>
|
|
90
|
+
/// <param name="input">Input buffer containing data to be checksummed.</param>
|
|
91
|
+
/// <returns>CRC-32 of the buffer.</returns>
|
|
92
|
+
public static uint Compute(byte[] input)
|
|
93
|
+
{
|
|
94
|
+
return Append(0, input);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// <summary>
|
|
98
|
+
/// Computes CRC-32 from input buffer and writes it after end of data (buffer should have 4 bytes reserved space for it). Can be used in conjunction with <see cref="IsValidWithCrcAtEnd(byte[],int,int)"/>
|
|
99
|
+
/// </summary>
|
|
100
|
+
/// <param name="input">Input buffer with data to be checksummed.</param>
|
|
101
|
+
/// <param name="offset">Offset of the input data within the buffer.</param>
|
|
102
|
+
/// <param name="length">Length of the input data in the buffer.</param>
|
|
103
|
+
/// <returns>CRC-32 of the data in the buffer.</returns>
|
|
104
|
+
public static uint ComputeAndWriteToEnd(byte[] input, int offset, int length)
|
|
105
|
+
{
|
|
106
|
+
if (length + 4 > input.Length)
|
|
107
|
+
throw new ArgumentOutOfRangeException("length", "Length of data should be less than array length - 4 bytes of CRC data");
|
|
108
|
+
var crc = Append(0, input, offset, length);
|
|
109
|
+
var r = offset + length;
|
|
110
|
+
input[r] = (byte)crc;
|
|
111
|
+
input[r + 1] = (byte)(crc >> 8);
|
|
112
|
+
input[r + 2] = (byte)(crc >> 16);
|
|
113
|
+
input[r + 3] = (byte)(crc >> 24);
|
|
114
|
+
return crc;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/// <summary>
|
|
118
|
+
/// Computes CRC-32 from input buffer - 4 bytes and writes it as last 4 bytes of buffer. Can be used in conjunction with <see cref="IsValidWithCrcAtEnd(byte[])"/>
|
|
119
|
+
/// </summary>
|
|
120
|
+
/// <param name="input">Input buffer with data to be checksummed.</param>
|
|
121
|
+
/// <returns>CRC-32 of the data in the buffer.</returns>
|
|
122
|
+
public static uint ComputeAndWriteToEnd(byte[] input)
|
|
123
|
+
{
|
|
124
|
+
if (input.Length < 4)
|
|
125
|
+
throw new ArgumentOutOfRangeException("input", "Input array should be 4 bytes at least");
|
|
126
|
+
return ComputeAndWriteToEnd(input, 0, input.Length - 4);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// <summary>
|
|
130
|
+
/// Validates correctness of CRC-32 data in source buffer with assumption that CRC-32 data located at end of buffer in reverse bytes order. Can be used in conjunction with <see cref="ComputeAndWriteToEnd(byte[],int,int)"/>
|
|
131
|
+
/// </summary>
|
|
132
|
+
/// <param name="input">Input buffer with data to be checksummed.</param>
|
|
133
|
+
/// <param name="offset">Offset of the input data within the buffer.</param>
|
|
134
|
+
/// <param name="lengthWithCrc">Length of the input data in the buffer with CRC-32 bytes.</param>
|
|
135
|
+
/// <returns>Is checksum valid.</returns>
|
|
136
|
+
public static bool IsValidWithCrcAtEnd(byte[] input, int offset, int lengthWithCrc)
|
|
137
|
+
{
|
|
138
|
+
return Append(0, input, offset, lengthWithCrc) == 0x2144DF1C;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/// <summary>
|
|
142
|
+
/// Validates correctness of CRC-32 data in source buffer with assumption that CRC-32 data located at end of buffer in reverse bytes order. Can be used in conjunction with <see cref="ComputeAndWriteToEnd(byte[],int,int)"/>
|
|
143
|
+
/// </summary>
|
|
144
|
+
/// <param name="input">Input buffer with data to be checksummed.</param>
|
|
145
|
+
/// <returns>Is checksum valid.</returns>
|
|
146
|
+
public static bool IsValidWithCrcAtEnd(byte[] input)
|
|
147
|
+
{
|
|
148
|
+
if (input.Length < 4)
|
|
149
|
+
throw new ArgumentOutOfRangeException("input", "Input array should be 4 bytes at least");
|
|
150
|
+
return Append(0, input, 0, input.Length) == 0x2144DF1C;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/// <summary>
|
|
154
|
+
/// Resets internal state of the algorithm. Used internally.
|
|
155
|
+
/// </summary>
|
|
156
|
+
public override void Initialize()
|
|
157
|
+
{
|
|
158
|
+
_currentCrc = 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/// <summary>
|
|
162
|
+
/// Appends CRC-32 from given buffer
|
|
163
|
+
/// </summary>
|
|
164
|
+
protected override void HashCore(byte[] input, int offset, int length)
|
|
165
|
+
{
|
|
166
|
+
_currentCrc = AppendInternal(_currentCrc, input, offset, length);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/// <summary>
|
|
170
|
+
/// Computes CRC-32 from <see cref="HashCore"/>
|
|
171
|
+
/// </summary>
|
|
172
|
+
protected override byte[] HashFinal()
|
|
173
|
+
{
|
|
174
|
+
if (_isBigEndian)
|
|
175
|
+
return new[] { (byte)(_currentCrc >> 24), (byte)(_currentCrc >> 16), (byte)(_currentCrc >> 8), (byte)_currentCrc };
|
|
176
|
+
else
|
|
177
|
+
return new[] { (byte)_currentCrc, (byte)(_currentCrc >> 8), (byte)(_currentCrc >> 16), (byte)(_currentCrc >> 24) };
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private static readonly SafeProxy _proxy = new SafeProxy();
|
|
181
|
+
|
|
182
|
+
private static uint AppendInternal(uint initial, byte[] input, int offset, int length)
|
|
183
|
+
{
|
|
184
|
+
if (length > 0)
|
|
185
|
+
{
|
|
186
|
+
return _proxy.Append(initial, input, offset, length);
|
|
187
|
+
}
|
|
188
|
+
else
|
|
189
|
+
return initial;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 force
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* This is .NET safe implementation of Crc32 algorithm.
|
|
2
|
+
* This implementation was investigated as fastest from different variants. It based on Robert Vazan native implementations of Crc32C
|
|
3
|
+
* Also, it is good for x64 and for x86, so, it seems, there is no sense to do 2 different realizations.
|
|
4
|
+
*
|
|
5
|
+
* Addition: some speed increase was found with splitting xor to 4 independent blocks. Also, some attempts to optimize unaligned tails was unsuccessfull (JIT limitations?).
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* Max Vysokikh, 2016-2017
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
namespace Force.Crc32
|
|
12
|
+
{
|
|
13
|
+
internal class SafeProxy
|
|
14
|
+
{
|
|
15
|
+
private const uint Poly = 0xedb88320u;
|
|
16
|
+
|
|
17
|
+
private readonly uint[] _table = new uint[16 * 256];
|
|
18
|
+
|
|
19
|
+
internal SafeProxy()
|
|
20
|
+
{
|
|
21
|
+
Init(Poly);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected void Init(uint poly)
|
|
25
|
+
{
|
|
26
|
+
var table = _table;
|
|
27
|
+
for (uint i = 0; i < 256; i++)
|
|
28
|
+
{
|
|
29
|
+
uint res = i;
|
|
30
|
+
for (int t = 0; t < 16; t++)
|
|
31
|
+
{
|
|
32
|
+
for (int k = 0; k < 8; k++) res = (res & 1) == 1 ? poly ^ (res >> 1) : (res >> 1);
|
|
33
|
+
table[(t * 256) + i] = res;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public uint Append(uint crc, byte[] input, int offset, int length)
|
|
39
|
+
{
|
|
40
|
+
uint crcLocal = uint.MaxValue ^ crc;
|
|
41
|
+
|
|
42
|
+
uint[] table = _table;
|
|
43
|
+
while (length >= 16)
|
|
44
|
+
{
|
|
45
|
+
var a = table[(3 * 256) + input[offset + 12]]
|
|
46
|
+
^ table[(2 * 256) + input[offset + 13]]
|
|
47
|
+
^ table[(1 * 256) + input[offset + 14]]
|
|
48
|
+
^ table[(0 * 256) + input[offset + 15]];
|
|
49
|
+
|
|
50
|
+
var b = table[(7 * 256) + input[offset + 8]]
|
|
51
|
+
^ table[(6 * 256) + input[offset + 9]]
|
|
52
|
+
^ table[(5 * 256) + input[offset + 10]]
|
|
53
|
+
^ table[(4 * 256) + input[offset + 11]];
|
|
54
|
+
|
|
55
|
+
var c = table[(11 * 256) + input[offset + 4]]
|
|
56
|
+
^ table[(10 * 256) + input[offset + 5]]
|
|
57
|
+
^ table[(9 * 256) + input[offset + 6]]
|
|
58
|
+
^ table[(8 * 256) + input[offset + 7]];
|
|
59
|
+
|
|
60
|
+
var d = table[(15 * 256) + ((byte)crcLocal ^ input[offset])]
|
|
61
|
+
^ table[(14 * 256) + ((byte)(crcLocal >> 8) ^ input[offset + 1])]
|
|
62
|
+
^ table[(13 * 256) + ((byte)(crcLocal >> 16) ^ input[offset + 2])]
|
|
63
|
+
^ table[(12 * 256) + ((crcLocal >> 24) ^ input[offset + 3])];
|
|
64
|
+
|
|
65
|
+
crcLocal = d ^ c ^ b ^ a;
|
|
66
|
+
offset += 16;
|
|
67
|
+
length -= 16;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
while (--length >= 0)
|
|
71
|
+
crcLocal = table[(byte)(crcLocal ^ input[offset++])] ^ crcLocal >> 8;
|
|
72
|
+
|
|
73
|
+
return crcLocal ^ uint.MaxValue;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"GUID:ec266f293c0b4f6c9d06847488a52a0c",
|
|
24
24
|
"GUID:325984b52e4128546bc7558552f8b1d2",
|
|
25
25
|
"GUID:befe48b9a36afc04ea625c93daad910e",
|
|
26
|
+
"GUID:47a57257b08841e9a7b6a61ce7119d42",
|
|
26
27
|
"GUID:21d1eb854b91ade49bc69a263d12bee2",
|
|
27
28
|
"GUID:d8b63aba1907145bea998dd612889d6b"
|
|
28
29
|
],
|
|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|
|
3
3
|
using System.Linq;
|
|
4
4
|
using System.Runtime.InteropServices;
|
|
5
5
|
using Assets.Code.Luau;
|
|
6
|
+
using Code.Luau;
|
|
6
7
|
using JetBrains.Annotations;
|
|
7
8
|
using Luau;
|
|
8
9
|
using UnityEngine;
|
|
@@ -57,7 +58,7 @@ internal delegate void ReconcileAirshipComponent(AirshipReconcileEventData data)
|
|
|
57
58
|
[AddComponentMenu("Airship/Airship Component")]
|
|
58
59
|
[HelpURL("https://docs.airship.gg/typescript/airshipbehaviour")]
|
|
59
60
|
[LuauAPI(LuauContext.Protected)]
|
|
60
|
-
public class AirshipComponent : MonoBehaviour {
|
|
61
|
+
public class AirshipComponent : MonoBehaviour, ITriggerReceiver {
|
|
61
62
|
internal static bool UsePostCompileReconciliation { get; set; } = true;
|
|
62
63
|
private const bool ElevateToProtectedWithinCoreScene = true;
|
|
63
64
|
|
|
@@ -230,6 +231,7 @@ public class AirshipComponent : MonoBehaviour {
|
|
|
230
231
|
LuauCore.onResetInstance += OnLuauReset;
|
|
231
232
|
|
|
232
233
|
InitAirshipComponent();
|
|
234
|
+
InitTriggerEvents();
|
|
233
235
|
}
|
|
234
236
|
|
|
235
237
|
private unsafe void InitAirshipComponent() {
|
|
@@ -287,6 +289,13 @@ public class AirshipComponent : MonoBehaviour {
|
|
|
287
289
|
InitStringPtrs.Clear();
|
|
288
290
|
}
|
|
289
291
|
|
|
292
|
+
private void InitTriggerEvents() {
|
|
293
|
+
if (HasAirshipMethod(AirshipComponentUpdateType.AirshipTriggerStay)) {
|
|
294
|
+
var triggerEvent = gameObject.AddComponent<AirshipComponentTriggerEvents>();
|
|
295
|
+
triggerEvent.AttachReceiver(this);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
290
299
|
private void Start() {
|
|
291
300
|
if (thread == IntPtr.Zero || !LuauCore.IsReady) return;
|
|
292
301
|
|
|
@@ -367,11 +376,11 @@ public class AirshipComponent : MonoBehaviour {
|
|
|
367
376
|
|
|
368
377
|
InvokeAirshipCollision(AirshipComponentUpdateType.AirshipTriggerEnter, other);
|
|
369
378
|
}
|
|
370
|
-
|
|
371
|
-
|
|
379
|
+
|
|
380
|
+
public void OnTriggerStayReceiver(Collider other) {
|
|
372
381
|
if (thread == IntPtr.Zero || !LuauCore.IsReady) return;
|
|
373
382
|
|
|
374
|
-
InvokeAirshipCollision(AirshipComponentUpdateType.AirshipTriggerStay, other);
|
|
383
|
+
InvokeAirshipCollision(AirshipComponentUpdateType.AirshipTriggerStay, other);
|
|
375
384
|
}
|
|
376
385
|
|
|
377
386
|
private void OnTriggerExit(Collider other) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace Code.Luau {
|
|
5
|
+
public interface ITriggerReceiver {
|
|
6
|
+
public void OnTriggerStayReceiver(Collider other);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public class AirshipComponentTriggerEvents : MonoBehaviour {
|
|
10
|
+
private ITriggerReceiver receiver;
|
|
11
|
+
|
|
12
|
+
public void AttachReceiver(ITriggerReceiver receiver) {
|
|
13
|
+
this.receiver = receiver;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private void OnTriggerStay(Collider other) {
|
|
17
|
+
this.receiver.OnTriggerStayReceiver(other);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
using System;
|
|
2
|
-
using
|
|
3
|
-
using
|
|
4
|
-
using System.Text;
|
|
5
|
-
using Code.Zstd;
|
|
2
|
+
using Mirror;
|
|
3
|
+
using Code.Util;
|
|
6
4
|
using UnityEngine;
|
|
7
|
-
using UnityEngine.Serialization;
|
|
8
|
-
using static LuauCore;
|
|
9
5
|
|
|
10
6
|
namespace Assets.Luau {
|
|
11
7
|
[Serializable]
|
|
@@ -29,5 +25,103 @@ namespace Assets.Luau {
|
|
|
29
25
|
public bool Equals(BinaryBlob other) {
|
|
30
26
|
return this.dataSize == other?.dataSize;
|
|
31
27
|
}
|
|
28
|
+
|
|
29
|
+
public byte[] CreateDiff(BinaryBlob other) {
|
|
30
|
+
int length = Math.Max(other.data.Length, data.Length);
|
|
31
|
+
var neededBytes = (int) Math.Ceiling(length / 8f);
|
|
32
|
+
byte[] changeBytes = new byte[neededBytes];
|
|
33
|
+
var writer = NetworkWriterPool.Get();
|
|
34
|
+
writer.WriteByte((byte) changeBytes.Length);
|
|
35
|
+
|
|
36
|
+
var changedByteWriter = NetworkWriterPool.Get();
|
|
37
|
+
for (int i = 0; i < length; i++) {
|
|
38
|
+
int bitIndex = i % 8;
|
|
39
|
+
int byteIndex = i / 8;
|
|
40
|
+
|
|
41
|
+
// We ran out of new data. we will continue to write changed bits, but we will not write byte data
|
|
42
|
+
if (i > other.data.Length - 1) {
|
|
43
|
+
BitUtil.SetBit(ref changeBytes[byteIndex], bitIndex, true);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// We ran out of base data. We will continue to write change bits and the new data
|
|
48
|
+
if (i > data.Length - 1) {
|
|
49
|
+
BitUtil.SetBit(ref changeBytes[byteIndex], bitIndex, true);
|
|
50
|
+
changedByteWriter.Write(other.data[i]);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// We have values to compare
|
|
55
|
+
if (other.data[i] == data[i]) {
|
|
56
|
+
// Byte values are equal. No need to write a new value
|
|
57
|
+
BitUtil.SetBit(ref changeBytes[byteIndex], bitIndex, false);
|
|
58
|
+
} else {
|
|
59
|
+
// Byte values don't match. Write new value
|
|
60
|
+
BitUtil.SetBit(ref changeBytes[byteIndex], bitIndex, true);
|
|
61
|
+
changedByteWriter.Write(other.data[i]);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
writer.WriteBytes(changeBytes, 0, changeBytes.Length);
|
|
66
|
+
var newByteValues = changedByteWriter.ToArray();
|
|
67
|
+
writer.WriteBytes(newByteValues, 0 ,newByteValues.Length);
|
|
68
|
+
var bytes = writer.ToArray();
|
|
69
|
+
|
|
70
|
+
NetworkWriterPool.Return(writer);
|
|
71
|
+
NetworkWriterPool.Return(changedByteWriter);
|
|
72
|
+
|
|
73
|
+
// Debug.Log($"Final diff is {bytes.Length} bytes");
|
|
74
|
+
return bytes;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public BinaryBlob ApplyDiff(byte[] bytes) {
|
|
78
|
+
// first byte in bytes will be the number of bytes to read as the change bit flags.
|
|
79
|
+
// Each bit of the change flag bytes refers to the index of the base byte array
|
|
80
|
+
// ie. bit 0 is byte zero of the base data. If the flag is true, we should read
|
|
81
|
+
// a byte from the diff data and replace index 0 with the new byte data.
|
|
82
|
+
byte changedLength = bytes[0];
|
|
83
|
+
if (changedLength == 0) return new BinaryBlob() {
|
|
84
|
+
dataSize = dataSize,
|
|
85
|
+
data = (byte[]) data.Clone(),
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
var byteWriter = NetworkWriterPool.Get();
|
|
89
|
+
var diffReadIndex = changedLength + 1; // + 1 for the byte used to encode the data size
|
|
90
|
+
for (byte curByte = 0; curByte < changedLength; curByte++) {
|
|
91
|
+
byte flags = bytes[curByte + 1];
|
|
92
|
+
for (byte curBitOfByte = 0; curBitOfByte < 8; curBitOfByte++) {
|
|
93
|
+
// The index into the existing byte array that the bit flag refers to.
|
|
94
|
+
var existingByteIndex = curBitOfByte + (curByte * 8);
|
|
95
|
+
|
|
96
|
+
// Should we update the byte at the current position?
|
|
97
|
+
bool update = BitUtil.GetBit(flags, curBitOfByte);
|
|
98
|
+
|
|
99
|
+
// If we have run out of diff data, but the bit flag says we should update the position,
|
|
100
|
+
// we are going to delete the remaining bytes by not writing them. This happens when
|
|
101
|
+
// the diff is supposed to shorten the base data.
|
|
102
|
+
if (diffReadIndex > (bytes.Length - 1) && update) {
|
|
103
|
+
// The absence of a write here "removes" data from the end of the base data.
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// If we run out of base data, but update wasn't set, it means we've reached the end of the changed flags. This happens when you have
|
|
108
|
+
// 7 bytes of data, but you have to include 1 full byte of change flags (8 bits). The last bit will be zero since there's no associated byte for that flag.
|
|
109
|
+
if (existingByteIndex > (data.Length - 1) && !update) {
|
|
110
|
+
// We do nothing since this bit flag is meaningless.
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
byteWriter.Write(update ? bytes[diffReadIndex] : data[existingByteIndex]);
|
|
115
|
+
if (update) diffReadIndex++; // Move our read pointer forward since we read a byte from our diff data.
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
var newBlob = new BinaryBlob() {
|
|
120
|
+
data = byteWriter.ToArray(), // new byte array with the diff applied
|
|
121
|
+
dataSize = byteWriter.Position // size of new byte array
|
|
122
|
+
};
|
|
123
|
+
NetworkWriterPool.Return(byteWriter);
|
|
124
|
+
return newBlob;
|
|
125
|
+
}
|
|
32
126
|
}
|
|
33
127
|
}
|
|
@@ -7,7 +7,7 @@ using Debug = UnityEngine.Debug;
|
|
|
7
7
|
|
|
8
8
|
public class LuauCompiler {
|
|
9
9
|
// Any globals in Luau that have values that change need to be added to this list (e.g. "Time" because "Time.time" changes):
|
|
10
|
-
public static readonly string[] MutableGlobals = {"Time", "NetworkTime", "Physics", "Screen", "Input"};
|
|
10
|
+
public static readonly string[] MutableGlobals = {"Time", "NetworkTime", "Physics", "Screen", "Input", "AirshipSimulationManager"};
|
|
11
11
|
|
|
12
12
|
public struct CompilationResult {
|
|
13
13
|
public IntPtr Data;
|
|
@@ -990,6 +990,7 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
990
990
|
}
|
|
991
991
|
|
|
992
992
|
public static string GetRequirePath(string originalScriptPath, string fileNameStr) {
|
|
993
|
+
Profiler.BeginSample("GetRequirePath");
|
|
993
994
|
if (!string.IsNullOrEmpty(originalScriptPath)) {
|
|
994
995
|
if (!fileNameStr.Contains("/")) {
|
|
995
996
|
// Get a stripped name
|
|
@@ -1026,6 +1027,7 @@ public partial class LuauCore : MonoBehaviour {
|
|
|
1026
1027
|
//Fully qualify it
|
|
1027
1028
|
fileNameStr = GetTidyPathNameForLuaFile(fileNameStr);
|
|
1028
1029
|
|
|
1030
|
+
Profiler.EndSample();
|
|
1029
1031
|
return fileNameStr;
|
|
1030
1032
|
}
|
|
1031
1033
|
|