Skip to content

Commit a4ece56

Browse files
authored
Merge branch 'master' into moretests
2 parents 0a710a1 + 757ac49 commit a4ece56

File tree

13 files changed

+100
-95
lines changed

13 files changed

+100
-95
lines changed

MLAPI-Editor/NetworkedObjectEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public override void OnInspectorGUI()
3838
}
3939
else if(networkedObject.isSpawned)
4040
{
41-
EditorGUILayout.LabelField("NetworkId: ", networkedObject.NetworKId.ToString(), EditorStyles.label);
41+
EditorGUILayout.LabelField("NetworkId: ", networkedObject.NetworkId.ToString(), EditorStyles.label);
4242
EditorGUILayout.LabelField("OwnerId: ", networkedObject.OwnerClientId.ToString(), EditorStyles.label);
4343
EditorGUILayout.LabelField("isSpawned: ", networkedObject.isSpawned.ToString(), EditorStyles.label);
4444
EditorGUILayout.LabelField("isLocalPlayer: ", networkedObject.isLocalPlayer.ToString(), EditorStyles.label);

MLAPI.Tests/NetworkingManagerComponents/Binary/BitStreamTest.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,20 @@ public void TestNibble()
426426

427427
//Assert.That(inStream.ReadNibble(), Is.EqualTo(0b0011));
428428
Assert.Fail("There is no way to read back Nibbles");
429+
}
429430

431+
public void TestReadWriteMissaligned()
432+
{
433+
BitStream outStream = new BitStream();
434+
outStream.WriteBit(true);
435+
byte[] writeBytes = new byte[16] {0, 5, 2, 54, 192, 60, 214, 65, 95, 2, 43, 62, 252, 190, 45, 2};
436+
outStream.Write(writeBytes);
437+
438+
BitStream inStream = new BitStream(outStream.GetBuffer());
439+
Assert.That(inStream.ReadBit(), Is.True);
440+
byte[] readTo = new byte[16];
441+
inStream.Read(readTo, 0, 16);
442+
Assert.That(readTo, Is.EquivalentTo(writeBytes));
430443
}
431444
}
432445
}

MLAPI.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLAPI", "MLAPI\MLAPI.csproj
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLAPI-Editor", "MLAPI-Editor\MLAPI-Editor.csproj", "{A45DBD43-D640-4562-9F24-6745269CEDF7}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLAPI.Tests", "MLAPI.tests\MLAPI.Tests.csproj", "{59E9F73A-398C-4F46-85E7-1DCDEEB2A85F}"
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLAPI.Tests", "MLAPI.Tests\MLAPI.Tests.csproj", "{59E9F73A-398C-4F46-85E7-1DCDEEB2A85F}"
1111
EndProject
1212
Global
1313
GlobalSection(SolutionConfigurationPlatforms) = preSolution

MLAPI/Attributes/ClientRpc.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public class ClientRpc : Attribute
1111
/// <summary>
1212
/// The channelName to send this Rpc
1313
/// </summary>
14-
public string channelName = "MLAPI_INTERNAL";
14+
public string channelName { get; set; } = "MLAPI_INTERNAL";
1515
}
1616
}

MLAPI/Attributes/Command.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public class Command : Attribute
1111
/// <summary>
1212
/// The channelName to send this Command
1313
/// </summary>
14-
public string channelName = "MLAPI_INTERNAL";
14+
public string channelName { get; set; } = "MLAPI_INTERNAL";
1515
}
1616
}

MLAPI/Attributes/SyncedVar.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ public class SyncedVar : Attribute
1111
/// <summary>
1212
/// The method name to invoke when the SyncVar get's updated.
1313
/// </summary>
14-
public string hookMethodName = string.Empty;
14+
public string hookMethodName { get; set; } = string.Empty;
1515
/// <summary>
1616
/// If true, the syncedVar will only be synced to the owner.
1717
/// </summary>
18-
public bool target = false;
18+
public bool target { get; set; }
1919
/// <summary>
2020
/// The delay for syncing this variable.
2121
/// </summary>
22-
public float syncDelay = 0.1f;
23-
internal float lastSyncTime = 0f;
22+
public float syncDelay { get; set; } = 0.1f;
23+
/// <summary>
24+
/// Gets the time the Syncedvar was last synced
25+
/// </summary>
26+
public float lastSyncTime { get; internal set; }
2427
}
2528
}

MLAPI/Attributes/TargetRpc.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ public class TargetRpc : Attribute
1111
/// <summary>
1212
/// The channelName to send this Target
1313
/// </summary>
14-
public string channelName = "MLAPI_INTERNAL";
14+
public string channelName { get; set; } = "MLAPI_INTERNAL";
1515
}
1616
}

MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public NetworkedObject networkedObject
5858
/// <summary>
5959
/// Gets the NetworkId of the NetworkedObject that owns the NetworkedBehaviour instance
6060
/// </summary>
61-
public uint networkId => networkedObject.NetworKId;
61+
public uint networkId => networkedObject.NetworkId;
6262
/// <summary>
6363
/// Gets the clientId that owns the NetworkedObject
6464
/// </summary>
@@ -74,7 +74,6 @@ private void OnEnable()
7474
NetworkedObject.NetworkedBehaviours.Add(this);
7575
OnEnabled();
7676
}
77-
7877
internal bool networkedStartInvoked = false;
7978
/// <summary>
8079
/// Gets called when message handlers are ready to be registered and the networking is setup

MLAPI/MonoBehaviours/Core/NetworkedObject.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private void OnValidate()
2525
/// <summary>
2626
/// Gets the unique ID of this object that is synced across the network
2727
/// </summary>
28-
public uint NetworKId { get; internal set; }
28+
public uint NetworkId { get; internal set; }
2929
/// <summary>
3030
/// Gets the clientId of the owner of this NetworkedObject
3131
/// </summary>
@@ -132,7 +132,7 @@ internal void RebuildObservers(uint? clientId = null)
132132
//Something changed for this client.
133133
using (BitWriter writer = BitWriter.Get())
134134
{
135-
writer.WriteUInt(NetworKId);
135+
writer.WriteUInt(NetworkId);
136136
writer.WriteBool(observers.Contains(pair.Key));
137137

138138
if (observers.Contains(pair.Key))
@@ -163,7 +163,7 @@ internal void SetLocalVisibility(bool visibility)
163163
private void OnDestroy()
164164
{
165165
if (NetworkingManager.singleton != null)
166-
SpawnManager.OnDestroyObject(NetworKId, false);
166+
SpawnManager.OnDestroyObject(NetworkId, false);
167167
}
168168

169169
/// <summary>
@@ -207,15 +207,15 @@ public void SpawnAsPlayerObject(uint clientId, BitWriter spawnPayload = null)
207207
/// </summary>
208208
public void RemoveOwnership()
209209
{
210-
SpawnManager.RemoveOwnership(NetworKId);
210+
SpawnManager.RemoveOwnership(NetworkId);
211211
}
212212
/// <summary>
213213
/// Changes the owner of the object. Can only be called from server
214214
/// </summary>
215215
/// <param name="newOwnerClientId">The new owner clientId</param>
216216
public void ChangeOwnership(uint newOwnerClientId)
217217
{
218-
SpawnManager.ChangeOwnership(NetworKId, newOwnerClientId);
218+
SpawnManager.ChangeOwnership(NetworkId, newOwnerClientId);
219219
}
220220

221221
internal void InvokeBehaviourOnLostOwnership()

MLAPI/MonoBehaviours/Core/NetworkingManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ internal void HandleApproval(uint clientId, int prefabId, bool approved, Vector3
11621162
pair.Value.RebuildObservers(clientId); //Rebuilds observers for the new client
11631163

11641164
writer.WriteBool(pair.Value.isPlayerObject);
1165-
writer.WriteUInt(pair.Value.NetworKId);
1165+
writer.WriteUInt(pair.Value.NetworkId);
11661166
writer.WriteUInt(pair.Value.OwnerClientId);
11671167
writer.WriteInt(NetworkConfig.NetworkPrefabIds[pair.Value.NetworkedPrefabName]);
11681168
writer.WriteBool(pair.Value.gameObject.activeInHierarchy);
@@ -1199,7 +1199,7 @@ internal void HandleApproval(uint clientId, int prefabId, bool approved, Vector3
11991199
if (NetworkConfig.HandleObjectSpawning)
12001200
{
12011201
writer.WriteBool(true);
1202-
writer.WriteUInt(ConnectedClients[clientId].PlayerObject.GetComponent<NetworkedObject>().NetworKId);
1202+
writer.WriteUInt(ConnectedClients[clientId].PlayerObject.GetComponent<NetworkedObject>().NetworkId);
12031203
writer.WriteUInt(clientId);
12041204
writer.WriteInt(prefabId);
12051205
writer.WriteBool(false);

0 commit comments

Comments
 (0)