Пример #1
0
        private void SendEntities()
        {
            if (_server == null)
            {
                return;
            }

            var msg = new GenericMessage();

            msg.WriteUnsignedInteger(2);
            msg.WriteUnsignedInteger((ulong)_entities.Count);

            foreach (var entity in _entities.Values)
            {
                msg.WriteGuid(entity.ID);

                msg.WriteFloat(entity.Pos.X);
                msg.WriteFloat(entity.Pos.Y);
                msg.WriteFloat(entity.Pos.Z);

                msg.WriteFloat(entity.LookVec.X);
                msg.WriteFloat(entity.LookVec.Y);
                msg.WriteFloat(entity.LookVec.Z);
            }

            foreach (var ep in _server.RemoteEndPoints)
            {
                _server.SendToAsync(ep, msg);
            }
        }
Пример #2
0
        public void Tick()
        {
            if (client == null)
            {
                return;
            }

            if (SharpCraft.Instance.Player != null)
            {
                var m = new GenericMessage();
                m.WriteUnsignedInteger(1);

                var pos = SharpCraft.Instance.Player.Pos;
                var dir = SharpCraft.Instance.Camera.GetLookVec();

                m.WriteFloat(pos.X);
                m.WriteFloat(pos.Y);
                m.WriteFloat(pos.Z);

                m.WriteFloat(dir.X);
                m.WriteFloat(dir.Y);
                m.WriteFloat(dir.Z);

                client?.Send(m);
            }
        }