Ejemplo n.º 1
0
        public GunOrient[] GunOrients; //4 bytes each (half floats)

        public void WriteTo(ref BitWriter message)
        {
            message.PutInt(ID);
            message.PutBool(Hidden);
            if (Hidden)
            {
                return;
            }
            message.PutUInt((uint)CruiseThrust, 2); //2 bits
            message.PutBool(HasPosition);
            message.PutBool(HasOrientation);
            message.PutBool(HasHealth);
            message.PutBool(HasGuns);
            message.PutBool(DockingLights);
            if (HasPosition)
            {
                message.PutVector3(Position);
                message.PutByte(EngineThrottlePct);
            }
            if (HasOrientation)
            {
                message.PutQuaternion(Orientation);
            }
            if (CruiseThrust == CruiseThrustState.CruiseCharging)
            {
                message.PutByte(CruiseChargePct);
            }
            if (HasHealth)
            {
                message.PutBool(HasShield);
                message.PutBool(HasHull);
                message.PutBool(HasParts);
                if (HasParts)
                {
                    message.PutByte((byte)Parts.Length);
                    for (int i = 0; i < Parts.Length; i++)
                    {
                        message.PutUInt(Parts[i], 3);
                    }
                }
                if (HasShield)
                {
                    message.PutInt(ShieldHp);            //4 bytes
                }
                if (HasHull)
                {
                    message.PutInt(HullHp);          //4 bytes
                }
            }
            if (HasGuns)
            {
                message.PutByte((byte)GunOrients.Length);
                foreach (var g in GunOrients)
                {
                    g.WriteTo(ref message);
                }
            }
        }
Ejemplo n.º 2
0
 public void WriteTo(ref BitWriter message)
 {
     //8 bytes each
     message.PutUInt(Hardpoint, 32);
     message.PutRadiansQuantized(AnglePitch);
     message.PutRadiansQuantized(AngleRot);
 }
Ejemplo n.º 3
0
        public void WriteContents(NetDataWriter message)
        {
            message.Put(Tick);
            var writer = new BitWriter();

            if (Updates.Length > 255)
            {
                throw new Exception("Too many updates for net packet");
            }
            writer.PutUInt((uint)Updates.Length, 8);
            foreach (var p in Updates)
            {
                p.WriteTo(ref writer);
            }
            writer.WriteToPacket(message);
        }