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 | /** |
---|
46 | * Constructor with XML Element |
---|
47 | */ |
---|
48 | AdmTurret::AdmTurret (const TiXmlElement* root) |
---|
49 | { |
---|
50 | this->init(); |
---|
51 | if (root != NULL) |
---|
52 | { |
---|
53 | this->loadParams(root); |
---|
54 | } |
---|
55 | } |
---|
56 | |
---|
57 | void AdmTurret::init() |
---|
58 | { |
---|
59 | this->registerObject(this, AdmTurret::_objectList); |
---|
60 | |
---|
61 | // load the 3 parts of the turret |
---|
62 | // this-> loadModel ("...", , ) |
---|
63 | // this-> loadModel ("...", , ) |
---|
64 | // this-> loadModel ("...", , ) |
---|
65 | |
---|
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( , , ) |
---|
71 | |
---|
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 |
---|
79 | } |
---|
80 | |
---|
81 | void AdmTurret::loadParams(const TiXmlElement* root) |
---|
82 | { |
---|
83 | if (root != NULL) |
---|
84 | { |
---|
85 | WorldEntity::loadParams(root); |
---|
86 | |
---|
87 | LoadParam(root, "target", this, AdmTurret, setTarget) |
---|
88 | .describe("the filename of the World Entity, that is to be shot at") |
---|
89 | .defaultValues(""); |
---|
90 | } |
---|
91 | } |
---|
92 | |
---|
93 | void AdmTurret::tick(float dt) |
---|
94 | { |
---|
95 | } |
---|
96 | |
---|
97 | void AdmTurret::draw() const |
---|
98 | { |
---|
99 | } |
---|
100 | |
---|
101 | void AdmTurret::collidesWith(WorldEntity* entity, const Vector& location) |
---|
102 | { |
---|
103 | } |
---|
104 | |
---|
105 | void AdmTurret::activate() |
---|
106 | { |
---|
107 | } |
---|
108 | |
---|
109 | void AdmTurret::deactivate() |
---|
110 | { |
---|
111 | } |
---|
112 | |
---|
113 | void AdmTurret::setTarget(const std::string& target) |
---|
114 | { |
---|
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 | } |
---|
124 | } |
---|
125 | |
---|
126 | bool AdmTurret::isVisible(const WorldEntity myTarget) |
---|
127 | { |
---|
128 | return true; |
---|
129 | } |
---|
130 | |
---|
131 | float AdmTurret::aim(const WorldEntity Target) |
---|
132 | { |
---|
133 | return 0; |
---|
134 | } |
---|
135 | |
---|
136 | void AdmTurret::fire() |
---|
137 | { |
---|
138 | // Projectile* pj = this->getProjectile(); |
---|
139 | // if (pj == NULL) return; |
---|
140 | |
---|
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 | } |
---|