[8685] | 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: Patrick Boenzli |
---|
| 13 | co-programmer: ... |
---|
| 14 | |
---|
| 15 | */ |
---|
| 16 | |
---|
| 17 | #include "fps_player.h" |
---|
| 18 | |
---|
| 19 | #include "interactive_model.h" |
---|
[8731] | 20 | #include "state.h" |
---|
[8685] | 21 | |
---|
| 22 | #include "src/lib/util/loading/factory.h" |
---|
| 23 | |
---|
[9110] | 24 | #include "md2/md2Model.h" |
---|
| 25 | |
---|
[8776] | 26 | #include "weapons/weapon_manager.h" |
---|
| 27 | #include "weapons/test_gun.h" |
---|
| 28 | #include "weapons/turret.h" |
---|
| 29 | #include "weapons/cannon.h" |
---|
[8894] | 30 | #include "weapons/fps_sniper_rifle.h" |
---|
[9163] | 31 | #include "weapons/aiming_system.h" |
---|
[8776] | 32 | |
---|
[9110] | 33 | #include "aabb.h" |
---|
| 34 | |
---|
[9166] | 35 | |
---|
[8685] | 36 | #include "key_mapper.h" |
---|
| 37 | |
---|
[8687] | 38 | #include "debug.h" |
---|
[8685] | 39 | |
---|
[9110] | 40 | #include "shared_network_data.h" |
---|
[8685] | 41 | |
---|
[8687] | 42 | |
---|
[8731] | 43 | |
---|
[8685] | 44 | CREATE_FACTORY(FPSPlayer, CL_FPS_PLAYER); |
---|
| 45 | |
---|
[8894] | 46 | #include "script_class.h" |
---|
| 47 | CREATE_SCRIPTABLE_CLASS(FPSPlayer, CL_FPS_PLAYER, |
---|
| 48 | addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor)) |
---|
| 49 | ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX)) |
---|
| 50 | ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY)) |
---|
| 51 | ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ)) |
---|
| 52 | ); |
---|
[8685] | 53 | |
---|
[8894] | 54 | |
---|
[8685] | 55 | /** |
---|
| 56 | * destructs the FPSPlayer, deletes alocated memory |
---|
| 57 | */ |
---|
| 58 | FPSPlayer::~FPSPlayer () |
---|
| 59 | { |
---|
| 60 | this->setPlayer(NULL); |
---|
[9191] | 61 | |
---|
| 62 | if( this->aimingSystem) |
---|
| 63 | delete this->aimingSystem; |
---|
[8685] | 64 | } |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | /** |
---|
| 68 | * creates a new FPSPlayer from Xml Data |
---|
| 69 | * @param root the xml element containing FPSPlayer data |
---|
| 70 | * |
---|
| 71 | */ |
---|
| 72 | FPSPlayer::FPSPlayer(const TiXmlElement* root) |
---|
| 73 | { |
---|
| 74 | this->init(); |
---|
| 75 | |
---|
| 76 | if (root != NULL) |
---|
| 77 | this->loadParams(root); |
---|
| 78 | |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | /** |
---|
| 83 | * initializes a FPSPlayer |
---|
| 84 | */ |
---|
| 85 | void FPSPlayer::init() |
---|
| 86 | { |
---|
| 87 | this->setClassID(CL_FPS_PLAYER, "FPSPlayer"); |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | this->bLeft = false; |
---|
| 91 | this->bRight = false; |
---|
| 92 | this->bForward = false; |
---|
| 93 | this->bBackward = false; |
---|
| 94 | this->bJump = false; |
---|
[9003] | 95 | this->bPosBut = false; |
---|
[9166] | 96 | this->bFire = false; |
---|
[8731] | 97 | |
---|
[8685] | 98 | this->xMouse = 0.0f; |
---|
| 99 | this->yMouse = 0.0f; |
---|
| 100 | |
---|
| 101 | this->setHealthMax(100); |
---|
| 102 | this->setHealth(80); |
---|
| 103 | |
---|
[9003] | 104 | this->fallVelocity = 0.0f; |
---|
[9110] | 105 | this->jumpForce = 0.0f; |
---|
[8685] | 106 | |
---|
[8731] | 107 | this->cameraNode.setParent(this); |
---|
| 108 | |
---|
| 109 | this->attitude = this->getAbsDir().getAttitude(); |
---|
| 110 | this->heading = this->getAbsDir().getHeading(); |
---|
| 111 | |
---|
[8685] | 112 | //add events to the eventlist |
---|
| 113 | registerEvent(KeyMapper::PEV_FORWARD); |
---|
| 114 | registerEvent(KeyMapper::PEV_BACKWARD); |
---|
| 115 | registerEvent(KeyMapper::PEV_LEFT); |
---|
| 116 | registerEvent(KeyMapper::PEV_RIGHT); |
---|
| 117 | registerEvent(KeyMapper::PEV_FIRE1); |
---|
[8687] | 118 | registerEvent(KeyMapper::PEV_JUMP); |
---|
[8685] | 119 | registerEvent(EV_MOUSE_MOTION); |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|
[8776] | 123 | // weapon manager for the fps |
---|
[8685] | 124 | dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false); |
---|
| 125 | |
---|
[8894] | 126 | Weapon* wpRight = new FPSSniperRifle(0); |
---|
[8776] | 127 | wpRight->setName("testGun Right"); |
---|
[8894] | 128 | /* Weapon* wpLeft = new TestGun(1);*/ |
---|
[8776] | 129 | // Weapon* wpLeft = new Turret(); |
---|
[8894] | 130 | // wpLeft->setName("testGun Left"); |
---|
[8776] | 131 | |
---|
[8894] | 132 | // this->addWeapon(wpLeft, 1, 0); |
---|
| 133 | this->addWeapon(wpRight,1, 0); |
---|
[8776] | 134 | this->getWeaponManager().changeWeaponConfig(1); |
---|
| 135 | |
---|
| 136 | this->getWeaponManager().setSlotCount(2); |
---|
[9207] | 137 | this->getWeaponManager().setSlotDirection(0, Quaternion(M_PI_4*-0.55f, Vector(0,0,1))); |
---|
[8776] | 138 | this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL); |
---|
[9110] | 139 | this->getWeaponManager().setSlotDirection(1, Quaternion(M_PI_4*.5, Vector(1,0,0))); |
---|
| 140 | this->getWeaponManager().setSlotPosition(0, Vector(1.5, -0.7, 1.1)); |
---|
[9003] | 141 | this->getWeaponManager().setSlotPosition(1, Vector(5.0, 0.0, 0.0)); |
---|
[8776] | 142 | |
---|
[9207] | 143 | // this->getWeaponManager().getFixedTarget()->setRelDir(Quaternion(M_PI_4*-0.6f, Vector(0,0,1))); |
---|
[9110] | 144 | |
---|
[9207] | 145 | |
---|
[8844] | 146 | this->getWeaponManager().setParentNode(&this->cameraNode); |
---|
[8846] | 147 | this->cameraNode.addNodeFlags(PNODE_PROHIBIT_CHILD_DELETE); |
---|
| 148 | |
---|
[8776] | 149 | this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode); |
---|
| 150 | this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0); |
---|
| 151 | |
---|
[9168] | 152 | this->aimingSystem = new AimingSystem(this); |
---|
[9207] | 153 | //this->addChild(this->aimingSystem); |
---|
| 154 | wpRight->addChild(this->aimingSystem); |
---|
| 155 | // this->getWeaponManager().sl |
---|
[8776] | 156 | |
---|
[9166] | 157 | |
---|
[8686] | 158 | // network registration |
---|
[8685] | 159 | registerVar( new SynchronizeableBool( &bLeft, &bLeft, "bLeft", PERMISSION_OWNER ) ); |
---|
| 160 | registerVar( new SynchronizeableBool( &bRight, &bRight, "bRight", PERMISSION_OWNER ) ); |
---|
| 161 | registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) ); |
---|
| 162 | registerVar( new SynchronizeableBool( &bBackward, &bBackward, "bBackward", PERMISSION_OWNER ) ); |
---|
[9139] | 163 | registerVar( new SynchronizeableBool( &bJump, &bJump, "bJump", PERMISSION_OWNER ) ); |
---|
[9110] | 164 | registerVar( new SynchronizeableFloat( &heading, &heading, "heading", PERMISSION_OWNER ) ); |
---|
| 165 | registerVar( new SynchronizeableFloat( &attitude, &attitude, "attitude", PERMISSION_OWNER ) ); |
---|
[9126] | 166 | |
---|
| 167 | //subscribe to collision reaction |
---|
| 168 | this->subscribeReaction(CREngine::CR_PHYSICS_FULL_WALK, CL_BSP_ENTITY); |
---|
[9148] | 169 | |
---|
[9139] | 170 | this->initWeapon = false; |
---|
[9214] | 171 | this->damageTicker = 0.0f; |
---|
| 172 | |
---|
[9213] | 173 | toList( OM_PLAYERS ); |
---|
[8685] | 174 | } |
---|
| 175 | |
---|
| 176 | |
---|
| 177 | /** |
---|
| 178 | * loads the Settings of a FPSPlayer from an XML-element. |
---|
| 179 | * @param root the XML-element to load the Spaceship's properties from |
---|
| 180 | */ |
---|
| 181 | void FPSPlayer::loadParams(const TiXmlElement* root) |
---|
| 182 | { |
---|
| 183 | Playable::loadParams(root); |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | void FPSPlayer::setPlayDirection(const Quaternion& quat, float speed) |
---|
| 187 | { |
---|
[8731] | 188 | this->attitude = this->getAbsDir().getAttitude(); |
---|
| 189 | this->heading = this->getAbsDir().getHeading(); |
---|
[8685] | 190 | } |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | void FPSPlayer::reset() |
---|
| 194 | { |
---|
| 195 | this->bLeft = false; |
---|
| 196 | this->bRight = false; |
---|
| 197 | this->bForward = false; |
---|
| 198 | this->bBackward = false; |
---|
| 199 | this->xMouse = 0.0f; |
---|
| 200 | this->yMouse = 0.0f; |
---|
| 201 | |
---|
| 202 | this->setHealth(80); |
---|
| 203 | } |
---|
| 204 | |
---|
| 205 | |
---|
| 206 | void FPSPlayer::enter() |
---|
| 207 | { |
---|
[8731] | 208 | dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( true ); |
---|
| 209 | |
---|
| 210 | State::getCameraNode()->setParentSoft(&this->cameraNode); |
---|
| 211 | State::getCameraTargetNode()->setParentSoft(&this->cameraNode); |
---|
| 212 | |
---|
| 213 | this->getWeaponManager().getFixedTarget()->setParent(State::getCameraTargetNode()); |
---|
| 214 | this->getWeaponManager().getFixedTarget()->setRelCoor(0,0,0); |
---|
[9123] | 215 | |
---|
[9136] | 216 | if ( !State::isOnline() ) |
---|
| 217 | { |
---|
| 218 | this->respawn(); |
---|
| 219 | } |
---|
[8685] | 220 | } |
---|
| 221 | |
---|
| 222 | void FPSPlayer::leave() |
---|
| 223 | { |
---|
| 224 | dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false); |
---|
| 225 | this->detachCamera(); |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | |
---|
| 229 | |
---|
| 230 | /** |
---|
| 231 | * the function called for each passing timeSnap |
---|
| 232 | * @param time The timespan passed since last update |
---|
| 233 | */ |
---|
| 234 | void FPSPlayer::tick (float time) |
---|
| 235 | { |
---|
[9148] | 236 | |
---|
[9139] | 237 | if ( !this->initWeapon ) |
---|
| 238 | { |
---|
| 239 | this->initWeapon = true; |
---|
[9148] | 240 | |
---|
[9207] | 241 | this->cameraNode.setParentMode(PNODE_ROTATE_AND_MOVE); |
---|
[9194] | 242 | |
---|
| 243 | this->getWeaponManager().getParentNode()->setParentMode(PNODE_ROTATE_AND_MOVE); |
---|
| 244 | this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode); |
---|
| 245 | this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ROTATE_AND_MOVE); |
---|
| 246 | |
---|
| 247 | |
---|
| 248 | this->aimingSystem->toList(OM_GROUP_01); |
---|
| 249 | this->aimingSystem->setParent(&this->cameraNode); |
---|
[9207] | 250 | // this->aimingSystem->setParentMode(PNODE_ROTATE_AND_MOVE); |
---|
[9211] | 251 | this->aimingSystem->setRelDir(Quaternion(M_PI_4*-0.58f, Vector(0,0,1))); |
---|
[9207] | 252 | this->aimingSystem->setRelCoor(0, -1, -1); |
---|
[9194] | 253 | |
---|
| 254 | |
---|
[9139] | 255 | AABB* box = this->getModelAABB(); |
---|
| 256 | if( box != NULL) |
---|
| 257 | { |
---|
[9209] | 258 | float f = 1.0; |
---|
[9207] | 259 | this->cameraNode.setRelCoor(0, box->halfLength[1] * f, 0); |
---|
[9211] | 260 | // this->cameraNode.setRelCoor(10, box->halfLength[1] * f, 0); |
---|
[9110] | 261 | |
---|
[9211] | 262 | float v = 0.1f; |
---|
| 263 | this->getWeaponManager().setSlotPosition(0, Vector(-8.0, box->halfLength[1] * v, 1.1)); |
---|
| 264 | this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * v, 0.0)); |
---|
[9139] | 265 | } |
---|
| 266 | } |
---|
| 267 | |
---|
[9123] | 268 | if( this->bJump) |
---|
[9003] | 269 | { |
---|
[9110] | 270 | printf("mechanic2:walkTo( %f, mtheight, %f)\n",this->getAbsCoorX(),this->getAbsCoorZ()); |
---|
[9003] | 271 | } |
---|
[9110] | 272 | |
---|
[9151] | 273 | |
---|
[9166] | 274 | this->getWeaponManager().tick(time); |
---|
| 275 | if( this->bFire) |
---|
| 276 | { |
---|
[9207] | 277 | this->getWeaponManager().fire(); |
---|
[9151] | 278 | |
---|
[9214] | 279 | // WorldEntity* target = this->aimingSystem->getNearestTarget(); |
---|
| 280 | // if( target != NULL) |
---|
| 281 | // { |
---|
| 282 | // PRINTF(0)("hit hit hit, got: %s\n", target->getClassName()); |
---|
| 283 | // } |
---|
| 284 | // else |
---|
| 285 | // { |
---|
| 286 | // PRINTF(0)("nothing hit\n"); |
---|
| 287 | // } |
---|
| 288 | } |
---|
| 289 | |
---|
| 290 | |
---|
| 291 | //dealing damage |
---|
| 292 | |
---|
| 293 | if ( State::isOnline() && SharedNetworkData::getInstance()->isGameServer() ) |
---|
| 294 | { |
---|
| 295 | this->damageTicker -= time; |
---|
| 296 | |
---|
| 297 | if ( this->damageTicker <= 0.0f && this->beFire() ) |
---|
[9166] | 298 | { |
---|
[9214] | 299 | this->damageTicker = 0.25; |
---|
| 300 | |
---|
| 301 | WorldEntity * victim = aimingSystem->getNearestTarget(); |
---|
| 302 | |
---|
| 303 | if ( victim ) |
---|
| 304 | { |
---|
| 305 | PRINTF(0)("FIRE: hit %s\n", victim->getClassName()); |
---|
| 306 | victim->hit( 20, this ); |
---|
| 307 | } |
---|
| 308 | else |
---|
| 309 | { |
---|
| 310 | PRINTF(0)("FIRE: nothing hit\n"); |
---|
| 311 | } |
---|
[9166] | 312 | } |
---|
| 313 | } |
---|
[9151] | 314 | |
---|
[8685] | 315 | |
---|
[9110] | 316 | if( ( xMouse != 0 || yMouse != 0 ) && (this->getOwner() == SharedNetworkData::getInstance()->getHostID() || !State::isOnline() ) ) |
---|
[8685] | 317 | { |
---|
[8687] | 318 | xMouse *= time ; |
---|
| 319 | yMouse *= time ; |
---|
[8685] | 320 | |
---|
[8731] | 321 | heading -= xMouse; |
---|
| 322 | attitude-= yMouse; |
---|
[8685] | 323 | |
---|
| 324 | |
---|
[9207] | 325 | if ( attitude > 1.95 ) |
---|
| 326 | attitude = 1.95; |
---|
| 327 | else if ( attitude < -1.07 ) |
---|
| 328 | attitude = -1.07; |
---|
[8685] | 329 | |
---|
| 330 | xMouse = yMouse = 0; |
---|
| 331 | } |
---|
| 332 | |
---|
[9110] | 333 | this->setAbsDir(Quaternion(heading, Vector(0,1,0))); |
---|
| 334 | this->cameraNode.setRelDir(Quaternion( attitude, Vector( 0, 0, 1 ) )); |
---|
[8685] | 335 | |
---|
| 336 | Vector velocity; |
---|
| 337 | |
---|
| 338 | if ( this->bForward ) |
---|
| 339 | { |
---|
| 340 | velocity += this->getAbsDirX(); |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | if ( this->bBackward ) |
---|
| 344 | { |
---|
| 345 | velocity -= this->getAbsDirX(); |
---|
| 346 | } |
---|
| 347 | |
---|
| 348 | if ( this->bRight ) |
---|
| 349 | { |
---|
| 350 | velocity += this->getAbsDirZ(); |
---|
| 351 | } |
---|
| 352 | |
---|
| 353 | if ( this->bLeft ) |
---|
| 354 | { |
---|
| 355 | velocity -= this->getAbsDirZ(); |
---|
| 356 | } |
---|
| 357 | |
---|
[9003] | 358 | |
---|
[8685] | 359 | velocity *= 100; |
---|
| 360 | |
---|
[9110] | 361 | if( this->bJump && likely(this->getModel(0) != NULL)) |
---|
| 362 | { |
---|
| 363 | if( this->jumpForce < 1.0f) |
---|
| 364 | { |
---|
| 365 | this->jumpForce = 300.0f; |
---|
[9003] | 366 | |
---|
[9110] | 367 | if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP) |
---|
| 368 | ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP); |
---|
| 369 | } |
---|
| 370 | } |
---|
| 371 | else if(velocity.len() != 0.0f) |
---|
| 372 | { |
---|
| 373 | if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN) |
---|
| 374 | ((InteractiveModel*)this->getModel(0))->setAnimation(RUN); |
---|
| 375 | } |
---|
| 376 | else |
---|
| 377 | { |
---|
| 378 | if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND) |
---|
| 379 | ((InteractiveModel*)this->getModel(0))->setAnimation(STAND); |
---|
| 380 | } |
---|
| 381 | |
---|
| 382 | |
---|
| 383 | velocity.y += this->jumpForce; |
---|
| 384 | if( this->jumpForce > 1.0f) |
---|
| 385 | this->jumpForce *= 0.9f; |
---|
| 386 | |
---|
| 387 | |
---|
[9003] | 388 | // physical falling of the player |
---|
| 389 | if( !this->isOnGround()) |
---|
| 390 | { |
---|
| 391 | this->fallVelocity += 300.0f * time; |
---|
| 392 | velocity -= Vector(0.0, 1.0, 0.0) * this->fallVelocity; |
---|
[9211] | 393 | |
---|
[9213] | 394 | // PRINTF(0)("vel %f\n", this->fallVelocity); |
---|
[9003] | 395 | } |
---|
| 396 | else |
---|
| 397 | { |
---|
| 398 | this->fallVelocity = 0.0f; |
---|
| 399 | } |
---|
| 400 | |
---|
[8685] | 401 | this->shiftCoor( velocity*time ); |
---|
| 402 | |
---|
| 403 | |
---|
| 404 | |
---|
| 405 | |
---|
[9003] | 406 | |
---|
| 407 | |
---|
| 408 | |
---|
[8693] | 409 | if( likely(this->getModel(0) != NULL) && this->getModel(0)->isA(CL_INTERACTIVE_MODEL)) |
---|
| 410 | { |
---|
| 411 | ((InteractiveModel*)this->getModel(0))->tick(time); |
---|
[9110] | 412 | |
---|
| 413 | // handle animations differently |
---|
| 414 | |
---|
| 415 | |
---|
| 416 | |
---|
| 417 | |
---|
| 418 | |
---|
[8685] | 419 | // else if( this->bFire && likely(this->getModel(0) != NULL)) |
---|
| 420 | // { |
---|
| 421 | // if( ((InteractiveModel*)this->getModel(0))->getAnim() != ATTACK) |
---|
| 422 | // ((InteractiveModel*)this->getModel(0))->setAnimation(ATTACK); |
---|
| 423 | // } |
---|
| 424 | // else if( fabs(move.len()) > 0.0f && likely(this->getModel(0) != NULL)) |
---|
| 425 | // { |
---|
| 426 | // if( ((InteractiveModel*)this->getModel(0))->getAnim() != RUN) |
---|
| 427 | // ((InteractiveModel*)this->getModel(0))->setAnimation(RUN); |
---|
| 428 | // } |
---|
[8687] | 429 | // else if (likely(this->getModel(0) != NULL)) |
---|
| 430 | // { |
---|
| 431 | // if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND) |
---|
| 432 | // ((InteractiveModel*)this->getModel(0))->setAnimation(STAND); |
---|
| 433 | // } |
---|
[8693] | 434 | } |
---|
[8685] | 435 | |
---|
[9148] | 436 | this->setOnGround(false); |
---|
[9172] | 437 | this->aimingSystem->flushList(); |
---|
[8685] | 438 | } |
---|
| 439 | |
---|
| 440 | |
---|
| 441 | |
---|
[8686] | 442 | /** |
---|
| 443 | * draws the MD2Creature after transforming it. |
---|
| 444 | */ |
---|
| 445 | void FPSPlayer::draw () const |
---|
| 446 | { |
---|
| 447 | // only draw if this entity is not the player since the player nevers sees himself |
---|
[8699] | 448 | if( this->getCurrentPlayer() == NULL) |
---|
[8686] | 449 | WorldEntity::draw(); |
---|
| 450 | } |
---|
[8685] | 451 | |
---|
| 452 | |
---|
| 453 | |
---|
| 454 | /** |
---|
[8686] | 455 | * process |
---|
[8685] | 456 | */ |
---|
| 457 | void FPSPlayer::process(const Event &event) |
---|
| 458 | { |
---|
| 459 | Playable::process(event); |
---|
| 460 | |
---|
| 461 | if( event.type == KeyMapper::PEV_LEFT) |
---|
| 462 | this->bLeft = event.bPressed; |
---|
| 463 | else if( event.type == KeyMapper::PEV_RIGHT) |
---|
| 464 | this->bRight = event.bPressed; |
---|
| 465 | else if( event.type == KeyMapper::PEV_FORWARD) |
---|
| 466 | this->bForward = event.bPressed; //this->shiftCoor(0,.1,0); |
---|
| 467 | else if( event.type == KeyMapper::PEV_BACKWARD) |
---|
| 468 | this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0); |
---|
| 469 | else if( event.type == EV_MOUSE_MOTION) |
---|
| 470 | { |
---|
| 471 | this->xMouse += event.xRel; |
---|
| 472 | this->yMouse += event.yRel; |
---|
| 473 | } |
---|
[8705] | 474 | else if( event.type == KeyMapper::PEV_JUMP) |
---|
[9166] | 475 | { |
---|
[9110] | 476 | this->bJump = event.bPressed; |
---|
[9166] | 477 | } |
---|
| 478 | else if( event.type == KeyMapper::PEV_FIRE1) |
---|
| 479 | { |
---|
| 480 | this->bFire = event.bPressed; |
---|
| 481 | } |
---|
[8685] | 482 | } |
---|
| 483 | |
---|
[9158] | 484 | |
---|
[9122] | 485 | void FPSPlayer::respawn( ) |
---|
| 486 | { |
---|
[9151] | 487 | if( State::isOnline()) |
---|
| 488 | toList( OM_PLAYERS ); |
---|
[9214] | 489 | |
---|
| 490 | this->damageTicker = 0.0f; |
---|
[9122] | 491 | } |
---|
[8685] | 492 | |
---|
[9213] | 493 | |
---|
[9162] | 494 | void FPSPlayer::destroy( WorldEntity* killer ) |
---|
| 495 | { |
---|
| 496 | Playable::destroy( killer ); |
---|
[9166] | 497 | |
---|
[9162] | 498 | toList( OM_DEAD ); |
---|
| 499 | } |
---|
| 500 | |
---|