Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Boxhead_FS19/src/modules/weapons/projectiles/HoverGunProjectile.cc @ 12394

Last change on this file since 12394 was 12284, checked in by cwaupoti, 6 years ago

added working HoverGun

File size: 2.8 KB
RevLine 
[12262]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
[12284]23 *      Fabian 'x3n' Landau
[12262]24 *   Co-authors:
[12284]25 *      simonmie
[12262]26 *
27 */
28
29/**
[12273]30    @file HoverGunProjectile.h
31    @brief Implementation of the HoverGunProjectile class.
[12262]32*/
33
34#include "HoverGunProjectile.h"
35
[12284]36#include "core/config/ConfigValueIncludes.h"
[12262]37#include "core/CoreIncludes.h"
[12284]38#include "core/GameMode.h"
[12262]39#include "core/command/Executor.h"
40
[12284]41#include "worldentities/pawns/Pawn.h"
42
[12262]43namespace orxonox
44{
45    RegisterClass(HoverGunProjectile);
46
[12284]47    HoverGunProjectile::HoverGunProjectile(Context* context) : MovableEntity(context), BasicProjectile()
[12262]48    {
49        RegisterObject(HoverGunProjectile);
50
[12284]51        this->setConfigValues();
[12262]52
[12284]53        // Get notification about collisions
54        if (GameMode::isMaster())
55        {
56            this->setMass(0.0000000001f);
57            this->enableCollisionCallback();
58            this->setCollisionResponse(false);
59            this->setCollisionType(CollisionType::Dynamic);
60
61            // Create a sphere collision shape and attach it to the projectile.
62            collisionShape_ = new SphereCollisionShape(this->getContext());
63            setCollisionShapeRadius(2.0f);
64            this->attachCollisionShape(collisionShape_);
65
66            this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&BasicProjectile::destroyObject, this)));
67        }
[12262]68    }
69
[12284]70    HoverGunProjectile::~HoverGunProjectile()
[12262]71    {
72    }
73
[12284]74    void HoverGunProjectile::setConfigValues()
[12262]75    {
[12284]76        SetConfigValue(lifetime_, 4.0f).description("The time in seconds a projectile stays alive");
77    }
[12262]78
[12284]79
80    bool HoverGunProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
81    {
82        return this->processCollision(otherObject, contactPoint, cs);
[12262]83    }
84
[12284]85    void HoverGunProjectile::setCollisionShapeRadius(float radius)
[12262]86    {
[12284]87        if (collisionShape_ != nullptr && radius > 0)
88        {
89            collisionShape_->setRadius(radius);
90        }       
[12262]91    }
92}
Note: See TracBrowser for help on using the repository browser.