/* 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 co-programmer: */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY #include "util/loading/factory.h" #include "util/loading/load_param.h" #include "interactive_model.h" #include "door.h" #include "class_list.h" using namespace std; CREATE_FACTORY(Door, CL_DOOR); Door::Door () { this->init(); } Door::Door(const TiXmlElement* root) { this->init(); if (root != NULL) this->loadParams(root); } Door::~Door () {} void Door::init() { this->setClassID(CL_DOOR, "Door"); this->toList(OM_COMMON); } /** * loads the Settings of a MD2Creature from an XML-element. * @param root the XML-element to load the MD2Creature's properties from */ void Door::loadParams(const TiXmlElement* root) { WorldEntity::loadParams(root); // LoadParam(root, "", this, Door, set) // .describe("sets the animation of the md2 model") // .defaultValues(1); } void Door::setAnim(int animationIndex, int animPlaybackMode) { if( likely(this->getModel(0) != NULL)) ((InteractiveModel*)this->getModel(0))->setAnimation(animationIndex, animPlaybackMode); } void Door::tick (float time) { if( likely(this->getModel(0) != NULL)) ((InteractiveModel*)this->getModel(0))->tick(time); } /** * checks if the door is open */ bool Door::checkOpen() { std::list::const_iterator it; const std::list* list = ClassList::getList(CL_PLAYABLE); WorldEntity* entity; float distance; if( list == NULL) return false; // for all players for( it = list->begin(); it != list->end(); it++) { entity = dynamic_cast(*it); distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len()); if( distance < this->actionRadius) return true; } list = ClassList::getList(CL_GENERIC_NPC); if( list == NULL) return false; for( it = list->begin(); it != list->end(); it++) { entity = dynamic_cast(*it); distance = fabs((this->getAbsCoor() - entity->getAbsCoor()).len()); if( distance < this->actionRadius) return true; } return false; }