public bool Write(ref UdpBitStream bitstream, Frame frame)
        {
            ElementFrame      e         = frames[frame.frameid];
            CompressedElement compXform = e.compXform;

            Compress(compXform);
            e.xform = Decompress(compXform);             // Localized;

            /// Experimental - Apply the outgoing lossy values to the GhostGO so owner/authority of object can use it to replicate lossy events like weapon fire.
            if (ghostGO)
            {
                Apply(e.xform, ghostGO);
            }

            if (!nstElement.Enabled)
            {
                bitstream.WriteBool(false);
                return(false);
            }

            bool forceUpdate = IsUpdateForced(frame);

            // For frames between forced updates, we need to first send a flag bit for if this element is being sent
            if (!forceUpdate)
            {
                bool hasChanged = !compXform.Equals(lastSentCompressed) && sendCullMask.OnChanges();
                bitstream.WriteBool(hasChanged);

                // if no changes have occured we are done.
                if (!hasChanged)
                {
                    return(false);
                }
            }
            else
            {
                bitstream.WriteBool(true);
            }

            crusher.Write(compXform, bitstream.Data, ref bitstream.ptr);

            lastSentCompressed.CopyFrom(compXform);
            lastSentTransform = e.xform;

            return(true);
        }
Exemplo n.º 2
0
        public bool Write(ref UdpBitStream bitstream, Frame frame)
        {
            ElementFrame e = frames[frame.frameid];

            e.compXform = Compress();
            e.xform     = Localized;

            CompressedElement newComp = e.compXform;

            bool forceUpdate = IsUpdateForced(frame);

            // For frames between forced updates, we need to first send a flag bit for if this element is being sent
            if (!forceUpdate)
            {
                bool hasChanged = !CompressedElement.Compare(newComp, lastSentCompressed) && sendCullMask.OnChanges();
                bitstream.WriteBool(hasChanged);

                // if no changes have occured we are done.
                if (!hasChanged)
                {
                    return(false);
                }
            }

            crusher.Write(e.compXform, bitstream.Data, ref bitstream.ptr);

            lastSentCompressed = newComp;
            lastSentTransform  = e.xform;

            return(true);
        }