Exemple #1
0
        public static PackedShipUpdate ReadFrom(ref BitReader message)
        {
            var p = new PackedShipUpdate();

            p.ID     = (int)message.GetUInt(32);
            p.Hidden = message.GetBool();
            if (p.Hidden)
            {
                return(p);
            }
            p.CruiseThrust   = (CruiseThrustState)message.GetUInt(2);
            p.HasPosition    = message.GetBool();
            p.HasOrientation = message.GetBool();
            p.HasHealth      = message.GetBool();
            p.HasGuns        = message.GetBool();
            p.DockingLights  = message.GetBool();
            if (p.HasPosition)
            {
                p.Position          = message.GetVector3();
                p.EngineThrottlePct = message.GetByte();
            }
            if (p.HasOrientation)
            {
                p.Orientation = message.GetQuaternion();
            }
            if (p.HasHealth)
            {
                p.HasShield = message.GetBool();
                p.HasHull   = message.GetBool();
                p.HasParts  = message.GetBool();
                if (p.HasParts)
                {
                    p.Parts = new byte[message.GetByte()];
                    for (int i = 0; i < p.Parts.Length; i++)
                    {
                        p.Parts[i] = (byte)message.GetUInt(3);
                    }
                }
                if (p.HasShield)
                {
                    p.ShieldHp = message.GetFloat();
                }
                if (p.HasHull)
                {
                    p.HullHp = message.GetInt();
                }
            }
            if (p.HasGuns)
            {
                p.GunOrients = new GunOrient[message.GetByte()];
                for (int i = 0; i < p.GunOrients.Length; i++)
                {
                    p.GunOrients[i].ReadIn(ref message);
                }
            }
            return(p);
        }
Exemple #2
0
        public static object Read(NetPacketReader message)
        {
            var p = new ObjectUpdatePacket();

            p.Tick = message.GetUInt();
            var pack        = new BitReader(message.GetRemainingBytes(), 0);
            var updateCount = pack.GetUInt(8);

            p.Updates = new PackedShipUpdate[updateCount];
            for (int i = 0; i < p.Updates.Length; i++)
            {
                p.Updates[i] = PackedShipUpdate.ReadFrom(ref pack);
            }
            return(p);
        }
Exemple #3
0
 public void ReadIn(ref BitReader message)
 {
     Hardpoint  = message.GetUInt();
     AnglePitch = message.GetRadiansQuantized();
     AngleRot   = message.GetRadiansQuantized();
 }