示例#1
0
        static entity_t[] _TempEntities = new entity_t[MAX_TEMP_ENTITIES]; // cl_temp_entities[MAX_TEMP_ENTITIES]

        #endregion Fields

        #region Methods

        // CL_InitTEnts
        static void InitTempEntities()
        {
            _SfxWizHit =  Sound.PrecacheSound ("wizard/hit.wav");
            _SfxKnigtHit = Sound.PrecacheSound ("hknight/hit.wav");
            _SfxTink1 = Sound.PrecacheSound ("weapons/tink1.wav");
            _SfxRic1 = Sound.PrecacheSound ("weapons/ric1.wav");
            _SfxRic2 = Sound.PrecacheSound ("weapons/ric2.wav");
            _SfxRic3 = Sound.PrecacheSound ("weapons/ric3.wav");
            _SfxRExp3 = Sound.PrecacheSound ("weapons/r_exp3.wav");

            for (int i = 0; i < _TempEntities.Length; i++)
                _TempEntities[i] = new entity_t();

            for (int i = 0; i < _Beams.Length; i++)
                _Beams[i] = new beam_t();
        }
示例#2
0
        private static sfx_t _SfxRExp3;                                            // cl_sfx_r_exp3

        // CL_InitTEnts
        private static void InitTempEntities()
        {
            _SfxWizHit   = snd.PrecacheSound("wizard/hit.wav");
            _SfxKnigtHit = snd.PrecacheSound("hknight/hit.wav");
            _SfxTink1    = snd.PrecacheSound("weapons/tink1.wav");
            _SfxRic1     = snd.PrecacheSound("weapons/ric1.wav");
            _SfxRic2     = snd.PrecacheSound("weapons/ric2.wav");
            _SfxRic3     = snd.PrecacheSound("weapons/ric3.wav");
            _SfxRExp3    = snd.PrecacheSound("weapons/r_exp3.wav");

            for (int i = 0; i < _TempEntities.Length; i++)
            {
                _TempEntities[i] = new entity_t();
            }

            for (int i = 0; i < _Beams.Length; i++)
            {
                _Beams[i] = new beam_t();
            }
        }
示例#3
0
        /// <summary>
        /// CL_ParseBeam
        /// </summary>
        private static void ParseBeam(model_t m)
        {
            int ent = net.Reader.ReadShort();

            Vector3 start = net.Reader.ReadCoords();
            Vector3 end   = net.Reader.ReadCoords();

            // override any beam with the same entity
            for (int i = 0; i < MAX_BEAMS; i++)
            {
                beam_t b = _Beams[i];
                if (b.entity == ent)
                {
                    b.entity  = ent;
                    b.model   = m;
                    b.endtime = (float)(cl.time + 0.2);
                    b.start   = start;
                    b.end     = end;
                    return;
                }
            }

            // find a free beam
            for (int i = 0; i < MAX_BEAMS; i++)
            {
                beam_t b = _Beams[i];
                if (b.model == null || b.endtime < cl.time)
                {
                    b.entity  = ent;
                    b.model   = m;
                    b.endtime = (float)(cl.time + 0.2);
                    b.start   = start;
                    b.end     = end;
                    return;
                }
            }
            Con.Print("beam list overflow!\n");
        }
示例#4
0
        // CL_UpdateTEnts
        private static void UpdateTempEntities()
        {
            _NumTempEntities = 0;

            // update lightning
            for (int i = 0; i < MAX_BEAMS; i++)
            {
                beam_t b = _Beams[i];
                if (b.model == null || b.endtime < cl.time)
                {
                    continue;
                }

                // if coming from the player, update the start position
                if (b.entity == cl.viewentity)
                {
                    b.start = _Entities[cl.viewentity].origin;
                }

                // calculate pitch and yaw
                Vector3 dist = b.end - b.start;
                float   yaw, pitch, forward;

                if (dist.Y == 0 && dist.X == 0)
                {
                    yaw = 0;
                    if (dist.Z > 0)
                    {
                        pitch = 90;
                    }
                    else
                    {
                        pitch = 270;
                    }
                }
                else
                {
                    yaw = (int)(Math.Atan2(dist.Y, dist.X) * 180 / Math.PI);
                    if (yaw < 0)
                    {
                        yaw += 360;
                    }

                    forward = (float)Math.Sqrt(dist.X * dist.X + dist.Y * dist.Y);
                    pitch   = (int)(Math.Atan2(dist.Z, forward) * 180 / Math.PI);
                    if (pitch < 0)
                    {
                        pitch += 360;
                    }
                }

                // add new entities for the lightning
                Vector3 org = b.start;
                float   d   = mathlib.Normalize(ref dist);
                while (d > 0)
                {
                    entity_t ent = NewTempEntity();
                    if (ent == null)
                    {
                        return;
                    }

                    ent.origin   = org;
                    ent.model    = b.model;
                    ent.angles.X = pitch;
                    ent.angles.Y = yaw;
                    ent.angles.Z = sys.Random() % 360;

                    org += dist * 30;
                    // Uze: is this code bug (i is outer loop variable!!!) or what??????????????
                    //for (i=0 ; i<3 ; i++)
                    //    org[i] += dist[i]*30;
                    d -= 30;
                }
            }
        }