public override void Serialize(TeleportWriter writer) { base.Serialize(writer); writer.Write(_spawner.SpawnId); writer.Write(_instanceId); _spawner.ServerSidePreSpawnToClient(writer, SpawnedObject, _objectConfig); }
public override void Serialize(TeleportWriter writer) { base.Serialize(writer); writer.Write(_spawnId); writer.Write((ushort)_states.Length); for (int i = 0; i < _states.Length; i++) { _states[i].Serialize(writer); } }
public override void Serialize(TeleportWriter writer) { base.Serialize(writer); writer.Write(_spawner.SpawnId); writer.Write(_instanceId); var despawned = _spawner.GetInstanceById(_instanceId); _spawner.OnServerDespawn(writer, despawned); _spawner.DestroyInstance(despawned); }
public override bool SerializeForClient(TeleportWriter writer, uint clientId) { if (!_spawner.IsSpawnedForClient(_instanceId, clientId)) { return(false); } base.Serialize(writer); writer.Write(_spawner.SpawnId); writer.Write(_instanceId); return(true); }
public override void ServerSidePreSpawnToClient(TeleportWriter writer, GameObject spawned, object instanceConfig) { base.ServerSidePreSpawnToClient(writer, spawned, instanceConfig); var config = (TestSpawnConfig)instanceConfig; writer.Write(Color.green); }
private void SerializeClient(TeleportWriter w) { var seq = _clientDataSeq++; w.Write(seq); _serverMissingSeqs.Add(seq); }
public override void Serialize(TeleportWriter writer) { if (Timestamp < 0) { throw new Exception("Timed message must be serialized after it was called with the Timestamp constructor!"); } writer.Write(Timestamp); base.Serialize(writer); }
public override void Serialize(TeleportWriter writer) { bool didExist = true; if (SpawnedObject == null) { didExist = false; SpawnedObject = _spawner.CreateInstance(); SpawnedObject.transform.position = Position; } base.Serialize(writer); writer.Write(_spawner.SpawnId); writer.Write(_instanceId); writer.Write(Position); if (!didExist) { _spawner.OnServerSpawn(_instanceId, writer, SpawnedObject); } _spawner.ServerSidePreSpawnToClient(writer, SpawnedObject, _objectConfig); }
public override bool SerializeForClient(TeleportWriter writer, uint clientId) { base.Serialize(writer); int stateCount = 0; ITeleportState currentState; using (var subStream = new MemoryStream()) { using (var subWriter = new TeleportWriter(subStream)) { for (int i = 0; i < _states.Length; i++) { currentState = _states[i]; switch (currentState.GetDeliveryTarget()) { case DeliveryTargetType.NoOne: continue; case DeliveryTargetType.Everyone: stateCount++; _states[i].Serialize(subWriter); break; case DeliveryTargetType.PerConnection: if (_states[i].SerializeForConnection(subWriter, clientId)) { stateCount++; } break; } } writer.Write(_spawnId); writer.Write((ushort)stateCount); writer.Write(((MemoryStream)subWriter.BaseStream).ToArray()); } } return(stateCount > 0); }
public void SendMessage <T>(T message) where T : ITeleportMessage { StampMessageIfTimed(message); message.PreSendServer(); switch (message.GetDeliveryTarget()) { case DeliveryTargetType.Everyone: Send(message, message.GetChannelId()); break; case DeliveryTargetType.NoOne: break; case DeliveryTargetType.PerConnection: EndPoint endpoint; MemoryStream stream; bool shouldSend; foreach (var pair in _clientDataById) { endpoint = pair.Value.endpoint; using (stream = new MemoryStream()) { using (var writer = new TeleportWriter(stream)) { writer.Write(message.MsgTypeId); shouldSend = message.PreSendServerForClient(pair.Key) && message.SerializeForClient(writer, pair.Key); } if (shouldSend) { _transport.Send(stream.ToArray(), message.GetChannelId(), endpoint); } } } break; default: throw new Exception("Unknown DeliveryTargetType: " + message.GetDeliveryTarget()); } message.PostSendServer(); }
public virtual void SerializeWithId(TeleportWriter writer) { writer.Write(MsgTypeId); Serialize(writer); }
public override void Serialize(TeleportWriter writer) { base.Serialize(writer); writer.Write(_msgSeq); }
public void Serialize(TeleportWriter writer) { writer.Write(InstanceId); writer.Write(Position, FloatCompressionTypeShort.Short_Two_Decimals); writer.Write(Rotation, FloatCompressionTypeShort.Short_Two_Decimals); }
private void SerializeTimeSyncRequest(TeleportWriter writer) { writer.Write(TeleportMsgTypeIds.TimeSync); writer.Write(LocalTime); }
private void SerializeTimeSyncResponse(TeleportWriter writer, float clientTime) { writer.Write(TeleportMsgTypeIds.TimeSync); writer.Write(clientTime); writer.Write(LocalTime); }