/* * 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: Reto Luechinger */ #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY #include "adm_turret.h" #include "weapons/weapon_manager.h" #include "weapons/weapon.h" #include "lib/util/loading/factory.h" #include "world_entities/projectiles/projectile.h" #include "loading/load_param.h" #include "debug.h" ObjectListDefinition(AdmTurret); CREATE_FACTORY(AdmTurret); /** * Standard constructor */ AdmTurret::AdmTurret () { this->init(); } /** * destructs the turret, deletes allocated memory */ AdmTurret::~AdmTurret () { // will be deleted } /** * Constructor with XML Element */ AdmTurret::AdmTurret (const TiXmlElement* root) { this->init(); if (root != NULL) { this->loadParams(root); } } void AdmTurret::init() { this->registerObject(this, AdmTurret::_objectList); // load the 3 parts of the turret // this-> loadModel ("...", , ) // this-> loadModel ("...", , ) // this-> loadModel ("...", , ) //Cannon Node: 2 Cannons fixed left and right of the main turret this->cannonNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); this->cannonNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); this->cannonNode.setParent(this); // this->cannonNode.setRelCoor( , , ) //Sensor Node: Sensor rotating independently from main turret (like Radar) this->sensorNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); this->sensorNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); this->sensorNode.setParent(this); // this->sensorNode.setRelCoor( , , ) // initialise Weapons here } void AdmTurret::loadParams(const TiXmlElement* root) { if (root != NULL) { WorldEntity::loadParams(root); LoadParam(root, "target", this, AdmTurret, setTarget) .describe("the filename of the World Entity, that is to be shot at") .defaultValues(""); } } void AdmTurret::tick(float dt) { } void AdmTurret::draw() const { } void AdmTurret::collidesWith(WorldEntity* entity, const Vector& location) { } void AdmTurret::activate() { } void AdmTurret::deactivate() { } void AdmTurret::setTarget(const std::string& target) { WorldEntity* targetEntity = WorldEntity::objectList().getObject(target); if (targetEntity != NULL) { this->myTarget = targetEntity; } else { PRINTF(2)("ERROR ADMTURRET : Target %s does not exist\n", target.c_str()); } } bool AdmTurret::isVisible(const WorldEntity myTarget) { return true; } float AdmTurret::aim(const WorldEntity Target) { return 0; } void AdmTurret::fire() { // Projectile* pj = this->getProjectile(); // if (pj == NULL) return; //pj->setOwner(this->getOwner()); //pj->setParent(PNode::getNullParent()); //pj->setVelocity(this->getAbsDir().apply(Vector( , , )) ); //pj->setAbsCoor(this->getEmissionPoint()); //pj->setAbsDir(this->getAbsDir()); //pj->activate(); }