[Orxonox-commit 1687] r6405 - in code/branches/pickup2/src: libraries/core modules modules/pickup modules/weapons/projectiles orxonox orxonox/interfaces orxonox/items orxonox/pickup orxonox/worldentities/pawns
dafrick at orxonox.net
dafrick at orxonox.net
Wed Dec 23 20:27:17 CET 2009
Author: dafrick
Date: 2009-12-23 20:27:17 +0100 (Wed, 23 Dec 2009)
New Revision: 6405
Added:
code/branches/pickup2/src/modules/pickup/
code/branches/pickup2/src/modules/pickup/CMakeLists.txt
code/branches/pickup2/src/modules/pickup/DroppedItem.cc
code/branches/pickup2/src/modules/pickup/DroppedItem.h
code/branches/pickup2/src/modules/pickup/PickupCollection.cc
code/branches/pickup2/src/modules/pickup/PickupCollection.h
code/branches/pickup2/src/modules/pickup/PickupPrecompiledHeaders.h
code/branches/pickup2/src/modules/pickup/PickupPrereqs.h
code/branches/pickup2/src/modules/pickup/PickupSpawner.cc
code/branches/pickup2/src/modules/pickup/PickupSpawner.h
code/branches/pickup2/src/orxonox/interfaces/PickupCarrier.h
code/branches/pickup2/src/orxonox/interfaces/Pickupable.h
Removed:
code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc
code/branches/pickup2/src/orxonox/pickup/DroppedItem.h
code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc
code/branches/pickup2/src/orxonox/pickup/PickupSpawner.h
Modified:
code/branches/pickup2/src/libraries/core/Super.h
code/branches/pickup2/src/modules/CMakeLists.txt
code/branches/pickup2/src/modules/weapons/projectiles/Projectile.cc
code/branches/pickup2/src/orxonox/CMakeLists.txt
code/branches/pickup2/src/orxonox/OrxonoxPrereqs.h
code/branches/pickup2/src/orxonox/interfaces/InterfaceCompilation.cc
code/branches/pickup2/src/orxonox/items/Engine.cc
code/branches/pickup2/src/orxonox/pickup/CMakeLists.txt
code/branches/pickup2/src/orxonox/pickup/PickupCollection.cc
code/branches/pickup2/src/orxonox/pickup/PickupCollection.h
code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.cc
code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.h
Log:
Commit changes in pickup before merge.
Modified: code/branches/pickup2/src/libraries/core/Super.h
===================================================================
--- code/branches/pickup2/src/libraries/core/Super.h 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/libraries/core/Super.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -266,6 +266,9 @@
#define SUPER_changedGametype(classname, functionname, ...) \
SUPER_NOARGS(classname, functionname)
+
+ #define SUPER_changedUsed(classname, functionname, ...) \
+ SUPER_NOARGS(classname, functionname)
// (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
@@ -516,6 +519,10 @@
SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedGametype, false)
()
SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+ SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedUsed, false)
+ ()
+ SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
// (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
}
@@ -569,6 +576,7 @@
SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
SUPER_INTRUSIVE_DECLARATION(changedName);
SUPER_INTRUSIVE_DECLARATION(changedGametype);
+ SUPER_INTRUSIVE_DECLARATION(changedUsed);
// (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
Modified: code/branches/pickup2/src/modules/CMakeLists.txt
===================================================================
--- code/branches/pickup2/src/modules/CMakeLists.txt 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/modules/CMakeLists.txt 2009-12-23 19:27:17 UTC (rev 6405)
@@ -28,6 +28,7 @@
ADD_SUBDIRECTORY(objects)
ADD_SUBDIRECTORY(overlays)
+ADD_SUBDIRECTORY(pickup)
ADD_SUBDIRECTORY(pong)
ADD_SUBDIRECTORY(questsystem)
ADD_SUBDIRECTORY(weapons)
Added: code/branches/pickup2/src/modules/pickup/CMakeLists.txt
===================================================================
--- code/branches/pickup2/src/modules/pickup/CMakeLists.txt (rev 0)
+++ code/branches/pickup2/src/modules/pickup/CMakeLists.txt 2009-12-23 19:27:17 UTC (rev 6405)
@@ -0,0 +1,18 @@
+SET_SOURCE_FILES(PICKUP_SRC_FILES
+ PickupCollection.cc
+ PickupSpawner.cc
+)
+
+ORXONOX_ADD_LIBRARY(pickup
+ MODULE
+ FIND_HEADER_FILES
+ TOLUA_FILES
+ DEFINE_SYMBOL
+ "PICKUP_SHARED_BUILD"
+ PCH_FILE
+ PickupPrecompiledHeaders.h
+ LINK_LIBRARIES
+ orxonox
+ SOURCE_FILES ${PICKUP_SRC_FILES}
+)
+
Copied: code/branches/pickup2/src/modules/pickup/DroppedItem.cc (from rev 5953, code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc)
===================================================================
--- code/branches/pickup2/src/modules/pickup/DroppedItem.cc (rev 0)
+++ code/branches/pickup2/src/modules/pickup/DroppedItem.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -0,0 +1,114 @@
+/*
+ * 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 "DroppedItem.h"
+
+#include "util/Math.h"
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "BaseItem.h"
+#include "graphics/Billboard.h"
+#include "graphics/Model.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+ CreateFactory(DroppedItem); //TODO: This isn't needed, is it?
+
+ /**
+ @brief
+ Constructor. Registers object and sets default values.
+ */
+ DroppedItem::DroppedItem(BaseObject* creator) : PickupSpawner(creator)
+ {
+ RegisterObject(DroppedItem);
+ }
+
+ DroppedItem::DroppedItem(BaseObject* creator, BaseItem* item, float triggerDistance, float respawnTime, int maxSpawnedItems) : PickupSpawner(creator, item, triggerDistance, respawnTime, maxSpawnedItems)
+ {
+ RegisterObject(DroppedItem);
+ this->item_ = item;
+ }
+
+ /**
+ @brief
+ Default destructor.
+ */
+ DroppedItem::~DroppedItem()
+ {
+
+ }
+
+ BaseItem* DroppedItem::getItem(void)
+ {
+ return this->item_;
+ }
+
+ /**
+ @brief
+
+ */
+ //TODO: Comment.
+ //Each pickup should have a XML template where the Model and Billboard, and so on, is specified.
+ /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
+ {
+ //TODO: triggerDistance?
+ float triggerDistance = 20.0;
+ DroppedItem* droppedItem = new DroppedItem(item, item, triggerDistance, 0, 1);
+
+ //TODO: Do this somehwere else?
+ 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);
+
+ droppedItem->setPosition(position);
+ droppedItem->attach(model);
+ droppedItem->attach(billboard);
+
+ COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << "," << position.y << "," << position.z << ")." << std::endl;
+
+ return droppedItem;
+ }
+
+ /**
+ @brief
+
+ */
+ //TODO: See one function above.
+ 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: code/branches/pickup2/src/modules/pickup/DroppedItem.h (from rev 5953, code/branches/pickup2/src/orxonox/pickup/DroppedItem.h)
===================================================================
--- code/branches/pickup2/src/modules/pickup/DroppedItem.h (rev 0)
+++ code/branches/pickup2/src/modules/pickup/DroppedItem.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -0,0 +1,63 @@
+/*
+ * 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 DroppedItem
+*/
+
+#ifndef _DroppedItem_H__
+#define _DroppedItem_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "PickupSpawner.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport DroppedItem : public PickupSpawner
+ {
+ public:
+ DroppedItem(BaseObject* creator);
+ DroppedItem(BaseObject* creator, BaseItem* item, float triggerDistance, float respawnTime, int maxSpawnedItems);
+ virtual ~DroppedItem();
+
+ 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);
+
+ protected:
+ virtual BaseItem* getItem(void);
+
+ private:
+
+ BaseItem* item_; //!< The dropped item.
+
+ };
+}
+
+#endif /* _DroppedItem_H__ */
Added: code/branches/pickup2/src/modules/pickup/PickupCollection.cc
===================================================================
--- code/branches/pickup2/src/modules/pickup/PickupCollection.cc (rev 0)
+++ code/branches/pickup2/src/modules/pickup/PickupCollection.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -0,0 +1,231 @@
+/*
+ * 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:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of PickupCollection.
+*/
+
+#include "PickupCollection.h"
+
+#include "core/CoreIncludes.h"
+#include "core/Template.h"
+#include "core/XMLPort.h"
+#include "interfaces/PickupCarrier.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Default Constructor.
+ */
+ PickupCollection::PickupCollection(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(PickupCollection);
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ PickupCollection::~PickupCollection()
+ {
+ //! Destroy all Pickupables constructing this PickupCollection.
+ for(std::list<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ delete *it;
+ }
+ }
+
+ /**
+ @brief
+ Creates an instance of this Class through XML.
+ */
+ void PickupCollection::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(PickupCollection, XMLPort, xmlelement, mode);
+
+ //TODO: Does this work? Problem could be, that Pickupable itself cannot be instantiated through XML...
+ XMLPortObject(PickupCollection, PickupCollection, "pickupables", addPickupable, getPickupable, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Add the input Pickupable to list of Pickupables combined by this PickupCollection.
+ @param pickup
+ The Pickupable to be added.
+ @return
+ Returns true if successful,
+ */
+ bool PickupCollection::addPickupable(Pickupable* pickup)
+ {
+ if(pickup == NULL)
+ return false;
+
+ this->pickups_.insert(pickup);
+ return true;
+ }
+
+ /**
+ @brief
+ Get the Pickupable at the given index.
+ @param index
+ The index the Pickupable is fetched from.
+ @return
+ Returns a pointer to the Pickupable at the index given by index.
+ */
+ Pickupable* PickupCollection::getPickupable(unsigned int index)
+ {
+ return this->pickups_[index]; //TODO. Does this work?
+ }
+
+ //TODO: Steal description from Pickupable.
+ void PickupCollection::changedUsed(void)
+ {
+ SUPER(PickupCollection, changedUsed);
+
+ //! Change used for all Pickupables this PickupCollection consists of.
+ for(std::list<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ (*it)->changedUsed();
+ }
+ }
+
+ /**
+ @brief
+ Puts the PickupCollection in use.
+ @return
+ Returns true if successful.
+ */
+ //TODO: Revert if one fails? (same for unused)
+ bool PickupCollection::use(void)
+ {
+ if(this->isUsed())
+ return false;
+
+ bool success = true;
+ //! Set all Pickupables to used.
+ for(std::list<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ if(!(*it)->use())
+ {
+ success = false;
+ }
+ }
+
+ this->changedUsed();
+
+ return success;
+ }
+
+ /**
+ @brief
+ Puts the PickupCollection out of use.
+ @return
+ Returns true if successful.
+ */
+ bool PickupCollection::unuse(void)
+ {
+ if(!this->isUsed())
+ return false;
+
+ bool success = true;
+ //! Set all Pickupables to unused.
+ for(std::list<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ if(!(*it)->unuse())
+ {
+ success = false;
+ }
+ }
+
+ this->changedUsed();
+
+ return success;
+ }
+
+ /**
+ @brief
+ Is invoked when the pickup is picked up.
+ @param carrier
+ The PickupCarrier that is picking up this pickup.
+ @return
+ Returns true if successful.
+ */
+ //TODO: Something should happen in the carrier as well, maybe just in the carrier. Owner might not be correct if the carrier hands the pickup down or up. Maybe even a Pawn as input instead fo a carrier. Or do this in Spawner?
+ bool PickupCollection::pickup(PickupCarrier* carrier)
+ {
+ if(this->getOwner() != NULL)
+ {
+ COUT(2) << "Pickup wanted to get picked up by a new carrier, but it already has a carrier." << std::endl;
+ return false;
+ }
+ for(std::list<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ (*it)->setOwner(carrier);
+ }
+
+ this->setOwner(carrier);
+
+ return true;
+ }
+
+ /**
+ @brief
+ Drop the pickup.
+ @return
+ Return true if successful.
+ */
+ bool PickupCollection::drop(void)
+ {
+ this->unuse();
+ this->setOwner(NULL);
+
+ //TODO: Create new Pickupspawner/DroppedPickup
+ return true;
+ }
+
+ //TODO: Steal description from Pickupable.
+ Pickupable* PickupCollection::clone()
+ {
+ Template* collectionTemplate = Template::getTemplate(this->getIdentifier()->getName());
+ BaseObject* newObject = collectionTemplate->getBaseclassIdentifier()->fabricate(this);
+
+ PickupCollection* newCollection = dynamic_cast<PickupCollection*>(newObject);
+ for(std::list<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ Pickupable* newPickup = (*it)->clone();
+ newCollection->pickups_.push_back(newPickup);
+ }
+
+ Pickupable* pickup = dynamic_cast<Pickupable*>(newCollection);
+ return pickup;
+ }
+
+}
\ No newline at end of file
Added: code/branches/pickup2/src/modules/pickup/PickupCollection.h
===================================================================
--- code/branches/pickup2/src/modules/pickup/PickupCollection.h (rev 0)
+++ code/branches/pickup2/src/modules/pickup/PickupCollection.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -0,0 +1,81 @@
+/*
+ * 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:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _PickupCollection_H__
+#define _PickupCollection_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include "interfaces/Pickupable.h"
+#include "core/BaseObject.h"
+#include "core/XMLPort.h"
+
+#include <list>
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The PickupCollection combines different Pickupables to a coherent, single pickup and makes the seem (from the outside looking in) just as if they were just one Pickupable.
+ @author
+ Damian 'Mozork' Frick
+ */
+ //TODO: Isn't private inheritance sufficient?
+ class _PickupExport PickupCollection : public Pickupable, public BaseObject
+ {
+
+ public:
+
+ PickupCollection(BaseObject* creator);
+ virtual ~PickupCollection();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ virtual void changedUsed(void);
+
+ virtual bool use(void);
+ virtual bool unuse(void);
+
+ virtual bool pickup(PickupCarrier* carrier);
+ virtual bool drop(void);
+
+ virtual Pickupable* clone(void);
+
+ bool addPickupable(Pickupable* pickup);
+ Pickupable* getPickupable(unsigned int index);
+
+ private:
+
+ std::list<Pickupable*> pickups_;
+
+ };
+
+}
+
+#endif /* _PickupCollection_H__ */
\ No newline at end of file
Added: code/branches/pickup2/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/pickup2/src/modules/pickup/PickupPrereqs.h (rev 0)
+++ code/branches/pickup2/src/modules/pickup/PickupPrereqs.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -0,0 +1,73 @@
+/*
+ * 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:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ at file
+ at brief
+ Shared library macros, enums, constants and forward declarations for the questsystem module
+*/
+
+#ifndef _PickupPrereqs_H__
+#define _PickupPrereqs_H__
+
+#include "OrxonoxConfig.h"
+#include "OrxonoxPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+
+#if defined(ORXONOX_PLATFORM_WINDOWS) && !defined(ORXONOX_STATIC_BUILD)
+# ifdef QUESTSYSTEM_SHARED_BUILD
+# define _PickupExport __declspec(dllexport)
+# else
+# if defined( __MINGW32__ )
+# define _PickupExport
+# else
+# define _PickupExport __declspec(dllimport)
+# endif
+# endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+# define _PickupExport __attribute__ ((visibility("default")))
+#else
+# define _PickupExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+
+ class PickupCollection;
+ class PickupSpawner;
+
+}
+
+#endif /* _PickupPrereqs_H__ */
Copied: code/branches/pickup2/src/modules/pickup/PickupSpawner.cc (from rev 5953, code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc)
===================================================================
--- code/branches/pickup2/src/modules/pickup/PickupSpawner.cc (rev 0)
+++ code/branches/pickup2/src/modules/pickup/PickupSpawner.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -0,0 +1,295 @@
+/*
+ * 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:
+ * Damian 'Mozork' Frick
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of PickupSpawner.
+*/
+
+#include "PickupSpawner.h"
+
+#include "core/CoreIncludes.h"
+//#include "core/GUIManager.h" // HACK; see below
+#include "core/Template.h"
+#include "core/XMLPort.h"
+#include "worldentities/pawns/Pawn.h"
+//#include "PickupInventory.h" // HACK; Only for hack, remove later
+
+
+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)
+ {
+ this->initialize();
+ }
+
+ PickupSpawner::PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems) : StaticEntity(creator)
+ {
+ this->initialize();
+
+ this->pickup_ = pickup;
+
+ this->triggerDistance_ = triggerDistance;
+ this->respawnTime_ = respawnTime;
+ this->setMaxSpawnedItems(maxSpawnedItems);
+ }
+
+ void PickupSpawner::initialize(void)
+ {
+ RegisterObject(PickupSpawner);
+
+ this->pickup_ = NULL;
+
+ this->triggerDistance_ = 20;
+ this->respawnTime_ = 0;
+ this->tickSum_ = 0;
+ this->maxSpawnedItems_ = INF;
+ this->spawnsRemaining_ = INF;
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ 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);
+
+ XMLPortObject(PickupSpawner, Pickupable, "pickup", addPickupable, getPickupable, xmlelement, mode);
+
+ XMLPortParam(PickupSpawner, "triggerDistance", setTriggerDistance, getTriggerDistance, xmlelement, mode);
+ XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode);
+ XMLPortParam(PickupSpawner, "maxSpawnedItems", setMaxSpawnedItems, getMaxSpawnedItems, xmlelement, mode);
+
+ //TODO: Kill hack.
+ // 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 = orxonox_cast<BaseItem*>(newObject);
+// if (asItem)
+// {
+// asItem->addTemplate(this->itemTemplate_);
+// PickupInventory::getImageForItem(asItem);
+// newObject->destroy();
+// }
+
+ // & load the GUI itself too, along with some empty windows
+ // = even less delays
+// GUIManager::getInstance().showGUI("PickupInventory");
+// GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
+// PickupInventory::getSingleton();
+ }
+
+ void PickupSpawner::addPickupable(Pickupable* pickup)
+ {
+ if(this->pickup_ != NULL)
+ {
+ COUT(1) << "addPickupable called, with this->pickup_ already set." << std::endl;
+ return;
+ }
+ if(pickup == NULL)
+ {
+ COUT(1) << "Argument of addPickupable is NULL." << std::endl;
+ return;
+ }
+
+ this->pickup_ = pickup;
+ }
+
+ Pickupable* PickupSpawner::getPickupable(void)
+ {
+ return this->pickup_;
+ }
+
+ /**
+ @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());
+// }
+
+ void PickupSpawner::setMaxSpawnedItems(int items)
+ {
+ this->maxSpawnedItems_ = items;
+ this->spawnsRemaining_ = items;
+ }
+
+ /**
+ @brief
+ Tick, checks if any Pawn is close enough to trigger.
+ @param dt
+ Time since last tick.
+ */
+ //TODO: Replace this with a real DistanceTrigger?
+ void PickupSpawner::tick(float dt)
+ {
+ //! If the PickupSpawner is active.
+ if (this->isActive())
+ {
+ //! Iterate trough all Pawns.
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+ {
+ Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
+ //! If a Pawn, that fits the target-range of the item spawned by this Pickup, is in trigger-distance.
+ if (distance.length() < this->triggerDistance_ && this->pickup_->isTarget(*it))
+ {
+ this->trigger(*it);
+ }
+ }
+
+ //! Animation.
+// 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)
+ {
+ //TODO: If private, isActive doesn't need to be tested anymore.
+ if (this->isActive()) //!< Checks whether PickupItem is active.
+ {
+ Pickupable* pickup = this->getPickup();
+ if (pickup != NULL) //!< If everything went ok, and pickup is not NULL.
+ {
+ PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn);
+ if(carrier == NULL)
+ {
+ COUT(1) << "This is bad. Pawn isn't PickupCarrier." << std::endl;
+ return;
+ }
+
+ if(pickup->pickup(carrier))
+ {
+ COUT(3) << "Pickup got picked up." << std::endl;
+
+ this->decrementSpawnsRemaining();
+ }
+ else
+ {
+ pickup->destroy();
+ }
+ }
+ }
+ }
+
+ void PickupSpawner::decrementSpawnsRemaining(void)
+ {
+ if(this->spawnsRemaining_ != INF)
+ {
+ this->spawnsRemaining_--;
+ }
+ if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)
+ {
+ //TODO: Nicer?
+ this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
+
+ this->setActive(false);
+ this->fireEvent();
+ }
+ else
+ {
+ COUT(3) << "PickupSpawner empty, selfdistruct initialized." << std::endl;
+ this->setActive(false);
+ this->destroy(); //TODO: Implement destroy().
+ }
+ }
+
+ /**
+ @brief
+ Creates a new Pickupable.
+ @return
+ The Pickupable created.
+ */
+ Pickupable* PickupSpawner::getPickup(void)
+ {
+ if(this->spawnsRemaining_ == 0)
+ {
+ COUT(1) << "Massive Error: PickupSpawner still alive until having spawned last item." << std::endl;
+ return NULL;
+ }
+
+ Pickupable* pickup = this->pickup_->clone();
+ return pickup;
+ }
+
+ /**
+ @brief
+ Invoked by the timer, re-activates the PickupSpawner.
+ */
+ void PickupSpawner::respawnTimerCallback()
+ {
+ COUT(3) << "PickupSpawner reactivated." << std::endl;
+
+ this->setActive(true);
+ }
+}
Copied: code/branches/pickup2/src/modules/pickup/PickupSpawner.h (from rev 5953, code/branches/pickup2/src/orxonox/pickup/PickupSpawner.h)
===================================================================
--- code/branches/pickup2/src/modules/pickup/PickupSpawner.h (rev 0)
+++ code/branches/pickup2/src/modules/pickup/PickupSpawner.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -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 PickupSpawner.
+*/
+
+#ifndef _PickupSpawner_H__
+#define _PickupSpawner_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include <string>
+#include "tools/Timer.h"
+#include "tools/interfaces/Tickable.h"
+#include "worldentities/StaticEntity.h"
+#include "interfaces/Pickupable.h"
+
+namespace orxonox
+{
+ /**
+ @brief PickupSpawner.
+ @author Daniel 'Huty' Haggenmueller
+ */
+ class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable
+ {
+ public:
+ //TODO: Add limit of items spawned here.
+ PickupSpawner(BaseObject* creator);
+ PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems);
+ 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);
+
+ /**
+ @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; }
+
+
+ inline int getMaxSpawnedItems(void)
+ { return this->maxSpawnedItems_; }
+ void setMaxSpawnedItems(int items);
+
+ protected:
+ virtual Pickupable* getPickup(void);
+
+ void addPickupable(Pickupable* pickup);
+ Pickupable* getPickupable(void);
+
+ void decrementSpawnsRemaining(void);
+
+ private:
+ void initialize(void);
+
+ void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough.
+ void respawnTimerCallback(); //!< Method called when the timer runs out.
+
+
+ Pickupable* pickup_;
+
+ int maxSpawnedItems_; //!< Maximum number of items spawned by this PickupSpawner.
+ int spawnsRemaining_; //!< Number of items that can be spawned by this PickupSpawner until it selfdestructs.
+
+ 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 respawnTimer_; //!< Timer used for re-activating.
+
+ static const int INF = -1; //!< Constant for infinity.
+ };
+}
+
+#endif /* _PickupSpawner_H__ */
Modified: code/branches/pickup2/src/modules/weapons/projectiles/Projectile.cc
===================================================================
--- code/branches/pickup2/src/modules/weapons/projectiles/Projectile.cc 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/modules/weapons/projectiles/Projectile.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -122,8 +122,9 @@
}
float dmg = this->damage_;
- if (this->owner_)
- dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
+ //TODO: Remove.
+// if (this->owner_)
+// dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
Pawn* victim = orxonox_cast<Pawn*>(otherObject);
if (victim)
Modified: code/branches/pickup2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/pickup2/src/orxonox/CMakeLists.txt 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/CMakeLists.txt 2009-12-23 19:27:17 UTC (rev 6405)
@@ -45,7 +45,6 @@
ADD_SUBDIRECTORY(interfaces)
ADD_SUBDIRECTORY(items)
ADD_SUBDIRECTORY(overlays)
-ADD_SUBDIRECTORY(pickup)
ADD_SUBDIRECTORY(sound)
ADD_SUBDIRECTORY(weaponsystem)
ADD_SUBDIRECTORY(worldentities)
@@ -54,8 +53,6 @@
FIND_HEADER_FILES
TOLUA_FILES
LevelManager.h
- pickup/BaseItem.h
- pickup/PickupInventory.h
DEFINE_SYMBOL
"ORXONOX_SHARED_BUILD"
PCH_FILE
Modified: code/branches/pickup2/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/pickup2/src/orxonox/OrxonoxPrereqs.h 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/OrxonoxPrereqs.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -116,6 +116,8 @@
// interfaces
class GametypeMessageListener;
class NotificationListener;
+ class Pickupable;
+ class PickupCarrier;
class PlayerTrigger;
class RadarListener;
class RadarViewable;
@@ -133,21 +135,6 @@
class OrxonoxOverlay;
class OverlayGroup;
- // pickup
- class BaseItem;
- class DroppedItem;
- class EquipmentItem;
- class ModifierPickup;
- class PassiveItem;
- class PickupCollection;
- class PickupInventory;
- class PickupSpawner;
- class UsableItem;
- // pickup, items
- class HealthImmediate;
- class HealthUsable;
- class Jump;
-
//sound
class AmbientSound;
class BaseSound;
Modified: code/branches/pickup2/src/orxonox/interfaces/InterfaceCompilation.cc
===================================================================
--- code/branches/pickup2/src/orxonox/interfaces/InterfaceCompilation.cc 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/interfaces/InterfaceCompilation.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -33,6 +33,8 @@
*/
#include "GametypeMessageListener.h"
+#include "Pickupable.h"
+#include "PickupCarrier.h"
#include "PlayerTrigger.h"
#include "RadarListener.h"
#include "Rewardable.h"
@@ -50,8 +52,38 @@
{
RegisterRootObject(GametypeMessageListener);
}
+
+ //----------------------------
+ // Pickupable
+ //----------------------------
+ Pickupable::Pickupable()
+ {
+ RegisterRootObject(Pickupable);
+ this->used_ = false;
+ this->owner_ = NULL;
+ }
+
//----------------------------
+ // PickupCarrier
+ //----------------------------
+ PickupCarrier::PickupCarrier()
+ {
+ RegisterRootObject(PickupCarrier);
+ }
+
+ //----------------------------
+ // PlayerTrigger
+ //----------------------------
+ PlayerTrigger::PlayerTrigger()
+ {
+ RegisterRootObject(PlayerTrigger);
+
+ this->player_ = NULL;
+ this->isForPlayer_ = true;
+ }
+
+ //----------------------------
// RadarListener
//----------------------------
RadarListener::RadarListener()
@@ -82,15 +114,4 @@
{
RegisterRootObject(NotificationListener);
}
-
- //----------------------------
- // PlayerTrigger
- //----------------------------
- PlayerTrigger::PlayerTrigger()
- {
- RegisterRootObject(PlayerTrigger);
-
- this->player_ = NULL;
- this->isForPlayer_ = true;
- }
}
Added: code/branches/pickup2/src/orxonox/interfaces/PickupCarrier.h
===================================================================
--- code/branches/pickup2/src/orxonox/interfaces/PickupCarrier.h (rev 0)
+++ code/branches/pickup2/src/orxonox/interfaces/PickupCarrier.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -0,0 +1,60 @@
+/*
+ * 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:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the PickupCarrier class.
+*/
+
+#ifndef _PickupCarrier_H__
+#define _PickupCarrier_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+#include <set>
+
+namespace orxonox
+{
+
+ class _OrxonoxExport PickupCarrier : public OrxonoxClass
+ {
+
+ public:
+ PickupCarrier();
+ virtual ~PickupCarrier();
+
+ private:
+
+ std::set<Pickupable*> pickups_;
+
+ };
+
+}
+
+#endif /* _PickupCarrier_H__ */
Added: code/branches/pickup2/src/orxonox/interfaces/Pickupable.h
===================================================================
--- code/branches/pickup2/src/orxonox/interfaces/Pickupable.h (rev 0)
+++ code/branches/pickup2/src/orxonox/interfaces/Pickupable.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -0,0 +1,197 @@
+/*
+ * 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:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the Pickupable class.
+*/
+
+#ifndef _Pickupable_H__
+#define _Pickupable_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+#include "core/Identifier.h"
+#include "core/Super.h"
+#include "interfaces/PickupCarrier.h"
+#include "worldentities/pawns/Pawn.h"
+#include <list>
+
+namespace orxonox
+{
+
+ //! Enum for the activation type.
+ namespace pickupActivationType
+ {
+ enum Value
+ {
+ immediate,
+ onUse,
+ };
+ }
+
+ //! Enum for the duration tyoe.
+ namespace pickupDurationType
+ {
+ enum Value
+ {
+ once,
+ continuous,
+ };
+ }
+
+ /**
+ @brief
+ An Interface (or more precisely an abstract Class) to model and manage different (all kinds of) pickups.
+ @author
+ Damian 'Mozork' Frick
+ */
+ //TODO: Add stuff like weight/space ?
+ class _OrxonoxExport Pickupable : virtual public OrxonoxClass
+ {
+ public:
+ Pickupable(); //!< Default constructor.
+ virtual ~Pickupable() {} //!< Default destructor.
+
+ /**
+ @brief Get the activation type of the pickup.
+ @return Returns the activation type of the pickup.
+ */
+ inline pickupActivationType::Value getActivationType(void)
+ { return this->activationType_; }
+ /**
+ @brief Get the duration type of the pickup.
+ @return Returns the duration type of the pickup.
+ */
+ inline pickupDurationType::Value getDurationType(void)
+ { return this->durationType_; }
+
+ /**
+ @brief Get the owner of the pickup.
+ @return Returns a pointer to the owner of the pickup.
+ */
+ inline PickupCarrier* getOwner(void)
+ { return this->owner_; }
+
+ /**
+ @brief Get whether the pickup is currently in use or not.
+ @return Returns true if the pickup is currently in use.
+ */
+ inline bool isUsed(void)
+ { return this->used_; }
+
+ /**
+ @brief Get whether the given pawn is a target of this pickup.
+ @param pawn The Pawn of which it has to be determinde whether it is a target of this pickup.
+ @return Retruns true if the given Pawn is a target.
+ */
+ //TODO: Determine whether Pawn includes all possible cases and if PickupCarrier wouldn't be better.
+ inline bool isTarget(Pawn* pawn)
+ {
+ Identifier* identifier = pawn->getIdentifier();
+ for(std::list<Identifier*>::iterator it = this->targets_.begin(); it != this->targets_.end(); it++)
+ {
+ if(identifier->isA(*it))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ @brief Should be called when the pickup has transitetd from used to unused or the other way around.
+ Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedUsed); to their changeUsed method.
+ */
+ virtual inline void changedUsed(void)
+ {
+ if(this->isUsed())
+ this->used_ = false;
+ else
+ this->used_ = true;
+ }
+
+ /**
+ @brief Sets the pickup to used and makes sure the effects of the pickup take effect at the right places.
+ This method needs to be implemented by any Class inheriting from Pickupable.
+ @return Returns false if for some reason the method could not take effect, e.g. because it is already in use, or some other circumstance.
+ */
+ virtual bool use(void) = 0;
+ /**
+ @brief Sets the pickup to unused and makes sure the effects of the pickup no longer take effect.
+ This method needs to be implemented by any Class inheriting from Pickupable.
+ @return Returns false if for some reason the method could not take effect, e.g. because the pickup is already unused, or some other circumstance.
+ */
+ virtual bool unuse(void) = 0;
+
+ /**
+ @brief Adds the pickup to the input PickupCarrier.
+ This method needs to be implemented by any Class inheriting from Pickupable.
+ @return Returns false if, for some reason, the pickup could not be picked up.
+ */
+ //TODO: Maybe better in PickupCarrier?
+ virtual bool pickup(PickupCarrier* carrier) = 0;
+ /**
+ @brief Drops the pickup. Creates a PickupSpawner at the place the Pickup has been dropped.
+ This method needs to be implemented by any Class inheriting from Pickupable.
+ @return Returns false if the pickup could not be dropped.
+ */
+ //TODO: Probably could be done here?
+ virtual bool drop(void) = 0;
+
+ /**
+ @brief Creates a duplicate of the pickup.
+ This method needs to e implemented by any Class inheriting from Pickupable.
+ @return Returns the clone of this pickup as a pointer to a Pickupable.
+ */
+ //TODO: Would be nicer if standard case was implemented here.
+ virtual Pickupable* clone(void) = 0;
+
+ /**
+ @brief Sets the owner of the pickup.
+ @param owner Sets the input PickupCarrier as the owner of the pickup.
+ */
+ //TODO: Protected? Check for NULL and return true/false?
+ inline void setOwner(PickupCarrier* owner)
+ { this->owner_ = owner; }
+
+ private:
+
+ pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
+ pickupDurationType::Value durationType_; //!< The duration type of the pickup.
+
+ bool used_; //!< Whether the pickup is currently in use or not.
+
+ PickupCarrier* owner_; //!< The owner of the pickup.
+ std::list<Identifier*> targets_; //!< The possible targets of this pickup.
+
+ };
+
+ SUPER_FUNCTION(10, Pickupable, changedUsed, true)
+}
+
+#endif /* _Pickupable_H__ */
Modified: code/branches/pickup2/src/orxonox/items/Engine.cc
===================================================================
--- code/branches/pickup2/src/orxonox/items/Engine.cc 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/items/Engine.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -34,7 +34,8 @@
#include "core/XMLPort.h"
#include "Scene.h"
#include "worldentities/pawns/SpaceShip.h"
-#include "pickup/ModifierType.h"
+//TODO: Remove.
+//#include "pickup/ModifierType.h"
#include "tools/Shader.h"
namespace orxonox
@@ -192,7 +193,8 @@
acceleration.y = direction.y * this->accelerationUpDown_ * clamp((this->maxSpeedUpDown_ - velocity.y) / this->maxSpeedUpDown_, 0.0f, 1.0f);
}
- this->ship_->setAcceleration(this->ship_->getPickups().processModifiers(ModifierType::Acceleration, this->ship_->getOrientation() * acceleration, false));
+ //TODO: Remove.
+ //this->ship_->setAcceleration(this->ship_->getPickups().processModifiers(ModifierType::Acceleration, this->ship_->getOrientation() * acceleration, false));
if (!this->ship_->getPermanentBoost())
this->ship_->setBoost(false);
Modified: code/branches/pickup2/src/orxonox/pickup/CMakeLists.txt
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/CMakeLists.txt 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/pickup/CMakeLists.txt 2009-12-23 19:27:17 UTC (rev 6405)
@@ -1,12 +1,10 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
BaseItem.cc
- DroppedItem.cc
EquipmentItem.cc
ModifierPickup.cc
PassiveItem.cc
PickupCollection.cc
PickupInventory.cc
- PickupSpawner.cc
UsableItem.cc
)
Deleted: code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -1,114 +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:
- * ...
- *
- */
-
-#include "DroppedItem.h"
-
-#include "util/Math.h"
-#include "core/CoreIncludes.h"
-#include "core/Executor.h"
-#include "BaseItem.h"
-#include "graphics/Billboard.h"
-#include "graphics/Model.h"
-#include "worldentities/pawns/Pawn.h"
-
-namespace orxonox
-{
- CreateFactory(DroppedItem); //TODO: This isn't needed, is it?
-
- /**
- @brief
- Constructor. Registers object and sets default values.
- */
- DroppedItem::DroppedItem(BaseObject* creator) : PickupSpawner(creator)
- {
- RegisterObject(DroppedItem);
- }
-
- DroppedItem::DroppedItem(BaseObject* creator, BaseItem* item, float triggerDistance, float respawnTime, int maxSpawnedItems) : PickupSpawner(creator, item, triggerDistance, respawnTime, maxSpawnedItems)
- {
- RegisterObject(DroppedItem);
- this->item_ = item;
- }
-
- /**
- @brief
- Default destructor.
- */
- DroppedItem::~DroppedItem()
- {
-
- }
-
- BaseItem* DroppedItem::getItem(void)
- {
- return this->item_;
- }
-
- /**
- @brief
-
- */
- //TODO: Comment.
- //Each pickup should have a XML template where the Model and Billboard, and so on, is specified.
- /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
- {
- //TODO: triggerDistance?
- float triggerDistance = 20.0;
- DroppedItem* droppedItem = new DroppedItem(item, item, triggerDistance, 0, 1);
-
- //TODO: Do this somehwere else?
- 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);
-
- droppedItem->setPosition(position);
- droppedItem->attach(model);
- droppedItem->attach(billboard);
-
- COUT(3) << "Created DroppedItem for '" << item->getPickupIdentifier() << "' at (" << position.x << "," << position.y << "," << position.z << ")." << std::endl;
-
- return droppedItem;
- }
-
- /**
- @brief
-
- */
- //TODO: See one function above.
- 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);
- }
-}
Deleted: code/branches/pickup2/src/orxonox/pickup/DroppedItem.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/DroppedItem.h 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/pickup/DroppedItem.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -1,63 +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 DroppedItem
-*/
-
-#ifndef _DroppedItem_H__
-#define _DroppedItem_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "PickupSpawner.h"
-
-namespace orxonox
-{
- class _OrxonoxExport DroppedItem : public PickupSpawner
- {
- public:
- DroppedItem(BaseObject* creator);
- DroppedItem(BaseObject* creator, BaseItem* item, float triggerDistance, float respawnTime, int maxSpawnedItems);
- virtual ~DroppedItem();
-
- 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);
-
- protected:
- virtual BaseItem* getItem(void);
-
- private:
-
- BaseItem* item_; //!< The dropped item.
-
- };
-}
-
-#endif /* _DroppedItem_H__ */
Modified: code/branches/pickup2/src/orxonox/pickup/PickupCollection.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupCollection.cc 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/pickup/PickupCollection.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -51,13 +51,15 @@
}
/**
- @brief
- Add an item to the collection.
+ @brief
+ Add an item to the collection.
- Only adds the item if there's a free slot for it.
+ 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.
+ @param item
+ Item to add to the collection.
+ @return
+ Returns whether the item has been added to the collection.
*/
bool PickupCollection::add(BaseItem* item)
{
Modified: code/branches/pickup2/src/orxonox/pickup/PickupCollection.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupCollection.h 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/pickup/PickupCollection.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -49,10 +49,9 @@
@brief PickupCollection for organising items.
@author Daniel 'Huty' Haggenmueller
*/
- class _OrxonoxExport PickupCollection
+ class _OrxonoxExport PickupCollection : public orxonox::OrxonoxClass
{
public:
- //TODO: Should probably be derived from OrxonoxClass???
PickupCollection();
bool add(BaseItem* item); //!< Add an item to the collection.
@@ -64,31 +63,11 @@
void remove(BaseItem* item, bool removeAllOfType = false); //!< Remove an item from the collection.
- //TODO: What's up with that?
+ //TODO: Hmm... probably should stay...
void useItem(); //!< Use the first usable item.
void useItem(UsableItem* item); //!< Use a usable item.
- //TODO: This really shouldn't be here. It's nbot the Collections business to know about stuff like that.
- void addAdditiveModifier(ModifierType::Value type, float value); //!< Add an additive modifier.
- void addMultiplicativeModifier(ModifierType::Value type, float value); //!< Add a multiplicative modifier.
-
- float getAdditiveModifier(ModifierType::Value type); //!< Get total additive modifier.
- float getMultiplicativeModifier(ModifierType::Value type); //!< Get total multiplicative modifier.
-
- void removeAdditiveModifier(ModifierType::Value type, float value); //!< Remove an additive modifier.
- void removeMultiplicativeModifier(ModifierType::Value type, float value); //!< Remove a multiplicative modifier.
-
- float processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float.
- Vector3 processModifiers(ModifierType::Value 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.
*/
@@ -109,15 +88,12 @@
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.
+ Pawn* owner_; //!< The owner of the PickupCollection.
UsableItem* currentUsable_;
+ int slots_;
- bool bBlockRemovals_; //!< Whether to block direct removals through remove().
-
- std::multimap<ModifierType::Value, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType).
- std::multimap<ModifierType::Value, 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).
};
}
Deleted: code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -1,270 +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 PickupSpawner.
-*/
-
-#include "PickupSpawner.h"
-
-#include "BaseItem.h"
-
-#include "core/CoreIncludes.h"
-#include "core/GUIManager.h" // HACK; see below
-#include "core/Template.h"
-#include "core/XMLPort.h"
-#include "worldentities/pawns/Pawn.h"
-#include "PickupInventory.h" // HACK; Only for hack, remove later
-
-
-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)
- {
- this->initialize();
- }
-
- PickupSpawner::PickupSpawner(BaseObject* creator, BaseItem* item, float triggerDistance, float respawnTime, int maxSpawnedItems) : StaticEntity(creator)
- {
- this->initialize();
-
- //TODO: Does this actually work?
- this->itemTemplateName_ = item->getIdentifier()->getName();
- this->itemTemplate_ = Template::getTemplate(this->itemTemplateName_);
-
- this->triggerDistance_ = triggerDistance;
- this->respawnTime_ = respawnTime;
- this->setMaxSpawnedItems(maxSpawnedItems);
- }
-
- void PickupSpawner::initialize(void)
- {
- RegisterObject(PickupSpawner);
-
- this->itemTemplate_ = NULL;
- this->triggerDistance_ = 20;
- this->respawnTime_ = 0.0f;
- this->tickSum_ = 0.0f;
- this->maxSpawnedItems_ = INF;
- this->spawnsRemaining_ = INF;
- }
-
- /**
- @brief
- Destructor.
- */
- 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);
- XMLPortParam(PickupSpawner, "maxSpawnedItems", setMaxSpawnedItems, getMaxSpawnedItems, xmlelement, mode);
-
- //TODO: Kill hack.
- // 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 = orxonox_cast<BaseItem*>(newObject);
- if (asItem)
- {
- asItem->addTemplate(this->itemTemplate_);
- PickupInventory::getImageForItem(asItem);
- newObject->destroy();
- }
-
- // & load the GUI itself too, along with some empty windows
- // = even less delays
- GUIManager::getInstance().showGUI("PickupInventory");
- GUIManager::getInstance().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);
- }
-
- void PickupSpawner::setMaxSpawnedItems(int items)
- {
- this->maxSpawnedItems_ = items;
- this->spawnsRemaining_ = items;
- }
-
- /**
- @brief
- Tick, checks if any Pawn is close enough to trigger.
- @param dt
- Time since last tick.
- */
- //TODO: Replace this with a real DistanceTrigger.
- void PickupSpawner::tick(float dt)
- {
- if (this->isActive())
- {
- //! Triggers as soon as a Pawn is in the specified distance.
- 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);
- }
-
- //! Animation.
- 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()) //!< Checks whether PickupItem is active, amongst other things.
- {
- BaseItem* item = this->getItem();
- if (item != NULL) //!< If the conversion was successful.
- {
- item->setPickupIdentifier(this->itemTemplateName_); //TODO: Needed?
- item->addTemplate(this->itemTemplate_); //TODO: Does what?
-
- if(item->pickedUp(pawn))
- {
- COUT(3) << this->itemTemplateName_ << " got picked up." << std::endl;
-
-
- if(this->spawnsRemaining_ != INF)
- {
- this->spawnsRemaining_--;
- }
-
- if (this->spawnsRemaining_ != 0 && this->respawnTime_ > 0.0f)
- {
- this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
-
- this->setActive(false);
- this->fireEvent();
- }
- }
- else
- {
- item->destroy();
- }
- }
- }
-
- if(this->spawnsRemaining_ == 0)
- {
- COUT(3) << "PickupSpawner empty, selfdistruct initialized." << std::endl;
- this->setActive(false);
- this->destroy();
- }
- }
-
- /**
- @brief
- Creates a BaseItem of the type specified by the PickupSpawner.
- @return
- The BaseItem created.
- */
- BaseItem* PickupSpawner::getItem(void)
- {
- BaseObject* newItem = this->itemTemplate_->getBaseclassIdentifier()->fabricate(this); //!< Creates new object of specified item type.
- return orxonox_cast<BaseItem*>(newItem);
- }
-
- /**
- @brief
- Invoked by the timer, re-activates the PickupSpawner.
- */
- void PickupSpawner::respawnTimerCallback()
- {
- COUT(3) << "PickupSpawner reactivated." << std::endl;
-
- this->setActive(true);
- }
-}
Deleted: code/branches/pickup2/src/orxonox/pickup/PickupSpawner.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupSpawner.h 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/pickup/PickupSpawner.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -1,138 +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 PickupSpawner.
-*/
-
-#ifndef _PickupSpawner_H__
-#define _PickupSpawner_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <string>
-#include "tools/Timer.h"
-#include "tools/interfaces/Tickable.h"
-#include "worldentities/StaticEntity.h"
-
-namespace orxonox
-{
- /**
- @brief PickupSpawner.
- @author Daniel 'Huty' Haggenmueller
- */
- class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable
- {
- public:
- //TODO: Add limit of items spawned here. Also possibility to spawn collections?
- PickupSpawner(BaseObject* creator);
- PickupSpawner(BaseObject* creator, BaseItem* item, float triggerDistance, float respawnTime, int maxSpawnedItems);
- 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; }
-
-
- inline int getMaxSpawnedItems(void)
- { return this->maxSpawnedItems_; }
- void setMaxSpawnedItems(int items);
-
- protected:
- virtual BaseItem* getItem(void);
-
- private:
- void initialize(void);
-
- std::string itemTemplateName_; //!< Template name of the item to spawn.
- Template* itemTemplate_; //!< Template of the item to spawn.
-
- int maxSpawnedItems_; //!< Maximum number of items spawned by this PickupSpawner.
- int spawnsRemaining_; //!< Number of items that can be spawned by this PickupSpawner until it selfdestructs.
-
- 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 respawnTimer_; //!< Timer used for re-activating.
-
- static const int INF = -1; //!< Constant for infinity.
- };
-}
-
-#endif /* _PickupSpawner_H__ */
Modified: code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.cc 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.cc 2009-12-23 19:27:17 UTC (rev 6405)
@@ -69,7 +69,8 @@
this->spawnparticleduration_ = 3.0f;
- this->getPickups().setOwner(this);
+ //TODO: Remove.
+ //this->getPickups().setOwner(this);
if (GameMode::isMaster())
{
@@ -294,10 +295,11 @@
this->spawneffect();
}
- void Pawn::dropItems()
- {
- this->getPickups().clear();
- }
+//TODO: Remove.
+// void Pawn::dropItems()
+// {
+// this->getPickups().clear();
+// }
/* WeaponSystem:
Modified: code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.h 2009-12-23 18:44:49 UTC (rev 6404)
+++ code/branches/pickup2/src/orxonox/worldentities/pawns/Pawn.h 2009-12-23 19:27:17 UTC (rev 6405)
@@ -34,7 +34,8 @@
#include <string>
#include "interfaces/RadarViewable.h"
#include "worldentities/ControllableEntity.h"
-#include "pickup/PickupCollection.h"
+//TODO: Remove.
+//#include "pickup/PickupCollection.h"
namespace orxonox
{
@@ -108,11 +109,12 @@
inline unsigned int getExplosionChunks() const
{ return this->numexplosionchunks_; }
- virtual void dropItems();
- inline PickupCollection& getPickups()
- { return this->pickups_; }
- virtual void useItem()
- { this->pickups_.useItem(); }
+//TODO: Remove.
+// virtual void dropItems();
+// inline PickupCollection& getPickups()
+// { return this->pickups_; }
+// virtual void useItem()
+// { this->pickups_.useItem(); }
virtual void startLocalHumanControl();
@@ -127,7 +129,8 @@
bool bAlive_;
- PickupCollection pickups_;
+ //TODO: Remove.
+ //PickupCollection pickups_;
float health_;
float maxHealth_;
More information about the Orxonox-commit
mailing list