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" |
---|
18 | #include "weapons/weapon_manager.h" |
---|
19 | #include "weapons/weapon.h" |
---|
20 | #include "lib/util/loading/factory.h" |
---|
21 | #include "world_entities/projectiles/projectile.h" |
---|
22 | #include "loading/load_param.h" |
---|
23 | #include "debug.h" |
---|
24 | |
---|
25 | ObjectListDefinition(AdmTurret); |
---|
26 | CREATE_FACTORY(AdmTurret); |
---|
27 | |
---|
28 | |
---|
29 | /** |
---|
30 | * Standard constructor |
---|
31 | */ |
---|
32 | AdmTurret::AdmTurret () |
---|
33 | { |
---|
34 | this->init(); |
---|
35 | } |
---|
36 | |
---|
37 | /** |
---|
38 | * destructs the turret, deletes allocated memory |
---|
39 | */ |
---|
40 | AdmTurret::~AdmTurret () |
---|
41 | { |
---|
42 | // will be deleted |
---|
43 | } |
---|
44 | |
---|
45 | AdmTurret::AdmTurret (const TiXmlElement* root) |
---|
46 | { |
---|
47 | this->init(); |
---|
48 | if (root != NULL) |
---|
49 | { |
---|
50 | this->loadParams(root); |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | void AdmTurret::init() |
---|
55 | { |
---|
56 | this->registerObject(this, AdmTurret::_objectList); |
---|
57 | |
---|
58 | // load the 3 parts of the turret |
---|
59 | // this-> loadModel ("...", , ) |
---|
60 | // this-> loadModel ("...", , ) |
---|
61 | // this-> loadModel ("...", , ) |
---|
62 | |
---|
63 | //Cannon Node: 2 Cannons fixed left and right of the main turret |
---|
64 | this->cannonNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); |
---|
65 | this->cannonNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); |
---|
66 | this->cannonNode.setParent(this); |
---|
67 | // this->cannonNode.setRelCoor( , , ) |
---|
68 | |
---|
69 | //Sensor Node: Sensor rotating independently from main turret (like Radar) |
---|
70 | this->sensorNode.addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT); |
---|
71 | this->sensorNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); |
---|
72 | this->sensorNode.setParent(this); |
---|
73 | // this->sensorNode.setRelCoor( , , ) |
---|
74 | |
---|
75 | // initialise Weapons here |
---|
76 | } |
---|
77 | |
---|
78 | void AdmTurret::loadParams(const TiXmlElement* root) |
---|
79 | { |
---|
80 | WorldEntity::loadParams(root); |
---|
81 | |
---|
82 | LoadParam(root, "target", this, AdmTurret, setTarget) |
---|
83 | .describe("the filename of the World Entity, that is to be shot at") |
---|
84 | .defaultValues(""); |
---|
85 | } |
---|
86 | |
---|
87 | void AdmTurret::tick(float dt) |
---|
88 | { |
---|
89 | } |
---|
90 | |
---|
91 | void AdmTurret::draw() const |
---|
92 | { |
---|
93 | } |
---|
94 | |
---|
95 | void AdmTurret::collidesWith(WorldEntity* entity, const Vector& location) |
---|
96 | { |
---|
97 | } |
---|
98 | |
---|
99 | void AdmTurret::activate() |
---|
100 | { |
---|
101 | } |
---|
102 | |
---|
103 | void AdmTurret::deactivate() |
---|
104 | { |
---|
105 | } |
---|
106 | |
---|
107 | void AdmTurret::setTarget(const std::string& target) |
---|
108 | { |
---|
109 | WorldEntity* targetEntity = WorldEntity::objectList().getObject(target); |
---|
110 | if (targetEntity != NULL) |
---|
111 | { |
---|
112 | this->myTarget = targetEntity; |
---|
113 | } |
---|
114 | else |
---|
115 | { |
---|
116 | PRINTF(2)("ERROR ADMTURRET : Target %s does not exist\n", target.c_str()); |
---|
117 | } |
---|
118 | } |
---|
119 | |
---|
120 | bool AdmTurret::isVisible(const WorldEntity myTarget) |
---|
121 | { |
---|
122 | return true; |
---|
123 | } |
---|
124 | |
---|
125 | float AdmTurret::aim(const WorldEntity Target) |
---|
126 | { |
---|
127 | return 0; |
---|
128 | } |
---|
129 | |
---|
130 | void AdmTurret::fire() |
---|
131 | { |
---|
132 | // Projectile* pj = this->getProjectile(); |
---|
133 | // if (pj == NULL) return; |
---|
134 | |
---|
135 | //pj->setOwner(this->getOwner()); |
---|
136 | //pj->setParent(PNode::getNullParent()); |
---|
137 | //pj->setVelocity(this->getAbsDir().apply(Vector( , , )) ); |
---|
138 | //pj->setAbsCoor(this->getEmissionPoint()); |
---|
139 | //pj->setAbsDir(this->getAbsDir()); |
---|
140 | //pj->activate(); |
---|
141 | } |
---|