Exemple #1
0
        protected virtual void UpdateGuidePos(long now)
        {
            if (now < guidedNextUpdate)
            {
                return;
            }

            Vec3f          pos = this.Position;
            Angles         ang = this.Angles;
            VobEnvironment env = this.Environment;

            if (now - guidedNextUpdate < TimeSpan.TicksPerSecond)
            {
                // nothing really changed, only update every second
                if (pos.GetDistance(guidedLastPos) < MinPositionDistance &&
                    !ang.DifferenceIsBigger(guidedLastAng, MinAnglesDifference) &&
                    env == guidedLastEnv)
                {
                    return;
                }
            }

            guidedLastPos = pos;
            guidedLastAng = ang;
            guidedLastEnv = env;

            Messages.WritePosDirMessage(this, pos, ang, env);

            guidedNextUpdate = now + PosUpdateInterval;

            //this.ScriptObject.OnPosChanged();
        }
Exemple #2
0
            public static void WritePosDirMessage(GuidedVob vob, Vec3f pos, Angles ang, VobEnvironment env)
            {
                PacketWriter stream = GameClient.SetupStream(ClientMessages.GuidedVobMessage);

                stream.Write((ushort)vob.ID);
                stream.WriteCompressedPosition(pos);
                stream.WriteCompressedAngles(ang);

                // compress environment
                int bitfield = env.InAir ? 0x8000 : 0;

                bitfield |= (int)(env.WaterDepth * 0x7F) << 8;
                bitfield |= (int)(env.WaterLevel * 0xFF);
                stream.Write((short)bitfield);

                GameClient.Send(stream, NetPriority.Low, NetReliability.Unreliable);
            }