diff --git a/Assets/Scripts/Controls/PlayerController.cs b/Assets/Scripts/Controls/PlayerController.cs
index 2cd517e..3cbd41f 100644
--- a/Assets/Scripts/Controls/PlayerController.cs
+++ b/Assets/Scripts/Controls/PlayerController.cs
@@ -4,6 +4,7 @@ using Cyber.Console;
using Cyber.Networking.Clientside;
using Cyber.Networking;
using Cyber.Networking.Messages;
+using Cyber.Entities;
namespace Cyber.Controls {
@@ -56,7 +57,7 @@ namespace Cyber.Controls {
if (LookingAt != null && (LookingAt.transform.position - Character.GetPosition()).magnitude < Character.InteractionDistance) {
LookingAt.Interact(Character);
if (LookingAt.GetInteractableSyncdata().PublicInteractions) {
- Client.Send(PktType.Interact, new InteractionPkt(LookingAt.ID));
+ Client.Send(PktType.Interact, new InteractionPkt(LookingAt.ID, InteractionType.Press));
}
}
}
diff --git a/Assets/Scripts/Entities/InteractionType.cs b/Assets/Scripts/Entities/InteractionType.cs
new file mode 100644
index 0000000..3d20b64
--- /dev/null
+++ b/Assets/Scripts/Entities/InteractionType.cs
@@ -0,0 +1,12 @@
+
+namespace Cyber.Entities {
+
+ ///
+ /// Describes the type of interaction being made.
+ ///
+ public enum InteractionType : byte {
+
+ Press, Release, Enter, Exit
+
+ }
+}
diff --git a/Assets/Scripts/Entities/InteractionType.cs.meta b/Assets/Scripts/Entities/InteractionType.cs.meta
new file mode 100644
index 0000000..57a44b8
--- /dev/null
+++ b/Assets/Scripts/Entities/InteractionType.cs.meta
@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: d4438a8b75336fd46ab611ac2f2e745f
+timeCreated: 1494542205
+licenseType: Free
+MonoImporter:
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Entities/Spawner.cs b/Assets/Scripts/Entities/Spawner.cs
index 66c7e9c..555ca25 100644
--- a/Assets/Scripts/Entities/Spawner.cs
+++ b/Assets/Scripts/Entities/Spawner.cs
@@ -54,6 +54,10 @@ namespace Cyber.Entities {
return Spawned;
}
+ ///
+ /// Removes the gameobject that was given as an argument from the world.
+ ///
+ /// Gameobject to be removed.
public void Remove(GameObject gameObject) {
SyncDB.RemoveEntity(gameObject);
Destroy(gameObject);
diff --git a/Assets/Scripts/Networking/Messages/InteractionPkt.cs b/Assets/Scripts/Networking/Messages/InteractionPkt.cs
index 63cf651..ddfa02e 100644
--- a/Assets/Scripts/Networking/Messages/InteractionPkt.cs
+++ b/Assets/Scripts/Networking/Messages/InteractionPkt.cs
@@ -1,4 +1,5 @@
+using Cyber.Entities;
using UnityEngine.Networking;
namespace Cyber.Networking.Messages {
@@ -18,12 +19,19 @@ namespace Cyber.Networking.Messages {
///
public int OwnerSyncBaseID;
+ ///
+ /// The interaction type that was made.
+ ///
+ public InteractionType InteractionType;
+
///
/// Creates an InteraktionPkt, which contains the message "someone interacted".
///
/// The Sync Base ID of the interacted thing.
- public InteractionPkt(int syncBaseID) {
+ /// The type of interaction that was made.
+ public InteractionPkt(int syncBaseID, InteractionType interactionType) {
InteractSyncBaseID = syncBaseID;
+ InteractionType = interactionType;
}
///
@@ -38,6 +46,7 @@ namespace Cyber.Networking.Messages {
public override void Deserialize(NetworkReader reader) {
InteractSyncBaseID = reader.ReadInt32();
OwnerSyncBaseID = reader.ReadInt32();
+ InteractionType = (InteractionType) reader.ReadByte();
}
///
@@ -47,6 +56,7 @@ namespace Cyber.Networking.Messages {
public override void Serialize(NetworkWriter writer) {
writer.Write(InteractSyncBaseID);
writer.Write(OwnerSyncBaseID);
+ writer.Write((byte) InteractionType);
}
}
diff --git a/Assets/Scripts/Networking/Serverside/ServerSyncHandler.cs b/Assets/Scripts/Networking/Serverside/ServerSyncHandler.cs
index e95ae08..1ff5cc5 100644
--- a/Assets/Scripts/Networking/Serverside/ServerSyncHandler.cs
+++ b/Assets/Scripts/Networking/Serverside/ServerSyncHandler.cs
@@ -44,6 +44,10 @@ namespace Cyber.Networking.Serverside {
// Disregard the package, it's too old.
}
+ ///
+ /// Clears the 'LastSyncIDReceived' from the given connection id, making sure that any new connections re-using this connectionID will be properly synced.
+ ///
+ /// The connectionID to be cleared.
public void ClearConnectionFromSyncDict(int connectionID) {
LastSyncIDReceived.Remove(connectionID);
}