예제 #1
0
        public T Allocate <T>() where T : ISyncByReference
        {
            // Rexxar will hate me
            var objectID = (ulong)MyRandom.Instance.NextLong() ^ NetworkComponent.Id;
            var result   = SyncObjectFactory.CreateSyncByReference(typeof(T), this,
                                                                   MyAPIGateway.Session.IsDecider() ? SyncDirection.ServerToClient : SyncDirection.ClientToServer, objectID);

            result.StartReplication(NetworkComponent.Id);
            // this works, but direct cast doesn't?
            return((T)(ISyncByReference)result);
        }
예제 #2
0
        private void HandlePacket(AllocateSyncObjectPacket packet)
        {
            if (m_objects.ContainsKey(packet.ObjectID))
            {
                Log(MyLogSeverity.Warning, "Someone requested we allocate something already allocated.  ID {0}", packet.ObjectID);
                return;
            }
            var result = SyncObjectFactory.CreateSyncByReference(packet.ObjectType, this, packet.SyncDirection, packet.ObjectID);

            result.StartReplication(NetworkComponent.Id);
            result.StartReplication(packet.Source);
            m_objects[result.SyncObjectID] = result;
            result.ReadChanges(packet.Stream);
        }
예제 #3
0
 public static void RegisterAll()
 {
     SyncObjectFactory.Register <NetworkISyncByReferenceImpl>(typeof(Equinox.Utils.Network.ISyncByReference));
 }