[Orxonox-commit 523] r3073 - in trunk: . src/orxonox src/orxonox/objects/controllers src/orxonox/objects/items src/orxonox/objects/pickup src/orxonox/objects/pickup/items src/orxonox/objects/weaponsystem/projectiles src/orxonox/objects/worldentities src/orxonox/objects/worldentities/pawns
landauf at orxonox.net
landauf at orxonox.net
Mon May 25 20:30:15 CEST 2009
Author: landauf
Date: 2009-05-25 20:30:15 +0200 (Mon, 25 May 2009)
New Revision: 3073
Added:
trunk/src/orxonox/objects/pickup/BaseItem.cc
trunk/src/orxonox/objects/pickup/BaseItem.h
trunk/src/orxonox/objects/pickup/DroppedItem.cc
trunk/src/orxonox/objects/pickup/DroppedItem.h
trunk/src/orxonox/objects/pickup/EquipmentItem.cc
trunk/src/orxonox/objects/pickup/EquipmentItem.h
trunk/src/orxonox/objects/pickup/ModifierPickup.cc
trunk/src/orxonox/objects/pickup/ModifierPickup.h
trunk/src/orxonox/objects/pickup/ModifierType.h
trunk/src/orxonox/objects/pickup/PassiveItem.cc
trunk/src/orxonox/objects/pickup/PassiveItem.h
trunk/src/orxonox/objects/pickup/PickupCollection.cc
trunk/src/orxonox/objects/pickup/PickupCollection.h
trunk/src/orxonox/objects/pickup/PickupInventory.cc
trunk/src/orxonox/objects/pickup/PickupInventory.h
trunk/src/orxonox/objects/pickup/PickupSpawner.cc
trunk/src/orxonox/objects/pickup/PickupSpawner.h
trunk/src/orxonox/objects/pickup/UsableItem.cc
trunk/src/orxonox/objects/pickup/UsableItem.h
trunk/src/orxonox/objects/pickup/items/
trunk/src/orxonox/objects/pickup/items/CMakeLists.txt
trunk/src/orxonox/objects/pickup/items/HealthImmediate.cc
trunk/src/orxonox/objects/pickup/items/HealthImmediate.h
trunk/src/orxonox/objects/pickup/items/HealthUsable.cc
trunk/src/orxonox/objects/pickup/items/HealthUsable.h
trunk/src/orxonox/objects/pickup/items/Jump.cc
trunk/src/orxonox/objects/pickup/items/Jump.h
Removed:
trunk/src/orxonox/objects/pickup/BaseItem.cc
trunk/src/orxonox/objects/pickup/BaseItem.h
trunk/src/orxonox/objects/pickup/PickupSpawner.cc
trunk/src/orxonox/objects/pickup/PickupSpawner.h
trunk/src/orxonox/objects/pickup/ShipEquipment.cc
trunk/src/orxonox/objects/pickup/ShipEquipment.h
trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.cc
trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.h
trunk/src/orxonox/objects/pickup/ShipItem.cc
trunk/src/orxonox/objects/pickup/ShipItem.h
trunk/src/orxonox/objects/pickup/Turbo.cc
trunk/src/orxonox/objects/pickup/Turbo.h
trunk/src/orxonox/objects/pickup/Usable.h
trunk/src/orxonox/objects/pickup/items/CMakeLists.txt
trunk/src/orxonox/objects/pickup/items/HealthImmediate.cc
trunk/src/orxonox/objects/pickup/items/HealthImmediate.h
trunk/src/orxonox/objects/pickup/items/HealthUsable.cc
trunk/src/orxonox/objects/pickup/items/HealthUsable.h
trunk/src/orxonox/objects/pickup/items/Jump.cc
trunk/src/orxonox/objects/pickup/items/Jump.h
Modified:
trunk/
trunk/src/orxonox/CMakeLists.txt
trunk/src/orxonox/objects/controllers/HumanController.cc
trunk/src/orxonox/objects/controllers/HumanController.h
trunk/src/orxonox/objects/items/Engine.cc
trunk/src/orxonox/objects/pickup/CMakeLists.txt
trunk/src/orxonox/objects/weaponsystem/projectiles/Projectile.cc
trunk/src/orxonox/objects/worldentities/ControllableEntity.h
trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
Log:
merged pickups2 branch back to trunk. not yet tested.
Property changes on: trunk
___________________________________________________________________
Modified: svn:ignore
- build
codeblocks
+ build
codeblocks
dependencies
Modified: svn:mergeinfo
- /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/miniprojects:2755-2825
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128
/branches/pickups2:2108-2498
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/sound:2830-3011
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891
+ /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/miniprojects:2755-2825
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128,2828-2916
/branches/pickups2:2108-2498,2916-3072
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/sound:2830-3011
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891
Modified: trunk/src/orxonox/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/CMakeLists.txt 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/CMakeLists.txt 2009-05-25 18:30:15 UTC (rev 3073)
@@ -35,7 +35,7 @@
SET(ORXONOX_FILES ${ORXONOX_SRC_FILES} ${ORXONOX_HDR_FILES})
GENERATE_SOURCE_GROUPS(${ORXONOX_FILES})
-GENERATE_TOLUA_BINDINGS(Orxonox ORXONOX_FILES INPUTFILES gui/GUIManager.h objects/quest/QuestManager.h objects/quest/QuestDescription.h)
+GENERATE_TOLUA_BINDINGS(Orxonox ORXONOX_FILES INPUTFILES gui/GUIManager.h objects/quest/QuestManager.h objects/quest/QuestDescription.h objects/pickup/PickupInventory.h objects/pickup/BaseItem.h)
# Not using precompiled header files: Avoid dependencies
INCLUDE_DIRECTORIES(pch/nopch)
Modified: trunk/src/orxonox/objects/controllers/HumanController.cc
===================================================================
--- trunk/src/orxonox/objects/controllers/HumanController.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/controllers/HumanController.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -48,13 +48,13 @@
SetConsoleCommand(HumanController, reload, true);
SetConsoleCommand(HumanController, boost, true).keybindMode(KeybindMode::OnHold);
SetConsoleCommand(HumanController, greet, true);
- SetConsoleCommand(HumanController, use, true);
SetConsoleCommand(HumanController, switchCamera, true);
SetConsoleCommand(HumanController, mouseLook, true);
SetConsoleCommand(HumanController, suicide, true);
SetConsoleCommand(HumanController, addBots, true).defaultValues(1);
SetConsoleCommand(HumanController, killBots, true).defaultValues(0);
SetConsoleCommand(HumanController, dropItems, true);
+ SetConsoleCommand(HumanController, useItem, true);
CreateUnloadableFactory(HumanController);
@@ -132,12 +132,6 @@
HumanController::localController_s->controllableEntity_->greet();
}
- void HumanController::use()
- {
- if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
- HumanController::localController_s->controllableEntity_->use();
- }
-
void HumanController::switchCamera()
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
@@ -162,6 +156,12 @@
}
}
+ void HumanController::useItem()
+ {
+ if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
+ HumanController::localController_s->controllableEntity_->useItem();
+ }
+
void HumanController::addBots(unsigned int amount)
{
if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
Modified: trunk/src/orxonox/objects/controllers/HumanController.h
===================================================================
--- trunk/src/orxonox/objects/controllers/HumanController.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/controllers/HumanController.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -33,6 +33,7 @@
#include "util/Math.h"
#include "Controller.h"
+#include "objects/worldentities/pawns/Pawn.h"
namespace orxonox
{
@@ -55,16 +56,27 @@
static void boost();
static void greet();
- static void use();
static void switchCamera();
static void mouseLook();
static void dropItems();
+ static void useItem();
static void suicide();
static void addBots(unsigned int amount);
static void killBots(unsigned int amount = 0);
+ static inline HumanController* getLocalControllerSingleton()
+ { return HumanController::localController_s; }
+ static inline Pawn* getLocalControllerEntityAsPawn()
+ {
+ if (HumanController::localController_s) {
+ return dynamic_cast<Pawn*>(HumanController::localController_s->getControllableEntity());
+ } else {
+ return NULL;
+ }
+ }
+
private:
static HumanController* localController_s;
};
Modified: trunk/src/orxonox/objects/items/Engine.cc
===================================================================
--- trunk/src/orxonox/objects/items/Engine.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/items/Engine.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -199,7 +199,7 @@
acceleration.y = direction.y * this->accelerationUpDown_ * clamp((this->maxSpeedUpDown_ - velocity.y) / this->maxSpeedUpDown_, 0.0f, 1.0f);
}
- this->ship_->setAcceleration(this->ship_->getOrientation() * acceleration);
+ this->ship_->setAcceleration(this->ship_->getPickups().processModifiers(ModifierType::Acceleration, this->ship_->getOrientation() * acceleration, false));
if (!this->ship_->getPermanentBoost())
this->ship_->setBoost(false);
Deleted: trunk/src/orxonox/objects/pickup/BaseItem.cc
===================================================================
--- trunk/src/orxonox/objects/pickup/BaseItem.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/BaseItem.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,78 +0,0 @@
-/* has to be added to player
- multimap<std::string, BaseItem*> Equipment;*/
-
-
-#include "OrxonoxStableHeaders.h"
-#include "BaseItem.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/String.h"
-#include "objects/worldentities/pawns/Pawn.h"
-
-
-namespace orxonox
-{
-BaseItem::BaseItem(BaseObject* creator) : BaseObject(creator)
-{
- RegisterObject(BaseItem);
-
- this->playerBaseClass_ = 0;
-}
-
-BaseItem::~BaseItem()
-{
-}
- void BaseItem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(BaseItem, XMLPort, xmlelement, mode);
-
- XMLPortParam(BaseItem, "playerclass", setPlayerBaseClassName, getPlayerBaseClassName, xmlelement, mode);
- }
-
-bool BaseItem::addTo (Pawn* player)
-{
-
- return player->getPickUp().insert(this);
- /*if(checkSlot(player)==true)
- player->pickUp.Equipment.insert ( std::pair<std::string, BaseItem*>(this->getName(),this) );
- else
- COUT(3) << "swap?" << std::endl;*/
-}
-bool BaseItem::remove(Pawn* player)
-{
- /*if(player->pickUp.Equipment.find(this->getName())!= player->pickUp.Equipment.end())
- {
- std::multimap<std::string,BaseItem*>::iterator it;
- it=player->pickUp.Equipment.find(this->getName());
- player->pickUp.Equipment.erase (it);
- return true;
- }
- else
- return false;*/
- return player->getPickUp().erase(this);
-}
-bool BaseItem::checkSlot(Pawn* player)
-{
- /*std::multimap<std::string,BaseItem*>::iterator it;
- for ( it=player->getPickUp().getEquipment().begin() ; it != player->getPickUp().getEquipment().end(); it++ )
- {
- if((*it).second->playerBaseClass_==this->playerBaseClass_)
- //das isch schmarre...machs mit isExactlyA(...)
- return false;
- }
- return true;*/
- return player->getPickUp().checkSlot(this);
-}
-void BaseItem::setPlayerBaseClassName(const std::string& name)
-{
- this->playerBaseClass_ = ClassByString(name);
-}
-
-const std::string& BaseItem::getPlayerBaseClassName() const
-{
- if (this->playerBaseClass_)
- return this->playerBaseClass_->getName();
- else
- return BLANKSTRING;
-}
-}
Copied: trunk/src/orxonox/objects/pickup/BaseItem.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/BaseItem.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/BaseItem.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/BaseItem.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,108 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of BaseItem (base-class for items/pickups).
+*/
+
+#include "BaseItem.h"
+
+#include "PickupCollection.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor. Registers the BaseItem.
+ @param creator Pointer to the object which created this item.
+ */
+ BaseItem::BaseItem(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(BaseItem);
+
+ this->setOwner(0);
+ this->setPickupIdentifier(this->getName());
+ this->setGUIImage("");
+ this->setGUIText("");
+ }
+ //! Deconstructor.
+ BaseItem::~BaseItem()
+ {
+ }
+
+ /**
+ @brief XMLPort for BaseItem.
+ @param xmlelement Element of the XML-file.
+ @param mode XMLPort mode to use.
+ */
+ void BaseItem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(BaseItem, XMLPort, xmlelement, mode);
+
+ XMLPortParam(BaseItem, "guiText", setGUIText, getGUIText, xmlelement, mode);
+ XMLPortParam(BaseItem, "guiImage", setGUIImage, getGUIImage, xmlelement, mode);
+ }
+
+ /**
+ @brief Method to add the item to a pawn.
+ @param pawn Pawn to which the item should get added.
+ @return Returns whether the pawn's PickupCollection accepted the item.
+ */
+ bool BaseItem::addTo(Pawn* pawn)
+ {
+ this->setOwner(pawn);
+
+ if (pawn->getPickups().add(this))
+ {
+ COUT(3) << "Added '" << this->getPickupIdentifier() << "' item." << std::endl;
+ return true;
+ }
+ return false;
+ }
+ /**
+ @brief Removes the item from a pawn.
+ @param pawn Pawn from which to remove the item.
+ @return Returns whether the pawn's PickupCollection was able to locate and remove the item.
+ */
+ bool BaseItem::removeFrom(Pawn* pawn)
+ {
+ this->setOwner(0);
+
+ COUT(3) << "Removing '" << this->getPickupIdentifier() << "' item." << std::endl;
+
+ pawn->getPickups().remove(this, false);
+
+ return true;
+ }
+
+ const std::string& BaseItem::getGUIText() const { return this->guiText_; }
+}
Deleted: trunk/src/orxonox/objects/pickup/BaseItem.h
===================================================================
--- trunk/src/orxonox/objects/pickup/BaseItem.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/BaseItem.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,37 +0,0 @@
-#ifndef _BaseItem_H__
-#define _BaseItem_H__
-
-#include "core/BaseObject.h"
-#include "OrxonoxPrereqs.h"
-
-namespace orxonox
-{
- class ShipEquipment;
-
- class _OrxonoxExport BaseItem : public BaseObject
- {
- public:
- BaseItem( BaseObject* creator);
- virtual ~BaseItem();
- bool checkSlot(Pawn* player);
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- virtual bool pickedUp(Pawn* player) { return true; }
- virtual bool dropped(Pawn* player) { return true; } //erst bei festen Items
- bool remove(Pawn* player);
- bool addTo(Pawn* player);
-
- inline void setPlayerBaseClass(Identifier* identifier)
- { this->playerBaseClass_ = identifier; }
- inline Identifier* getPlayerBaseClass() const
- { return this->playerBaseClass_; }
-
- private:
- void setPlayerBaseClassName(const std::string& name);
- const std::string& getPlayerBaseClassName() const;
-
- Identifier* playerBaseClass_;
- };
-}
-
-#endif /* _BaseItem_H__ */
Copied: trunk/src/orxonox/objects/pickup/BaseItem.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/BaseItem.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/BaseItem.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/BaseItem.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,152 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of BaseItem (base-class for items/pickups).
+*/
+
+#ifndef _BaseItem_H__
+#define _BaseItem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+// tolua_begin
+namespace orxonox
+{
+ /**
+ @brief
+ Base class for all items/pickups.
+
+ Provides common methods to be used in derived classes.
+ @author
+ Daniel 'Huty' Haggenmueller
+ */
+ class _OrxonoxExport BaseItem
+// tolua_end
+ : public BaseObject
+// tolua_begin
+ {
+// tolua_end
+ public:
+ BaseItem(BaseObject* creator);
+ virtual ~BaseItem();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
+
+ /**
+ @brief Checks how many instances of this item can be carried at a time.
+ @return How many of this item can be carried.
+ */
+ virtual int getMaxCarryAmount() const
+ { return 1; }
+
+ bool addTo(Pawn* pawn); //!< Add the item to a pawn.
+ bool removeFrom(Pawn* pawn); //!< Removes the item from a pawn.
+ /**
+ @brief
+ Method invoked when the item gets picked up.
+
+ Has to be overridden for an item to work,
+ should contain a call to addTo().
+
+ @param pawn Pawn who picks up the item.
+ @return Returns whether the pawn was able to pick up the item.
+ */
+ virtual bool pickedUp(Pawn* pawn)
+ { return false; }
+ /**
+ @brief
+ Method invoked when the item is dropped from a player.
+
+ Should be overridden by derived classes,
+ should also contain a call to removeFrom().
+
+ @param pawn Pawn which dropped the item.
+ @return Returns whether the item was able to get dropped by the pawn.
+ */
+ virtual bool dropped(Pawn* pawn)
+ { return false; }
+
+ /**
+ @brief Gets the current owner of the pickup.
+ @return Returns the current owner.
+ */
+ inline Pawn* getOwner() const
+ { return this->owner_; }
+ /**
+ @brief Sets the owner of the pickup.
+ @param owner New owner for the pickup.
+ */
+ inline void setOwner(Pawn* owner)
+ { this->owner_ = owner; }
+
+ /**
+ @brief Gets the pickupIdentifier of the item.
+ @return Returns the pickupIdentifier of the item.
+ @see pickupIdentifier_
+ */
+ inline const std::string& getPickupIdentifier() const
+ { return this->pickupIdentifier_; }
+ /**
+ @brief Sets the pickupIdentifier for the item.
+ @param identifier New pickupIdentifier for the item.
+ @see pickupIdentifier_
+ */
+ inline void setPickupIdentifier(const std::string& identifier)
+ { this->pickupIdentifier_ = identifier; }
+
+ // GUI stuff
+ virtual const std::string& getGUIText() const; // tolua_export
+ inline void setGUIText(const std::string& text)
+ { this->guiText_ = text; }
+
+ virtual const std::string& getGUIImage() const
+ { return this->guiImage_; }
+ inline void setGUIImage(const std::string& image)
+ { this->guiImage_ = image; }
+ private:
+ Pawn* owner_; //!< The current owner of the item.
+
+ /**
+ @brief
+ The pickupIdentifier of the item..
+
+ Usually set to the template name used by a PickupSpawner,
+ used to index items in the PickupCollection.
+ */
+ std::string pickupIdentifier_;
+
+ std::string guiText_;
+ std::string guiImage_;
+ }; // tolua_export
+} // tolua_export
+
+#endif /* _BaseItem_H__ */
Modified: trunk/src/orxonox/objects/pickup/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/objects/pickup/CMakeLists.txt 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/CMakeLists.txt 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,6 +1,13 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ BaseItem.cc
+ DroppedItem.cc
+ EquipmentItem.cc
+ ModifierPickup.cc
+ PassiveItem.cc
+ PickupCollection.cc
+ PickupInventory.cc
PickupSpawner.cc
- BaseItem.cc
- Turbo.cc
- ShipEquipment.cc
+ UsableItem.cc
)
+
+ADD_SUBDIRECTORY(items)
Copied: trunk/src/orxonox/objects/pickup/DroppedItem.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/DroppedItem.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/DroppedItem.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/DroppedItem.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,96 @@
+#include "DroppedItem.h"
+
+#include "BaseItem.h"
+#include "objects/worldentities/pawns/Pawn.h"
+#include "objects/worldentities/Model.h"
+#include "objects/worldentities/Billboard.h"
+
+#include "core/CoreIncludes.h"
+#include "core/Core.h"
+
+namespace orxonox
+{
+ CreateFactory(DroppedItem);
+
+ DroppedItem::DroppedItem(BaseObject* creator) : StaticEntity(creator)
+ {
+ RegisterObject(DroppedItem);
+
+ this->triggerDistance_ = 20.0f;
+ this->timeToLive_ = 0;
+ this->item_ = 0;
+ }
+ DroppedItem::~DroppedItem()
+ {
+ }
+ void DroppedItem::tick(float dt)
+ {
+ if (this->item_)
+ {
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++)
+ {
+ Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
+ if (distance.length() < this->triggerDistance_)
+ this->trigger(*it);
+ }
+ }
+ }
+ void DroppedItem::trigger(Pawn* pawn)
+ {
+ if (this->item_->pickedUp(pawn))
+ {
+ COUT(3) << "DroppedItem '" << this->item_->getPickupIdentifier() << "' picked up." << std::endl;
+ delete this;
+ }
+ }
+ void DroppedItem::createTimer()
+ {
+ if (this->timeToLive_ > 0)
+ {
+ ExecutorMember<DroppedItem>* exec = createExecutor(createFunctor(&DroppedItem::timerCallback));
+ this->timer_.setTimer(this->timeToLive_, false, this, exec, false);
+ }
+ }
+ void DroppedItem::timerCallback()
+ {
+ if (this->item_)
+ {
+ COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << "'" << std::endl;
+ delete this->item_;
+ }
+
+ delete this;
+ }
+
+ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
+ {
+ DroppedItem* drop = new DroppedItem(item);
+ Model* model = new Model(item);
+ Billboard* billboard = new Billboard(item);
+
+ model->setMeshSource("sphere.mesh");
+ model->setScale(3.0f);
+
+ billboard->setMaterial("Examples/Flare");
+ billboard->setColour(flareColour);
+ billboard->setScale(0.5f);
+
+ drop->setPosition(position);
+ drop->attach(model);
+ drop->attach(billboard);
+
+ drop->setItem(item);
+
+ drop->setTimeToLive(timeToLive);
+ drop->createTimer();
+
+ COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << "," << position.y << "," << position.z << ")." << std::endl;
+
+ return drop;
+ }
+ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive)
+ {
+ Vector3 after = pawn->getPosition() + pawn->getOrientation() * Vector3(0.0f, 0.0f, 50.0f);
+ return DroppedItem::createDefaultDrop(item, after, flareColour, timeToLive);
+ }
+}
Copied: trunk/src/orxonox/objects/pickup/DroppedItem.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/DroppedItem.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/DroppedItem.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/DroppedItem.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,86 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of BaseItem (base-class for items/pickups).
+*/
+
+#ifndef _DroppedItem_H__
+#define _DroppedItem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "objects/Tickable.h"
+#include "objects/worldentities/StaticEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class BaseItem;
+ class Pawn;
+
+ class _OrxonoxExport DroppedItem : public StaticEntity, public Tickable
+ {
+ public:
+ DroppedItem(BaseObject* creator);
+ virtual ~DroppedItem();
+
+ void tick(float dt);
+ void trigger(Pawn* pawn);
+
+ static DroppedItem* createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour = ColourValue(0.5f, 1.0f, 0.3f), float timeToLive = 0);
+ static DroppedItem* createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour = ColourValue(0.5f, 1.0f, 0.3f), float timeToLive = 0);
+
+ void createTimer();
+ void timerCallback();
+
+ inline float getTriggerDistance() const
+ { return this->triggerDistance_; }
+ inline void setTriggerDistance(float distance)
+ { this->triggerDistance_ = distance; }
+
+ inline BaseItem* getItem() const
+ { return this->item_; }
+ inline void setItem(BaseItem* item)
+ { this->item_ = item; }
+
+ inline float getTimeToLive() const
+ { return this->timeToLive_; }
+ inline void setTimeToLive(float time)
+ { this->timeToLive_ = time; }
+ private:
+ float timeToLive_;
+ float triggerDistance_;
+ BaseItem* item_;
+
+ Timer<DroppedItem> timer_;
+ };
+}
+
+#endif /* _DroppedItem_H__ */
Copied: trunk/src/orxonox/objects/pickup/EquipmentItem.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/EquipmentItem.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/EquipmentItem.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/EquipmentItem.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,52 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of EquipmentItem.
+*/
+
+#include "EquipmentItem.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor. Registers the EquipmentItem.
+ @param creator Pointer to the object which created this item.
+ */
+ EquipmentItem::EquipmentItem(BaseObject* creator) : BaseItem(creator)
+ {
+ RegisterObject(EquipmentItem);
+ }
+ //! Deconstructor.
+ EquipmentItem::~EquipmentItem()
+ {
+ }
+}
Copied: trunk/src/orxonox/objects/pickup/EquipmentItem.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/EquipmentItem.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/EquipmentItem.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/EquipmentItem.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,55 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of EquipmentItem (base-class for equipment-type items).
+*/
+
+#ifndef _EquipmentPickup_H__
+#define _EquipmentPickup_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "BaseItem.h"
+
+namespace orxonox
+{
+ /**
+ @brief Base class for all equipment-type items.
+ @author Daniel 'Huty' Haggenmueller
+ */
+ class _OrxonoxExport EquipmentItem : public BaseItem
+ {
+ public:
+ EquipmentItem(BaseObject* creator);
+ virtual ~EquipmentItem();
+ };
+}
+
+#endif /* _EquipmentPickup_H__ */
Copied: trunk/src/orxonox/objects/pickup/ModifierPickup.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/ModifierPickup.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/ModifierPickup.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/ModifierPickup.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,210 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of ModifierPickup (temporary(?) pickup for testing).
+*/
+
+#include "ModifierPickup.h"
+#include "PickupCollection.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/Core.h"
+
+#include "objects/worldentities/pawns/Pawn.h"
+
+#include "util/Debug.h"
+
+namespace orxonox
+{
+ CreateFactory(ModifierPickup);
+
+ /**
+ @brief Constructor. Registers the ModifierPickup.
+ @param creator Pointer to the object which created this item.
+ */
+ ModifierPickup::ModifierPickup(BaseObject* creator) : PassiveItem(creator)
+ {
+ RegisterObject(ModifierPickup);
+
+ this->duration_ = 0.0f;
+ }
+ //! Deconstructor.
+ ModifierPickup::~ModifierPickup()
+ {
+ }
+ /**
+ @brief Method for loading information from a level file.
+ @param element XMLElement from which to read the data.
+ @param mode XMLPort mode to use.
+ */
+ void ModifierPickup::XMLPort(Element& element, XMLPort::Mode mode)
+ {
+ SUPER(ModifierPickup, XMLPort, element, mode);
+
+ XMLPortParam(ModifierPickup, "duration", setDuration, getDuration, element, mode);
+
+ XMLPortParamTemplate(ModifierPickup, "damageAdd", setAdditiveDamage, getAdditiveDamage, element, mode, float);
+ XMLPortParamTemplate(ModifierPickup, "damageMulti", setMultiplicativeDamage, getMultiplicativeDamage, element, mode, float);
+
+ XMLPortParamTemplate(ModifierPickup, "accelerationAdd", setAdditiveAcceleration, getAdditiveAcceleration, element, mode, float);
+ XMLPortParamTemplate(ModifierPickup, "accelerationMulti", setMultiplicativeAcceleration, getMultiplicativeAcceleration, element, mode, float);
+ }
+ /**
+ @brief
+ Invoked when a pawn picks up the pickup.
+
+ Adds the modifiers to the pawn and sets a timer (if effect is limited)
+ if the pickup could be added to the pawn's PickupCollection.
+
+ @param pawn Pawn which picked up the pickup.
+ @return Returns whether the pickup was able to be added to the pawn.
+ */
+ bool ModifierPickup::pickedUp(Pawn* pawn)
+ {
+ if (this->addTo(pawn))
+ {
+ std::map<ModifierType::Enum, float>::iterator it;
+
+ for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
+ {
+ pawn->getPickups().addAdditiveModifier((*it).first, (*it).second);
+ }
+
+ for (it = this->multiplicativeModifiers_.begin(); it != this->multiplicativeModifiers_.end(); it++)
+ {
+ pawn->getPickups().addMultiplicativeModifier((*it).first, (*it).second);
+ }
+
+ if (this->duration_ > 0.0f)
+ {
+ ExecutorMember<ModifierPickup>* executor = createExecutor(createFunctor(&ModifierPickup::timerCallback));
+ executor->setDefaultValues(pawn);
+ this->timer_.setTimer(this->duration_, false, this, executor);
+ }
+
+ return true;
+ }
+ return false;
+ }
+ /**
+ @brief
+ Invoked when a pawn drops the pickup.
+
+ Removes the modifiers from the pawn if the pickup
+ was successfully removed from it's PickupCollection.
+
+ @param pawn Pawn which dropped the pickup.
+ @return Returns whether the pickup could be removed.
+ */
+ bool ModifierPickup::dropped(Pawn* pawn)
+ {
+ if (this->removeFrom(pawn))
+ {
+ std::map<ModifierType::Enum, float>::iterator it;
+
+ for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
+ {
+ pawn->getPickups().removeAdditiveModifier((*it).first, (*it).second);
+ }
+
+ for (it = this->multiplicativeModifiers_.begin(); it != this->multiplicativeModifiers_.end(); it++)
+ {
+ pawn->getPickups().removeMultiplicativeModifier((*it).first, (*it).second);
+ }
+
+ if (this->timer_.getRemainingTime() > 0.0f)
+ this->timer_.stopTimer();
+
+ delete this;
+
+ return true;
+ }
+ return false;
+ }
+ /**
+ @brief Invoked when the timer finished, calls dropped().
+ */
+ void ModifierPickup::timerCallback(Pawn* pawn)
+ {
+ if (!this->dropped(pawn))
+ COUT(2) << "Failed to remove modifier pickup after the timer ran out!" << std::endl;
+ }
+ /**
+ @brief Gets the additive modifier of a given type.
+ @param type ModifierType for which to return the modifier.
+ @return Returns the additive modifier for type (or 0 if not exists).
+ */
+ float ModifierPickup::getAdditiveModifier(ModifierType::Enum type) const
+ {
+ std::map<ModifierType::Enum, float>::const_iterator it = this->additiveModifiers_.find(type);
+ if (it != this->additiveModifiers_.end())
+ return (*it).second;
+ else
+ return 0.0f;
+ }
+ /**
+ @brief Gets the multiplicative modifier of a given type.
+ @param type ModifierType for which to return the modifier.
+ @return Returns the multiplicative modifier for type (or 1 if not exists).
+ */
+ float ModifierPickup::getMultiplicativeModifier(ModifierType::Enum type) const
+ {
+ std::map<ModifierType::Enum, float>::const_iterator it = this->multiplicativeModifiers_.find(type);
+ if (it != this->multiplicativeModifiers_.end())
+ return (*it).second;
+ else
+ return 1.0f;
+ }
+ /**
+ @brief Gets the additive modifier of a given type.
+ @param type ModifierType for which to return the modifier.
+ @param value The new additive modifier for type.
+ */
+ void ModifierPickup::setAdditiveModifier(ModifierType::Enum type, float value)
+ {
+ if (this->additiveModifiers_.find(type) == this->additiveModifiers_.end())
+ this->additiveModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+ else
+ this->additiveModifiers_[type] = value;
+ }
+ /**
+ @brief Gets the multiplicative modifier of a given type.
+ @param type ModifierType for which to return the modifier.
+ @param value The new multiplicative modifier for type.
+ */
+ void ModifierPickup::setMultiplicativeModifier(ModifierType::Enum type, float value)
+ {
+ if (this->multiplicativeModifiers_.find(type) == this->multiplicativeModifiers_.end())
+ this->multiplicativeModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+ else
+ this->multiplicativeModifiers_[type] = value;
+ }
+}
Copied: trunk/src/orxonox/objects/pickup/ModifierPickup.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/ModifierPickup.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/ModifierPickup.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/ModifierPickup.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,144 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of ModifierPickup (temporary(?) pickup for testing).
+*/
+
+#ifndef _ModifierPickup_H__
+#define _ModifierPickup_H__
+
+#include <climits>
+
+#include "OrxonoxPrereqs.h"
+
+#include "PassiveItem.h"
+#include "ModifierType.h"
+#include "orxonox/tools/Timer.h"
+
+namespace orxonox
+{
+ /**
+ @brief Class for a (temporary) modifier effect.
+ @author Daniel 'Huty' Haggenmueller
+ */
+ class _OrxonoxExport ModifierPickup : public PassiveItem
+ {
+ public:
+ ModifierPickup(BaseObject* creator);
+ virtual ~ModifierPickup();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< To create a ModifierPickup through the level file.
+
+ virtual bool pickedUp(Pawn* pawn); //!< Override of the BaseItem::pickedUp() method.
+ virtual bool dropped(Pawn* pawn); //!< Override of the BaseItem::dropped() method
+
+ virtual int getMaxCarryAmount(){ return INT_MAX; } //!< Allow the player to carry infinite ModPickups
+
+ /**
+ @brief Get the duration of this pickup.
+ @return Returns how long the effect holds on.
+ */
+ inline float getDuration() const
+ { return this->duration_; }
+ /**
+ @brief Set the duration of this pickup.
+ @param duration How long the effect should hold.
+ */
+ inline void setDuration(float duration)
+ { this->duration_ = duration; }
+
+ /**
+ @brief Get the amount of damage this pickup adds.
+ @return Returns how much damage this pickup adds.
+ */
+ inline float getAdditiveDamage() const
+ { return this->getAdditiveModifier(ModifierType::Damage); }
+ /**
+ @brief Get the factor by which this pickup multiplies the damage.
+ @return Returns the factor by which to multiply damage.
+ */
+ inline float getMultiplicativeDamage() const
+ { return this->getMultiplicativeModifier(ModifierType::Damage); }
+
+ /**
+ @brief Set the amount of damage this pickup adds.
+ @param value How much damage this pickup adds.
+ */
+ inline void setAdditiveDamage(float value)
+ { this->setAdditiveModifier(ModifierType::Damage, value); }
+ /**
+ @brief Set the factor by which this pickup multiplies the damage.
+ @param value Factor by which to multiply damage.
+ */
+ inline void setMultiplicativeDamage(float value)
+ { this->setMultiplicativeModifier(ModifierType::Damage, value); }
+
+ /**
+ @brief Get the amount of acceleration this pickup adds.
+ @return Returns how much acceleration this pickup adds.
+ */
+ inline float getAdditiveAcceleration() const
+ { return this->getAdditiveModifier(ModifierType::Acceleration); }
+ /**
+ @brief Get the factor by which this pickup multiplies the acceleration.
+ @return Returns the factor by which to multiply acceleration.
+ */
+ inline float getMultiplicativeAcceleration() const
+ { return this->getMultiplicativeModifier(ModifierType::Acceleration); }
+
+ /**
+ @brief Set the amount of acceleration this pickup adds.
+ @param value How much acceleration this pickup adds.
+ */
+ inline void setAdditiveAcceleration(float value)
+ { this->setAdditiveModifier(ModifierType::Acceleration, value); }
+ /**
+ @brief Set the factor by which this pickup multiplies the acceleration.
+ @param value Factor by which to multiply acceleration.
+ */
+ inline void setMultiplicativeAcceleration(float value)
+ { this->setMultiplicativeModifier(ModifierType::Acceleration, value); }
+
+ void timerCallback(Pawn* pawn); //!< Method called when the timer runs out.
+ private:
+ float getAdditiveModifier(ModifierType::Enum type) const; //!< Get the additive modifier for a given ModifierType.
+ float getMultiplicativeModifier(ModifierType::Enum type) const; //!< Get the multiplicative modifier for a given ModifierType.
+ void setAdditiveModifier(ModifierType::Enum type, float value); //!< Set the additive modifier for a given ModifierType.
+ void setMultiplicativeModifier(ModifierType::Enum type, float value); //!< Set the multiplicative modifier for a given ModifierType
+
+ std::map<ModifierType::Enum, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType.
+ std::map<ModifierType::Enum, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType.
+
+ float duration_; //!< Duration of this pickup's effect (0 for unlimited).
+ Timer<ModifierPickup> timer_; //!< Timer used if the pickup's effect has a time limit.
+ };
+}
+
+#endif /* _ModifierPickup_H__ */
Copied: trunk/src/orxonox/objects/pickup/ModifierType.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/ModifierType.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/ModifierType.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/ModifierType.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,53 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Contains enumeration for different types of modifiers.
+*/
+
+#ifndef _ModifierType_H__
+#define _ModifierType_H__
+
+namespace orxonox
+{
+ namespace ModifierType
+ {
+ /**
+ @brief Gives the available types for modifiers.
+ */
+ enum Enum
+ {
+ Unknown = 0,
+ Damage,
+ Acceleration
+ };
+ }
+}
+
+#endif /* _ModifierType_H__ */
Copied: trunk/src/orxonox/objects/pickup/PassiveItem.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/PassiveItem.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/PassiveItem.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/PassiveItem.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,47 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "PassiveItem.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor. Registers the PassiveItem.
+ @param creator Pointer to the object which created this item.
+ */
+ PassiveItem::PassiveItem(BaseObject* creator) : BaseItem(creator)
+ {
+ RegisterObject(PassiveItem);
+ }
+ //! Deconstructor.
+ PassiveItem::~PassiveItem()
+ {
+ }
+}
Copied: trunk/src/orxonox/objects/pickup/PassiveItem.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/PassiveItem.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/PassiveItem.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/PassiveItem.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,55 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of PassiveItem (base class for passive items).
+*/
+
+#ifndef _PassiveItem_H__
+#define _PassiveItem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "BaseItem.h"
+
+namespace orxonox
+{
+ /**
+ @brief Base class for all passive items.
+ @author Daniel 'Huty' Haggenmueller
+ */
+ class _OrxonoxExport PassiveItem : public BaseItem
+ {
+ public:
+ PassiveItem(BaseObject* creator);
+ virtual ~PassiveItem();
+ };
+}
+
+#endif /* _PassiveItem_H__ */
Copied: trunk/src/orxonox/objects/pickup/PickupCollection.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/PickupCollection.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupCollection.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/PickupCollection.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,381 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of PickupCollection.
+*/
+
+#include "PickupCollection.h"
+
+#include "BaseItem.h"
+#include "EquipmentItem.h"
+#include "PassiveItem.h"
+#include "UsableItem.h"
+
+#include "core/CoreIncludes.h"
+
+#include "objects/worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ typedef std::pair<std::multimap<std::string, BaseItem*>::iterator, std::multimap<std::string, BaseItem*>::iterator> item_range;
+ typedef std::pair<std::multimap<ModifierType::Enum, float>::iterator, std::multimap<ModifierType::Enum, float>::iterator> modifier_range;
+
+ //! Constructor
+ PickupCollection::PickupCollection()
+ {
+ this->bBlockRemovals_ = false;
+ this->currentUsable_ = NULL;
+ }
+
+ /**
+ @brief
+ Add an item to the collection.
+
+ Only adds the item if there's a free slot for it.
+
+ @param item Item to add to the collection.
+ @return Returns whether the item has been added to the collection.
+ */
+ bool PickupCollection::add(BaseItem* item)
+ {
+ if (this->checkSlot(item))
+ {
+ Identifier* ident = Class(UsableItem);
+ if(this->currentUsable_ == NULL && item->isA(ident))
+ this->currentUsable_ = dynamic_cast<UsableItem*>(item);
+
+ this->items_.insert( std::pair<std::string, BaseItem*> (item->getPickupIdentifier(), item) );
+ return true;
+ }
+ else
+ return false;
+ }
+ /**
+ @brief
+ Check if there's a free slot for an item.
+
+ Compares the amount of the item-type in the collection
+ against the maximal amount of the item that can be carried.
+
+ @param item Item to check for a slot.
+ @return Returns if there's a free slot for the item.
+ */
+ bool PickupCollection::checkSlot(BaseItem* item)
+ {
+ return (this->items_.count(item->getPickupIdentifier()) < item->getMaxCarryAmount());
+ }
+ /**
+ @brief
+ Empty the collection.
+
+ Calls dropped() on all the items in the collection,
+ then clears the collection.
+ */
+ void PickupCollection::clear()
+ {
+ this->bBlockRemovals_ = true;
+ for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
+ {
+ if((*it).second && (*it).second->getOwner())
+ (*it).second->dropped((*it).second->getOwner());
+ }
+ this->currentUsable_ = NULL;
+ this->items_.clear();
+ this->bBlockRemovals_ = false;
+ }
+ /**
+ @brief Check if an item/type of item is in the collection.
+ @param item Item to check.
+ @param anyOfType If it should look for any item of the item's type (default: false).
+ @return Whether the collection contains the item/type of item.
+ */
+ bool PickupCollection::contains(BaseItem* item, bool anyOfType)
+ {
+ if (anyOfType)
+ {
+ return (this->items_.count(item->getPickupIdentifier()) > 0);
+ }
+ else
+ {
+ item_range bounds = this->items_.equal_range(item->getPickupIdentifier());
+ for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
+ {
+ if ((*it).second == item)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+ //! Uses the first usable item in the collection on the owner.
+ void PickupCollection::useItem()
+ {
+ if(this->currentUsable_)
+ this->currentUsable_->used(this->owner_);
+ }
+ /**
+ @brief Uses a usable item on the owner of the collection.
+ @param item Item to use.
+ */
+ void PickupCollection::useItem(UsableItem* item)
+ {
+ if (item && this->owner_)
+ item->used(this->owner_);
+ }
+ /**
+ @brief Remove an item/all of a type from the collection.
+ @param item Item to remove.
+ @param removeAllOfType Whether to remove all the items with the item's type (default: false).
+ */
+ void PickupCollection::remove(BaseItem* item, bool removeAllOfType)
+ {
+ if (!item || !this->contains(item, removeAllOfType) || this->bBlockRemovals_)
+ return;
+
+ bool getNewUsable = false;
+ if (item == this->currentUsable_ || (this->currentUsable_ && removeAllOfType && this->currentUsable_->getPickupIdentifier() == item->getPickupIdentifier()))
+ {
+ getNewUsable = true;
+ }
+
+ if (removeAllOfType)
+ {
+ std::multimap<std::string, BaseItem*>::iterator it;
+ while ((it = this->items_.find(item->getPickupIdentifier())) != this->items_.end())
+ {
+ this->items_.erase(it);
+ }
+ }
+ else
+ {
+ item_range bounds = this->items_.equal_range(item->getPickupIdentifier());
+ for (std::multimap<std::string, BaseItem*>::iterator it = bounds.first; it != bounds.second && it != this->items_.end(); it++)
+ {
+ if ((*it).second == item)
+ {
+ this->items_.erase(it);
+ break;
+ }
+ }
+ }
+
+ if (getNewUsable)
+ {
+ std::deque<UsableItem*> usables = this->getUsableItems();
+
+ if(usables.size() > 0)
+ this->currentUsable_ = usables.at(0);
+ else
+ this->currentUsable_ = NULL;
+
+ }
+ }
+ /**
+ @brief Add an additive modifier.
+ @param type ModifierType to add.
+ @param value Value for the modifier.
+ */
+ void PickupCollection::addAdditiveModifier(ModifierType::Enum type, float value)
+ {
+ this->additiveModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+ }
+ /**
+ @brief Get the total amount of an additive modifier.
+ @param type Type for which to get the total.
+ @return Returns the sum of the additive modifiers of the type.
+ */
+ float PickupCollection::getAdditiveModifier(ModifierType::Enum type)
+ {
+ float v = 0.0f;
+
+ modifier_range range = this->additiveModifiers_.equal_range(type);
+
+ for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
+ {
+ v += (*it).second;
+ }
+
+ return v;
+ }
+ /**
+ @brief Remove an additive modifier.
+ @param type Type of modifier.
+ @param value Value which is to be removed.
+ */
+ void PickupCollection::removeAdditiveModifier(ModifierType::Enum type, float value)
+ {
+ modifier_range range = this->additiveModifiers_.equal_range(type);
+ for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
+ {
+ if ((*it).second == value)
+ {
+ this->additiveModifiers_.erase(it);
+ return;
+ }
+ }
+ }
+ /**
+ @brief Add a multiplicative modifier.
+ @param type ModifierType to add.
+ @param value Value for the modifier.
+ */
+ void PickupCollection::addMultiplicativeModifier(ModifierType::Enum type, float value)
+ {
+ this->multiplicativeModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+ }
+ /**
+ @brief Get the total amount of a multiplicative modifier.
+ @param type Type for which to get the total.
+ @return Returns the product of the multiplicative modifiers of the type.
+ */
+ float PickupCollection::getMultiplicativeModifier(ModifierType::Enum type)
+ {
+ float v = 1.0f;
+
+ modifier_range range = this->multiplicativeModifiers_.equal_range(type);
+ for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
+ {
+ v *= (*it).second;
+ }
+
+ return v;
+ }
+ /**
+ @brief Remove a multiplicative modifier.
+ @param type Type of modifier.
+ @param value Value which is to be removed.
+ */
+ void PickupCollection::removeMultiplicativeModifier(ModifierType::Enum type, float value)
+ {
+ modifier_range range = this->multiplicativeModifiers_.equal_range(type);
+ for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
+ {
+ if ((*it).second == value)
+ {
+ this->multiplicativeModifiers_.erase(it);
+ return;
+ }
+ }
+ }
+ /**
+ @brief Applies modifiers to a float.
+ @param type Type of modifier tp apply.
+ @param inputValue Value which is to be processed.
+ @param addBeforeMultiplication Whether to apply the additive modifier before the multiplicative one (default: false).
+ @return Returns the value after being processed.
+ */
+ float PickupCollection::processModifiers(ModifierType::Enum type, float inputValue, bool addBeforeMultiplication)
+ {
+ float outputValue = inputValue;
+
+ if (addBeforeMultiplication)
+ outputValue += this->getAdditiveModifier(type);
+
+ outputValue *= this->getMultiplicativeModifier(type);
+
+ if (!addBeforeMultiplication)
+ outputValue += this->getAdditiveModifier(type);
+
+ return outputValue;
+ }
+ /**
+ @brief Applies modifiers to a Vector3.
+ @param type Type of modifier tp apply.
+ @param inputValue Value which is to be processed.
+ @param addBeforeMultiplication Whether to apply the additive modifier before the multiplicative one (default: false).
+ @return Returns the value after being processed.
+ */
+ Vector3 PickupCollection::processModifiers(ModifierType::Enum type, Vector3 inputValue, bool addBeforeMultiplication)
+ {
+ Vector3 outputValue = inputValue;
+
+ if (addBeforeMultiplication)
+ outputValue += Vector3(this->getAdditiveModifier(type));
+
+ outputValue *= this->getMultiplicativeModifier(type);
+
+ if (!addBeforeMultiplication)
+ outputValue += Vector3(this->getAdditiveModifier(type));
+
+ return outputValue;
+ }
+ /**
+ @brief Get a list of equipment-type items.
+ @return Returns a list of all the equipment-type items in the collection.
+ */
+ std::deque<EquipmentItem*> PickupCollection::getEquipmentItems()
+ {
+ std::deque<EquipmentItem*> ret;
+ Identifier* ident = Class(EquipmentItem);
+
+ for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
+ {
+ if ((*it).second->isA(ident))
+ ret.push_back(dynamic_cast<EquipmentItem*>((*it).second));
+ }
+
+ return ret;
+ }
+ /**
+ @brief Get a list of passive items.
+ @return Returns a list of all the passive items in the collection.
+ */
+ std::deque<PassiveItem*> PickupCollection::getPassiveItems()
+ {
+ std::deque<PassiveItem*> ret;
+ Identifier* ident = Class(PassiveItem);
+
+ for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
+ {
+ if ((*it).second->isA(ident))
+ ret.push_back(dynamic_cast<PassiveItem*>((*it).second));
+ }
+
+ return ret;
+ }
+ /**
+ @brief Get a list of usable items.
+ @return Returns a list of all the usable items in the collection.
+ */
+ std::deque<UsableItem*> PickupCollection::getUsableItems()
+ {
+ std::deque<UsableItem*> ret;
+ Identifier* ident = Class(UsableItem);
+
+ for (std::multimap<std::string, BaseItem*>::iterator it = this->items_.begin(); it != this->items_.end(); it++)
+ {
+ if ((*it).second->isA(ident))
+ ret.push_back(dynamic_cast<UsableItem*>((*it).second));
+ }
+
+ return ret;
+ }
+}
Copied: trunk/src/orxonox/objects/pickup/PickupCollection.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/PickupCollection.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupCollection.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/PickupCollection.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,129 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of PickupCollection.
+*/
+
+#ifndef _PickupCollection_H__
+#define _PickupCollection_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <deque>
+#include <string>
+
+#include "util/Math.h"
+
+#include "ModifierType.h"
+
+namespace orxonox
+{
+ class BaseItem;
+ class EquipmentItem;
+ class PassiveItem;
+ class UsableItem;
+ class Pawn;
+
+ /**
+ @brief PickupCollection for organising items.
+ @author Daniel 'Huty' Haggenmueller
+ */
+ class _OrxonoxExport PickupCollection
+ {
+ public:
+ PickupCollection();
+
+ bool add(BaseItem* item); //!< Add an item to the collection.
+
+ bool checkSlot(BaseItem* item); //!< Check if there's a free slot in the collection for an item.
+
+ void clear(); //!< Empty the collection
+ bool contains(BaseItem* item, bool anyOfType = false); //!< Check if the collection contains an item.
+
+ void remove(BaseItem* item, bool removeAllOfType = false); //!< Remove an item from the collection.
+
+ void useItem(); //!< Use the first usable item.
+ void useItem(UsableItem* item); //!< Use a usable item.
+
+ void addAdditiveModifier(ModifierType::Enum type, float value); //!< Add an additive modifier.
+ void addMultiplicativeModifier(ModifierType::Enum type, float value); //!< Add a multiplicative modifier.
+
+ float getAdditiveModifier(ModifierType::Enum type); //!< Get total additive modifier.
+ float getMultiplicativeModifier(ModifierType::Enum type); //!< Get total multiplicative modifier.
+
+ void removeAdditiveModifier(ModifierType::Enum type, float value); //!< Remove an additive modifier.
+ void removeMultiplicativeModifier(ModifierType::Enum type, float value); //!< Remove a multiplicative modifier.
+
+ float processModifiers(ModifierType::Enum type, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float.
+ Vector3 processModifiers(ModifierType::Enum type, Vector3 inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a Vector3.
+
+ /**
+ @brief Get the map of contained items.
+ @return The map of items.
+ */
+ std::multimap<std::string, BaseItem*> getItems() const
+ { return this->items_; }
+
+ /**
+ @brief Get the owner of the PickupCollection.
+ @return Returns the pawn which owns the PickupCollection.
+ */
+ inline Pawn* getOwner() const
+ { return this->owner_; }
+ /**
+ @brief Set the owner of the PickupCollection.
+ @param owner The new Pawn which owns the PickupCollection.
+ */
+ inline void setOwner(Pawn* owner)
+ { this->owner_ = owner; }
+
+ inline UsableItem* getCurrentUsable()
+ { return this->currentUsable_; };
+ inline void setCurrentUsable(UsableItem* usable)
+ { this->currentUsable_ = usable; }
+
+ std::deque<EquipmentItem*> getEquipmentItems(); //!< Get a list of equipment-type items.
+ std::deque<PassiveItem*> getPassiveItems(); //!< Get a list of passive items.
+ std::deque<UsableItem*> getUsableItems(); //!< Get a list of usable items.
+ private:
+ Pawn* owner_; //!< The owner of the PickupCollection.
+ UsableItem* currentUsable_;
+
+ bool bBlockRemovals_; //!< Whether to block direct removals through remove().
+
+ std::multimap<ModifierType::Enum, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType).
+ std::multimap<ModifierType::Enum, float> multiplicativeModifiers_; //!< Contains multiplicative modifiers (indexed by ModifierType).
+
+ std::multimap<std::string, BaseItem*> items_; //!< Map of items in the collection (indexed by pickupIdentifier of the items).
+ };
+}
+
+#endif /* _PickupCollection_H__ */
Copied: trunk/src/orxonox/objects/pickup/PickupInventory.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/PickupInventory.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupInventory.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/PickupInventory.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,353 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "PickupInventory.h"
+
+#include "EquipmentItem.h"
+#include "PassiveItem.h"
+#include "UsableItem.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+
+#include "gui/GUIManager.h"
+#include "objects/controllers/HumanController.h"
+#include "objects/worldentities/pawns/Pawn.h"
+
+#include <CEGUIImage.h>
+#include <CEGUIImageset.h>
+#include <CEGUIImagesetManager.h>
+#include <CEGUIWindow.h>
+#include <CEGUIWindowManager.h>
+#include <elements/CEGUITabControl.h>
+
+namespace orxonox
+{
+ orxonox::ConsoleCommand& function_PickupInventory_ToggleInventory_0 =
+ orxonox::CommandExecutor::addConsoleCommandShortcut(orxonox::createConsoleCommand(orxonox::createFunctor(&PickupInventory::toggleInventory), "toggleInventory"), true);
+
+ PickupInventory* PickupInventory::pickupInventory_s = NULL;
+ PickupInventory* PickupInventory::getSingleton()
+ {
+ if(!PickupInventory::pickupInventory_s)
+ PickupInventory::pickupInventory_s = new PickupInventory();
+
+ return PickupInventory::pickupInventory_s;
+ }
+
+ PickupInventory::PickupInventory()
+ {
+ this->bInventoryVisible_ = false;
+ this->visibleEquipmentWindows_ = this->visibleUsableWIndows_ = 0;
+
+ // Create some windows to avoid creating them while playing
+ CEGUI::WindowManager* winMgr = CEGUI::WindowManager::getSingletonPtr();
+ for(int i = 0; i < 10; i++)
+ {
+ std::ostringstream id;
+ id << i;
+
+ PickupInventory::createItemWindows(winMgr, "equ/" + id.str(), i % 5, i / 5);
+ PickupInventory::createItemWindows(winMgr, "use/" + id.str(), i % 5, i / 5);
+ }
+ this->createdEquipmentWindows_ = this->createdUsableWindows_ = 10;
+ }
+ PickupInventory::~PickupInventory()
+ {
+ }
+
+
+
+ void PickupInventory::toggleInventory()
+ {
+ if(PickupInventory::getSingleton()->isVisible()) {
+ GUIManager::getInstancePtr()->executeCode("hideGUI(\"PickupInventory\")");
+ GUIManager::getInstancePtr()->executeCode("hideCursor()");
+ InputManager::getInstance().requestLeaveState("guiMouseOnly");
+ }
+ else
+ {
+ GUIManager::getInstancePtr()->showGUI("PickupInventory");
+ GUIManager::getInstancePtr()->executeCode("showCursor()");
+ InputManager::getInstance().requestEnterState("guiMouseOnly");
+ }
+ PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible());
+ }
+
+ unsigned int PickupInventory::getCurrentUsableIndex()
+ {
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn && pawn->getPickups().getCurrentUsable())
+ {
+ UsableItem* use = pawn->getPickups().getCurrentUsable();
+ std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
+ for(unsigned int i = 0; i < items.size(); i++)
+ {
+ if(items.at(i) == use)
+ return i;
+ }
+ }
+
+ return 0;
+ }
+ bool PickupInventory::isCurrentUsable(const BaseItem* item)
+ {
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
+ return (pawn->getPickups().getCurrentUsable() == item);
+ else
+ return false;
+ }
+ void PickupInventory::selectUsable(unsigned int i)
+ {
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
+ {
+ std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
+ if(i < items.size())
+ pawn->getPickups().setCurrentUsable(items.at(i));
+ }
+ }
+
+ unsigned int PickupInventory::getEquipmentCount()
+ {
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
+ return pawn->getPickups().getEquipmentItems().size();
+ else
+ return 0;
+ }
+ unsigned int PickupInventory::getUsableCount()
+ {
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
+ return pawn->getPickups().getUsableItems().size();
+ else
+ return 0;
+ }
+ unsigned int PickupInventory::getPassiveCount()
+ {
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
+ return pawn->getPickups().getPassiveItems().size();
+ else
+ return 0;
+ }
+ BaseItem* PickupInventory::getEquipmentItem(unsigned int i)
+ {
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
+ {
+ std::deque<EquipmentItem*> l = pawn->getPickups().getEquipmentItems();
+ if (i >= l.size()) { return NULL; }
+ return l.at(i);
+ }
+ else
+ return NULL;
+ }
+ BaseItem* PickupInventory::getUsableItem(unsigned int i)
+ {
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
+ {
+ std::deque<UsableItem*> l = pawn->getPickups().getUsableItems();
+ if (i >= l.size()) { return NULL; }
+ return l.at(i);
+ }
+ else
+ return NULL;
+ }
+ BaseItem* PickupInventory::getPassiveItem(unsigned int i)
+ {
+ Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
+ if(pawn)
+ {
+ std::deque<PassiveItem*> l = pawn->getPickups().getPassiveItems();
+ if (i >= l.size()) { return NULL; }
+ return l.at(i);
+ }
+ else
+ return NULL;
+ }
+
+ std::string PickupInventory::getImageForItem(const BaseItem* item)
+ {
+ if(!item)
+ return "";
+
+ std::string name = "pickup_" + item->getGUIImage();
+
+ if(!CEGUI::ImagesetManager::getSingletonPtr()->isImagesetPresent(name))
+ {
+ CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile(name, item->getGUIImage(), "");
+ }
+
+ return "set:" + name + " image:full_image";
+ }
+
+ void PickupInventory::clearInventory(CEGUI::WindowManager* winMgr, CEGUI::Window* equipPane, CEGUI::Window* usablePane)
+ {
+ for(unsigned int i = 0; i < this->visibleEquipmentWindows_; i++)
+ {
+ std::ostringstream id;
+ id << i;
+
+ winMgr->getWindow("orxonox/Inventory/Frame/equ/" + id.str())->setVisible(false);
+ winMgr->getWindow("orxonox/Inventory/Title/equ/" + id.str())->setVisible(false);
+ winMgr->getWindow("orxonox/Inventory/Items/equ/" + id.str())->setVisible(false);
+
+ /*equipPane->removeChildWindow("orxonox/Inventory/Frame/equ/" + id.str());
+ equipPane->removeChildWindow("orxonox/Inventory/Title/equ/" + id.str());
+ equipPane->removeChildWindow("orxonox/Inventory/Items/equ/" + id.str());*/
+ }
+ for(unsigned int i = 0; i < this->visibleUsableWIndows_; i++)
+ {
+ std::ostringstream id;
+ id << i;
+
+ winMgr->getWindow("orxonox/Inventory/Frame/use/" + id.str())->setVisible(false);
+ winMgr->getWindow("orxonox/Inventory/Title/use/" + id.str())->setVisible(false);
+ winMgr->getWindow("orxonox/Inventory/Items/use/" + id.str())->setVisible(false);
+
+ /*usablePane->removeChildWindow("orxonox/Inventory/Frame/use/" + id.str());
+ usablePane->removeChildWindow("orxonox/Inventory/Title/use/" + id.str());
+ usablePane->removeChildWindow("orxonox/Inventory/Items/use/" + id.str());*/
+ }
+ }
+ void PickupInventory::updateTabs(CEGUI::WindowManager *winMgr, CEGUI::Window *equipWindow, CEGUI::Window *usableWindow)
+ {
+ this->updateEquipment(winMgr, equipWindow);
+ this->updateUsable(winMgr, usableWindow);
+ }
+
+ void PickupInventory::updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target)
+ {
+ Pawn* pawn;
+ if(pawn = HumanController::getLocalControllerEntityAsPawn())
+ {
+ std::deque<EquipmentItem*> items = pawn->getPickups().getEquipmentItems();
+ for(unsigned int i = 0; i < items.size(); i++)
+ {
+ std::ostringstream id;
+ id << "equ/" << i;
+
+ EquipmentItem* item = items.at(i);
+
+ if(this->createdEquipmentWindows_ <= i)
+ {
+ PickupInventory::createItemWindows(winMgr, id.str(), i % 5, i / 5);
+ this->createdEquipmentWindows_++;
+ }
+
+ PickupInventory::setWindowProperties(winMgr, target, id.str(), item, "FFFFFFFF");
+ }
+ this->visibleEquipmentWindows_ = items.size();
+ }
+ }
+ void PickupInventory::updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target)
+ {
+ Pawn* pawn;
+ if(pawn = HumanController::getLocalControllerEntityAsPawn())
+ {
+ std::deque<UsableItem*> items = pawn->getPickups().getUsableItems();
+ for(unsigned int i = 0; i < items.size(); i++)
+ {
+ std::ostringstream id;
+ id << "use/" << i;
+
+ UsableItem* item = items.at(i);
+ std::string colour;
+
+ if(PickupInventory::isCurrentUsable(item))
+ colour = "FFFF5555";
+ else
+ colour = "FFFFFFFF";
+
+ if(this->createdUsableWindows_ <= i)
+ {
+ PickupInventory::createItemWindows(winMgr, id.str(), i % 5, i / 5);
+ this->createdUsableWindows_++;
+ }
+
+ PickupInventory::setWindowProperties(winMgr, target, id.str(), item, colour);
+ }
+ this->visibleUsableWIndows_ = items.size();
+ }
+ }
+
+ void PickupInventory::createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y)
+ {
+ if(!winMgr) { return; }
+
+ CEGUI::Window* frame = winMgr->createWindow("TaharezLook/StaticImage", "orxonox/Inventory/Frame/" + id);
+ frame->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 5 + x * 70), CEGUI::UDim(0, 5 + y * 90)));
+ frame->setSize(CEGUI::UVector2(CEGUI::UDim(0, 65), CEGUI::UDim(0, 65)));
+ frame->setVisible(false);
+
+ CEGUI::Window* text = winMgr->createWindow("TaharezLook/StaticText", "orxonox/Inventory/Title/" + id);
+ text->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 5 + x * 70), CEGUI::UDim(0, 70 + y * 90)));
+ text->setSize(CEGUI::UVector2(CEGUI::UDim(0, 65), CEGUI::UDim(0, 20)));
+ text->setProperty("FrameEnabled", "False");
+ text->setProperty("BackgroundEnabled", "False");
+ text->setProperty("HorzFormatting", "HorzCentred");
+ text->setProperty("VertFormatting", "VertCentred");
+ text->setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF");
+ text->setVisible(false);
+
+ CEGUI::Window* btn = winMgr->createWindow("TaharezLook/Button", "orxonox/Inventory/Items/" + id);
+ btn->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 8 + x * 70), CEGUI::UDim(0, 8 + y * 90)));
+ btn->setSize(CEGUI::UVector2(CEGUI::UDim(0, 59), CEGUI::UDim(0, 59)));
+ btn->subscribeScriptedEvent("Clicked", "itemClicked");
+ btn->setVisible(false);
+ }
+ void PickupInventory::setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour)
+ {
+ CEGUI::Window* txt = winMgr->getWindow("orxonox/Inventory/Title/" + id);
+ CEGUI::Window* btn = winMgr->getWindow("orxonox/Inventory/Items/" + id);
+ CEGUI::Window* frm = winMgr->getWindow("orxonox/Inventory/Frame/" + id);
+
+ frm->setVisible(true);
+
+ txt->setVisible(true);
+ txt->setProperty("Text", item->getGUIText());
+ txt->setProperty("TextColours", "tl:" + textColour + " tr:" + textColour + " bl:" + textColour + " br:" + textColour + "");
+
+ std::string image = PickupInventory::getImageForItem(item);
+ btn->setVisible(true);
+ btn->setProperty("NormalImage", image);
+ btn->setProperty("HoverImage", image);
+ btn->setProperty("PushedImage", image);
+ btn->setProperty("DisabledImage", image);
+ btn->setProperty("Tooltip", item->getGUIText());
+
+ target->addChildWindow(frm);
+ target->addChildWindow(txt);
+ target->addChildWindow(btn);
+ }
+}
Copied: trunk/src/orxonox/objects/pickup/PickupInventory.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/PickupInventory.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupInventory.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/PickupInventory.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,103 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Declaration of static class for the inventory GUI window.
+*/
+
+#ifndef _PickupInventory_H__
+#define _PickupInventory_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+namespace CEGUI { class Window; class WindowManager; class Image; }
+
+// tolua_begin
+namespace orxonox
+{
+// tolua_end
+ class _OrxonoxExport BaseItem;
+
+ /**
+ @brief Static class for the inventory GUI window.
+ @author Daniel 'Huty' Haggenmueller
+ */
+// tolua_begin
+ class _OrxonoxExport PickupInventory
+ {
+// tolua_end
+ public:
+ PickupInventory();
+ virtual ~PickupInventory();
+
+ static PickupInventory* getSingleton(); // tolua_export
+
+ static void toggleInventory(); // tolua_export
+
+ static unsigned int getEquipmentCount(); // tolua_export
+ static unsigned int getUsableCount(); // tolua_export
+ static unsigned int getPassiveCount(); // tolua_export
+
+ static unsigned int getCurrentUsableIndex(); // tolua_export
+ static bool isCurrentUsable(const BaseItem* item); // tolua_export
+ static void selectUsable(unsigned int i); // tolua_export
+
+ static BaseItem* getEquipmentItem(unsigned int i); // tolua_export
+ static BaseItem* getUsableItem(unsigned int i); // tolua_export
+ static BaseItem* getPassiveItem(unsigned int i); // tolua_export
+
+ static std::string getImageForItem(const BaseItem* item); // tolua_export
+
+ void clearInventory(CEGUI::WindowManager* winMgr, CEGUI::Window* equipPane, CEGUI::Window* usablePane); // tolua_export
+ void updateTabs(CEGUI::WindowManager* winMgr, CEGUI::Window* equipWindow, CEGUI::Window* usableWindow); // tolua_export
+
+ void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
+ void updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
+
+ static void createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y);
+ static void setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour);
+
+ const bool isVisible() const
+ { return this->bInventoryVisible_; }
+ void setVisible(bool visible)
+ { this->bInventoryVisible_ = visible; }
+ private:
+ bool bInventoryVisible_;
+ unsigned int createdEquipmentWindows_;
+ unsigned int createdUsableWindows_;
+ unsigned int visibleEquipmentWindows_;
+ unsigned int visibleUsableWIndows_;
+
+ static PickupInventory* pickupInventory_s;
+ }; // tolua_export
+} // tolua_export
+
+#endif /* _PickupInventory_H__ */
Deleted: trunk/src/orxonox/objects/pickup/PickupSpawner.cc
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupSpawner.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/PickupSpawner.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,121 +0,0 @@
-#include "OrxonoxStableHeaders.h"
-#include "PickupSpawner.h"
-#include "BaseItem.h"
-#include "objects/worldentities/pawns/Pawn.h"
-#include "objects/worldentities/triggers/DistanceTrigger.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "core/Template.h"
-
-namespace orxonox
-{
-CreateFactory(PickupSpawner);
-
-PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator)
-{
- RegisterObject(PickupSpawner);
-
- this->template_ = 0;
- this->distance_ = 20;
- this->respawntimer_= 0;
-}
-
-PickupSpawner::~PickupSpawner()
-{
-}
-
-void PickupSpawner::XMLPort(Element& xmlelement, XMLPort::Mode mode)
-{
- SUPER(PickupSpawner, XMLPort, xmlelement, mode);
-
- XMLPortParam(PickupSpawner, "item", setItemTemplate, getItemTemplate, xmlelement, mode);
- XMLPortParam(PickupSpawner, "distance", setDistance, getDistance, xmlelement, mode).defaultValues(20.0f);
- XMLPortParam(PickupSpawner, "respawntimer", setRespawnTimer, getRespawnTimer, xmlelement, mode);
-
-}
-
-void PickupSpawner::tick(float dt)
-{
- if (this->isActive())
- {
- for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
- {
- Vector3 distanceVec = it->getWorldPosition() - this->getWorldPosition();
- if (distanceVec.length() < this->distance_)
- this->triggering(*it);
- }
- }
-}
-
-void PickupSpawner::setItemTemplate(const std::string& itemtemplate)
-{
- this->itemtemplate_ = itemtemplate;
- this->template_ = Template::getTemplate(itemtemplate);
-}
-
-void PickupSpawner::triggering(Pawn* player)
-{
- if (this->isActive() && this->template_ && this->template_->getBaseclassIdentifier())
- {
- COUT(0) << "ITEM PICKED UP" << std::endl;
- //if(player->isA(itemtemplate_->getPlayerBaseClass()))
- {
- BaseObject* newobject = this->template_->getBaseclassIdentifier()->fabricate(this);
- BaseItem* newitem = dynamic_cast<BaseItem*>(newobject);
- if (newitem)
- {
- newitem->addTemplate(this->itemtemplate_);
- if (newitem->pickedUp(player)== true)
- {
- if(respawntimer_!=0)
- this->triggerRespawnTimer();
- this->setActive(false);
- this->fireEvent();
- }
- else
- delete newobject;
- }
- }
- //else
- // delete newobject;
- }
-}
-
-void PickupSpawner::triggerRespawnTimer()
-{
-
- if(respawntimer_!=0)
- {
- ExecutorMember<BaseObject>* executor = createExecutor(createFunctor(&BaseObject::setActive));
- executor->setDefaultValues(true);
- RespawnTimer_.setTimer(this->respawntimer_, false, this, executor);
- COUT(0) << "TIMER SET" << std::endl;
- }
-}
-void PickupSpawner::changedActivity()
-{
-/*
- COUT(0) << "Visble?" << std::endl;
- if(isActive())
- {
- setVisible(true);
- COUT(0) << "Visble!" << std::endl;
- }
- if(isActive()==false)
- {
- setVisible(false);
- COUT(0) << "INvisble!" << std::endl;
- }
-
-*/
- SUPER(PickupSpawner, changedActivity);
-
- for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); ++it)
- (*it)->setVisible(this->isActive());
-}
-
-
-}
-
-
-
Copied: trunk/src/orxonox/objects/pickup/PickupSpawner.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupSpawner.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/PickupSpawner.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,189 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of PickupSpawner.
+*/
+
+#include "PickupSpawner.h"
+#include "BaseItem.h"
+#include "PickupInventory.h" // HACK; Only for hack, remove later
+#include "gui/GUIManager.h" // HACK; see above
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/Template.h"
+
+#include "objects/worldentities/pawns/Pawn.h"
+#include "objects/worldentities/triggers/DistanceTrigger.h"
+
+namespace orxonox
+{
+ const float PickupSpawner::bounceSpeed_s = 6.0f;
+ const float PickupSpawner::rotationSpeed_s = 1.0f;
+ const float PickupSpawner::bounceDistance_s = 4.0f;
+
+ CreateFactory(PickupSpawner);
+
+ /**
+ @brief Constructor. Registers the PickupSpawner.
+ @param creator Pointer to the object which created this item.
+ */
+ PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator)
+ {
+ RegisterObject(PickupSpawner);
+
+ this->itemTemplate_ = 0;
+ this->triggerDistance_ = 20;
+ this->respawnTime_ = 0.0f;
+ this->tickSum_ = 0.0f;
+ }
+ //! Deconstructor.
+ PickupSpawner::~PickupSpawner()
+ {
+ }
+ /**
+ @brief Method for creating a PickupSpawner through XML.
+ @param xmlelement XML element which contains the PickupSpawner.
+ @param mode XMLPort mode.
+ */
+ void PickupSpawner::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(PickupSpawner, XMLPort, xmlelement, mode);
+
+ XMLPortParam(PickupSpawner, "item", setItemTemplateName, getItemTemplateName, xmlelement, mode);
+ XMLPortParam(PickupSpawner, "triggerDistance", setTriggerDistance, getTriggerDistance, xmlelement, mode);
+ XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode);
+
+ // HACKs
+ // Load the GUI image as soon as the PickupSpawner gets loaded
+ // = less delays while running
+ BaseObject* newObject = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this);
+ BaseItem* asItem = dynamic_cast<BaseItem*>(newObject);
+ if (asItem)
+ {
+ asItem->addTemplate(this->itemTemplate_);
+ PickupInventory::getImageForItem(asItem);
+ delete newObject;
+ }
+
+ // & load the GUI itself too, along with some empty windows
+ // = even less delays
+ GUIManager::getInstancePtr()->showGUI("PickupInventory");
+ GUIManager::getInstancePtr()->executeCode("hideGUI(\"PickupInventory\")");
+ PickupInventory::getSingleton();
+ }
+ /**
+ @brief Invoked when the activity has changed. Sets visibility of attached objects.
+ */
+ void PickupSpawner::changedActivity()
+ {
+ SUPER(PickupSpawner, changedActivity);
+
+ for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
+ (*it)->setVisible(this->isActive());
+ }
+ /**
+ @brief Set the template name of the item to spawn, also loads the template.
+ @param name Name of the new template.
+ */
+ void PickupSpawner::setItemTemplateName(const std::string& name)
+ {
+ this->itemTemplateName_ = name;
+ this->itemTemplate_ = Template::getTemplate(name);
+ }
+ /**
+ @brief Tick, checks if any Pawn is close enough to trigger.
+ @param dt Time since last tick.
+ */
+ void PickupSpawner::tick(float dt)
+ {
+ if (this->isActive())
+ {
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++)
+ {
+ Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
+ if (distance.length() < this->triggerDistance_)
+ this->trigger(*it);
+ }
+ this->yaw(Radian(rotationSpeed_s*dt));
+ this->tickSum_ += bounceSpeed_s*dt;
+ this->translate(Vector3(0,bounceDistance_s*dt*sin(this->tickSum_),0));
+ if (this->tickSum_ > 2*Ogre::Math::PI)
+ this->tickSum_ -= 2*Ogre::Math::PI;
+ }
+ }
+ /**
+ @brief
+ Trigger the PickupSpawner.
+
+ Adds the pickup to the Pawn that triggered,
+ sets the timer to re-activate and deactives the PickupSpawner.
+
+ @param pawn Pawn which triggered the PickupSpawner.
+ */
+ void PickupSpawner::trigger(Pawn* pawn)
+ {
+ if (this->isActive() && this->itemTemplate_ && this->itemTemplate_->getBaseclassIdentifier())
+ {
+ BaseObject* newObject = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this);
+ BaseItem* asItem = dynamic_cast<BaseItem*>(newObject);
+ if (asItem)
+ {
+ asItem->setPickupIdentifier(this->itemTemplateName_);
+ asItem->addTemplate(this->itemTemplate_);
+
+ if (asItem->pickedUp(pawn))
+ {
+ COUT(3) << this->itemTemplateName_ << " got picked up." << std::endl;
+
+ if (this->respawnTime_ > 0.0f)
+ {
+ ExecutorMember<PickupSpawner>* executor = createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback));
+ this->respawnTimer_.setTimer(this->respawnTime_, false, this, executor);
+
+ this->setActive(false);
+ this->fireEvent();
+ }
+ }
+ else
+ delete newObject;
+ }
+ }
+ }
+ /**
+ @brief Invoked by the timer, re-activates the PickupSpawner.
+ */
+ void PickupSpawner::respawnTimerCallback()
+ {
+ COUT(3) << "PickupSpawner reactivated." << std::endl;
+
+ this->setActive(true);
+ }
+}
Deleted: trunk/src/orxonox/objects/pickup/PickupSpawner.h
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupSpawner.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/PickupSpawner.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,67 +0,0 @@
-#ifndef _PickupSpawner_H__
-#define _PickupSpawner_H__
-
-#include "OrxonoxPrereqs.h"
-#include "BaseItem.h"
-#include "tools/Timer.h"
-#include "objects/worldentities/StaticEntity.h"
-#include "objects/Tickable.h"
-
-namespace orxonox
-{
- class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable
- {
- public:
- PickupSpawner(BaseObject* creator);
- virtual ~PickupSpawner();
- virtual void changedActivity();
- virtual void tick(float dt);
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual void triggering(Pawn* trigger); // Wenn ein Spieler in die Naehe kommt
- void triggerRespawnTimer();
-
- /*inline void setVisibility(bool visible)
- { this->setActive(visible); }
- inline float getVisibility() const
- { return this->isActive(); }*/
-
- void setItemTemplate(const std::string& itemtemplate);
- inline const std::string& getItemTemplate() const
- { return this->itemtemplate_; }
-
- inline void setDistance(float distance)
- { this->distance_ = distance; }
- inline float getDistance() const
- { return this->distance_; }
- inline void setRespawnTimer (float respawntimer)
- { this->respawntimer_ = respawntimer; }
- inline float getRespawnTimer() const
- { return this->respawntimer_; }
-
- private:
- std::string itemtemplate_;
- Template* template_;
- float distance_;
- float respawntimer_;
- Timer<BaseObject> RespawnTimer_;
- };
-}
-
-#endif /* _PickupSpawner_H__ */
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Copied: trunk/src/orxonox/objects/pickup/PickupSpawner.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/PickupSpawner.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupSpawner.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/PickupSpawner.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,122 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of PickupSpawner.
+*/
+
+#ifndef _PickupSpawner_H__
+#define _PickupSpawner_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+#include "objects/Tickable.h"
+#include "objects/worldentities/StaticEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+ class BaseItem;
+
+ /**
+ @brief PickupSpawner.
+ @author Daniel 'Huty' Haggenmueller
+ */
+ class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable
+ {
+ public:
+ PickupSpawner(BaseObject* creator);
+ virtual ~PickupSpawner();
+
+ virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML.
+ virtual void tick(float dt);
+
+ void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough.
+ void respawnTimerCallback(); //!< Method called when the timer runs out.
+
+ /**
+ @brief Get the template name for the item to spawn.
+ @return Returns the name of the template of the item to spawn.
+ */
+ inline const std::string& getItemTemplateName() const
+ { return this->itemTemplateName_; }
+ void setItemTemplateName(const std::string& name); //!< Set the template name of the item to spawn.
+
+ /**
+ @brief Get the template for the item to spawn.
+ @return Returns the template of the item to spawn.
+ */
+ inline Template* getItemTemplate() const
+ { return this->itemTemplate_; }
+
+ /**
+ @brief Get the distance in which to trigger.
+ @return Returns the distance in which this gets triggered.
+ */
+ inline float getTriggerDistance() const
+ { return this->triggerDistance_; }
+ /**
+ @brief Set the distance in which to trigger.
+ @param value The new distance in which to trigger.
+ */
+ inline void setTriggerDistance(float value)
+ { this->triggerDistance_ = value; }
+
+ /**
+ @brief Get the time to respawn.
+ @returns Returns the time after which this gets re-actived.
+ */
+ inline float getRespawnTime() const
+ { return this->respawnTime_; }
+ /**
+ @brief Set the time to respawn.
+ @param time New time after which this gets re-actived.
+ */
+ inline void setRespawnTime(float time)
+ { this->respawnTime_ = time; }
+ private:
+ std::string itemTemplateName_; //!< Template name of the item to spawn.
+ Template* itemTemplate_; //!< Template of the item to spawn.
+
+ float triggerDistance_; //!< Distance in which this gets triggered.
+
+ /* Pickup animation */
+ float tickSum_; //!< Adds up tick to use in sine movement
+ static const float bounceSpeed_s; //!< Speed of pickup to bounce up and down
+ static const float bounceDistance_s; //!< Distance the pickup bounces up and down
+ static const float rotationSpeed_s; //!< Rotation speed of pickup
+
+ float respawnTime_; //!< Time after which this gets re-actived.
+ Timer<PickupSpawner> respawnTimer_; //!< Timer used for re-activating.
+ };
+}
+
+#endif /* _PickupSpawner_H__ */
Deleted: trunk/src/orxonox/objects/pickup/ShipEquipment.cc
===================================================================
--- trunk/src/orxonox/objects/pickup/ShipEquipment.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/ShipEquipment.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,98 +0,0 @@
-#include "OrxonoxStableHeaders.h"
-#include "BaseItem.h"
-#include "ShipEquipment.h"
-#include "objects/worldentities/pawns/Pawn.h"
-
-
-namespace orxonox
-{
-/**
- at brief
- Insert a permanent Item to the Equipment. Is usually called by the addTo function in Items.
-
- at param item
- pointer to the item which is to be inserted.
-
- at return
- if new item has sucessfully been added it will return true, in any other case the return value is false.
-*/
- bool ShipEquipment::insert(BaseItem* item)
- {
- if(checkSlot(item)==NULL)
- {
- Equipment.insert ( std::pair<std::string, BaseItem*>(item->getName(),item) );
- return true;
- }
- else
- {
- COUT(3) << "SWAP?" << endl;
- //Abfrage- irgendne ifschleife...
- if((checkSlot(item)->dropped(player))==true)
- {
- Equipment.insert ( std::pair<std::string, BaseItem*>(item->getName(),item) );
- COUT(3) << "SWAPPED!" << endl;
- return true;
- }
- return false;
- }
-
- return false;
- };
-
-/**
- at brief
- Erases a permanent Item in the Equipment. Is usually called by the remove/dropped function in Items.
-
- at param item
- pointer to the item which is to be erased.
-
- at return
- if new item has sucessfully been erased it will return true, in any other case the return value is false.
-*/
- bool ShipEquipment::erase (BaseItem* item)
- {
- std::multimap<std::string,BaseItem*>::iterator it = Equipment.find(item->getName());
- if(it != Equipment.end())
- {
- Equipment.erase (it);
- return true;
- }
- return false;
- };
- /*void print(std::multimap<std::string, BaseItem*> eut)
- {
- std::multimap<std::string,BaseItem*>::iterator it;
- COUT(3) << "Liste:" << endl;
- for ( it=eut.begin() ; it != eut.end(); ++it )
- COUT(3) << (*it).first << endl;
-
- }*/
-/**
- at brief
- Erases all permanent Items in the Equipment. Its Triggered by hitting the L button.
-
-*/
- void ShipEquipment::eraseAll()
- {
- //print(Equipment);
- for (std::multimap<std::string,BaseItem*>::iterator it = Equipment.begin(); it != Equipment.end(); )
- {
-
- (it++)->second->dropped(this->getPlayer());
- }
- //print(Equipment);
- }
-
- BaseItem* ShipEquipment::checkSlot(BaseItem* item)
- {
- std::multimap<std::string,BaseItem*>::iterator it;
- for ( it= getPlayer()->getPickUp().getEquipment().begin() ; it != getPlayer()->getPickUp().getEquipment().end(); it++ )
- {
- //if((*it).second->getPlayerBaseClass()==item->getPlayerBaseClass())
- if(item->isExactlyA((*it).second->getIdentifier()))
- return (*it).second;
- }
- return NULL;
- };
-
-}
Deleted: trunk/src/orxonox/objects/pickup/ShipEquipment.h
===================================================================
--- trunk/src/orxonox/objects/pickup/ShipEquipment.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/ShipEquipment.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,66 +0,0 @@
-#ifndef _ShipEquipment_H__
-#define _ShipEquipment_H__
-#include <string>
-#include <map>
-
-/*
-multimap<std::string, BaseItem*> equipment_;
-equipment_.insert(pair<std::string, BaseItem*>("Weapon", new BaseItem()));*/
-
-
-/* std::map<std::itemtype, BaseItem*> EQClasses;
- EQClasses["jacke"] = 0;
- BaseItem* item = itemMap_["jacke"];
-
- if (itemMap_["jacke"])
- if (itemMap_.find("jacke") != itemMap_.end()) */
-namespace orxonox
-{
- class BaseItem;
-/**
- at brief
- ShipEquipment is the inventory of a player. It's part of the Pawn class.
-
-*/
- class _OrxonoxExport ShipEquipment
- {
- public:
- inline int getSpace()
- {
- return Usable.size()+Trunk.size();
- };
- bool insert(BaseItem* item);
- bool erase (BaseItem* item);
- //void print(std::multimap<std::string, BaseItem*> eut);
- void eraseAll();
- //bool checkSlot(BaseItem* item);
- BaseItem* checkSlot(BaseItem* item);
-// const std::multimap<std::string, BaseItem*>& getEquipment() const { return this->Equipment; }
- inline std::multimap<std::string, BaseItem*>& getEquipment() {return this->Equipment;}
- inline std::multimap<std::string, BaseItem*>& getUsable() {return this->Usable;}
- inline std::multimap<std::string, BaseItem*>& getTrunk() {return this->Trunk;}
- inline Pawn* getPlayer() {return this->player ;}
- inline void setPlayer(Pawn* setplayer)
- {this->player = setplayer;}
- private:
- Pawn* player;//!< Is a pointer to the belonging player
- std::multimap<std::string, BaseItem*> Equipment;//!< the Equipment for permanent Items
- std::multimap<std::string, BaseItem*> Usable;//!< Where Usables are stored
- std::multimap<std::string, BaseItem*> Trunk;//!< Every other Item is stored here
- };
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#endif
Deleted: trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.cc
===================================================================
--- trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,136 +0,0 @@
-namespace orxonox
-{
- const int maxweapons_ =2; //Weaponslots (provisorisch)
- const int maxslots_= 50; //Inventoryslots (provisorisch)
-
-
- bool ShipEquipment::CheckifSpace()
- {
- if((Usable.size()+Trunk.size())>=maxslots_)
- return false;
- return true;
- }
-
- /* Checks if the Ship can pick an Item up. Permanents will give a "false" back unless the Ship doesnt carry a Item for that Slot (2 Weaponslots) yet.Others will be picked up unless there is no Space in the Trunk.*/
-
- bool ShipEquipment::CheckifValid(Shipitem* toBeChecked)
- {
- switch(toBeChecked.CheckType())
- {
- case Powerups:
- activatePowerUp(); //gibts noch nicht
- return true;
- case Permanent:
- switch (toBeChecked.CheckSubType())
- {
- case Weapon:
- int weaponcheck=0;
- multimap<string, ShipItem*>::iterator it;
- for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
- if((*it).second->CheckSubType()==Weapon)
- weaponcheck++;
- };
- if (weaponcheck>=maxweapons_){
- weaponcheck=0;
- return false;
- }
- break;
- case Thrusters:
- multimap<string, ShipItem*>::iterator it;
- for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
- if((*it).second->CheckSubType()==Thrusters)
- return false;
- }
- break;
- case Shields:
- multimap<string, ShipItem*>::iterator it;
- for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
- if((*it).second->CheckSubType()==Shields)
- return false;
- }
- break;
- case Armor:
- multimap<string, ShipItem*>::iterator it;
- for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
- if((*it).second->CheckSubType()==Armor)
- return false;
- }
- break;
- }
- case Useable:
- return CheckifSpace();
- }
- return true;
- }
-
- /*Adds the Item to the Ship*/
- void ShipEquipment::AddItem(ShipItem* toAddItem)
- {
- if(CheckifValid(toAddItem)==true)
- {
- switch(toAddItem.CheckType())
- {
- case Permanent:
- Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
- break;
- case Usable:
- Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
- break;
- case Trunk:
- Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
- break;
- }
- }
- else if(toAddItem.CheckType()==Permanent)
- {
- if(CheckifSpace()==true)
- Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,*toAddItem) );
- }
- }
-
- /*Adds the Item to the Ship*/
- void ShipEquipment::AddItem(Shipitem* toAddItem)
- {
- if(CheckifValid(toAddItem)==true)
- {
- switch(toAddItem.CheckType()){
- case Permanent:
- Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
- break;
- case Usable:
- Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
- break;
- case Trunk:
- Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
- break;
- }
- }
- else if(toAddItem.CheckType()==Permanent)
- {
- if(CheckifSpace()==true)
- Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
- }
- }
-
- void ShipEquipment::SwitchItem(Permanent* toSwitchItem)
- {
- multimap<string, ShipItem*>::iterator it;
- string equippedname;
- equippedname=GetNameofPermanent(toSwitchItem.CheckSubType());
- it=Equipment.find(equippedname);
- Trunk.insert (find(equippedname));
- Equipment.erase (it);
- Equipment.insert(pair<std::string, ShipItem*>(toSwitchItem.itemname,toSwitchItem)
- }
-
- string ShipEquipment::GetNameofPermanent (subItemTypePermanent NametoGet)
- {
- multimap<string, ShipItem*>::iterator it;
- for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
- if((*it).second->CheckSubType()==NametoGet){
- return (*it).first.itemname;
- }
- }
- return 0;
- }
-}
Deleted: trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.h
===================================================================
--- trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,52 +0,0 @@
-
-#ifndef _ShipEquipment_H__
-#define _ShipEquipment_H__
-#include <string>
-#include "SpaceShip.h"
-#include <map>
-
-
-/*
-multimap<std::string, BaseItem*> equipment_;
-equipment_.insert(pair<std::string, BaseItem*>("Weapon", new BaseItem()));*/
-
-
-/* std::map<std::itemtype, BaseItem*> EQClasses;
- EQClasses["jacke"] = 0;
- BaseItem* item = itemMap_["jacke"];
-
- if (itemMap_["jacke"])
- if (itemMap_.find("jacke") != itemMap_.end()) */
-namespace orxonox
-{
- class _OrxonoxExport ShipEquipment
- {
- public:
- /*void AddItem(Shipitem* toAddItem);
- void RemoveItem(Shipitem* toRemoveItem);
- bool CheckifValid(Shipitem* toBeChecked);
- bool CheckifSpace();
- void SwitchItem(Permanent* toSwitchItem);
- string GetNameofPermanent (subItemTypePermanent NametoGet);*/ //holt den Namen des getragenen Items im jeweiligen Slot.
-
- private:
- multimap<std::string, BaseItem*> Equipment;
- multimap<std::string, BaseItem*> Usable;
- multimap<std::string, BaseItem*> Trunk;
- };
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#endif
Deleted: trunk/src/orxonox/objects/pickup/ShipItem.cc
===================================================================
--- trunk/src/orxonox/objects/pickup/ShipItem.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/ShipItem.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,24 +0,0 @@
-#include "Shipitem.h"
-
-namespace orxonox
-{
- itemtype ShipItem::CheckType()
- {
- return this->type;
- }
-
- subItemTypePermanent CheckSubType()
- {
- return this->subtype_permanent;
- }
-
- subItemTypePowerups CheckSubType()
- {
- return this->subtype_powerups;
- }
- subItemTypeUsable CheckSubType()
- {
- return this->subtype_usables;
- }
-
-}
Deleted: trunk/src/orxonox/objects/pickup/ShipItem.h
===================================================================
--- trunk/src/orxonox/objects/pickup/ShipItem.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/ShipItem.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,91 +0,0 @@
-#ifndef _ShipItems_H__
-#define _ShipItems_H__
-#include <string>
-#include "SpaceShip.h"
-#include <map>
-#include "ShipEquipmentClasses.h"
-
-
-
-namespace orxonox
-{
- class _OrxonoxExport ShipItem
- {
- enum itemType //Diffrent Types of Items
- {
- Useable,
- Powerups,
- Permanent
- };
-
- public:
- itemType CheckType();
- //virtual ChecksubType();
-
- private:
- itemType type;
- string itemname;
- };
-
- /* Useables are Items the Player can choose when to activate and then show an instant action/effect
- * or for a certain duration */
- class _OrxonoxExport Useable : public ShipItem
- {
- enum subItemTypeUseable //Diffrent Types of Items of the Type Useable
- {
- Rockets,
- Repairkits,
- Triggers, //trigger events usable by the player (Quests f.exp.)
- Boosters,
- Shields,
- Appearance,
- };
-
- public:
- //subItemTypeUseable CheckSubType();
-
- private:
- subItemTypeUseable subtype_usable;
- };
-
- /* Permanents are Items, that effect the Player or his Ship from the instance he picks them up
- until he drops them again */
- class _OrxonoxExport Permanent : public ShipItem
- {
- enum subItemTypePermanent //Diffrent Types of Items of the Type Permanent
- {
- Weapon,
- Thrusters,
- Shields,
- Armor
- };
-
- public:
- subItemTypePermanent CheckSubType();
-
- private:
- subItemTypePermanent subtype_permanent;
- };
-
- // Powerups effect the Player right after he picks them up for a certain Duration /or permanently.
- class _OrxonoxExport Powerups : public ShipItem
- {
- enum subItem TypePowerups //Diffrent Types of Items of the Type Powerups
- {
- Weapon,
- Boosters,
- Shields,
- Repairkits,
- Appearance,
- Trigger
- };
-
- public:
- //subItemTypePowerups CheckSubType();
-
- private:
- subItemTypePowerups subtype_powerups;
- };
-}
-
-#endif
Deleted: trunk/src/orxonox/objects/pickup/Turbo.cc
===================================================================
--- trunk/src/orxonox/objects/pickup/Turbo.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/Turbo.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,128 +0,0 @@
-#include "OrxonoxStableHeaders.h"
-#include "Turbo.h"
-
-#include "objects/worldentities/pawns/SpaceShip.h"
-#include "core/Executor.h"
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-
-namespace orxonox
-{
-
-
- CreateFactory(Turbo);
-
- Turbo::Turbo(BaseObject* creator) : BaseItem(creator)
- {
- RegisterObject(Turbo);
-
- this->boost_ = 0;
- this->duration_ = 0;
- this->accboost_ = 1;
- this->rotacc_= 0;
- }
-
- Turbo::~Turbo()
- {
- }
-
- void Turbo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(Turbo, XMLPort, xmlelement, mode);
-
- XMLPortParam(Turbo, "boost", setBoost, getBoost, xmlelement, mode);
- XMLPortParam(Turbo, "duration", setDuration, getDuration, xmlelement, mode);
- XMLPortParam(Turbo, "accboost", setAccBoost, getAccBoost, xmlelement, mode);
- XMLPortParam(Turbo, "rotacc", setRotAcc, getRotAcc, xmlelement, mode);
- }
-
- bool Turbo::pickedUp(Pawn* player)
- {
-
- if(player-> isA(this->getPlayerBaseClass()))
- {
- SpaceShip* ship = dynamic_cast <SpaceShip*>(player);
- if(duration_==0 )
- {
- if(addTo(player))
- {
- COUT(3)<<"ITEM EQUIPPED"<<std::endl;
- this->setSpeedBoost(ship);
- return true;
- }
- return false;
- }
- else
- {
- this->setSpeedBoost(ship);
- return true;
- }
- return false;
- }
- return false;
-
- }
-
-
- void Turbo::unsetSpeedBoost(SpaceShip* ship)
- {
-/*
- ship->setMaxSpeed( ship->getMaxSpeed() - this->boost_);
- ship->setTransAcc( ship->getTransAcc()/this->accboost_);
- ship->setMaxRotation( ship->getMaxRotation()-this->rotacc_);
- ship->setRotAcc( ship->getRotAcc()-this->rotacc_);
- COUT(3)<<"BOOST UNSET"<<std::endl;
- COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl;
-*/
- ship->setPermanentBoost(false);
- }
-
- void Turbo::setSpeedBoost(SpaceShip* ship)
- {
-/*
- COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl;
- ship->setMaxSpeed( ship->getMaxSpeed() + this->boost_);
- ship->setTransAcc( ship->getTransAcc()*this->accboost_);
- ship->setMaxRotation( ship->getMaxRotation()+this->rotacc_);
- ship->setRotAcc( ship->getRotAcc()+this->rotacc_);
-*/
- ship->setPermanentBoost(true);
- ship->setBoost(true);
-
- if( this->duration_ != 0)
- {
- ExecutorMember<Turbo>* executor = createExecutor(createFunctor(&Turbo::unsetSpeedBoost));
- executor->setDefaultValues(ship);
- turbotimer_.setTimer(this->duration_, false, this, executor);
- }
-// COUT(3)<<"Speed:"<< ship->getMaxSpeed()<<std::endl;
- }
- bool Turbo::dropped(Pawn* player)
- {
- if (this->duration_ == 0)
- {
- COUT(0) << "ITEM DROPPED" << std::endl;
- if(remove(player)==true)
- {
- SpaceShip* ship = dynamic_cast <SpaceShip*>(player);
- this->unsetSpeedBoost(ship);
- }
- }
- return true;
- }
-
-}
-/*<Template baseclass="Turbo" name=turboitem>
- <Turbo playerclass="SpaceShip" boost=150 duration=10 accboost=10 />
- </Template>
-
- <PickupSpawner item=turboitem>
- <attached>
- <Billboard material="Examples/Flare" scale=0.2 colour="0.0, 0.0, 1.0, 1.0" />
- </attached>
- </PickupSpawner>*/
-
-
-
-
-
Deleted: trunk/src/orxonox/objects/pickup/Turbo.h
===================================================================
--- trunk/src/orxonox/objects/pickup/Turbo.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/Turbo.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,56 +0,0 @@
-#ifndef _Turbo_H__
-#define _Turbo_H__
-
-#include "tools/Timer.h"
-#include "BaseItem.h"
-#include "OrxonoxPrereqs.h"
-#include "util/Math.h"
-
-namespace orxonox
-{
- class _OrxonoxExport Turbo : public BaseItem
- {
-
- public:
- Turbo(BaseObject* creator);
- virtual ~Turbo();
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- virtual bool pickedUp(Pawn* player);
- virtual bool dropped(Pawn* player); //erst bei festen Items
-
- void setSpeedBoost(SpaceShip* ship);
- void unsetSpeedBoost(SpaceShip* ship);
-
- inline void setBoost(float boost)
- { this->boost_ = boost; }
- inline float getBoost() const
- { return this->boost_; }
-
- inline void setDuration(float duration)
- { this->duration_ = duration; }
- inline float getDuration() const
- { return this->duration_; }
-
- inline void setRotAcc(Degree rotacc)
- { this->rotacc_ = rotacc; }
- inline Degree getRotAcc() const
- { return this->rotacc_; }
-
-
- inline void setAccBoost(float accboost)
- { this->accboost_ = accboost; }
- inline float getAccBoost() const
- { return this->accboost_; }
-
- private:
- Timer<Turbo> turbotimer_;
- float boost_;
- float duration_;
- float accboost_;
- Degree rotacc_;
- };
-}
-
-#endif /* _Turbo_H__ */
Deleted: trunk/src/orxonox/objects/pickup/Usable.h
===================================================================
--- trunk/src/orxonox/objects/pickup/Usable.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/Usable.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,12 +0,0 @@
-/*enum subItemType{ Subtypes (thrusters etc)*/
-
-namespace orxonox
-{
- class _OrxonoxExport Usable: public ShipItem
- {
- public:
- subtypeusable CheckSubType();
- private:
- subtypeusable subtype;
- };
-}
Copied: trunk/src/orxonox/objects/pickup/UsableItem.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/UsableItem.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/UsableItem.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/UsableItem.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,52 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of UsableItem.
+*/
+
+#include "UsableItem.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor. Registers the UsableItem.
+ @param creator Pointer to the object which created this item.
+ */
+ UsableItem::UsableItem(BaseObject* creator) : BaseItem(creator)
+ {
+ RegisterObject(UsableItem);
+ }
+ //! Deconstructor.
+ UsableItem::~UsableItem()
+ {
+ }
+}
Copied: trunk/src/orxonox/objects/pickup/UsableItem.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/UsableItem.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/UsableItem.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/UsableItem.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,61 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of UsableItem.
+*/
+
+#ifndef _UsableItem_H__
+#define _UsableItem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "BaseItem.h"
+
+namespace orxonox
+{
+ /**
+ @brief Base class for all usable items (not usable yet).
+ @author Daniel 'Huty' Haggenmueller
+ */
+ class _OrxonoxExport UsableItem : public BaseItem
+ {
+ public:
+ UsableItem(BaseObject* creator);
+ virtual ~UsableItem();
+
+ /**
+ @brief Method invoked when the item is being used.
+ @param pawn Pawn which is using the item.
+ */
+ virtual void used(Pawn* pawn) { }
+ };
+}
+
+#endif /* _UsableItem_H__ */
Deleted: trunk/src/orxonox/objects/pickup/items/CMakeLists.txt
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/items/CMakeLists.txt 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/items/CMakeLists.txt 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,5 +0,0 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
- HealthImmediate.cc
- HealthUsable.cc
- Jump.cc
-)
Copied: trunk/src/orxonox/objects/pickup/items/CMakeLists.txt (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/items/CMakeLists.txt)
===================================================================
--- trunk/src/orxonox/objects/pickup/items/CMakeLists.txt (rev 0)
+++ trunk/src/orxonox/objects/pickup/items/CMakeLists.txt 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,5 @@
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ HealthImmediate.cc
+ HealthUsable.cc
+ Jump.cc
+)
Deleted: trunk/src/orxonox/objects/pickup/items/HealthImmediate.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/items/HealthImmediate.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/items/HealthImmediate.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,76 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Daniel 'Huty' Haggenmueller
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of HealthImmediate.
-*/
-
-#include "HealthImmediate.h"
-
-#include "objects/worldentities/pawns/Pawn.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "core/Core.h"
-
-namespace orxonox
-{
- CreateFactory(HealthImmediate);
-
- HealthImmediate::HealthImmediate(BaseObject* creator) : PassiveItem(creator)
- {
- RegisterObject(HealthImmediate);
-
- this->recoveredHealth_ = 0;
- }
- HealthImmediate::~HealthImmediate()
- {
- }
-
- void HealthImmediate::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(HealthImmediate, XMLPort, xmlelement, mode);
-
- XMLPortParam(HealthImmediate, "recoveredHealth", setRecoveredHealth, getRecoveredHealth, xmlelement, mode);
- }
-
- bool HealthImmediate::pickedUp(Pawn* pawn)
- {
- float maxH = pawn->getMaxHealth();
- float curH = pawn->getHealth();
-
- if (curH < maxH)
- {
- pawn->addHealth(this->recoveredHealth_);
- delete this;
- }
-
- return (curH < maxH);
- }
-}
\ No newline at end of file
Copied: trunk/src/orxonox/objects/pickup/items/HealthImmediate.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/items/HealthImmediate.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/items/HealthImmediate.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/items/HealthImmediate.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,76 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of HealthImmediate.
+*/
+
+#include "HealthImmediate.h"
+
+#include "objects/worldentities/pawns/Pawn.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/Core.h"
+
+namespace orxonox
+{
+ CreateFactory(HealthImmediate);
+
+ HealthImmediate::HealthImmediate(BaseObject* creator) : PassiveItem(creator)
+ {
+ RegisterObject(HealthImmediate);
+
+ this->recoveredHealth_ = 0;
+ }
+ HealthImmediate::~HealthImmediate()
+ {
+ }
+
+ void HealthImmediate::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(HealthImmediate, XMLPort, xmlelement, mode);
+
+ XMLPortParam(HealthImmediate, "recoveredHealth", setRecoveredHealth, getRecoveredHealth, xmlelement, mode);
+ }
+
+ bool HealthImmediate::pickedUp(Pawn* pawn)
+ {
+ float maxH = pawn->getMaxHealth();
+ float curH = pawn->getHealth();
+
+ if (curH < maxH)
+ {
+ pawn->addHealth(this->recoveredHealth_);
+ delete this;
+ }
+
+ return (curH < maxH);
+ }
+}
\ No newline at end of file
Deleted: trunk/src/orxonox/objects/pickup/items/HealthImmediate.h
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/items/HealthImmediate.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/items/HealthImmediate.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,68 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Daniel 'Huty' Haggenmueller
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of HealthImmediate.
-*/
-
-#ifndef _HealthImmediate_H__
-#define _HealthImmediate_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "../PassiveItem.h"
-
-namespace orxonox
-{
- class Pawn;
-
- /**
- @brief Health-item, immediatly recovers health when picked up.
- */
- class _OrxonoxExport HealthImmediate : public PassiveItem
- {
- public:
- HealthImmediate(BaseObject* creator);
- virtual ~HealthImmediate();
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- virtual bool pickedUp(Pawn* pawn);
-
- inline float getRecoveredHealth() const
- { return this->recoveredHealth_; }
- inline void setRecoveredHealth(float recovery)
- { this->recoveredHealth_ = recovery; }
-
- private:
- float recoveredHealth_;
- };
-}
-
-#endif /* _HealthImmediate_H__ */
\ No newline at end of file
Copied: trunk/src/orxonox/objects/pickup/items/HealthImmediate.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/items/HealthImmediate.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/items/HealthImmediate.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/items/HealthImmediate.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,68 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of HealthImmediate.
+*/
+
+#ifndef _HealthImmediate_H__
+#define _HealthImmediate_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "../PassiveItem.h"
+
+namespace orxonox
+{
+ class Pawn;
+
+ /**
+ @brief Health-item, immediatly recovers health when picked up.
+ */
+ class _OrxonoxExport HealthImmediate : public PassiveItem
+ {
+ public:
+ HealthImmediate(BaseObject* creator);
+ virtual ~HealthImmediate();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ virtual bool pickedUp(Pawn* pawn);
+
+ inline float getRecoveredHealth() const
+ { return this->recoveredHealth_; }
+ inline void setRecoveredHealth(float recovery)
+ { this->recoveredHealth_ = recovery; }
+
+ private:
+ float recoveredHealth_;
+ };
+}
+
+#endif /* _HealthImmediate_H__ */
\ No newline at end of file
Deleted: trunk/src/orxonox/objects/pickup/items/HealthUsable.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/items/HealthUsable.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/items/HealthUsable.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,105 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Daniel 'Huty' Haggenmueller
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of HealthUsable.
-*/
-
-#include "HealthUsable.h"
-#include "../DroppedItem.h"
-
-#include "objects/worldentities/pawns/Pawn.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "core/Core.h"
-
-namespace orxonox
-{
- CreateFactory(HealthUsable);
-
- /**
- @brief Constructor
- @param creator Object that created this item.
- */
- HealthUsable::HealthUsable(BaseObject* creator) : UsableItem(creator)
- {
- RegisterObject(HealthUsable);
-
- this->recoveredHealth_ = 0;
- }
- //! Deconstructor
- HealthUsable::~HealthUsable()
- {
- }
- /**
- @brief XMLPort for Jump.
- @param xmlelement Element of the XML-file.
- @param mode XMLPort mode to use.
- */
- void HealthUsable::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(HealthUsable, XMLPort, xmlelement, mode);
-
- XMLPortParam(HealthUsable, "recoveredHealth", setRecoveredHealth, getRecoveredHealth, xmlelement, mode);
- }
- /**
- @brief Called when the item is used, makes the user "jump".
- @param pawn Pawn which used te item.
- */
- void HealthUsable::used(Pawn* pawn)
- {
- float maxH = pawn->getMaxHealth();
- float curH = pawn->getHealth();
-
- if (curH < maxH) {
- pawn->addHealth(this->recoveredHealth_);
-
- this->removeFrom(pawn);
- delete this;
- }
- }
- /**
- @brief Called when the item is picked up.
- @param pawn Pawn which picked up the item.
- */
- bool HealthUsable::pickedUp(Pawn* pawn)
- {
- return this->addTo(pawn);
- }
- /**
- @brief Called when the item is dropped, creates a DroppedItem behind the pawn.
- @param pawn Pawn which dropped the item.
- */
- bool HealthUsable::dropped(Pawn* pawn)
- {
- DroppedItem::createDefaultDrop(this, pawn, ColourValue(1.0f, 0.0f, 0.0f), 30.0f);
- return this->removeFrom(pawn);
- }
-}
Copied: trunk/src/orxonox/objects/pickup/items/HealthUsable.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/items/HealthUsable.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/items/HealthUsable.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/items/HealthUsable.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,105 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of HealthUsable.
+*/
+
+#include "HealthUsable.h"
+#include "../DroppedItem.h"
+
+#include "objects/worldentities/pawns/Pawn.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/Core.h"
+
+namespace orxonox
+{
+ CreateFactory(HealthUsable);
+
+ /**
+ @brief Constructor
+ @param creator Object that created this item.
+ */
+ HealthUsable::HealthUsable(BaseObject* creator) : UsableItem(creator)
+ {
+ RegisterObject(HealthUsable);
+
+ this->recoveredHealth_ = 0;
+ }
+ //! Deconstructor
+ HealthUsable::~HealthUsable()
+ {
+ }
+ /**
+ @brief XMLPort for Jump.
+ @param xmlelement Element of the XML-file.
+ @param mode XMLPort mode to use.
+ */
+ void HealthUsable::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(HealthUsable, XMLPort, xmlelement, mode);
+
+ XMLPortParam(HealthUsable, "recoveredHealth", setRecoveredHealth, getRecoveredHealth, xmlelement, mode);
+ }
+ /**
+ @brief Called when the item is used, makes the user "jump".
+ @param pawn Pawn which used te item.
+ */
+ void HealthUsable::used(Pawn* pawn)
+ {
+ float maxH = pawn->getMaxHealth();
+ float curH = pawn->getHealth();
+
+ if (curH < maxH) {
+ pawn->addHealth(this->recoveredHealth_);
+
+ this->removeFrom(pawn);
+ delete this;
+ }
+ }
+ /**
+ @brief Called when the item is picked up.
+ @param pawn Pawn which picked up the item.
+ */
+ bool HealthUsable::pickedUp(Pawn* pawn)
+ {
+ return this->addTo(pawn);
+ }
+ /**
+ @brief Called when the item is dropped, creates a DroppedItem behind the pawn.
+ @param pawn Pawn which dropped the item.
+ */
+ bool HealthUsable::dropped(Pawn* pawn)
+ {
+ DroppedItem::createDefaultDrop(this, pawn, ColourValue(1.0f, 0.0f, 0.0f), 30.0f);
+ return this->removeFrom(pawn);
+ }
+}
Deleted: trunk/src/orxonox/objects/pickup/items/HealthUsable.h
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/items/HealthUsable.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/items/HealthUsable.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,82 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Daniel 'Huty' Haggenmueller
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of HealthUsable.
-*/
-
-#ifndef _HealthUsable_H__
-#define _HealthUsable_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "../UsableItem.h"
-#include "util/Math.h"
-
-namespace orxonox
-{
- class Pawn;
-
- /**
- @brief Health-item, enables player recover health when used.
- */
- class _OrxonoxExport HealthUsable : public UsableItem
- {
- public:
- HealthUsable(BaseObject* creator); //!< Constructor
- virtual ~HealthUsable(); //!< Deconstructor
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
-
- virtual int getMaxCarryAmount() const
- { return INT_MAX; }
-
- virtual void used(Pawn* pawn); //!< Called when the item is used.
-
- virtual bool pickedUp(Pawn* pawn); //!< Called when the item is picked up.
- virtual bool dropped(Pawn* pawn); //!< Called when the item is dropped.
-
- /**
- @brief Get the amount of jumps available.
- @return Returns how many times the item can be used.
- */
- inline float getRecoveredHealth() const
- { return this->recoveredHealth_; }
- /**
- @brief Set the amount of jumps available.
- @param num New number of available jumps.
- */
- inline void setRecoveredHealth(float recovery)
- { this->recoveredHealth_ = recovery; }
- private:
- float recoveredHealth_; //!< Amount of jumps still available.
- };
-}
-
-#endif /* _HealthUsable_H__ */
Copied: trunk/src/orxonox/objects/pickup/items/HealthUsable.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/items/HealthUsable.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/items/HealthUsable.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/items/HealthUsable.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,82 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of HealthUsable.
+*/
+
+#ifndef _HealthUsable_H__
+#define _HealthUsable_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "../UsableItem.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+ class Pawn;
+
+ /**
+ @brief Health-item, enables player recover health when used.
+ */
+ class _OrxonoxExport HealthUsable : public UsableItem
+ {
+ public:
+ HealthUsable(BaseObject* creator); //!< Constructor
+ virtual ~HealthUsable(); //!< Deconstructor
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
+
+ virtual int getMaxCarryAmount() const
+ { return INT_MAX; }
+
+ virtual void used(Pawn* pawn); //!< Called when the item is used.
+
+ virtual bool pickedUp(Pawn* pawn); //!< Called when the item is picked up.
+ virtual bool dropped(Pawn* pawn); //!< Called when the item is dropped.
+
+ /**
+ @brief Get the amount of jumps available.
+ @return Returns how many times the item can be used.
+ */
+ inline float getRecoveredHealth() const
+ { return this->recoveredHealth_; }
+ /**
+ @brief Set the amount of jumps available.
+ @param num New number of available jumps.
+ */
+ inline void setRecoveredHealth(float recovery)
+ { this->recoveredHealth_ = recovery; }
+ private:
+ float recoveredHealth_; //!< Amount of jumps still available.
+ };
+}
+
+#endif /* _HealthUsable_H__ */
Deleted: trunk/src/orxonox/objects/pickup/items/Jump.cc
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/items/Jump.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/items/Jump.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,108 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Daniel 'Huty' Haggenmueller
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of Jump.
-*/
-
-#include "Jump.h"
-#include "DroppedItem.h"
-
-#include "objects/worldentities/pawns/Pawn.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "core/Core.h"
-
-namespace orxonox
-{
- CreateFactory(Jump);
-
- /**
- @brief Constructor
- @param creator Object that created this item.
- */
- Jump::Jump(BaseObject* creator) : UsableItem(creator)
- {
- RegisterObject(Jump);
-
- this->velocity_ = Vector3(0.0f, 0.0f, 0.0f);
- this->jumpsAvailable_ = 1;
- }
- //! Deconstructor
- Jump::~Jump()
- {
- }
- /**
- @brief XMLPort for Jump.
- @param xmlelement Element of the XML-file.
- @param mode XMLPort mode to use.
- */
- void Jump::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(Jump, XMLPort, xmlelement, mode);
-
- XMLPortParam(Jump, "velocity", setVelocity, getVelocity, xmlelement, mode);
- XMLPortParam(Jump, "jumpsAvailable", setJumpsAvailable, getJumpsAvailable, xmlelement, mode);
- }
- /**
- @brief Called when the item is used, makes the user "jump".
- @param pawn Pawn which used te item.
- */
- void Jump::used(Pawn* pawn)
- {
- if (this->jumpsAvailable_ > 0){
- pawn->setVelocity(pawn->getVelocity() + pawn->getOrientation() * this->velocity_);
- }
-
- this->jumpsAvailable_--;
- if (this->jumpsAvailable_ <= 0)
- {
- this->removeFrom(pawn);
- delete this;
- }
- }
- /**
- @brief Called when the item is picked up.
- @param pawn Pawn which picked up the item.
- */
- bool Jump::pickedUp(Pawn* pawn)
- {
- return this->addTo(pawn);
- }
- /**
- @brief Called when the item is dropped, creates a DroppedItem behind the pawn.
- @param pawn Pawn which dropped the item.
- */
- bool Jump::dropped(Pawn* pawn)
- {
- DroppedItem::createDefaultDrop(this, pawn, ColourValue(1.0f, 0.0f, 0.0f), 30.0f);
- return this->removeFrom(pawn);
- }
-}
Copied: trunk/src/orxonox/objects/pickup/items/Jump.cc (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/items/Jump.cc)
===================================================================
--- trunk/src/orxonox/objects/pickup/items/Jump.cc (rev 0)
+++ trunk/src/orxonox/objects/pickup/items/Jump.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,108 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of Jump.
+*/
+
+#include "Jump.h"
+#include "DroppedItem.h"
+
+#include "objects/worldentities/pawns/Pawn.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/Core.h"
+
+namespace orxonox
+{
+ CreateFactory(Jump);
+
+ /**
+ @brief Constructor
+ @param creator Object that created this item.
+ */
+ Jump::Jump(BaseObject* creator) : UsableItem(creator)
+ {
+ RegisterObject(Jump);
+
+ this->velocity_ = Vector3(0.0f, 0.0f, 0.0f);
+ this->jumpsAvailable_ = 1;
+ }
+ //! Deconstructor
+ Jump::~Jump()
+ {
+ }
+ /**
+ @brief XMLPort for Jump.
+ @param xmlelement Element of the XML-file.
+ @param mode XMLPort mode to use.
+ */
+ void Jump::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(Jump, XMLPort, xmlelement, mode);
+
+ XMLPortParam(Jump, "velocity", setVelocity, getVelocity, xmlelement, mode);
+ XMLPortParam(Jump, "jumpsAvailable", setJumpsAvailable, getJumpsAvailable, xmlelement, mode);
+ }
+ /**
+ @brief Called when the item is used, makes the user "jump".
+ @param pawn Pawn which used te item.
+ */
+ void Jump::used(Pawn* pawn)
+ {
+ if (this->jumpsAvailable_ > 0){
+ pawn->setVelocity(pawn->getVelocity() + pawn->getOrientation() * this->velocity_);
+ }
+
+ this->jumpsAvailable_--;
+ if (this->jumpsAvailable_ <= 0)
+ {
+ this->removeFrom(pawn);
+ delete this;
+ }
+ }
+ /**
+ @brief Called when the item is picked up.
+ @param pawn Pawn which picked up the item.
+ */
+ bool Jump::pickedUp(Pawn* pawn)
+ {
+ return this->addTo(pawn);
+ }
+ /**
+ @brief Called when the item is dropped, creates a DroppedItem behind the pawn.
+ @param pawn Pawn which dropped the item.
+ */
+ bool Jump::dropped(Pawn* pawn)
+ {
+ DroppedItem::createDefaultDrop(this, pawn, ColourValue(1.0f, 0.0f, 0.0f), 30.0f);
+ return this->removeFrom(pawn);
+ }
+}
Deleted: trunk/src/orxonox/objects/pickup/items/Jump.h
===================================================================
--- branches/pickups2/src/orxonox/objects/pickup/items/Jump.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/pickup/items/Jump.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -1,97 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Daniel 'Huty' Haggenmueller
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of Jump.
-*/
-
-#ifndef _Jump_H__
-#define _Jump_H__
-
-#include <climits>
-
-#include "OrxonoxPrereqs.h"
-
-#include "UsableItem.h"
-#include "util/Math.h"
-
-namespace orxonox
-{
- class Pawn;
-
- /**
- @brief Jump-item, enables player to "jump" into a direction.
- */
- class _OrxonoxExport Jump : public UsableItem
- {
- public:
- Jump(BaseObject* creator); //!< Constructor
- virtual ~Jump(); //!< Deconstructor
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
-
- virtual int getMaxCarryAmount() const
- { return INT_MAX; }
-
- virtual void used(Pawn* pawn); //!< Called when the item is used.
-
- virtual bool pickedUp(Pawn* pawn); //!< Called when the item is picked up.
- virtual bool dropped(Pawn* pawn); //!< Called when the item is dropped.
-
- /**
- @brief Get the velocity added when the item is used.
- @return Returns the added velocity (relative to the Pawn).
- */
- inline const Vector3& getVelocity() const
- { return this->velocity_; }
- /**
- @brief Set the velocity added when the item is used.
- @param velocity New added velocity (relative to Pawn).
- */
- inline void setVelocity(const Vector3& velocity)
- { this->velocity_ = velocity; }
- /**
- @brief Get the amount of jumps available.
- @return Returns how many times the item can be used.
- */
- inline int getJumpsAvailable() const
- { return this->jumpsAvailable_; }
- /**
- @brief Set the amount of jumps available.
- @param num New number of available jumps.
- */
- inline void setJumpsAvailable(int num)
- { this->jumpsAvailable_ = num; }
- private:
- Vector3 velocity_; //!< The velocity added when the item is used.
- int jumpsAvailable_; //!< Amount of jumps still available.
- };
-}
-
-#endif /* _Jump_H__ */
Copied: trunk/src/orxonox/objects/pickup/items/Jump.h (from rev 3072, branches/pickups2/src/orxonox/objects/pickup/items/Jump.h)
===================================================================
--- trunk/src/orxonox/objects/pickup/items/Jump.h (rev 0)
+++ trunk/src/orxonox/objects/pickup/items/Jump.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -0,0 +1,97 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Daniel 'Huty' Haggenmueller
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of Jump.
+*/
+
+#ifndef _Jump_H__
+#define _Jump_H__
+
+#include <climits>
+
+#include "OrxonoxPrereqs.h"
+
+#include "UsableItem.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+ class Pawn;
+
+ /**
+ @brief Jump-item, enables player to "jump" into a direction.
+ */
+ class _OrxonoxExport Jump : public UsableItem
+ {
+ public:
+ Jump(BaseObject* creator); //!< Constructor
+ virtual ~Jump(); //!< Deconstructor
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
+
+ virtual int getMaxCarryAmount() const
+ { return INT_MAX; }
+
+ virtual void used(Pawn* pawn); //!< Called when the item is used.
+
+ virtual bool pickedUp(Pawn* pawn); //!< Called when the item is picked up.
+ virtual bool dropped(Pawn* pawn); //!< Called when the item is dropped.
+
+ /**
+ @brief Get the velocity added when the item is used.
+ @return Returns the added velocity (relative to the Pawn).
+ */
+ inline const Vector3& getVelocity() const
+ { return this->velocity_; }
+ /**
+ @brief Set the velocity added when the item is used.
+ @param velocity New added velocity (relative to Pawn).
+ */
+ inline void setVelocity(const Vector3& velocity)
+ { this->velocity_ = velocity; }
+ /**
+ @brief Get the amount of jumps available.
+ @return Returns how many times the item can be used.
+ */
+ inline int getJumpsAvailable() const
+ { return this->jumpsAvailable_; }
+ /**
+ @brief Set the amount of jumps available.
+ @param num New number of available jumps.
+ */
+ inline void setJumpsAvailable(int num)
+ { this->jumpsAvailable_ = num; }
+ private:
+ Vector3 velocity_; //!< The velocity added when the item is used.
+ int jumpsAvailable_; //!< Amount of jumps still available.
+ };
+}
+
+#endif /* _Jump_H__ */
Modified: trunk/src/orxonox/objects/weaponsystem/projectiles/Projectile.cc
===================================================================
--- trunk/src/orxonox/objects/weaponsystem/projectiles/Projectile.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/weaponsystem/projectiles/Projectile.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -125,9 +125,13 @@
}
}
+ float dmg = this->damage_;
+ if (this->owner_)
+ dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
+
Pawn* victim = dynamic_cast<Pawn*>(otherObject);
if (victim)
- victim->damage(this->damage_, this->owner_);
+ victim->damage(dmg, this->owner_);
}
return false;
}
Modified: trunk/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/ControllableEntity.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/worldentities/ControllableEntity.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -84,7 +84,7 @@
virtual void boost() {}
virtual void greet() {}
- virtual void use() {}
+ virtual void useItem() {}
virtual void dropItems() {}
virtual void switchCamera();
virtual void mouseLook();
Modified: trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-05-25 18:30:15 UTC (rev 3073)
@@ -65,7 +65,7 @@
this->spawnparticleduration_ = 3.0f;
- this->getPickUp().setPlayer(this);
+ this->getPickups().setOwner(this);
if (GameMode::isMaster())
{
@@ -213,6 +213,8 @@
this->setDestroyWhenPlayerLeft(false);
+ this->dropItems();
+
if (this->getGametype())
this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
@@ -277,7 +279,7 @@
void Pawn::dropItems()
{
- pickUp.eraseAll();
+ this->getPickups().clear();
}
Modified: trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Pawn.h 2009-05-25 18:04:03 UTC (rev 3072)
+++ trunk/src/orxonox/objects/worldentities/pawns/Pawn.h 2009-05-25 18:30:15 UTC (rev 3073)
@@ -30,9 +30,9 @@
#define _Pawn_H__
#include "OrxonoxPrereqs.h"
-#include "objects/pickup/ShipEquipment.h"
#include "objects/worldentities/ControllableEntity.h"
#include "objects/RadarViewable.h"
+#include "objects/pickup/PickupCollection.h"
namespace orxonox
{
@@ -105,10 +105,11 @@
inline unsigned int getExplosionChunks() const
{ return this->numexplosionchunks_; }
- inline ShipEquipment& getPickUp()
- {return this->pickUp;}
-
virtual void dropItems();
+ inline PickupCollection& getPickups()
+ { return this->pickups_; }
+ virtual void useItem()
+ { this->pickups_.useItem(); }
protected:
virtual void setPlayer(PlayerInfo* player);
@@ -118,9 +119,9 @@
virtual void deatheffect();
virtual void spawneffect();
- ShipEquipment pickUp;
bool bAlive_;
+ PickupCollection pickups_;
float health_;
float maxHealth_;
More information about the Orxonox-commit
mailing list