Ejemplo n.º 1
0
        /// <summary>
        /// Decode network data.
        /// </summary>
        /// <param name="h"></param>
        /// <param name="br"></param>
        public override void Decode(Header h, BinaryReader br)
        {
            base.Decode(h, br);
            velocity.Set(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
            locationInWorldCoordinates.Decode(br);

            #if DIS_VERSION_7
            // Handle the descriptor based on the PDU protocol version.
            if (ProtocolVersion != ProtocolVersion.IEEE_1278_1_2012)
            {
                if (descriptor == null || !(descriptor is MunitionDescriptor))
                {
                    descriptor = new MunitionDescriptor();
                }
            }
            else
            {
                // The DTI field indicates if the descriptor is a Munition, Ependable or Explosion.
                if (DTI == DetonationTypeIndicator.Munition)
                {
                    if (descriptor == null || !(descriptor is MunitionDescriptor))
                    {
                        descriptor = new MunitionDescriptor();
                    }
                }
                if (DTI == DetonationTypeIndicator.Expendable)
                {
                    if (descriptor == null || !(descriptor is ExpendableDescriptor))
                    {
                        descriptor = new ExpendableDescriptor();
                    }
                }
                else
                {
                    if (descriptor == null || !(descriptor is ExplosionDescriptor))
                    {
                        descriptor = new ExplosionDescriptor();
                    }
                }
            }
            #else
            // Before DIS 7 the only descriptor was the BurstDescriptor aka MunitionDescriptor.
            if (descriptor == null)
            {
                descriptor = new MunitionDescriptor();
            }
            #endif

            descriptor.Decode(br);
            locationInEntityCoordinates.Set(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
            detonationResult = ( DetonationResult )br.ReadByte();
            byte numOfArticulationParams = br.ReadByte();
            br.BaseStream.Seek(2, SeekOrigin.Current);   // Skip padding
            variableParameters.Decode(br, numOfArticulationParams);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Decode network data.
        /// </summary>
        /// <param name="h"></param>
        /// <param name="br"></param>
        public override void Decode(Header h, BinaryReader br)
        {
            base.Decode(h, br);
            fireMissionIndex = ( int )br.ReadUInt32();
            locationInWorldCoordinates.Decode(br);

            #if DIS_VERSION_7
            // Handle the descriptor based on the PDU protocol version.
            if (ProtocolVersion != ProtocolVersion.IEEE_1278_1_2012)
            {
                if (descriptor == null || !(descriptor is MunitionDescriptor))
                {
                    descriptor = new MunitionDescriptor();
                }
            }
            else
            {
                // The FTI field indicates if the descriptor is a Munition or Ependable
                if (FTI == FireTypeIndicator.Munition)
                {
                    if (descriptor == null || !(descriptor is MunitionDescriptor))
                    {
                        descriptor = new  MunitionDescriptor();
                    }
                }
                else
                {
                    if (descriptor == null || !(descriptor is ExpendableDescriptor))
                    {
                        descriptor = new ExpendableDescriptor();
                    }
                }
            }
            #else
            // Before DIS 7 the only descriptor was the BurstDescriptor aka MunitionDescriptor.
            if (descriptor == null)
            {
                descriptor = new MunitionDescriptor();
            }
            #endif

            descriptor.Decode(br);
            velocity.Set(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
            range = br.ReadSingle();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Decode network data.
        /// </summary>
        /// <param name="h"></param>
        /// <param name="br"></param>
        public virtual void Decode(Header h, BinaryReader br)
        {
            // Copy header values.
            Clone(h);

            entityID.Decode(br);
            forceID = ( ForceID )br.ReadByte();
            byte numOfArticulationParams = br.ReadByte();

            entityType.Decode(br);
            alternateEntityType.Decode(br);
            linearVelocity.Set(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
            location.Decode(br);
            orientation.Set(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
            appearance.Decode(br);
            deadReckoningParameter.Decode(br);
            marking.Decode(br);
            capabilities.Decode(br);
            variableParameters.Decode(br, numOfArticulationParams);
        }