From 18388088603f03fe87861a62fb6d5d1cbd762cf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Albin=20Cor=C3=A9n?= <2108U9@gmail.com>
Date: Tue, 17 Apr 2018 19:37:12 +0200
Subject: [PATCH] Added Targeted SyncedVars that only sync to the owner of a
object
---
MLAPI/Attributes/SyncedVar.cs | 4 +
MLAPI/Data/SyncedVarField.cs | 18 +
MLAPI/MLAPI.csproj | 1 +
.../MonoBehaviours/Core/NetworkedBehaviour.cs | 764 ++++++++++++------
.../Core/InternalMessageHandler.Receive.cs | 4 +-
5 files changed, 544 insertions(+), 247 deletions(-)
create mode 100644 MLAPI/Data/SyncedVarField.cs
diff --git a/MLAPI/Attributes/SyncedVar.cs b/MLAPI/Attributes/SyncedVar.cs
index d88fa2c..19e7111 100644
--- a/MLAPI/Attributes/SyncedVar.cs
+++ b/MLAPI/Attributes/SyncedVar.cs
@@ -12,5 +12,9 @@ namespace MLAPI.Attributes
/// The method name to invoke when the SyncVar get's updated.
///
public string hook;
+ ///
+ /// If true, the syncedVar will only be synced to the owner.
+ ///
+ public bool target;
}
}
diff --git a/MLAPI/Data/SyncedVarField.cs b/MLAPI/Data/SyncedVarField.cs
new file mode 100644
index 0000000..1d662a1
--- /dev/null
+++ b/MLAPI/Data/SyncedVarField.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+
+namespace MLAPI.Data
+{
+ internal class SyncedVarField
+ {
+ internal FieldInfo FieldInfo;
+ internal FieldType FieldType;
+ internal object FieldValue;
+ internal MethodInfo HookMethod;
+ internal bool Dirty;
+ internal bool Target;
+ }
+}
diff --git a/MLAPI/MLAPI.csproj b/MLAPI/MLAPI.csproj
index 8e56c79..86817ba 100644
--- a/MLAPI/MLAPI.csproj
+++ b/MLAPI/MLAPI.csproj
@@ -73,6 +73,7 @@
+
diff --git a/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs b/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs
index e8840ff..31f37e9 100644
--- a/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs
+++ b/MLAPI/MonoBehaviours/Core/NetworkedBehaviour.cs
@@ -202,13 +202,8 @@ namespace MLAPI.MonoBehaviours.Core
}
#region SYNC_VAR
- private List syncedFields = new List();
- internal List syncedFieldTypes = new List();
- private List