[3573] | 1 | |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | orxonox - the future of 3D-vertical-scrollers |
---|
| 5 | |
---|
| 6 | Copyright (C) 2004 orx |
---|
| 7 | |
---|
| 8 | This program is free software; you can redistribute it and/or modify |
---|
| 9 | it under the terms of the GNU General Public License as published by |
---|
| 10 | the Free Software Foundation; either version 2, or (at your option) |
---|
| 11 | any later version. |
---|
| 12 | |
---|
| 13 | ### File Specific |
---|
| 14 | main-programmer: Patrick Boenzli |
---|
| 15 | co-programmer: |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | #include "weapon.h" |
---|
| 20 | #include "stdincl.h" |
---|
| 21 | #include "world_entity.h" |
---|
| 22 | #include "vector.h" |
---|
[3746] | 23 | #include "model.h" |
---|
[3575] | 24 | #include "projectile.h" |
---|
[3746] | 25 | #include "list.h" |
---|
| 26 | #include "world.h" |
---|
[3573] | 27 | |
---|
| 28 | using namespace std; |
---|
| 29 | |
---|
| 30 | |
---|
[3575] | 31 | /** |
---|
| 32 | \brief standard constructor |
---|
[3573] | 33 | |
---|
[3575] | 34 | creates a new weapon |
---|
| 35 | */ |
---|
[3746] | 36 | Weapon::Weapon (PNode* parent, Vector* coordinate, Quaternion* direction) |
---|
| 37 | : WorldEntity() |
---|
| 38 | { |
---|
| 39 | parent->addChild(this, PNODE_ROTATE_AND_MOVE); |
---|
| 40 | this->setRelCoor(coordinate); |
---|
| 41 | this->setRelDir(direction); |
---|
| 42 | WorldInterface* wi = WorldInterface::getInstance(); |
---|
| 43 | this->worldEntities = wi->getEntityList(); |
---|
| 44 | } |
---|
[3573] | 45 | |
---|
| 46 | |
---|
[3575] | 47 | /** |
---|
| 48 | \brief standard deconstructor |
---|
| 49 | */ |
---|
[3573] | 50 | Weapon::~Weapon () |
---|
| 51 | { |
---|
[3579] | 52 | // model will be deleted from WorldEntity-destructor |
---|
[3573] | 53 | } |
---|
| 54 | |
---|
| 55 | |
---|
[3577] | 56 | /** |
---|
| 57 | \brief enables the weapon |
---|
| 58 | |
---|
| 59 | a weapon can be enabled/disabled because of various reasons. if a weapon is |
---|
| 60 | been enabled, it can interact in a world. elswhere it wont react to any |
---|
| 61 | action. |
---|
| 62 | */ |
---|
| 63 | void Weapon::enable() |
---|
[3583] | 64 | { |
---|
| 65 | this->enabled = true; |
---|
| 66 | } |
---|
[3577] | 67 | |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | \brief disables the weapon |
---|
| 71 | |
---|
| 72 | a weapon can be enabled/disabled because of various reasons. if a weapon is |
---|
| 73 | been enabled, it can interact in a world. elswhere it wont react to any |
---|
| 74 | action. |
---|
| 75 | */ |
---|
| 76 | void Weapon::disable() |
---|
[3583] | 77 | { |
---|
| 78 | this->enabled = false; |
---|
| 79 | } |
---|
[3577] | 80 | |
---|
| 81 | |
---|
| 82 | /** |
---|
| 83 | \brief checks if the weapon is enabled |
---|
| 84 | \returns true if enabled |
---|
| 85 | |
---|
| 86 | a weapon can be ebabled/disabled because of various reasons. if a weapon is |
---|
| 87 | been enabled, it can interact in a world. elswhere it wont react to any |
---|
| 88 | action. |
---|
| 89 | */ |
---|
| 90 | bool Weapon::isEnabled() |
---|
[3583] | 91 | { |
---|
| 92 | return this->enabled; |
---|
| 93 | } |
---|
[3577] | 94 | |
---|
| 95 | |
---|
[3575] | 96 | /** |
---|
| 97 | \brief sets a new projectile to the weapon |
---|
| 98 | \param new projectile for this weapon |
---|
[3573] | 99 | |
---|
[3575] | 100 | weapon an projectile are independent, so you can combine them as you want |
---|
| 101 | */ |
---|
| 102 | void Weapon::setProjectile(Projectile* projectile) |
---|
| 103 | { |
---|
| 104 | this->projectile = projectile; |
---|
| 105 | } |
---|
[3573] | 106 | |
---|
| 107 | |
---|
[3575] | 108 | /** |
---|
| 109 | \brief sets a new projectile to the weapon |
---|
| 110 | \returns the current projectile of this weapon |
---|
| 111 | |
---|
| 112 | weapon an projectile are independent, so you can combine them as you want |
---|
| 113 | */ |
---|
| 114 | Projectile* Weapon::getProjectile() |
---|
| 115 | { |
---|
| 116 | return this->projectile; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | /** |
---|
| 121 | \brief this activates the weapon |
---|
| 122 | |
---|
| 123 | This is needed, since there can be more than one weapon on a ship. the |
---|
| 124 | activation can be connected with an animation. for example the weapon is |
---|
| 125 | been armed out. |
---|
| 126 | */ |
---|
| 127 | void Weapon::activate() |
---|
| 128 | {} |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | /** |
---|
| 132 | \brief this deactivates the weapon |
---|
| 133 | |
---|
| 134 | This is needed, since there can be more than one weapon on a ship. the |
---|
| 135 | activation can be connected with an animation. for example the weapon is |
---|
| 136 | been armed out. |
---|
| 137 | */ |
---|
| 138 | void Weapon::deactivate() |
---|
| 139 | {} |
---|
| 140 | |
---|
| 141 | /** |
---|
| 142 | \brief asks if the current weapon is active |
---|
| 143 | \returns true if it the weapon is active |
---|
| 144 | */ |
---|
| 145 | bool Weapon::isActive() |
---|
| 146 | {} |
---|
| 147 | |
---|
[3576] | 148 | /** |
---|
[3583] | 149 | \brief sets a weapon idle time |
---|
| 150 | \param idle time in ms |
---|
[3575] | 151 | |
---|
[3583] | 152 | a weapon idle time is the time spend after a shoot until the weapon can |
---|
| 153 | shoot again |
---|
[3576] | 154 | */ |
---|
[3583] | 155 | void Weapon::setWeaponIdleTime(float time) |
---|
[3746] | 156 | { |
---|
| 157 | this->idleTime = time; |
---|
| 158 | } |
---|
[3575] | 159 | |
---|
[3576] | 160 | /** |
---|
[3583] | 161 | \brief gets the weapon idle time |
---|
| 162 | \returns idle time in ms |
---|
[3575] | 163 | |
---|
[3583] | 164 | a weapon idle time is the time spend after a shoot until the weapon can |
---|
| 165 | shoot again |
---|
[3576] | 166 | */ |
---|
[3583] | 167 | float Weapon::getWeaponIdleTime(void) |
---|
[3746] | 168 | { |
---|
| 169 | return this->idleTime; |
---|
| 170 | } |
---|
[3576] | 171 | |
---|
[3575] | 172 | /** |
---|
[3583] | 173 | \brief checks if the idle time is elapsed |
---|
| 174 | \return true if time is elapsed |
---|
[3576] | 175 | |
---|
[3583] | 176 | a weapon idle time is the time spend after a shoot until the weapon can |
---|
| 177 | shoot again |
---|
[3576] | 178 | */ |
---|
[3583] | 179 | bool Weapon::hasWeaponIdleTimeElapsed(void) |
---|
[3746] | 180 | { |
---|
| 181 | return (this->localTime>this->idleTime)?true:false; |
---|
| 182 | } |
---|
[3576] | 183 | |
---|
| 184 | |
---|
| 185 | /** |
---|
[3577] | 186 | \brief fires the weapon |
---|
| 187 | |
---|
| 188 | this is called from the player.cc, when fire-button is been pushed |
---|
[3575] | 189 | */ |
---|
[3577] | 190 | void Weapon::fire() |
---|
[3575] | 191 | {} |
---|
| 192 | |
---|
[3577] | 193 | |
---|
[3575] | 194 | /** |
---|
| 195 | \brief is called, when the weapon gets hit (=collide with something) |
---|
| 196 | \param from which entity it is been hit |
---|
| 197 | \param where it is been hit |
---|
| 198 | |
---|
| 199 | this may not be used, since it would make the game relay complicated when one |
---|
| 200 | can destroy the weapons of enemies or vice versa. |
---|
| 201 | */ |
---|
[3578] | 202 | void Weapon::hit (WorldEntity* entity, Vector* position) |
---|
[3575] | 203 | {} |
---|
| 204 | |
---|
[3577] | 205 | |
---|
[3575] | 206 | /** |
---|
| 207 | \brief is called, when the weapon is destroyed |
---|
| 208 | |
---|
| 209 | this is in conjunction with the hit function, so when a weapon is able to get |
---|
| 210 | hit, it can also be destoryed. |
---|
| 211 | */ |
---|
| 212 | void Weapon::destroy () |
---|
| 213 | {} |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | /** |
---|
[3577] | 217 | \brief tick signal for time dependent/driven stuff |
---|
| 218 | */ |
---|
| 219 | void Weapon::tick (float time) |
---|
| 220 | {} |
---|
| 221 | |
---|
| 222 | |
---|
| 223 | /** |
---|
[3583] | 224 | \brief is called, when there is no fire button pressed |
---|
| 225 | */ |
---|
| 226 | void Weapon::weaponIdle() |
---|
| 227 | {} |
---|
| 228 | |
---|
| 229 | |
---|
| 230 | /** |
---|
[3575] | 231 | \brief this will draw the weapon |
---|
| 232 | */ |
---|
[3573] | 233 | void Weapon::draw () |
---|
[3583] | 234 | {} |
---|
[3575] | 235 | |
---|