Exemple #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);
        }
    public void PlayImpact(NetStructs.DetonationResult InteractionResult)
    {
        DetonationResult res = Convert(InteractionResult);

        foreach (ImpactType impact in Impacts)
        {
            if (impact.Detonations.Contains(DetonationResult.Any) || impact.Detonations.Contains(res))
            {
                foreach (ParticleSystem system in impact.ParticlesToPlay)
                {
                    system.Play();
                }
                break;
            }
        }
    }