void TestDemonstration::oneShip() { InternalMessage("Sound","entering TestDemonstration::oneShip") ; std::cerr << "TestDemonstration::oneShip" << std::endl ; std::cerr.flush() ; std::auto_ptr<Kernel::Model> model(new Kernel::Model()) ; model->init() ; Kernel::Object* root = model->createObject() ; Kernel::Object* universe = root->createObject() ; universe->addTrait(new Model::Universe()) ; universe->addTrait(new Model::Positioned()) ; universe->setName("universe") ; Kernel::Object* system = universe->createObject() ; system->addTrait(new Model::StellarSystem()) ; system->addTrait(new Model::Positioned()) ; system->setName("system") ; // Kernel::Object* ship = Model::loadShip("test_ship",system) ; Kernel::Object* pilot = system->createObject() ; pilot->addTrait(new Model::Listener()) ; pilot->addTrait(new Model::Positioned()) ; pilot->addTrait(new Model::Oriented()) ; pilot->addTrait(new Model::Player()) ; pilot->addTrait(new Model::Observer()) ; pilot->addTrait(new Model::Active()) ; pilot->addTrait(new Model::Mobile()) ; Kernel::Object* ship2 = Model::loadShip("test_ship",system) ; Model::Positioned* ship2_positioned = ship2->getTrait<Model::Positioned>() ; ship2_positioned->setPosition(Model::Position::Meter(0,0,200)) ; ship2->getTrait<Model::Mobile>()->setSpeed(Model::Speed::MeterPerSecond(0,0,-50)) ; Kernel::Timer global_timer ; Kernel::Timer timer ; std::set<Model::Throttle*> throttles = ship2->getChildren<Model::Throttle>() ; (*throttles.begin())->set(100) ; while (global_timer.getSecond() <= 4) { float seconds = timer.getSecond() ; if (seconds > 0) { timer.reset() ; ship2_positioned->setPosition(ship2_positioned->getPosition()+Model::Position::Meter(0,0,-50*seconds)) ; model->update(seconds) ; } } InternalMessage("Sound","leaving TestDemonstration::oneShip") ; }
void CustomMission::load() { // setup the system Kernel::Object* universe = getObject()->createObject() ; universe->addTrait(new Universe()) ; universe->addTrait(new Positioned()) ; universe->setName("universe") ; m_system = universe->createObject() ; m_system->addTrait(new StellarSystem()) ; m_system->addTrait(new Positioned()) ; m_system->setName("system") ; }