Esempio n. 1
0
        public ReplicatedObject Instantiate(
            ObjectType type,
            ConnectionId ownerConnectionId,
            Vector3?position    = null,
            Quaternion?rotation = null)
        {
            var objectId = RequestObjectId();
            var role     = ObjectRole.Authority | ((ownerConnectionId == ConnectionId.Self)
                    ? ObjectRole.Owner
                    : ObjectRole.Nobody);

            return(_store.Instantiate(type, role, objectId, ownerConnectionId, position, rotation));
        }
Esempio n. 2
0
 public static Action <MessageMetaData, BasicMessage.CreateObject, NetBuffer> CreateObject(
     ObjectMessageParser messageParser,
     ReplicatedObjectStore objectStore)
 {
     return((metadata, message, reader) => {
         var instance = objectStore.Instantiate(message.ObjectType, message.ObjectRole,
                                                message.ObjectId, metadata.ConnectionId, message.Position, message.Rotation);
         var bytesRead = 0;
         while (bytesRead < message.AdditionalData.WriterPosition())
         {
             var objectMessage = messageParser.Parse(message.AdditionalData);
             bytesRead = message.AdditionalData.ReaderPosition();
             objectStore.DispatchMessage(metadata.ConnectionId, message.ObjectId, objectMessage,
                                         new SequenceNumber(1), metadata.Latency);
         }
         objectStore.Activate(instance);
     });
 }