Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/AsteroidMining_HS17/src/orxonox/worldentities/pawns/AsteroidMinable.cc @ 11508

Last change on this file since 11508 was 11508, checked in by remartin, 7 years ago

Started cobbling together the class 'AsteroidMining'. Adapted the mesh of a crate in AsteroidFarming.oxw → destructible asteroid!

File size: 5.2 KB
Line 
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:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      Simon Miescher
26 *
27 */
28
29/*
30*
31*
32* An asteroid which can be destroyed. Some smaller asteroids are created and a pickup
33* spawns.
34*
35*
36*
37
38*/
39
40
41#include "Pawn.h"
42#include "AsteroidMinable.h"
43
44
45#include <algorithm>
46
47#include "core/CoreIncludes.h"
48#include "core/GameMode.h"
49#include "core/XMLPort.h"
50#include "core/EventIncludes.h"
51#include "network/NetworkFunction.h"
52
53#include "infos/PlayerInfo.h"
54#include "controllers/Controller.h"
55#include "gametypes/Gametype.h"
56#include "graphics/ParticleSpawner.h"
57#include "worldentities/ExplosionChunk.h"
58#include "worldentities/ExplosionPart.h"
59#include "weaponsystem/WeaponSystem.h"
60#include "weaponsystem/WeaponSlot.h"
61#include "weaponsystem/WeaponPack.h"
62#include "weaponsystem/WeaponSet.h"
63#include "weaponsystem/Munition.h"
64#include "sound/WorldSound.h"
65#include "core/object/ObjectListIterator.h"
66
67#include "controllers/FormationController.h"
68
69namespace orxonox
70{
71    RegisterClass(AsteroidMinable);
72
73    AsteroidMinable::AsteroidMinable(Context* context) : Pawn(context)
74    {
75        RegisterObject(AsteroidMinable);
76
77        this->bAlive_ = true;
78        this->bVulnerable_ = true;
79
80        this->health_ = 0;
81        this->maxHealth_ = 0;
82        this->initialHealth_ = 0;
83
84        this->damageMultiplier_ = 1;
85
86        this->spawnparticleduration_ = 3.0f;
87
88        this->aimPosition_ = Vector3::ZERO;
89
90        this->setRadarObjectColour(ColourValue::Yellow);
91        this->setRadarObjectShape(RadarViewable::Shape::Dot);
92 
93    }
94
95    AsteroidMinable::~AsteroidMinable()
96    {
97
98    }
99
100    void AsteroidMinable::XMLPort(Element& xmlelement, XMLPort::Mode mode)
101    {
102        SUPER(AsteroidMinable, XMLPort, xmlelement, mode);
103    }
104
105    void AsteroidMinable::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
106    {
107        SUPER(AsteroidMinable, XMLEventPort, xmlelement, mode);
108
109        XMLPortEventState(AsteroidMinable, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
110    }
111
112    void AsteroidMinable::registerVariables()
113    {
114        registerVariable(this->bAlive_,            VariableDirection::ToClient);
115        registerVariable(this->bVulnerable_,       VariableDirection::ToClient);
116        registerVariable(this->health_,            VariableDirection::ToClient);
117        registerVariable(this->maxHealth_,         VariableDirection::ToClient);
118    }
119
120    void AsteroidMinable::tick(float dt)
121    {
122        SUPER(Pawn, tick, dt);
123
124    }
125
126    void AsteroidMinable::death() //ueberschreiben
127    {
128        this->setHealth(1);
129        if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
130        {
131            // Set bAlive_ to false and wait for destroyLater() to do the destruction
132            this->bAlive_ = false;
133            this->destroyLater();
134
135            this->setDestroyWhenPlayerLeft(false);
136
137        }
138    }
139
140}
141
142
143
144/*
145    void DronePickup::changedUsed(void)
146    {
147        SUPER(DronePickup, changedUsed);
148
149        // If the pickup has transited to used.
150        if(this->isUsed())
151        {
152
153                Pawn* pawn = this->carrierToPawnHelper();
154                if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
155                    this->Pickupable::destroy();
156
157                //Attach to pawn
158                Drone* drone = new Drone(pawn->getContext()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)
159                drone->addTemplate(this->getDroneTemplate());
160
161                Controller* controller = drone->getController();
162                DroneController* droneController = orxonox_cast<DroneController*>(controller);
163                if(droneController != nullptr)
164                {
165                    droneController->setOwner(pawn);
166                }
167
168                Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(30,0,-30);
169                drone->setPosition(spawnPosition);
170
171                // The pickup has been used up.
172                this->setUsed(false);
173        }
174        else
175        {
176            // If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
177            if(this->isOnce() || (this->isContinuous() ))
178            {
179                this->Pickupable::destroy();
180            }
181        }
182    }
183*/
Note: See TracBrowser for help on using the repository browser.