/* orxonox - the future of 3D-vertical-scrollers Copyright (C) 2004 orx This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. ### File Specific: main-programmer: Patrick Boenzli */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD #include "single_player_world.h" #include "state.h" #include "class_list.h" #include "load_param.h" #include "fast_factory.h" #include "factory.h" #include "world_entity.h" #include "npcs/npc_test1.h" using namespace std; //! This creates a Factory to fabricate a SinglePlayerWorld CREATE_FACTORY(SinglePlayerWorld, CL_SINGLE_PLAYER_WORLD); SinglePlayerWorld::SinglePlayerWorld(const TiXmlElement* root) : GameWorld(root) { this->loadParams(root); } /** * remove the SinglePlayerWorld from memory * * delete everything explicitly, that isn't contained in the parenting tree! * things contained in the tree are deleted automaticaly */ SinglePlayerWorld::~SinglePlayerWorld () { PRINTF(3)("SinglePlayerWorld::~SinglePlayerWorld() - deleting current world\n"); } /** * initializes the world. * @param name the name of the world * @param worldID the ID of this world * * set all stuff here that is world generic and does not use to much memory * because the real init() function StoryEntity::init() will be called * shortly before start of the game. * since all worlds are initiated/referenced before they will be started. * NO LEVEL LOADING HERE - NEVER! */ void SinglePlayerWorld::constuctorInit(const char* name, int worldID) { this->setClassID(CL_SINGLE_PLAYER_WORLD, "SinglePlayerSinglePlayerWorld"); this->setName(name); this->gameTime = 0.0f; this->setSpeed(1.0); this->music = NULL; this->shell = NULL; this->localPlayer = NULL; this->localCamera = NULL; this->showPNodes = false; this->showBV = false; } /** * loads the parameters of a SinglePlayerWorld from an XML-element * @param root the XML-element to load from */ void SinglePlayerWorld::loadParams(const TiXmlElement* root) { static_cast(this)->loadParams(root); PRINTF(4)("Creating a SinglePlayerWorld\n"); } /** * this is executed just before load * * since the load function sometimes needs data, that has been initialized * before the load and after the proceeding storyentity has finished */ ErrorMessage SinglePlayerWorld::preLoad() { static_cast(this)->preLoad(); /* the the single player specific stuff */ } /** * loads the SinglePlayerWorld by initializing all resources, and set their default values. */ ErrorMessage SinglePlayerWorld::load() { static_cast(this)->load(); /* the the single player specific stuff here */ /* some static world entities */ for(int i = 0; i < 100; i++) { WorldEntity* tmp = new NPCTest1(); char npcChar[10]; sprintf (npcChar, "NPC_%d", i); tmp->setName(npcChar); tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30); this->spawn(tmp); } } /** * post loads the SinglePlayerWorld by initializing all resources, and set their default values. */ ErrorMessage SinglePlayerWorld::postLoad() { static_cast(this)->postLoad(); /* the single player specific stuff here */ }