public override void Update() { if (!_tickTimer.TryCycle()) { return; } base.Update(); // In case we disconnected. if (_disposed) { return; } if (!(_time is null)) { _time.Update(); var player = GM.CurrentPlayerBody; var transforms = new PlayerTransformsMessage(player.Head, player.LeftHand, player.RightHand); var timestamped = new Timestamped <PlayerTransformsMessage>(_time.Now, transforms); Server.Send(timestamped); } }
// Update is called once per frame void Update() { if (!Channel.GetNetwork().IsClient()) { DateTime now = new DateTime(); now = DateTime.Now; TimeSpan duration = now - last_clientupdate; if (duration > TimeSpan.FromMilliseconds(100)) { float time = Time.time; last_clientupdate = now; network_data.move_player m = new network_data.move_player(); IDictionaryEnumerator i = Channel.FirstEntity(); while (i.MoveNext()) { GameObject g = (GameObject)i.Value; m.set((int)i.Key, Channel.GetChannel()); m.position = ((GameObject)i.Value).transform.localPosition; m.velocity = ((GameObject)i.Value).GetComponent <ship>().GetVelocity(); m.rotation = ((GameObject)i.Value).transform.localRotation; m.time = time; byte[] data1 = network_utils.nData.Instance.SerializeMsg <network_data.move_player>(m); foreach (KeyValuePair <int, GameObject> gg in ShipList) { gg.Value.GetComponent <channel>().SendToChannel(ref data1); } } } } ServerTime.Update(Time.deltaTime); }
private IEnumerator TickTime() { while (true) { ServerTime.Update(Time.deltaTime); yield return(new WaitForEndOfFrame()); } }