-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hide Stacktrace Directory; Resolve NetworkObject List Errors (#24)
* Hide Stacktrace Directory; Resolve NetworkObject List Errors * Fix path & netvar set error
- Loading branch information
Showing
5 changed files
with
91 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
LethalNetworkAPI/Serializable/NetworkBehaviourFormatter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using LethalNetworkAPI.Serializable; | ||
|
||
#if NETSTANDARD2_1 | ||
using OdinSerializer; | ||
|
||
[assembly: RegisterFormatter(typeof(NetworkBehaviourFormatter))] | ||
|
||
namespace LethalNetworkAPI.Serializable; | ||
|
||
|
||
/// <summary> | ||
/// Custom formatter for the <see cref="NetworkBehaviour"/> type. | ||
/// </summary> | ||
public class NetworkBehaviourFormatter : MinimalBaseFormatter<NetworkBehaviour> | ||
{ | ||
private static readonly Serializer<NetworkBehaviourReference> NetworkBehaviourReferenceSerializer = Serializer.Get<NetworkBehaviourReference>(); | ||
|
||
protected override void Read(ref NetworkBehaviour value, IDataReader reader) | ||
{ | ||
value = NetworkBehaviourReferenceSerializer.ReadValue(reader); | ||
} | ||
|
||
protected override void Write(ref NetworkBehaviour value, IDataWriter writer) | ||
{ | ||
NetworkBehaviourReferenceSerializer.WriteValue(value, writer); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using LethalNetworkAPI.Serializable; | ||
|
||
#if NETSTANDARD2_1 | ||
using OdinSerializer; | ||
|
||
[assembly: RegisterFormatter(typeof(NetworkObjectFormatter))] | ||
[assembly: RegisterFormatter(typeof(GameObjectFormatter))] | ||
|
||
namespace LethalNetworkAPI.Serializable; | ||
|
||
/// <summary> | ||
/// Custom formatter for the <see cref="NetworkObject"/> type. | ||
/// </summary> | ||
public class NetworkObjectFormatter : MinimalBaseFormatter<NetworkObject> | ||
{ | ||
private static readonly Serializer<NetworkObjectReference> NetworkObjectReferenceSerializer = Serializer.Get<NetworkObjectReference>(); | ||
|
||
protected override void Read(ref NetworkObject value, IDataReader reader) | ||
{ | ||
value = NetworkObjectReferenceSerializer.ReadValue(reader); | ||
} | ||
|
||
protected override void Write(ref NetworkObject value, IDataWriter writer) | ||
{ | ||
NetworkObjectReferenceSerializer.WriteValue(value, writer); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Custom formatter for the <see cref="GameObject"/> type. | ||
/// </summary> | ||
public class GameObjectFormatter : MinimalBaseFormatter<GameObject> | ||
{ | ||
private static readonly Serializer<NetworkObjectReference> NetworkObjectReferenceSerializer = Serializer.Get<NetworkObjectReference>(); | ||
|
||
protected override void Read(ref GameObject value, IDataReader reader) | ||
{ | ||
value = NetworkObjectReferenceSerializer.ReadValue(reader); | ||
} | ||
|
||
protected override void Write(ref GameObject value, IDataWriter writer) | ||
{ | ||
NetworkObjectReferenceSerializer.WriteValue(value, writer); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters