internal void DestroyObjectOn(SyncByReference obj, EndpointId dest) { if (dest == NetworkComponent.Id) { return; } if (!MyAPIGateway.Session.IsDecider()) { if (dest != NetworkComponent.ServerID) { Log(MyLogSeverity.Warning, "Client tried to instruct another client to destroy"); return; } if (obj.SyncDirection != SyncDirection.ClientToServer) { Log(MyLogSeverity.Warning, "Client tried to instruction a server to client object to be destroyed"); return; } } var packet = m_network.AllocatePacket <DestroySyncObjectPacket>(); packet.ObjectID = obj.SyncObjectID; if (MyAPIGateway.Session.IsDecider()) { m_network.SendMessage(packet, dest); } else { m_network.SendMessageToServer(packet); } m_network.ReturnPacket(packet); }
internal void AllocateObjectOn(SyncByReference obj, EndpointId dest) { if (dest == NetworkComponent.Id) { return; } if (!MyAPIGateway.Session.IsDecider()) { if (dest != NetworkComponent.ServerID) { Log(MyLogSeverity.Warning, "Client tried to instruct another client to allocate"); return; } if (obj.SyncDirection != SyncDirection.ClientToServer) { Log(MyLogSeverity.Warning, "Client tried to instruction a server to client object to be allocated"); return; } } var packet = m_network.AllocatePacket <AllocateSyncObjectPacket>(); packet.ObjectID = obj.SyncObjectID; packet.ObjectType = obj.TypeInfo.TypeID; packet.SyncDirection = obj.SyncDirection; packet.Stream.ReadHead = packet.Stream.WriteHead = 0; obj.WriteChanges(packet.Stream); if (MyAPIGateway.Session.IsDecider()) { m_network.SendMessage(packet, dest); } else { m_network.SendMessageToServer(packet); } m_network.ReturnPacket(packet); }
public void QueueUpdate(SyncByReference instance) { lock (m_updateQueue) m_updateQueue.Enqueue(instance); }