Example #1
0
        // Takes part of the full data and disassembles it into a NetworkEvent
        public static NetworkEvent DisassembleMessage(byte[] message, int startIndex, out int newIndex)
        {
            ushort              objId           = DeserializeUShort(message, startIndex);
            NetworkEventType    netEventType    = (NetworkEventType)DeserializeUShort(message, startIndex + 2);
            NetworkSubeventType netSubeventType = (NetworkSubeventType)message[startIndex + 4];
            object              data            = null;

            newIndex = 1;

            switch (netEventType)
            {
            case NetworkEventType.TriggerEvent:
                break;

            case NetworkEventType.UpdatePosition:
                data     = DeserializeTransform(message, startIndex + 5);
                newIndex = 41;
                break;

            default:
                break;
            }

            NetworkEvent returnVal = new NetworkEvent(objId, netEventType, netSubeventType, data);

            return(returnVal);
        }
Example #2
0
 public NetworkEvent(ushort networkedObjectId, NetworkEventType networkEventType, NetworkSubeventType networkSubeventType, object data)
 {
     this.destNetId           = (NetworkIdentity)NetworkSerializer.GetNetworkedObjects()[networkedObjectId];
     this.networkEventType    = networkEventType;
     this.networkSubeventType = networkSubeventType;
     this.data = data;
 }
Example #3
0
        // Creates a message based on the event type
        public static void AssembleMessage(ushort netObjectId, NetworkEventType netEventType, NetworkSubeventType netSubeventType, object data)
        {
            byte[] message = null;

            switch (netEventType)
            {
            case NetworkEventType.TriggerEvent:
                break;

            case NetworkEventType.UpdatePosition:
                message = new byte[53];
                SerializeUShort(netObjectId, message, 0);
                SerializeUShort((ushort)netEventType, message, 2);
                message[4] = (byte)netSubeventType;
                Transform typedObject = (Transform)data;
                SerializeTransform(typedObject, message, 5);
                break;
            }

            NetworkCommunicator.UpdateSendMessage(message);
        }
Example #4
0
 public void SendDataOverNetwork(NetworkEventType eventType, NetworkSubeventType subeventType, object data)
 {
     NetworkSerializer.AssembleMessage(networkId, eventType, subeventType, data);
 }