Пример #1
0
        static void AddPacketEntities(frame_t frame)
        {
            entity_state_t s1;
            Single         autorotate;
            Int32          i;
            Int32          pnum;
            centity_t      cent;
            Int32          autoanim;
            clientinfo_t   ci;
            Int32          effects, renderfx;

            autorotate = Math3D.Anglemod(Globals.cl.time / 10);
            autoanim   = 2 * Globals.cl.time / 1000;
            ent.Clear();
            for (pnum = 0; pnum < frame.num_entities; pnum++)
            {
                s1       = Globals.cl_parse_entities[(frame.parse_entities + pnum) & (Defines.MAX_PARSE_ENTITIES - 1)];
                cent     = Globals.cl_entities[s1.number];
                effects  = s1.effects;
                renderfx = s1.renderfx;
                if ((effects & Defines.EF_ANIM01) != 0)
                {
                    ent.frame = autoanim & 1;
                }
                else if ((effects & Defines.EF_ANIM23) != 0)
                {
                    ent.frame = 2 + (autoanim & 1);
                }
                else if ((effects & Defines.EF_ANIM_ALL) != 0)
                {
                    ent.frame = autoanim;
                }
                else if ((effects & Defines.EF_ANIM_ALLFAST) != 0)
                {
                    ent.frame = Globals.cl.time / 100;
                }
                else
                {
                    ent.frame = s1.frame;
                }
                if ((effects & Defines.EF_PENT) != 0)
                {
                    effects  &= ~Defines.EF_PENT;
                    effects  |= Defines.EF_COLOR_SHELL;
                    renderfx |= Defines.RF_SHELL_RED;
                }

                if ((effects & Defines.EF_QUAD) != 0)
                {
                    effects  &= ~Defines.EF_QUAD;
                    effects  |= Defines.EF_COLOR_SHELL;
                    renderfx |= Defines.RF_SHELL_BLUE;
                }

                if ((effects & Defines.EF_DOUBLE) != 0)
                {
                    effects  &= ~Defines.EF_DOUBLE;
                    effects  |= Defines.EF_COLOR_SHELL;
                    renderfx |= Defines.RF_SHELL_DOUBLE;
                }

                if ((effects & Defines.EF_HALF_DAMAGE) != 0)
                {
                    effects  &= ~Defines.EF_HALF_DAMAGE;
                    effects  |= Defines.EF_COLOR_SHELL;
                    renderfx |= Defines.RF_SHELL_HALF_DAM;
                }

                ent.oldframe = cent.prev.frame;
                ent.backlerp = 1F - Globals.cl.lerpfrac;
                if ((renderfx & (Defines.RF_FRAMELERP | Defines.RF_BEAM)) != 0)
                {
                    Math3D.VectorCopy(cent.current.origin, ent.origin);
                    Math3D.VectorCopy(cent.current.old_origin, ent.oldorigin);
                }
                else
                {
                    for (i = 0; i < 3; i++)
                    {
                        ent.origin[i] = ent.oldorigin[i] = cent.prev.origin[i] + Globals.cl.lerpfrac * (cent.current.origin[i] - cent.prev.origin[i]);
                    }
                }

                if ((renderfx & Defines.RF_BEAM) != 0)
                {
                    ent.alpha   = 0.3F;
                    ent.skinnum = ( Int32 )(s1.skinnum >> ((Globals.rnd.Next(4)) * 8)) & 0xff;
                    //Math.Random();
                    ent.model = null;
                }
                else
                {
                    if (s1.modelindex == 255)
                    {
                        ent.skinnum = 0;
                        ci          = Globals.cl.clientinfo[s1.skinnum & 0xff];
                        ent.skin    = ci.skin;
                        ent.model   = ci.model;
                        if (null == ent.skin || null == ent.model)
                        {
                            ent.skin  = Globals.cl.baseclientinfo.skin;
                            ent.model = Globals.cl.baseclientinfo.model;
                        }

                        if ((renderfx & Defines.RF_USE_DISGUISE) != 0)
                        {
                            if (ent.skin.name.StartsWith("players/male"))
                            {
                                ent.skin  = Globals.re.RegisterSkin("players/male/disguise.pcx");
                                ent.model = Globals.re.RegisterModel("players/male/tris.md2");
                            }
                            else if (ent.skin.name.StartsWith("players/female"))
                            {
                                ent.skin  = Globals.re.RegisterSkin("players/female/disguise.pcx");
                                ent.model = Globals.re.RegisterModel("players/female/tris.md2");
                            }
                            else if (ent.skin.name.StartsWith("players/cyborg"))
                            {
                                ent.skin  = Globals.re.RegisterSkin("players/cyborg/disguise.pcx");
                                ent.model = Globals.re.RegisterModel("players/cyborg/tris.md2");
                            }
                        }
                    }
                    else
                    {
                        ent.skinnum = ( Int32 )s1.skinnum;
                        ent.skin    = null;
                        ent.model   = Globals.cl.model_draw[s1.modelindex];
                    }
                }

                if (renderfx == Defines.RF_TRANSLUCENT)
                {
                    ent.alpha = 0.7F;
                }
                if ((effects & Defines.EF_COLOR_SHELL) != 0)
                {
                    ent.flags = 0;
                }
                else
                {
                    ent.flags = renderfx;
                }
                if ((effects & Defines.EF_ROTATE) != 0)
                {
                    ent.angles[0] = 0;
                    ent.angles[1] = autorotate;
                    ent.angles[2] = 0;
                }
                else if ((effects & Defines.EF_SPINNINGLIGHTS) != 0)
                {
                    ent.angles[0] = 0;
                    ent.angles[1] = Math3D.Anglemod(Globals.cl.time / 2) + s1.angles[1];
                    ent.angles[2] = 180;
                    {
                        Single[] forward = new Single[] { 0, 0, 0 };
                        Single[] start   = new Single[] { 0, 0, 0 };
                        Math3D.AngleVectors(ent.angles, forward, null, null);
                        Math3D.VectorMA(ent.origin, 64, forward, start);
                        V.AddLight(start, 100, 1, 0, 0);
                    }
                }
                else
                {
                    Single a1, a2;
                    for (i = 0; i < 3; i++)
                    {
                        a1            = cent.current.angles[i];
                        a2            = cent.prev.angles[i];
                        ent.angles[i] = Math3D.LerpAngle(a2, a1, Globals.cl.lerpfrac);
                    }
                }

                if (s1.number == Globals.cl.playernum + 1)
                {
                    ent.flags |= Defines.RF_VIEWERMODEL;
                    if ((effects & Defines.EF_FLAG1) != 0)
                    {
                        V.AddLight(ent.origin, 225, 1F, 0.1F, 0.1F);
                    }
                    else if ((effects & Defines.EF_FLAG2) != 0)
                    {
                        V.AddLight(ent.origin, 225, 0.1F, 0.1F, 1F);
                    }
                    else if ((effects & Defines.EF_TAGTRAIL) != 0)
                    {
                        V.AddLight(ent.origin, 225, 1F, 1F, 0F);
                    }
                    else if ((effects & Defines.EF_TRACKERTRAIL) != 0)
                    {
                        V.AddLight(ent.origin, 225, -1F, -1F, -1F);
                    }
                    continue;
                }

                if (s1.modelindex == 0)
                {
                    continue;
                }
                if ((effects & Defines.EF_BFG) != 0)
                {
                    ent.flags |= Defines.RF_TRANSLUCENT;
                    ent.alpha  = 0.3F;
                }

                if ((effects & Defines.EF_PLASMA) != 0)
                {
                    ent.flags |= Defines.RF_TRANSLUCENT;
                    ent.alpha  = 0.6F;
                }

                if ((effects & Defines.EF_SPHERETRANS) != 0)
                {
                    ent.flags |= Defines.RF_TRANSLUCENT;
                    if ((effects & Defines.EF_TRACKERTRAIL) != 0)
                    {
                        ent.alpha = 0.6F;
                    }
                    else
                    {
                        ent.alpha = 0.3F;
                    }
                }

                V.AddEntity(ent);
                if ((effects & Defines.EF_COLOR_SHELL) != 0)
                {
                    if ((renderfx & Defines.RF_SHELL_HALF_DAM) != 0)
                    {
                        if (FS.Developer_searchpath(2) == 2)
                        {
                            if ((renderfx & (Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE)) != 0)
                            {
                                renderfx &= ~Defines.RF_SHELL_HALF_DAM;
                            }
                        }
                    }

                    if ((renderfx & Defines.RF_SHELL_DOUBLE) != 0)
                    {
                        if (FS.Developer_searchpath(2) == 2)
                        {
                            if ((renderfx & (Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_GREEN)) != 0)
                            {
                                renderfx &= ~Defines.RF_SHELL_DOUBLE;
                            }
                            if ((renderfx & Defines.RF_SHELL_RED) != 0)
                            {
                                renderfx |= Defines.RF_SHELL_BLUE;
                            }
                            else if ((renderfx & Defines.RF_SHELL_BLUE) != 0)
                            {
                                if ((renderfx & Defines.RF_SHELL_GREEN) != 0)
                                {
                                    renderfx &= ~Defines.RF_SHELL_BLUE;
                                }
                                else
                                {
                                    renderfx |= Defines.RF_SHELL_GREEN;
                                }
                            }
                        }
                    }

                    ent.flags = renderfx | Defines.RF_TRANSLUCENT;
                    ent.alpha = 0.3F;
                    V.AddEntity(ent);
                }

                ent.skin    = null;
                ent.skinnum = 0;
                ent.flags   = 0;
                ent.alpha   = 0;
                if (s1.modelindex2 != 0)
                {
                    if (s1.modelindex2 == 255)
                    {
                        ci = Globals.cl.clientinfo[s1.skinnum & 0xff];
                        i  = ( Int32 )(s1.skinnum >> 8);                           // These casts probably break something TODO
                        if (0 == Globals.cl_vwep.value || i > Defines.MAX_CLIENTWEAPONMODELS - 1)
                        {
                            i = 0;
                        }
                        ent.model = ci.weaponmodel[i];
                        if (null == ent.model)
                        {
                            if (i != 0)
                            {
                                ent.model = ci.weaponmodel[0];
                            }
                            if (null == ent.model)
                            {
                                ent.model = Globals.cl.baseclientinfo.weaponmodel[0];
                            }
                        }
                    }
                    else
                    {
                        ent.model = Globals.cl.model_draw[s1.modelindex2];
                    }
                    if (Globals.cl.configstrings[Defines.CS_MODELS + (s1.modelindex2)].EqualsIgnoreCase("models/items/shell/tris.md2"))
                    {
                        ent.alpha = 0.32F;
                        ent.flags = Defines.RF_TRANSLUCENT;
                    }

                    V.AddEntity(ent);
                    ent.flags = 0;
                    ent.alpha = 0;
                }

                if (s1.modelindex3 != 0)
                {
                    ent.model = Globals.cl.model_draw[s1.modelindex3];
                    V.AddEntity(ent);
                }

                if (s1.modelindex4 != 0)
                {
                    ent.model = Globals.cl.model_draw[s1.modelindex4];
                    V.AddEntity(ent);
                }

                if ((effects & Defines.EF_POWERSCREEN) != 0)
                {
                    ent.model    = CL_tent.cl_mod_powerscreen;
                    ent.oldframe = 0;
                    ent.frame    = 0;
                    ent.flags   |= (Defines.RF_TRANSLUCENT | Defines.RF_SHELL_GREEN);
                    ent.alpha    = 0.3F;
                    V.AddEntity(ent);
                }

                if ((effects & ~Defines.EF_ROTATE) != 0)
                {
                    if ((effects & Defines.EF_ROCKET) != 0)
                    {
                        CL_fx.RocketTrail(cent.lerp_origin, ent.origin, cent);
                        V.AddLight(ent.origin, 200, 1, 1, 0);
                    }
                    else if ((effects & Defines.EF_BLASTER) != 0)
                    {
                        if ((effects & Defines.EF_TRACKER) != 0)
                        {
                            CL_newfx.BlasterTrail2(cent.lerp_origin, ent.origin);
                            V.AddLight(ent.origin, 200, 0, 1, 0);
                        }
                        else
                        {
                            CL_fx.BlasterTrail(cent.lerp_origin, ent.origin);
                            V.AddLight(ent.origin, 200, 1, 1, 0);
                        }
                    }
                    else if ((effects & Defines.EF_HYPERBLASTER) != 0)
                    {
                        if ((effects & Defines.EF_TRACKER) != 0)
                        {
                            V.AddLight(ent.origin, 200, 0, 1, 0);
                        }
                        else
                        {
                            V.AddLight(ent.origin, 200, 1, 1, 0);
                        }
                    }
                    else if ((effects & Defines.EF_GIB) != 0)
                    {
                        CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects);
                    }
                    else if ((effects & Defines.EF_GRENADE) != 0)
                    {
                        CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects);
                    }
                    else if ((effects & Defines.EF_FLIES) != 0)
                    {
                        CL_fx.FlyEffect(cent, ent.origin);
                    }
                    else if ((effects & Defines.EF_BFG) != 0)
                    {
                        if ((effects & Defines.EF_ANIM_ALLFAST) != 0)
                        {
                            CL_fx.BfgParticles(ent);
                            i = 200;
                        }
                        else
                        {
                            i = bfg_lightramp[s1.frame];
                        }

                        V.AddLight(ent.origin, i, 0, 1, 0);
                    }
                    else if ((effects & Defines.EF_TRAP) != 0)
                    {
                        ent.origin[2] += 32;
                        CL_fx.TrapParticles(ent);
                        i = (Globals.rnd.Next(100)) + 100;
                        V.AddLight(ent.origin, i, 1, 0.8F, 0.1F);
                    }
                    else if ((effects & Defines.EF_FLAG1) != 0)
                    {
                        CL_fx.FlagTrail(cent.lerp_origin, ent.origin, 242);
                        V.AddLight(ent.origin, 225, 1, 0.1F, 0.1F);
                    }
                    else if ((effects & Defines.EF_FLAG2) != 0)
                    {
                        CL_fx.FlagTrail(cent.lerp_origin, ent.origin, 115);
                        V.AddLight(ent.origin, 225, 0.1F, 0.1F, 1);
                    }
                    else if ((effects & Defines.EF_TAGTRAIL) != 0)
                    {
                        CL_newfx.TagTrail(cent.lerp_origin, ent.origin, 220);
                        V.AddLight(ent.origin, 225, 1F, 1F, 0F);
                    }
                    else if ((effects & Defines.EF_TRACKERTRAIL) != 0)
                    {
                        if ((effects & Defines.EF_TRACKER) != 0)
                        {
                            Single intensity;
                            intensity = ( Single )(50 + (500 * (Math.Sin(Globals.cl.time / 500) + 1)));
                            if (Globals.vidref_val == Defines.VIDREF_GL)
                            {
                                V.AddLight(ent.origin, intensity, -1F, -1F, -1F);
                            }
                            else
                            {
                                V.AddLight(ent.origin, -1F * intensity, 1F, 1F, 1F);
                            }
                        }
                        else
                        {
                            CL_newfx.Tracker_Shell(cent.lerp_origin);
                            V.AddLight(ent.origin, 155, -1F, -1F, -1F);
                        }
                    }
                    else if ((effects & Defines.EF_TRACKER) != 0)
                    {
                        CL_newfx.TrackerTrail(cent.lerp_origin, ent.origin, 0);
                        if (Globals.vidref_val == Defines.VIDREF_GL)
                        {
                            V.AddLight(ent.origin, 200, -1, -1, -1);
                        }
                        else
                        {
                            V.AddLight(ent.origin, -200, 1, 1, 1);
                        }
                    }
                    else if ((effects & Defines.EF_GREENGIB) != 0)
                    {
                        CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects);
                    }
                    else if ((effects & Defines.EF_IONRIPPER) != 0)
                    {
                        CL_fx.IonripperTrail(cent.lerp_origin, ent.origin);
                        V.AddLight(ent.origin, 100, 1, 0.5F, 0.5F);
                    }
                    else if ((effects & Defines.EF_BLUEHYPERBLASTER) != 0)
                    {
                        V.AddLight(ent.origin, 200, 0, 0, 1);
                    }
                    else if ((effects & Defines.EF_PLASMA) != 0)
                    {
                        if ((effects & Defines.EF_ANIM_ALLFAST) != 0)
                        {
                            CL_fx.BlasterTrail(cent.lerp_origin, ent.origin);
                        }

                        V.AddLight(ent.origin, 130, 1, 0.5F, 0.5F);
                    }
                }

                Math3D.VectorCopy(ent.origin, cent.lerp_origin);
            }
        }