idk even stuff
parent
70dcf597c4
commit
21859b6349
|
|
@ -1,6 +1,6 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public abstract class NetworkComponent : MonoBehaviour
|
public abstract class NetworkComponent : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +24,6 @@ namespace VelNetUnity
|
||||||
networkObject.SendBytesToGroup(this, group, message, reliable);
|
networkObject.SendBytesToGroup(this, group, message, reliable);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is called by <see cref="NetworkObject"/> when messages are received for this component
|
/// This is called by <see cref="NetworkObject"/> when messages are received for this component
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is a base class for all objects that a player can instantiated/owned
|
/// This is a base class for all objects that a player can instantiated/owned
|
||||||
|
|
@ -43,7 +43,7 @@ namespace VelNetUnity
|
||||||
|
|
||||||
public void SendBytesToGroup(NetworkComponent component, string group, byte[] message, bool reliable = true)
|
public void SendBytesToGroup(NetworkComponent component, string group, byte[] message, bool reliable = true)
|
||||||
{
|
{
|
||||||
if (owner == null || !owner.isLocal)
|
if (!IsMine)
|
||||||
{
|
{
|
||||||
Debug.LogError("Can't send message if owner is null or not local", this);
|
Debug.LogError("Can't send message if owner is null or not local", this);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a network player
|
/// Represents a network player
|
||||||
|
|
@ -53,10 +53,11 @@ namespace VelNetUnity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// These are generally things that come from the "owner" and should be enacted locally, where appropriate
|
||||||
|
/// </summary>
|
||||||
public void HandleMessage(VelNetManager.Message m)
|
public void HandleMessage(VelNetManager.Message m)
|
||||||
{
|
{
|
||||||
//these are generally things that come from the "owner" and should be enacted locally, where appropriate
|
|
||||||
//we need to parse the message
|
//we need to parse the message
|
||||||
|
|
||||||
//types of messages
|
//types of messages
|
||||||
|
|
@ -104,7 +105,7 @@ namespace VelNetUnity
|
||||||
break; //we already have this one, ignore
|
break; //we already have this one, ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
VelNetManager.InstantiateNetworkObject(networkId, prefabName, this);
|
VelNetManager.SomebodyInstantiatedNetworkObject(networkId, prefabName, this);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public abstract class NetworkSerializedObject : NetworkComponent
|
public abstract class NetworkSerializedObject : NetworkComponent
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public static class BinaryWriterExtensions
|
public static class BinaryWriterExtensions
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A simple class that will sync the position and rotation of a network object
|
/// A simple class that will sync the position and rotation of a network object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AddComponentMenu("VelNetUnity/VelNet Sync Transform")]
|
[AddComponentMenu("VelNet/VelNet Sync Transform")]
|
||||||
public class SyncTransform : NetworkSerializedObject
|
public class SyncTransform : NetworkSerializedObject
|
||||||
{
|
{
|
||||||
public Vector3 targetPosition;
|
public Vector3 targetPosition;
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,9 @@ using System.Threading;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
[AddComponentMenu("VelNetUnity/VelNet Manager")]
|
[AddComponentMenu("VelNet/VelNet Manager")]
|
||||||
public class VelNetManager : MonoBehaviour
|
public class VelNetManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
public enum MessageType
|
public enum MessageType
|
||||||
|
|
@ -332,8 +332,7 @@ namespace VelNetUnity
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Get a stream object for reading
|
// Get a stream object for reading
|
||||||
using (NetworkStream stream = socketConnection.GetStream())
|
using NetworkStream stream = socketConnection.GetStream();
|
||||||
{
|
|
||||||
int length;
|
int length;
|
||||||
// Read incomming stream into byte arrary.
|
// Read incomming stream into byte arrary.
|
||||||
while ((length = stream.Read(bytes, 0, bytes.Length)) != 0)
|
while ((length = stream.Read(bytes, 0, bytes.Length)) != 0)
|
||||||
|
|
@ -366,7 +365,6 @@ namespace VelNetUnity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
catch (Exception socketException)
|
catch (Exception socketException)
|
||||||
|
|
@ -464,7 +462,7 @@ namespace VelNetUnity
|
||||||
if (stream.CanWrite)
|
if (stream.CanWrite)
|
||||||
{
|
{
|
||||||
// Convert string message to byte array.
|
// Convert string message to byte array.
|
||||||
clientMessage = clientMessage + "\n"; //append a new line to delineate the message
|
clientMessage += "\n"; // append a new line to delineate the message
|
||||||
byte[] clientMessageAsByteArray = Encoding.ASCII.GetBytes(clientMessage);
|
byte[] clientMessageAsByteArray = Encoding.ASCII.GetBytes(clientMessage);
|
||||||
// Write byte array to socketConnection stream.
|
// Write byte array to socketConnection stream.
|
||||||
stream.Write(clientMessageAsByteArray, 0, clientMessageAsByteArray.Length);
|
stream.Write(clientMessageAsByteArray, 0, clientMessageAsByteArray.Length);
|
||||||
|
|
@ -538,9 +536,12 @@ namespace VelNetUnity
|
||||||
newObject.prefabName = prefabName;
|
newObject.prefabName = prefabName;
|
||||||
newObject.owner = localPlayer;
|
newObject.owner = localPlayer;
|
||||||
instance.objects.Add(newObject.networkId, newObject);
|
instance.objects.Add(newObject.networkId, newObject);
|
||||||
|
|
||||||
|
// only sent to others, as I already instantiated this. Nice that it happens immediately.
|
||||||
|
instance.SendTo(MessageType.OTHERS, "7," + newObject.networkId + "," + prefabName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InstantiateNetworkObject(string networkId, string prefabName, NetworkPlayer owner)
|
public static void SomebodyInstantiatedNetworkObject(string networkId, string prefabName, NetworkPlayer owner)
|
||||||
{
|
{
|
||||||
NetworkObject prefab = instance.prefabs.Find(p => p.name == prefabName);
|
NetworkObject prefab = instance.prefabs.Find(p => p.name == prefabName);
|
||||||
if (prefab == null) return;
|
if (prefab == null) return;
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Added to the same object as DissonanceComms component. Only one in the scene.
|
/// Added to the same object as DissonanceComms component. Only one in the scene.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[RequireComponent(typeof(DissonanceComms))]
|
[RequireComponent(typeof(DissonanceComms))]
|
||||||
[AddComponentMenu("VelNetUnity/Dissonance/VelNet Comms Network")]
|
[AddComponentMenu("VelNet/Dissonance/VelNet Comms Network")]
|
||||||
public class VelCommsNetwork : MonoBehaviour, ICommsNetwork
|
public class VelCommsNetwork : MonoBehaviour, ICommsNetwork
|
||||||
{
|
{
|
||||||
public ConnectionStatus Status => manager.connected ? ConnectionStatus.Connected : ConnectionStatus.Disconnected;
|
public ConnectionStatus Status => manager.connected ? ConnectionStatus.Connected : ConnectionStatus.Disconnected;
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,12 @@ using System.Linq;
|
||||||
using Dissonance;
|
using Dissonance;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This should be added to your player object
|
/// This should be added to your player object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AddComponentMenu("VelNetUnity/Dissonance/VelNet Dissonance Player")]
|
[AddComponentMenu("VelNet/Dissonance/VelNet Dissonance Player")]
|
||||||
public class VelNetDissonancePlayer : NetworkComponent, IDissonancePlayer
|
public class VelNetDissonancePlayer : NetworkComponent, IDissonancePlayer
|
||||||
{
|
{
|
||||||
private VelCommsNetwork comms;
|
private VelCommsNetwork comms;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public class NetworkGUI : MonoBehaviour
|
public class NetworkGUI : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace VelNetUnity
|
namespace VelNet
|
||||||
{
|
{
|
||||||
public class PlayerController : NetworkSerializedObject
|
public class PlayerController : NetworkSerializedObject
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using VelNetUnity;
|
using VelNet;
|
||||||
|
|
||||||
public class VelNetMan : MonoBehaviour
|
public class VelNetMan : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "VelNetUnity",
|
"name": "VelNet",
|
||||||
"rootNamespace": "VelNetUnity",
|
"rootNamespace": "VelNet",
|
||||||
"references": [],
|
"references": [],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "edu.uga.engr.vel.velnetunity",
|
"name": "edu.uga.engr.vel.velnet",
|
||||||
"displayName": "VelNetUnity",
|
"displayName": "VelNet",
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"unity": "2019.1",
|
"unity": "2019.1",
|
||||||
"description": "A custom networking library for Unity.",
|
"description": "A custom networking library for Unity.",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue