Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/adm/src/world_entities/npcs/adm_turret.cc @ 10666

Last change on this file since 10666 was 10666, checked in by retolu, 17 years ago

little changes, arranged clearlier

File size: 3.2 KB
RevLine 
[10663]1/*
2* orxonox - the future of 3D-vertical-scrollers
3*
4* Copyright (C) 2004 orx
5*
6* This program is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation; either version 2, or (at your option)
9* any later version.
10*
11*     ### File Specific:
12*     main-programmer: Reto Luechinger
13*/
14
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17#include "adm_turret.h"
[10664]18#include "weapons/weapon_manager.h"
19#include "weapons/weapon.h"
[10663]20#include "lib/util/loading/factory.h"
21#include "world_entities/projectiles/projectile.h"
[10664]22#include "loading/load_param.h"
23#include "debug.h"
[10663]24
25ObjectListDefinition(AdmTurret);
26CREATE_FACTORY(AdmTurret);
27
[10664]28
[10663]29/**
30*  Standard constructor
31*/
32AdmTurret::AdmTurret ()
33{
[10664]34        this->init();
[10663]35}
36
37/**
[10666]38* destructs the turret, deletes allocated memory
[10663]39*/
40AdmTurret::~AdmTurret ()
41{
42          // will be deleted
43}
44
[10666]45/**
46* Constructor with XML Element
47*/
[10664]48AdmTurret::AdmTurret (const  TiXmlElement* root)
[10663]49{
[10664]50        this->init();
51        if (root != NULL)
52        {
53                this->loadParams(root);
54        }
[10663]55}
[10664]56
[10663]57void AdmTurret::init()
58{
[10664]59        this->registerObject(this, AdmTurret::_objectList);
[10663]60
[10664]61        // load the 3 parts of the turret
62        // this-> loadModel ("...", , )
63        // this-> loadModel ("...", , )
64        // this-> loadModel ("...", , )
[10663]65
[10664]66        //Cannon Node: 2 Cannons fixed left and right of the main turret
67        this->cannonNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
68        this->cannonNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
69        this->cannonNode.setParent(this);
70        // this->cannonNode.setRelCoor( , , )
[10663]71
[10664]72        //Sensor Node: Sensor rotating independently from main turret (like Radar)
73        this->sensorNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
74        this->sensorNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE);
75        this->sensorNode.setParent(this);
76        // this->sensorNode.setRelCoor( , , )
77
78        // initialise Weapons here
[10663]79}
80
81void AdmTurret::loadParams(const TiXmlElement* root)
82{
[10666]83        if (root != NULL)
84        {
85                WorldEntity::loadParams(root);
[10664]86
[10666]87                LoadParam(root, "target", this, AdmTurret, setTarget)
88                        .describe("the filename of the World Entity, that is to be shot at")
89                        .defaultValues("");
90        }
[10663]91}
92
[10664]93void AdmTurret::tick(float dt)
94{
95}
[10663]96
[10664]97void AdmTurret::draw() const
98{
99}
[10663]100
[10664]101void AdmTurret::collidesWith(WorldEntity* entity, const Vector& location)
102{
103}
[10663]104
[10664]105void AdmTurret::activate()
[10663]106{
107}
[10664]108
109void AdmTurret::deactivate()
110{
[10663]111}
112
[10664]113void AdmTurret::setTarget(const std::string& target)
[10663]114{
[10664]115        WorldEntity* targetEntity = WorldEntity::objectList().getObject(target);
116        if (targetEntity != NULL) 
117        {
118                this->myTarget = targetEntity;
119        }
120        else
121        {
122                PRINTF(2)("ERROR ADMTURRET : Target %s does not exist\n", target.c_str());
123        }
[10663]124}
[10664]125
[10663]126bool AdmTurret::isVisible(const WorldEntity myTarget)
[10664]127{
128return true;
[10663]129}
130
[10664]131float AdmTurret::aim(const WorldEntity Target)
132{
133return 0;
134}
[10663]135
136void AdmTurret::fire()
137{
[10664]138        // Projectile* pj =  this->getProjectile();
139        // if (pj == NULL) return;
[10663]140
[10664]141        //pj->setOwner(this->getOwner());
142        //pj->setParent(PNode::getNullParent());
143        //pj->setVelocity(this->getAbsDir().apply(Vector( , , )) );
144        //pj->setAbsCoor(this->getEmissionPoint());
145        //pj->setAbsDir(this->getAbsDir());
146        //pj->activate();
147}
Note: See TracBrowser for help on using the repository browser.