⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gamebase.java

📁 Jake2是一个Java 3D游戏引擎.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public static edict_t obstacle;    public static int c_yes, c_no;    public static int STEPSIZE = 18;    /**     * G_RunEntity     */    public static void G_RunEntity(edict_t ent) {        if (ent.prethink != null)            ent.prethink.think(ent);        switch ((int) ent.movetype) {        case Defines.MOVETYPE_PUSH:        case Defines.MOVETYPE_STOP:            SV.SV_Physics_Pusher(ent);            break;        case Defines.MOVETYPE_NONE:            SV.SV_Physics_None(ent);            break;        case Defines.MOVETYPE_NOCLIP:            SV.SV_Physics_Noclip(ent);            break;        case Defines.MOVETYPE_STEP:            SV.SV_Physics_Step(ent);            break;        case Defines.MOVETYPE_TOSS:        case Defines.MOVETYPE_BOUNCE:        case Defines.MOVETYPE_FLY:        case Defines.MOVETYPE_FLYMISSILE:            SV.SV_Physics_Toss(ent);            break;        default:            gi.error("SV_Physics: bad movetype " + (int) ent.movetype);        }    }    public static void ClearBounds(float[] mins, float[] maxs) {        mins[0] = mins[1] = mins[2] = 99999;        maxs[0] = maxs[1] = maxs[2] = -99999;    }    public static void AddPointToBounds(float[] v, float[] mins, float[] maxs) {        int i;        float val;        for (i = 0; i < 3; i++) {            val = v[i];            if (val < mins[i])                mins[i] = val;            if (val > maxs[i])                maxs[i] = val;        }    }    public static EdictFindFilter findByTarget = new EdictFindFilter() {        public boolean matches(edict_t e, String s) {            if (e.targetname == null)                return false;            return e.targetname.equalsIgnoreCase(s);        }    };    public static EdictFindFilter findByClass = new EdictFindFilter() {        public boolean matches(edict_t e, String s) {            return e.classname.equalsIgnoreCase(s);        }    };    public static void ShutdownGame() {        gi.dprintf("==== ShutdownGame ====\n");    }    /**     * ClientEndServerFrames.     */    public static void ClientEndServerFrames() {        int i;        edict_t ent;        // calc the player views now that all pushing        // and damage has been added        for (i = 0; i < maxclients.value; i++) {            ent = g_edicts[1 + i];            if (!ent.inuse || null == ent.client)                continue;            PlayerView.ClientEndServerFrame(ent);        }    }    /**     * Returns the created target changelevel.     */    public static edict_t CreateTargetChangeLevel(String map) {        edict_t ent;        ent = GameUtil.G_Spawn();        ent.classname = "target_changelevel";        level.nextmap = map;        ent.map = level.nextmap;        return ent;    }    /**     * The timelimit or fraglimit has been exceeded.     */    public static void EndDMLevel() {        edict_t ent;        //char * s, * t, * f;        //static const char * seps = " ,\n\r";        String s, t, f;        String seps = " ,\n\r";        // stay on same level flag        if (((int) dmflags.value & Defines.DF_SAME_LEVEL) != 0) {            PlayerHud.BeginIntermission(CreateTargetChangeLevel(level.mapname));            return;        }        // see if it's in the map list        if (sv_maplist.string.length() > 0) {            s = sv_maplist.string;            f = null;            StringTokenizer tk = new StringTokenizer(s, seps);                        while (tk.hasMoreTokens()){            	t = tk.nextToken();                 	// store first map            	if (f == null)            		f = t;            	                if (t.equalsIgnoreCase(level.mapname)) {                    // it's in the list, go to the next one                	if (!tk.hasMoreTokens()) {                		// end of list, go to first one                        if (f == null) // there isn't a first one, same level                            PlayerHud.BeginIntermission(CreateTargetChangeLevel(level.mapname));                        else                            PlayerHud.BeginIntermission(CreateTargetChangeLevel(f));                    } else                        PlayerHud.BeginIntermission(CreateTargetChangeLevel(tk.nextToken()));                    return;                }            }        }        //not in the map list        if (level.nextmap.length() > 0) // go to a specific map            PlayerHud.BeginIntermission(CreateTargetChangeLevel(level.nextmap));        else { // search for a changelevel            EdictIterator edit = null;            edit = G_Find(edit, findByClass, "target_changelevel");            if (edit == null) { // the map designer didn't include a                                // changelevel,                // so create a fake ent that goes back to the same level                PlayerHud.BeginIntermission(CreateTargetChangeLevel(level.mapname));                return;            }            ent = edit.o;            PlayerHud.BeginIntermission(ent);        }    }    /**     * CheckNeedPass.     */    public static void CheckNeedPass() {        int need;        // if password or spectator_password has changed, update needpass        // as needed        if (password.modified || spectator_password.modified) {            password.modified = spectator_password.modified = false;            need = 0;            if ((password.string.length() > 0)                    && 0 != Lib.Q_stricmp(password.string, "none"))                need |= 1;            if ((spectator_password.string.length() > 0)                    && 0 != Lib.Q_stricmp(spectator_password.string, "none"))                need |= 2;            gi.cvar_set("needpass", "" + need);        }    }    /**     * CheckDMRules.     */    public static void CheckDMRules() {        int i;        gclient_t cl;        if (level.intermissiontime != 0)            return;        if (0 == deathmatch.value)            return;        if (timelimit.value != 0) {            if (level.time >= timelimit.value * 60) {                gi.bprintf(Defines.PRINT_HIGH, "Timelimit hit.\n");                EndDMLevel();                return;            }        }        if (fraglimit.value != 0) {            for (i = 0; i < maxclients.value; i++) {                cl = game.clients[i];                if (!g_edicts[i + 1].inuse)                    continue;                if (cl.resp.score >= fraglimit.value) {                    gi.bprintf(Defines.PRINT_HIGH, "Fraglimit hit.\n");                    EndDMLevel();                    return;                }            }        }    }    /**     * Exits a level.     */    public static void ExitLevel() {        int i;        edict_t ent;        String command = "gamemap \"" + level.changemap + "\"\n";        gi.AddCommandString(command);        level.changemap = null;        level.exitintermission = false;        level.intermissiontime = 0;        ClientEndServerFrames();        // clear some things before going to next level        for (i = 0; i < maxclients.value; i++) {            ent = g_edicts[1 + i];            if (!ent.inuse)                continue;            if (ent.health > ent.client.pers.max_health)                ent.health = ent.client.pers.max_health;        }    }    /**     * G_RunFrame     *       * Advances the world by Defines.FRAMETIME (0.1) seconds.     */    public static void G_RunFrame() {        int i;        edict_t ent;        level.framenum++;        level.time = level.framenum * Defines.FRAMETIME;        // choose a client for monsters to target this frame        GameAI.AI_SetSightClient();        // exit intermissions        if (level.exitintermission) {            ExitLevel();            return;        }        //        // treat each object in turn        // even the world gets a chance to think        //        for (i = 0; i < num_edicts; i++) {            ent = g_edicts[i];            if (!ent.inuse)                continue;            level.current_entity = ent;            Math3D.VectorCopy(ent.s.origin, ent.s.old_origin);            // if the ground entity moved, make sure we are still on it            if ((ent.groundentity != null)                    && (ent.groundentity.linkcount != ent.groundentity_linkcount)) {                ent.groundentity = null;                if (0 == (ent.flags & (Defines.FL_SWIM | Defines.FL_FLY))                        && (ent.svflags & Defines.SVF_MONSTER) != 0) {                    M.M_CheckGround(ent);                }            }            if (i > 0 && i <= maxclients.value) {                PlayerClient.ClientBeginServerFrame(ent);                continue;            }            G_RunEntity(ent);        }        // see if it is time to end a deathmatch        CheckDMRules();        // see if needpass needs updated        CheckNeedPass();        // build the playerstate_t structures for all players        ClientEndServerFrames();    }    /**     * This return a pointer to the structure with all entry points and global     * variables.      */    public static void GetGameApi(game_import_t imp) {        gi = imp;        gi.pointcontents = new pmove_t.PointContentsAdapter() {            public int pointcontents(float[] o) {                return SV_WORLD.SV_PointContents(o);            }        };    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -