[Orxonox-commit 1806] r6524 - in code/trunk: . data/levels data/levels/includes data/levels/templates src/libraries/core src/modules src/modules/pickup src/modules/pickup/items src/modules/weapons/projectiles src/orxonox src/orxonox/interfaces src/orxonox/items src/orxonox/pickup src/orxonox/worldentities src/orxonox/worldentities/pawns
dafrick at orxonox.net
dafrick at orxonox.net
Mon Mar 15 15:27:10 CET 2010
Author: dafrick
Date: 2010-03-15 15:27:09 +0100 (Mon, 15 Mar 2010)
New Revision: 6524
Added:
code/trunk/data/levels/includes/pickups.oxi
code/trunk/data/levels/pickup.oxw
code/trunk/data/levels/templates/pickup_representation_templates.oxt
code/trunk/src/modules/pickup/
code/trunk/src/modules/pickup/CMakeLists.txt
code/trunk/src/modules/pickup/DroppedPickup.cc
code/trunk/src/modules/pickup/DroppedPickup.h
code/trunk/src/modules/pickup/Pickup.cc
code/trunk/src/modules/pickup/Pickup.h
code/trunk/src/modules/pickup/PickupCollection.cc
code/trunk/src/modules/pickup/PickupCollection.h
code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc
code/trunk/src/modules/pickup/PickupCollectionIdentifier.h
code/trunk/src/modules/pickup/PickupManager.cc
code/trunk/src/modules/pickup/PickupManager.h
code/trunk/src/modules/pickup/PickupPrecompiledHeaders.h
code/trunk/src/modules/pickup/PickupPrereqs.h
code/trunk/src/modules/pickup/PickupRepresentation.cc
code/trunk/src/modules/pickup/PickupRepresentation.h
code/trunk/src/modules/pickup/PickupSpawner.cc
code/trunk/src/modules/pickup/PickupSpawner.h
code/trunk/src/modules/pickup/items/
code/trunk/src/modules/pickup/items/CMakeLists.txt
code/trunk/src/modules/pickup/items/HealthPickup.cc
code/trunk/src/modules/pickup/items/HealthPickup.h
code/trunk/src/modules/pickup/items/MetaPickup.cc
code/trunk/src/modules/pickup/items/MetaPickup.h
code/trunk/src/orxonox/interfaces/PickupCarrier.h
code/trunk/src/orxonox/interfaces/Pickupable.cc
code/trunk/src/orxonox/interfaces/Pickupable.h
code/trunk/src/orxonox/pickup/PickupIdentifier.cc
code/trunk/src/orxonox/pickup/PickupIdentifier.h
Removed:
code/trunk/src/modules/pickup/CMakeLists.txt
code/trunk/src/modules/pickup/DroppedPickup.cc
code/trunk/src/modules/pickup/DroppedPickup.h
code/trunk/src/modules/pickup/Pickup.cc
code/trunk/src/modules/pickup/Pickup.h
code/trunk/src/modules/pickup/PickupCollection.cc
code/trunk/src/modules/pickup/PickupCollection.h
code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc
code/trunk/src/modules/pickup/PickupCollectionIdentifier.h
code/trunk/src/modules/pickup/PickupManager.cc
code/trunk/src/modules/pickup/PickupManager.h
code/trunk/src/modules/pickup/PickupPrecompiledHeaders.h
code/trunk/src/modules/pickup/PickupPrereqs.h
code/trunk/src/modules/pickup/PickupRepresentation.cc
code/trunk/src/modules/pickup/PickupRepresentation.h
code/trunk/src/modules/pickup/PickupSpawner.cc
code/trunk/src/modules/pickup/PickupSpawner.h
code/trunk/src/modules/pickup/items/
code/trunk/src/modules/pickup/items/CMakeLists.txt
code/trunk/src/modules/pickup/items/HealthPickup.cc
code/trunk/src/modules/pickup/items/HealthPickup.h
code/trunk/src/modules/pickup/items/MetaPickup.cc
code/trunk/src/modules/pickup/items/MetaPickup.h
code/trunk/src/orxonox/pickup/BaseItem.cc
code/trunk/src/orxonox/pickup/BaseItem.h
code/trunk/src/orxonox/pickup/DroppedItem.cc
code/trunk/src/orxonox/pickup/DroppedItem.h
code/trunk/src/orxonox/pickup/EquipmentItem.cc
code/trunk/src/orxonox/pickup/EquipmentItem.h
code/trunk/src/orxonox/pickup/ModifierPickup.cc
code/trunk/src/orxonox/pickup/ModifierPickup.h
code/trunk/src/orxonox/pickup/ModifierType.h
code/trunk/src/orxonox/pickup/PassiveItem.cc
code/trunk/src/orxonox/pickup/PassiveItem.h
code/trunk/src/orxonox/pickup/PickupCollection.cc
code/trunk/src/orxonox/pickup/PickupCollection.h
code/trunk/src/orxonox/pickup/PickupInventory.cc
code/trunk/src/orxonox/pickup/PickupInventory.h
code/trunk/src/orxonox/pickup/PickupSpawner.cc
code/trunk/src/orxonox/pickup/PickupSpawner.h
code/trunk/src/orxonox/pickup/UsableItem.cc
code/trunk/src/orxonox/pickup/UsableItem.h
code/trunk/src/orxonox/pickup/items/
Modified:
code/trunk/
code/trunk/data/levels/empty_level.oxw
code/trunk/src/libraries/core/BaseObject.cc
code/trunk/src/libraries/core/BaseObject.h
code/trunk/src/libraries/core/GraphicsManager.cc
code/trunk/src/libraries/core/OrxonoxClass.h
code/trunk/src/libraries/core/Super.h
code/trunk/src/modules/CMakeLists.txt
code/trunk/src/modules/weapons/projectiles/Projectile.cc
code/trunk/src/modules/weapons/projectiles/Rocket.cc
code/trunk/src/orxonox/CMakeLists.txt
code/trunk/src/orxonox/OrxonoxPrereqs.h
code/trunk/src/orxonox/interfaces/CMakeLists.txt
code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
code/trunk/src/orxonox/items/Engine.cc
code/trunk/src/orxonox/pickup/CMakeLists.txt
code/trunk/src/orxonox/worldentities/WorldEntity.cc
code/trunk/src/orxonox/worldentities/WorldEntity.h
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
Log:
Merged pickup branch into trunk. Yay. Persisting bugs will be fixed, very soon.
Property changes on: code/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/console:5941-6104
/code/branches/core5:5768-5928,6009
/code/branches/ingamemenu:6000-6023
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/menu:5941-6146,6148
/code/branches/particles2:6050-6106,6109
/code/branches/presentation2:6106-6416
/code/branches/resource2:3372-5694
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890
+ /code/branches/console:5941-6104
/code/branches/core5:5768-5928,6009
/code/branches/ingamemenu:6000-6023
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/menu:5941-6146,6148
/code/branches/particles2:6050-6106,6109
/code/branches/pickup2:5942-6405
/code/branches/pickup3:6418-6523
/code/branches/presentation2:6106-6416
/code/branches/resource2:3372-5694
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890
Modified: code/trunk/data/levels/empty_level.oxw
===================================================================
--- code/trunk/data/levels/empty_level.oxw 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/data/levels/empty_level.oxw 2010-03-15 14:27:09 UTC (rev 6524)
@@ -29,6 +29,18 @@
</Model>
</attached>
</Rocket-->
+
+<?lua
+for i = 1,100,1
+do ?>
+ <StaticEntity position="<?lua print(math.random() * 1000) ?>, <?lua print(math.random() * 1000) ?>, <?lua print(math.random() * 1000) ?>">
+ <attached>
+ <Model scale="<?lua print(math.random() * 20 + 5) ?>" mesh="ast1.mesh" shadow=false />
+ </attached>
+ </StaticEntity>
+<?lua
+end
+?>
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
Copied: code/trunk/data/levels/includes/pickups.oxi (from rev 6523, code/branches/pickup3/data/levels/includes/pickups.oxi)
===================================================================
--- code/trunk/data/levels/includes/pickups.oxi (rev 0)
+++ code/trunk/data/levels/includes/pickups.oxi 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,49 @@
+<PickupRepresentation
+ name = "Small Health Boost"
+ description = "Adds a small amout of health to the ship."
+ spawnerTemplate = "smallhealthpickupRepresentation"
+>
+ <pickup>
+ <HealthPickup template=smallhealthpickup />
+ </pickup>
+</PickupRepresentation>
+
+<PickupRepresentation
+ name = "Medium Health Boost"
+ description = "Adds a medium amout of health to the ship."
+ spawnerTemplate = "mediumhealthpickupRepresentation"
+>
+ <pickup>
+ <HealthPickup template=mediumhealthpickup />
+ </pickup>
+</PickupRepresentation>
+
+<PickupRepresentation
+ name = "Huge Health Boost"
+ description = "Adds a huge amout of health to the ship."
+ spawnerTemplate = "hugehealthpickupRepresentation"
+>
+ <pickup>
+ <HealthPickup template=hugehealthpickup />
+ </pickup>
+</PickupRepresentation>
+
+<PickupRepresentation
+ name = "Crazy Madness Health Boost"
+ description = "Adds a crazy amout of health to the ship."
+ spawnerTemplate = "crazyhealthpickupRepresentation"
+>
+ <pickup>
+ <HealthPickup template=crazyhealthpickup />
+ </pickup>
+</PickupRepresentation>
+
+<PickupRepresentation
+ name = "Double Pickup"
+ description = "Does stuff."
+ spawnerTemplate = "crazyhealthpickupRepresentation"
+>
+ <pickup>
+ <PickupCollection template=doublepickup />
+ </pickup>
+</PickupRepresentation>
Copied: code/trunk/data/levels/pickup.oxw (from rev 6523, code/branches/pickup3/data/levels/pickup.oxw)
===================================================================
--- code/trunk/data/levels/pickup.oxw (rev 0)
+++ code/trunk/data/levels/pickup.oxw 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,82 @@
+<?lua
+ include("stats.oxo")
+ include("hudtemplates3.oxo")
+?>
+
+<?lua
+ include("templates/spaceship_assff.oxt")
+ include("templates/spaceship_pirate.oxt")
+ include("templates/pickup_representation_templates.oxt")
+?>
+
+<Level
+ name = "Sample"
+ description = "Just a few tests"
+>
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+<?lua
+ include("includes/pickups.oxi")
+?>
+
+ <PickupSpawner position="-100,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <MetaPickup metaType="drop" />
+ </pickup>
+ </PickupSpawner>
+
+ <PickupSpawner position="-75,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <MetaPickup metaType="use" />
+ </pickup>
+ </PickupSpawner>
+
+ <PickupSpawner position="-50,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <HealthPickup health=50 healthRate=5 durationType=continuous activationType=immediate healthType=permanent />
+ </pickup>
+ </PickupSpawner>
+
+ <PickupSpawner position="-25,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <HealthPickup template=smallhealthpickup />
+ </pickup>
+ </PickupSpawner>
+
+ <PickupSpawner position="0,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <HealthPickup template=mediumhealthpickup />
+ </pickup>
+ </PickupSpawner>
+
+ <PickupSpawner position="25,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <HealthPickup template=hugehealthpickup />
+ </pickup>
+ </PickupSpawner>
+
+ <PickupSpawner position="50,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <HealthPickup template=crazyhealthpickup />
+ </pickup>
+ </PickupSpawner>
+
+ <PickupSpawner position="75,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <PickupCollection template=doublepickup />
+ </pickup>
+ </PickupSpawner>
+
+ <!--PickupSpawner position="100,100,100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
+ <pickup>
+ <HealthPickup health=50 healthRate=5 durationType=continuous activationType=immediate healthType=limited />
+ </pickup>
+ </PickupSpawner-->
+
+ <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
+ <SpawnPoint position="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ </Scene>
+</Level>
Copied: code/trunk/data/levels/templates/pickup_representation_templates.oxt (from rev 6523, code/branches/pickup3/data/levels/templates/pickup_representation_templates.oxt)
===================================================================
--- code/trunk/data/levels/templates/pickup_representation_templates.oxt (rev 0)
+++ code/trunk/data/levels/templates/pickup_representation_templates.oxt 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,109 @@
+<Template name=smallhealthpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=0.3 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=smallhealthpickup>
+ <HealthPickup
+ health = 10
+ healthType = "limited"
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=mediumhealthpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=0.5 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=mediumhealthpickup>
+ <HealthPickup
+ health = 50
+ healthType = "limited"
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=hugehealthpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=0.7 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=hugehealthpickup>
+ <HealthPickup
+ health = 100
+ healthType = "limited"
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=crazyhealthpickupRepresentation>
+ <PickupRepresentation>
+ <spawner-representation>
+ <StaticEntity>
+ <attached>
+ <Billboard position="0,0,0" colour="0.50,0.90,0.25" material="Sphere2" scale=0.1>
+ <attached>
+ <Billboard position="0,0,0" colour="0.36,0.81,0.10" material="Cross" scale=1.2 />
+ </attached>
+ </Billboard>
+ </attached>
+ </StaticEntity>
+ </spawner-representation>
+ </PickupRepresentation>
+</Template>
+
+<Template name=crazyhealthpickup>
+ <HealthPickup
+ health = 1000
+ healthType = "permanent"
+ activationType = "immediate"
+ durationType = "once"
+ />
+</Template>
+
+<Template name=doublepickup>
+ <PickupCollection>
+ <pickupables>
+ <HealthPickup template=smallhealthpickup />
+ <HealthPickup health=50 healthRate=5 durationType=continuous activationType=immediate healthType=limited />
+ </pickupables>
+ </PickupCollection>
+</Template>
+
\ No newline at end of file
Modified: code/trunk/src/libraries/core/BaseObject.cc
===================================================================
--- code/trunk/src/libraries/core/BaseObject.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/libraries/core/BaseObject.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -114,7 +114,8 @@
XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode);
XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode);
XMLPortParam(BaseObject, "mainstate", setMainStateName, getMainStateName, xmlelement, mode);
-
+ XMLPortParamTemplate(BaseObject, "template", addTemplate, getSingleTemplate, xmlelement, mode, const std::string&);
+
XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*);
XMLPortObject(BaseObject, BaseObject, "eventlisteners", addEventListener, getEventListener, xmlelement, mode);
@@ -189,6 +190,18 @@
}
/**
+ @brief Returns the name of the first Template.
+ @return The name as string.
+ */
+ const std::string& BaseObject::getSingleTemplate(void) const
+ {
+ if(this->templates_.empty())
+ return BLANKSTRING;
+
+ return (*this->templates_.begin())->getName();
+ }
+
+ /**
@brief Returns the Template with the given index.
@param index The index
*/
Modified: code/trunk/src/libraries/core/BaseObject.h
===================================================================
--- code/trunk/src/libraries/core/BaseObject.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/libraries/core/BaseObject.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -194,6 +194,7 @@
{ this->eventListeners_.erase(object); }
void setXMLName(const std::string& name);
+ const std::string& getSingleTemplate(void) const;
Template* getTemplate(unsigned int index) const;
void registerEventStates();
Modified: code/trunk/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/libraries/core/GraphicsManager.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -317,7 +317,7 @@
// no ScopeGuards or anything to handle exceptions.
this->viewport_ = this->renderWindow_->addViewport(0, 0);
- Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(0);
+ Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(Ogre::MIP_UNLIMITED);
// add console commands
ccPrintScreen_ = createConsoleCommand(createFunctor(&GraphicsManager::printScreen, this), "printScreen");
Modified: code/trunk/src/libraries/core/OrxonoxClass.h
===================================================================
--- code/trunk/src/libraries/core/OrxonoxClass.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/libraries/core/OrxonoxClass.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -38,6 +38,7 @@
#define _OrxonoxClass_H__
#include "CorePrereqs.h"
+#include "Super.h"
#include <set>
#include <vector>
@@ -106,6 +107,8 @@
bool isDirectChildOf(const OrxonoxClass* object);
bool isParentOf(const OrxonoxClass* object);
bool isDirectParentOf(const OrxonoxClass* object);
+
+ virtual void clone(OrxonoxClass*& item) {}
inline unsigned int getReferenceCount() const
{ return this->referenceCount_; }
@@ -168,6 +171,9 @@
//! 'Fast map' that holds this-pointers of all derived types
std::vector<std::pair<unsigned int, void*> > objectPointers_;
};
+
+ SUPER_FUNCTION(11, OrxonoxClass, clone, true);
+
}
#endif /* _OrxonoxClass_H__ */
Modified: code/trunk/src/libraries/core/Super.h
===================================================================
--- code/trunk/src/libraries/core/Super.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/libraries/core/Super.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -266,6 +266,19 @@
#define SUPER_changedGametype(classname, functionname, ...) \
SUPER_NOARGS(classname, functionname)
+
+ #define SUPER_changedUsed(classname, functionname, ...) \
+ SUPER_NOARGS(classname, functionname)
+
+ #define SUPER_clone(classname, functionname, ...) \
+ SUPER_ARGS(classname, functionname, __VA_ARGS__)
+
+ #define SUPER_changedCarrier(classname, functionname, ...) \
+ SUPER_NOARGS(classname, functionname)
+
+ #define SUPER_changedPickedUp(classname, functionname, ...) \
+ SUPER_NOARGS(classname, functionname)
+
// (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
@@ -516,6 +529,23 @@
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;
+
+ SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(11, clone, true, OrxonoxClass* item)
+ (item)
+ SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+ SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(12, changedCarrier, false)
+ ()
+ SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+ SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(13, changedPickedUp, false)
+ ()
+ SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
// (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
}
@@ -569,6 +599,10 @@
SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
SUPER_INTRUSIVE_DECLARATION(changedName);
SUPER_INTRUSIVE_DECLARATION(changedGametype);
+ SUPER_INTRUSIVE_DECLARATION(changedUsed);
+ SUPER_INTRUSIVE_DECLARATION(clone);
+ SUPER_INTRUSIVE_DECLARATION(changedCarrier);
+ SUPER_INTRUSIVE_DECLARATION(changedPickedUp);
// (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
Modified: code/trunk/src/modules/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/CMakeLists.txt 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/CMakeLists.txt 2010-03-15 14:27:09 UTC (rev 6524)
@@ -28,6 +28,7 @@
ADD_SUBDIRECTORY(objects)
ADD_SUBDIRECTORY(overlays)
+ADD_SUBDIRECTORY(pickup)
ADD_SUBDIRECTORY(pong)
ADD_SUBDIRECTORY(questsystem)
ADD_SUBDIRECTORY(weapons)
Deleted: code/trunk/src/modules/pickup/CMakeLists.txt
===================================================================
--- code/branches/pickup3/src/modules/pickup/CMakeLists.txt 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/CMakeLists.txt 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,24 +0,0 @@
-SET_SOURCE_FILES(PICKUP_SRC_FILES
- DroppedPickup.cc
- Pickup.cc
- PickupCollection.cc
- PickupCollectionIdentifier.cc
- PickupManager.cc
- PickupRepresentation.cc
- PickupSpawner.cc
-)
-
-ADD_SUBDIRECTORY(items)
-
-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/trunk/src/modules/pickup/CMakeLists.txt (from rev 6523, code/branches/pickup3/src/modules/pickup/CMakeLists.txt)
===================================================================
--- code/trunk/src/modules/pickup/CMakeLists.txt (rev 0)
+++ code/trunk/src/modules/pickup/CMakeLists.txt 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,24 @@
+SET_SOURCE_FILES(PICKUP_SRC_FILES
+ DroppedPickup.cc
+ Pickup.cc
+ PickupCollection.cc
+ PickupCollectionIdentifier.cc
+ PickupManager.cc
+ PickupRepresentation.cc
+ PickupSpawner.cc
+)
+
+ADD_SUBDIRECTORY(items)
+
+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}
+)
Deleted: code/trunk/src/modules/pickup/DroppedPickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/DroppedPickup.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/DroppedPickup.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,98 +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:
- * Damian 'Mozork' Frick
- *
- */
-
-/**
- @file
- @brief Implementation of the DroppedPickup class.
-*/
-
-#include "DroppedPickup.h"
-
-#include "core/CoreIncludes.h"
-#include "interfaces/Pickupable.h"
-#include "graphics/Model.h"
-
-namespace orxonox
-{
-
- CreateFactory(DroppedPickup);
-
- /**
- @brief
- Default constructor. Registers object and sets default values.
- */
- DroppedPickup::DroppedPickup(BaseObject* creator) : PickupSpawner(creator)
- {
- RegisterObject(DroppedPickup);
-
- }
-
- /**
- @brief
- Constructor. Registers the object and sets values.
- @param creator
- The creator of the DroppedPickup.
- @param pickup
- The Pickupable that was dropped.
- @param position
- The position at which the DroppedPickup should be created.
- @param triggerDistance
- The distance at which the PickupSpawner triggers. Default is 10.
- */
- DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 10, 1)
- {
- RegisterObject(DroppedPickup);
-
- this->setPosition(position);
- this->setActive(false);
- this->startRespawnTimer();
- }
-
- /**
- @brief
- Destructor.
- */
- DroppedPickup::~DroppedPickup()
- {
- if(this->pickup_ != NULL && this->pickup_->isPickedUp())
- {
- this->pickup_ = NULL;
- }
- }
-
- /**
- @brief
- Creates the Pickupable that is going to get picked up.
- In the case of the DroppedItem it is the one and only Pickupable that was dropped. No additional Pickupables of the same type are created.
- */
- Pickupable* DroppedPickup::getPickup(void)
- {
- return this->pickup_;
- }
-
-}
Copied: code/trunk/src/modules/pickup/DroppedPickup.cc (from rev 6523, code/branches/pickup3/src/modules/pickup/DroppedPickup.cc)
===================================================================
--- code/trunk/src/modules/pickup/DroppedPickup.cc (rev 0)
+++ code/trunk/src/modules/pickup/DroppedPickup.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,98 @@
+/*
+ * 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 the DroppedPickup class.
+*/
+
+#include "DroppedPickup.h"
+
+#include "core/CoreIncludes.h"
+#include "interfaces/Pickupable.h"
+#include "graphics/Model.h"
+
+namespace orxonox
+{
+
+ CreateFactory(DroppedPickup);
+
+ /**
+ @brief
+ Default constructor. Registers object and sets default values.
+ */
+ DroppedPickup::DroppedPickup(BaseObject* creator) : PickupSpawner(creator)
+ {
+ RegisterObject(DroppedPickup);
+
+ }
+
+ /**
+ @brief
+ Constructor. Registers the object and sets values.
+ @param creator
+ The creator of the DroppedPickup.
+ @param pickup
+ The Pickupable that was dropped.
+ @param position
+ The position at which the DroppedPickup should be created.
+ @param triggerDistance
+ The distance at which the PickupSpawner triggers. Default is 10.
+ */
+ DroppedPickup::DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance) : PickupSpawner(creator, pickup, triggerDistance, 10, 1)
+ {
+ RegisterObject(DroppedPickup);
+
+ this->setPosition(position);
+ this->setActive(false);
+ this->startRespawnTimer();
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ DroppedPickup::~DroppedPickup()
+ {
+ if(this->pickup_ != NULL && this->pickup_->isPickedUp())
+ {
+ this->pickup_ = NULL;
+ }
+ }
+
+ /**
+ @brief
+ Creates the Pickupable that is going to get picked up.
+ In the case of the DroppedItem it is the one and only Pickupable that was dropped. No additional Pickupables of the same type are created.
+ */
+ Pickupable* DroppedPickup::getPickup(void)
+ {
+ return this->pickup_;
+ }
+
+}
Deleted: code/trunk/src/modules/pickup/DroppedPickup.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/DroppedPickup.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/DroppedPickup.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,64 +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:
- * Damian 'Mozork' Frick
- *
- */
-
-/**
- @file
- @brief Definition of the DroppedPickup class.
-*/
-
-#ifndef _DroppedPickup_H__
-#define _DroppedPickup_H__
-
-#include "PickupPrereqs.h"
-
-#include "PickupSpawner.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- Special PickupSpawner that is created whe a Pickupable is dropped. It just spawns one pickup, the one that was dropped.
- @author
- Daniel 'Huty' Haggenmueller
- Damian 'Mozork' Frick
- */
- class _PickupExport DroppedPickup : public PickupSpawner
- {
- public:
- DroppedPickup(BaseObject* creator); //!< Default constructor.
- DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance = 10.0); //!< Constructor.
- virtual ~DroppedPickup(); //!< Destructor.
-
- protected:
- virtual Pickupable* getPickup(void); //!< Creates the Pickupable that is going to get picked up.
-
- };
-}
-
-#endif /* _DroppedPickup_H__ */
Copied: code/trunk/src/modules/pickup/DroppedPickup.h (from rev 6523, code/branches/pickup3/src/modules/pickup/DroppedPickup.h)
===================================================================
--- code/trunk/src/modules/pickup/DroppedPickup.h (rev 0)
+++ code/trunk/src/modules/pickup/DroppedPickup.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,64 @@
+/*
+ * 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 Definition of the DroppedPickup class.
+*/
+
+#ifndef _DroppedPickup_H__
+#define _DroppedPickup_H__
+
+#include "PickupPrereqs.h"
+
+#include "PickupSpawner.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Special PickupSpawner that is created whe a Pickupable is dropped. It just spawns one pickup, the one that was dropped.
+ @author
+ Daniel 'Huty' Haggenmueller
+ Damian 'Mozork' Frick
+ */
+ class _PickupExport DroppedPickup : public PickupSpawner
+ {
+ public:
+ DroppedPickup(BaseObject* creator); //!< Default constructor.
+ DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance = 10.0); //!< Constructor.
+ virtual ~DroppedPickup(); //!< Destructor.
+
+ protected:
+ virtual Pickupable* getPickup(void); //!< Creates the Pickupable that is going to get picked up.
+
+ };
+}
+
+#endif /* _DroppedPickup_H__ */
Deleted: code/trunk/src/modules/pickup/Pickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/Pickup.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/Pickup.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,233 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
-*/
-
-#include "Pickup.h"
-
-#include "core/CoreIncludes.h"
-#include "util/StringUtils.h"
-#include "pickup/PickupIdentifier.h"
-#include "DroppedPickup.h"
-
-namespace orxonox
-{
-
- /*static*/ const std::string Pickup::activationTypeImmediate_s = "immediate";
- /*static*/ const std::string Pickup::activationTypeOnUse_s = "onUse";
- /*static*/ const std::string Pickup::durationTypeOnce_s = "once";
- /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous";
-
- //TODO: Should this be here? Does it work without?
- CreateFactory(Pickup);
-
- Pickup::Pickup(BaseObject* creator) : BaseObject(creator)
- {
- RegisterObject(Pickup);
-
- this->initialize();
- }
-
- Pickup::~Pickup()
- {
-
- }
-
- /**
- @brief
- Initializes the member variables.
- */
- void Pickup::initialize(void)
- {
- this->activationType_ = pickupActivationType::immediate;
- this->durationType_ = pickupDurationType::once;
- }
-
- /**
- @brief
- Initializes the PickupIdentififer of this Pickup.
- */
- void Pickup::initializeIdentifier(void)
- {
- //TODO: Works?
- std::string val1 = this->getActivationType();
- std::string type1 = "activationType";
- this->pickupIdentifier_->addParameter(type1, val1);
-
- std::string val2 = this->getDurationType();
- std::string type2 = "durationType";
- this->pickupIdentifier_->addParameter(type2, val2);
- }
-
- /**
- @brief
- Method for creating a Pickup object through XML.
- */
- void Pickup::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(Pickup, XMLPort, xmlelement, mode);
-
- XMLPortParam(Pickup, "activationType", setActivationType, getActivationType, xmlelement, mode);
- XMLPortParam(Pickup, "durationType", setDurationType, getDurationType, xmlelement, mode);
-
- this->initializeIdentifier();
- }
-
- /**
- @brief
- Get the activation type of the pickup.
- @return
- Returns a string containing the activation type.
- */
- const std::string& Pickup::getActivationType(void)
- {
- switch(this->activationType_)
- {
- case pickupActivationType::immediate:
- return activationTypeImmediate_s;
- case pickupActivationType::onUse:
- return activationTypeOnUse_s;
- default:
- return BLANKSTRING;
- }
- }
-
- /**
- @brief
- Get the duration type of the pickup.
- @return
- Returns a string containing the duration type.
- */
- const std::string& Pickup::getDurationType(void)
- {
- switch(this->durationType_)
- {
- case pickupDurationType::once:
- return durationTypeOnce_s;
- case pickupDurationType::continuous:
- return durationTypeContinuous_s;
- default:
- return BLANKSTRING;
- }
- }
-
- /**
- @brief
- Set the activation type of the Pickup.
- @param type
- The activation type of the Pickup as a string.
- */
- void Pickup::setActivationType(const std::string& type)
- {
- if(type == activationTypeImmediate_s)
- {
- this->activationType_ = pickupActivationType::immediate;
- }
- else if(type == activationTypeOnUse_s)
- {
- this->activationType_ = pickupActivationType::onUse;
- }
- else
- {
- COUT(1) << "Invalid activationType in pickup." << std::endl;
- }
- }
-
- /**
- @brief
- Set the duration type of the Pickup.
- @param type
- The duration type of the Pickup as a string.
- */
- void Pickup::setDurationType(const std::string& type)
- {
- if(type == durationTypeOnce_s)
- {
- this->durationType_ = pickupDurationType::once;
- }
- else if(type == durationTypeContinuous_s)
- {
- this->durationType_ = pickupDurationType::continuous;
- }
- else
- {
- COUT(1) << "Invalid durationType in pickup." << std::endl;
- }
- }
-
- /**
- @brief
- Should be called when the pickup has transited from picked up to dropped or the other way around.
- Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedPickedUp); to their changedPickedUp method.
- */
- void Pickup::changedPickedUp(void)
- {
- SUPER(Pickup, changedPickedUp);
-
- //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
- if(this->getCarrier() != NULL && this->isPickedUp() && this->isImmediate())
- {
- this->setUsed(true);
- }
- }
-
- /**
- @brief
- Creates a duplicate of the Pickup.
- @return
- Returns the clone of this pickup as a pointer to a Pickupable.
- */
- void Pickup::clone(OrxonoxClass*& item)
- {
- if(item == NULL)
- item = new Pickup(this);
-
- SUPER(Pickup, clone, item);
-
- Pickup* pickup = dynamic_cast<Pickup*>(item);
- pickup->setActivationTypeDirect(this->getActivationTypeDirect());
- pickup->setDurationTypeDirect(this->getDurationTypeDirect());
-
- pickup->initializeIdentifier();
- }
-
- /**
- @brief
- Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
- This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
- DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position);
- @param position
- The position at which the PickupSpawner should be placed.
- @return
- Returns true if a spawner was created, false if not.
- */
- bool Pickup::createSpawner(const Vector3& position)
- {
- new DroppedPickup(this, this, position);
- return true;
- }
-
-}
Copied: code/trunk/src/modules/pickup/Pickup.cc (from rev 6523, code/branches/pickup3/src/modules/pickup/Pickup.cc)
===================================================================
--- code/trunk/src/modules/pickup/Pickup.cc (rev 0)
+++ code/trunk/src/modules/pickup/Pickup.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,233 @@
+/*
+ * 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:
+ * ...
+ *
+*/
+
+#include "Pickup.h"
+
+#include "core/CoreIncludes.h"
+#include "util/StringUtils.h"
+#include "pickup/PickupIdentifier.h"
+#include "DroppedPickup.h"
+
+namespace orxonox
+{
+
+ /*static*/ const std::string Pickup::activationTypeImmediate_s = "immediate";
+ /*static*/ const std::string Pickup::activationTypeOnUse_s = "onUse";
+ /*static*/ const std::string Pickup::durationTypeOnce_s = "once";
+ /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous";
+
+ //TODO: Should this be here? Does it work without?
+ CreateFactory(Pickup);
+
+ Pickup::Pickup(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(Pickup);
+
+ this->initialize();
+ }
+
+ Pickup::~Pickup()
+ {
+
+ }
+
+ /**
+ @brief
+ Initializes the member variables.
+ */
+ void Pickup::initialize(void)
+ {
+ this->activationType_ = pickupActivationType::immediate;
+ this->durationType_ = pickupDurationType::once;
+ }
+
+ /**
+ @brief
+ Initializes the PickupIdentififer of this Pickup.
+ */
+ void Pickup::initializeIdentifier(void)
+ {
+ //TODO: Works?
+ std::string val1 = this->getActivationType();
+ std::string type1 = "activationType";
+ this->pickupIdentifier_->addParameter(type1, val1);
+
+ std::string val2 = this->getDurationType();
+ std::string type2 = "durationType";
+ this->pickupIdentifier_->addParameter(type2, val2);
+ }
+
+ /**
+ @brief
+ Method for creating a Pickup object through XML.
+ */
+ void Pickup::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(Pickup, XMLPort, xmlelement, mode);
+
+ XMLPortParam(Pickup, "activationType", setActivationType, getActivationType, xmlelement, mode);
+ XMLPortParam(Pickup, "durationType", setDurationType, getDurationType, xmlelement, mode);
+
+ this->initializeIdentifier();
+ }
+
+ /**
+ @brief
+ Get the activation type of the pickup.
+ @return
+ Returns a string containing the activation type.
+ */
+ const std::string& Pickup::getActivationType(void)
+ {
+ switch(this->activationType_)
+ {
+ case pickupActivationType::immediate:
+ return activationTypeImmediate_s;
+ case pickupActivationType::onUse:
+ return activationTypeOnUse_s;
+ default:
+ return BLANKSTRING;
+ }
+ }
+
+ /**
+ @brief
+ Get the duration type of the pickup.
+ @return
+ Returns a string containing the duration type.
+ */
+ const std::string& Pickup::getDurationType(void)
+ {
+ switch(this->durationType_)
+ {
+ case pickupDurationType::once:
+ return durationTypeOnce_s;
+ case pickupDurationType::continuous:
+ return durationTypeContinuous_s;
+ default:
+ return BLANKSTRING;
+ }
+ }
+
+ /**
+ @brief
+ Set the activation type of the Pickup.
+ @param type
+ The activation type of the Pickup as a string.
+ */
+ void Pickup::setActivationType(const std::string& type)
+ {
+ if(type == activationTypeImmediate_s)
+ {
+ this->activationType_ = pickupActivationType::immediate;
+ }
+ else if(type == activationTypeOnUse_s)
+ {
+ this->activationType_ = pickupActivationType::onUse;
+ }
+ else
+ {
+ COUT(1) << "Invalid activationType in pickup." << std::endl;
+ }
+ }
+
+ /**
+ @brief
+ Set the duration type of the Pickup.
+ @param type
+ The duration type of the Pickup as a string.
+ */
+ void Pickup::setDurationType(const std::string& type)
+ {
+ if(type == durationTypeOnce_s)
+ {
+ this->durationType_ = pickupDurationType::once;
+ }
+ else if(type == durationTypeContinuous_s)
+ {
+ this->durationType_ = pickupDurationType::continuous;
+ }
+ else
+ {
+ COUT(1) << "Invalid durationType in pickup." << std::endl;
+ }
+ }
+
+ /**
+ @brief
+ Should be called when the pickup has transited from picked up to dropped or the other way around.
+ Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedPickedUp); to their changedPickedUp method.
+ */
+ void Pickup::changedPickedUp(void)
+ {
+ SUPER(Pickup, changedPickedUp);
+
+ //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up.
+ if(this->getCarrier() != NULL && this->isPickedUp() && this->isImmediate())
+ {
+ this->setUsed(true);
+ }
+ }
+
+ /**
+ @brief
+ Creates a duplicate of the Pickup.
+ @return
+ Returns the clone of this pickup as a pointer to a Pickupable.
+ */
+ void Pickup::clone(OrxonoxClass*& item)
+ {
+ if(item == NULL)
+ item = new Pickup(this);
+
+ SUPER(Pickup, clone, item);
+
+ Pickup* pickup = dynamic_cast<Pickup*>(item);
+ pickup->setActivationTypeDirect(this->getActivationTypeDirect());
+ pickup->setDurationTypeDirect(this->getDurationTypeDirect());
+
+ pickup->initializeIdentifier();
+ }
+
+ /**
+ @brief
+ Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
+ This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
+ DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position);
+ @param position
+ The position at which the PickupSpawner should be placed.
+ @return
+ Returns true if a spawner was created, false if not.
+ */
+ bool Pickup::createSpawner(const Vector3& position)
+ {
+ new DroppedPickup(this, this, position);
+ return true;
+ }
+
+}
Deleted: code/trunk/src/modules/pickup/Pickup.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/Pickup.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/Pickup.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,158 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
-*/
-
-#ifndef _Pickup_H__
-#define _Pickup_H__
-
-#include "pickup/PickupPrereqs.h"
-
-#include "core/BaseObject.h"
-#include "core/XMLPort.h"
-
-#include "interfaces/Pickupable.h"
-
-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
- Pickup class. Offers base functionality for a wide range of pickups.
- Pickups ingeriting from this class cann choose an activation type and a duration type.
- @author
- Damian 'Mozork' Frick
- */
- class _PickupExport Pickup : public Pickupable, public BaseObject
- {
-
- public:
- Pickup(BaseObject* creator); //!< Constructor.
- virtual ~Pickup(); //!< Destructor.
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- /**
- @brief Get the activation type of the pickup.
- @return Returns the activation type of the pickup.
- */
- inline pickupActivationType::Value getActivationTypeDirect(void)
- { return this->activationType_; }
- /**
- @brief Get the duration type of the pickup.
- @return Returns the duration type of the pickup.
- */
- inline pickupDurationType::Value getDurationTypeDirect(void)
- { return this->durationType_; }
-
- const std::string& getActivationType(void); //!< Get the activation type of the pickup.
- const std::string& getDurationType(void); //!< Get the duration type of the pickup.
-
- /**
- @brief Get whether the activation type is 'immediate'.
- @return Returns true if the activation type is 'immediate'.
- */
- inline bool isImmediate(void)
- { return this->getActivationTypeDirect() == pickupActivationType::immediate; }
- /**
- @brief Get whether the activation type is 'onUse'.
- @return Returns true if the activation type is 'onUse'.
- */
- inline bool isOnUse(void)
- { return this->getActivationTypeDirect() == pickupActivationType::onUse; }
- /**
- @brief Get whether the duration type is 'once'.
- @return Returns true if the duration type is 'once'.
- */
- inline bool isOnce(void)
- { return this->getDurationTypeDirect() == pickupDurationType::once; }
- /**
- @brief Get whether the duration type is 'continuous'.
- @return Returns true if the duration type is 'continuous'.
- */
- inline bool isContinuous(void)
- { return this->getDurationTypeDirect() == pickupDurationType::continuous; }
-
- virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
-
- virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the Pickup.
-
- protected:
- void initializeIdentifier(void);
-
- virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
-
- /**
- @brief Set the activation type of the pickup.
- @param type The activation type of the pickup.
- */
- inline void setActivationTypeDirect(pickupActivationType::Value type)
- { this->activationType_ = type; }
- /**
- @brief Set the duration type of the pickup.
- @param type The duration type of the pickup.
- */
- inline void setDurationTypeDirect(pickupDurationType::Value type)
- { this->durationType_ = type; }
-
- void setActivationType(const std::string& type); //!< Set the activation type of the pickup.
- void setDurationType(const std::string& type); //!< Set the duration type of the pickup
-
- private:
- void initialize(void); //!< Initializes the member variables.
-
- pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
- pickupDurationType::Value durationType_; //!< The duration type of the pickup.
-
- static const std::string activationTypeImmediate_s;
- static const std::string activationTypeOnUse_s;
- static const std::string durationTypeOnce_s;
- static const std::string durationTypeContinuous_s;
-
- };
-
-}
-#endif // _Pickup_H__
Copied: code/trunk/src/modules/pickup/Pickup.h (from rev 6523, code/branches/pickup3/src/modules/pickup/Pickup.h)
===================================================================
--- code/trunk/src/modules/pickup/Pickup.h (rev 0)
+++ code/trunk/src/modules/pickup/Pickup.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,158 @@
+/*
+ * 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 _Pickup_H__
+#define _Pickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include "core/BaseObject.h"
+#include "core/XMLPort.h"
+
+#include "interfaces/Pickupable.h"
+
+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
+ Pickup class. Offers base functionality for a wide range of pickups.
+ Pickups ingeriting from this class cann choose an activation type and a duration type.
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _PickupExport Pickup : public Pickupable, public BaseObject
+ {
+
+ public:
+ Pickup(BaseObject* creator); //!< Constructor.
+ virtual ~Pickup(); //!< Destructor.
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ /**
+ @brief Get the activation type of the pickup.
+ @return Returns the activation type of the pickup.
+ */
+ inline pickupActivationType::Value getActivationTypeDirect(void)
+ { return this->activationType_; }
+ /**
+ @brief Get the duration type of the pickup.
+ @return Returns the duration type of the pickup.
+ */
+ inline pickupDurationType::Value getDurationTypeDirect(void)
+ { return this->durationType_; }
+
+ const std::string& getActivationType(void); //!< Get the activation type of the pickup.
+ const std::string& getDurationType(void); //!< Get the duration type of the pickup.
+
+ /**
+ @brief Get whether the activation type is 'immediate'.
+ @return Returns true if the activation type is 'immediate'.
+ */
+ inline bool isImmediate(void)
+ { return this->getActivationTypeDirect() == pickupActivationType::immediate; }
+ /**
+ @brief Get whether the activation type is 'onUse'.
+ @return Returns true if the activation type is 'onUse'.
+ */
+ inline bool isOnUse(void)
+ { return this->getActivationTypeDirect() == pickupActivationType::onUse; }
+ /**
+ @brief Get whether the duration type is 'once'.
+ @return Returns true if the duration type is 'once'.
+ */
+ inline bool isOnce(void)
+ { return this->getDurationTypeDirect() == pickupDurationType::once; }
+ /**
+ @brief Get whether the duration type is 'continuous'.
+ @return Returns true if the duration type is 'continuous'.
+ */
+ inline bool isContinuous(void)
+ { return this->getDurationTypeDirect() == pickupDurationType::continuous; }
+
+ virtual void changedPickedUp(void); //!< Should be called when the pickup has transited from picked up to dropped or the other way around.
+
+ virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the Pickup.
+
+ protected:
+ void initializeIdentifier(void);
+
+ virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
+
+ /**
+ @brief Set the activation type of the pickup.
+ @param type The activation type of the pickup.
+ */
+ inline void setActivationTypeDirect(pickupActivationType::Value type)
+ { this->activationType_ = type; }
+ /**
+ @brief Set the duration type of the pickup.
+ @param type The duration type of the pickup.
+ */
+ inline void setDurationTypeDirect(pickupDurationType::Value type)
+ { this->durationType_ = type; }
+
+ void setActivationType(const std::string& type); //!< Set the activation type of the pickup.
+ void setDurationType(const std::string& type); //!< Set the duration type of the pickup
+
+ private:
+ void initialize(void); //!< Initializes the member variables.
+
+ pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
+ pickupDurationType::Value durationType_; //!< The duration type of the pickup.
+
+ static const std::string activationTypeImmediate_s;
+ static const std::string activationTypeOnUse_s;
+ static const std::string durationTypeOnce_s;
+ static const std::string durationTypeContinuous_s;
+
+ };
+
+}
+#endif // _Pickup_H__
Deleted: code/trunk/src/modules/pickup/PickupCollection.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupCollection.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupCollection.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,206 +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:
- * 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"
-#include "DroppedPickup.h"
-
-#include "PickupCollectionIdentifier.h"
-
-namespace orxonox
-{
-
- CreateFactory(PickupCollection);
-
- /**
- @brief
- Default Constructor.
- */
- PickupCollection::PickupCollection(BaseObject* creator) : BaseObject(creator)
- {
- RegisterObject(PickupCollection);
-
- this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(this);
- }
-
- /**
- @brief
- Destructor.
- */
- PickupCollection::~PickupCollection()
- {
- //! Destroy all Pickupables constructing this PickupCollection.
- for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
- {
- (*it)->destroy();
- }
- }
-
- /**
- @brief
- Creates an instance of this Class through XML.
- */
- void PickupCollection::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(PickupCollection, XMLPort, xmlelement, mode);
-
- XMLPortObject(PickupCollection, Pickupable, "pickupables", addPickupable, getPickupable, xmlelement, mode);
-
- this->initializeIdentifier();
- }
-
- void PickupCollection::initializeIdentifier(void)
- {
- for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
- {
- this->pickupCollectionIdentifier_->addPickup((*it)->getPickupIdentifier());
- }
- }
-
- /**
- @brief
- Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
- This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
- DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position);
- @param position
- The position at which the PickupSpawner should be placed.
- @return
- Returns true if a spawner was created, false if not.
- */
- bool PickupCollection::createSpawner(const Vector3& position)
- {
- new DroppedPickup(this, this, position);
- return true;
- }
-
- /**
- @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_.push_back(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.
- */
- const Pickupable* PickupCollection::getPickupable(unsigned int index)
- {
- return this->pickups_[index]; //TODO. Does this work?
- }
-
- void PickupCollection::changedUsed(void)
- {
- SUPER(PickupCollection, changedUsed);
-
- //! Change used for all Pickupables this PickupCollection consists of.
- for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
- {
- (*it)->setUsed(this->isUsed());
- }
- }
-
- void PickupCollection::changedCarrier(void)
- {
- SUPER(PickupCollection, changedCarrier);
-
- //! Change used for all Pickupables this PickupCollection consists of.
- for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
- {
- (*it)->setCarrier(this->getCarrier());
- }
- }
-
- void PickupCollection::changedPickedUp()
- {
- SUPER(PickupCollection, changedPickedUp);
-
- //! Change the carrier for all Pickupables this PickupCollection consists of.
- for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
- {
- (*it)->setPickedUp(this->isPickedUp());
- }
- }
-
- void PickupCollection::clone(OrxonoxClass*& item)
- {
- if(item == NULL)
- item = new PickupCollection(this);
-
- SUPER(PickupCollection, clone, item);
-
- PickupCollection* pickup = dynamic_cast<PickupCollection*>(item);
- for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
- {
- Pickupable* newPickup = (*it)->clone();
- pickup->addPickupable(newPickup);
- }
-
- pickup->initializeIdentifier();
- }
-
- bool PickupCollection::isTarget(Identifier* identifier) const
- {
- for(std::vector<Pickupable*>::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
- {
- if(!(*it)->isTarget(identifier))
- return false;
- }
-
- return true;
- }
-
- const PickupIdentifier* PickupCollection::getPickupIdentifier(void)
- {
- return this->pickupCollectionIdentifier_;
- }
-
-}
\ No newline at end of file
Copied: code/trunk/src/modules/pickup/PickupCollection.cc (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupCollection.cc)
===================================================================
--- code/trunk/src/modules/pickup/PickupCollection.cc (rev 0)
+++ code/trunk/src/modules/pickup/PickupCollection.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,206 @@
+/*
+ * 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"
+#include "DroppedPickup.h"
+
+#include "PickupCollectionIdentifier.h"
+
+namespace orxonox
+{
+
+ CreateFactory(PickupCollection);
+
+ /**
+ @brief
+ Default Constructor.
+ */
+ PickupCollection::PickupCollection(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(PickupCollection);
+
+ this->pickupCollectionIdentifier_ = new PickupCollectionIdentifier(this);
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ PickupCollection::~PickupCollection()
+ {
+ //! Destroy all Pickupables constructing this PickupCollection.
+ for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ (*it)->destroy();
+ }
+ }
+
+ /**
+ @brief
+ Creates an instance of this Class through XML.
+ */
+ void PickupCollection::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(PickupCollection, XMLPort, xmlelement, mode);
+
+ XMLPortObject(PickupCollection, Pickupable, "pickupables", addPickupable, getPickupable, xmlelement, mode);
+
+ this->initializeIdentifier();
+ }
+
+ void PickupCollection::initializeIdentifier(void)
+ {
+ for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ this->pickupCollectionIdentifier_->addPickup((*it)->getPickupIdentifier());
+ }
+ }
+
+ /**
+ @brief
+ Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
+ This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
+ DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position);
+ @param position
+ The position at which the PickupSpawner should be placed.
+ @return
+ Returns true if a spawner was created, false if not.
+ */
+ bool PickupCollection::createSpawner(const Vector3& position)
+ {
+ new DroppedPickup(this, this, position);
+ return true;
+ }
+
+ /**
+ @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_.push_back(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.
+ */
+ const Pickupable* PickupCollection::getPickupable(unsigned int index)
+ {
+ return this->pickups_[index]; //TODO. Does this work?
+ }
+
+ void PickupCollection::changedUsed(void)
+ {
+ SUPER(PickupCollection, changedUsed);
+
+ //! Change used for all Pickupables this PickupCollection consists of.
+ for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ (*it)->setUsed(this->isUsed());
+ }
+ }
+
+ void PickupCollection::changedCarrier(void)
+ {
+ SUPER(PickupCollection, changedCarrier);
+
+ //! Change used for all Pickupables this PickupCollection consists of.
+ for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ (*it)->setCarrier(this->getCarrier());
+ }
+ }
+
+ void PickupCollection::changedPickedUp()
+ {
+ SUPER(PickupCollection, changedPickedUp);
+
+ //! Change the carrier for all Pickupables this PickupCollection consists of.
+ for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ (*it)->setPickedUp(this->isPickedUp());
+ }
+ }
+
+ void PickupCollection::clone(OrxonoxClass*& item)
+ {
+ if(item == NULL)
+ item = new PickupCollection(this);
+
+ SUPER(PickupCollection, clone, item);
+
+ PickupCollection* pickup = dynamic_cast<PickupCollection*>(item);
+ for(std::vector<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ Pickupable* newPickup = (*it)->clone();
+ pickup->addPickupable(newPickup);
+ }
+
+ pickup->initializeIdentifier();
+ }
+
+ bool PickupCollection::isTarget(Identifier* identifier) const
+ {
+ for(std::vector<Pickupable*>::const_iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ if(!(*it)->isTarget(identifier))
+ return false;
+ }
+
+ return true;
+ }
+
+ const PickupIdentifier* PickupCollection::getPickupIdentifier(void)
+ {
+ return this->pickupCollectionIdentifier_;
+ }
+
+}
\ No newline at end of file
Deleted: code/trunk/src/modules/pickup/PickupCollection.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupCollection.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupCollection.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,87 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _PickupCollection_H__
-#define _PickupCollection_H__
-
-#include "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
- */
- 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 void changedCarrier(void);
- virtual void changedPickedUp(void);
-
- virtual void clone(OrxonoxClass*& item);
-
- virtual bool isTarget(Identifier* identifier) const;
-
- virtual const PickupIdentifier* getPickupIdentifier(void);
-
- bool addPickupable(Pickupable* pickup);
- const Pickupable* getPickupable(unsigned int index);
-
- protected:
- void initializeIdentifier(void);
-
- virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
-
- PickupCollectionIdentifier* pickupCollectionIdentifier_;
-
- private:
-
- std::vector<Pickupable*> pickups_;
-
- };
-
-}
-
-#endif /* _PickupCollection_H__ */
\ No newline at end of file
Copied: code/trunk/src/modules/pickup/PickupCollection.h (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupCollection.h)
===================================================================
--- code/trunk/src/modules/pickup/PickupCollection.h (rev 0)
+++ code/trunk/src/modules/pickup/PickupCollection.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,87 @@
+/*
+ * 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 "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
+ */
+ 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 void changedCarrier(void);
+ virtual void changedPickedUp(void);
+
+ virtual void clone(OrxonoxClass*& item);
+
+ virtual bool isTarget(Identifier* identifier) const;
+
+ virtual const PickupIdentifier* getPickupIdentifier(void);
+
+ bool addPickupable(Pickupable* pickup);
+ const Pickupable* getPickupable(unsigned int index);
+
+ protected:
+ void initializeIdentifier(void);
+
+ virtual bool createSpawner(const Vector3& position); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
+
+ PickupCollectionIdentifier* pickupCollectionIdentifier_;
+
+ private:
+
+ std::vector<Pickupable*> pickups_;
+
+ };
+
+}
+
+#endif /* _PickupCollection_H__ */
\ No newline at end of file
Deleted: code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,77 +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:
- * ...
- * Co-authors:
- * ...
- *
-*/
-
-#include "PickupCollectionIdentifier.h"
-
-#include "core/CoreIncludes.h"
-
-namespace orxonox
-{
-
- PickupCollectionIdentifier::PickupCollectionIdentifier(Pickupable* pickup) : PickupIdentifier(pickup)
- {
- RegisterObject(PickupCollectionIdentifier);
- }
-
- PickupCollectionIdentifier::~PickupCollectionIdentifier()
- {
-
- }
-
- int PickupCollectionIdentifier::compare(const PickupIdentifier* identifier) const
- {
- PickupIdentifier* temp = const_cast<PickupIdentifier*>(identifier);
- const PickupCollectionIdentifier* collectionIdentifier = dynamic_cast<PickupCollectionIdentifier*>(temp);
- if(collectionIdentifier == NULL)
- {
- return this->PickupIdentifier::compare(identifier);
- }
-
- if(this->identifiers_.size() != collectionIdentifier->identifiers_.size())
- return this->identifiers_.size()-collectionIdentifier->identifiers_.size();
-
- std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it2 = collectionIdentifier->identifiers_.begin();
- for(std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); it++)
- {
-
- if((*it)->compare(*it2) < 0)
- return -1;
- if((*it2)->compare(*it) < 0)
- return 1;
- }
-
- return 0;
- }
-
- void PickupCollectionIdentifier::addPickup(const PickupIdentifier* identifier)
- {
- this->identifiers_.insert(identifier);
- }
-
-}
-
Copied: code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.cc)
===================================================================
--- code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc (rev 0)
+++ code/trunk/src/modules/pickup/PickupCollectionIdentifier.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,77 @@
+/*
+ * 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:
+ * ...
+ * Co-authors:
+ * ...
+ *
+*/
+
+#include "PickupCollectionIdentifier.h"
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+
+ PickupCollectionIdentifier::PickupCollectionIdentifier(Pickupable* pickup) : PickupIdentifier(pickup)
+ {
+ RegisterObject(PickupCollectionIdentifier);
+ }
+
+ PickupCollectionIdentifier::~PickupCollectionIdentifier()
+ {
+
+ }
+
+ int PickupCollectionIdentifier::compare(const PickupIdentifier* identifier) const
+ {
+ PickupIdentifier* temp = const_cast<PickupIdentifier*>(identifier);
+ const PickupCollectionIdentifier* collectionIdentifier = dynamic_cast<PickupCollectionIdentifier*>(temp);
+ if(collectionIdentifier == NULL)
+ {
+ return this->PickupIdentifier::compare(identifier);
+ }
+
+ if(this->identifiers_.size() != collectionIdentifier->identifiers_.size())
+ return this->identifiers_.size()-collectionIdentifier->identifiers_.size();
+
+ std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it2 = collectionIdentifier->identifiers_.begin();
+ for(std::set<const PickupIdentifier*, PickupIdentifierCompare>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); it++)
+ {
+
+ if((*it)->compare(*it2) < 0)
+ return -1;
+ if((*it2)->compare(*it) < 0)
+ return 1;
+ }
+
+ return 0;
+ }
+
+ void PickupCollectionIdentifier::addPickup(const PickupIdentifier* identifier)
+ {
+ this->identifiers_.insert(identifier);
+ }
+
+}
+
Deleted: code/trunk/src/modules/pickup/PickupCollectionIdentifier.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupCollectionIdentifier.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,58 +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:
- * ...
- * Co-authors:
- * ...
- *
-*/
-
-#ifndef _PickupCollectionIdentifier_H__
-#define _PickupCollectionIdentifier_H_
-
-#include "PickupPrereqs.h"
-
-#include "pickup/PickupIdentifier.h"
-#include <set>
-
-namespace orxonox
-{
-
- class _PickupExport PickupCollectionIdentifier : public PickupIdentifier
- {
-
- public:
- PickupCollectionIdentifier(Pickupable* pickup);
- ~PickupCollectionIdentifier();
-
- virtual int compare(const PickupIdentifier* identifier) const;
-
- void addPickup(const PickupIdentifier* identifier);
-
- private:
- std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_;
-
- };
-
-}
-
-#endif // _PickupCollectionIdentifier_H_
Copied: code/trunk/src/modules/pickup/PickupCollectionIdentifier.h (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupCollectionIdentifier.h)
===================================================================
--- code/trunk/src/modules/pickup/PickupCollectionIdentifier.h (rev 0)
+++ code/trunk/src/modules/pickup/PickupCollectionIdentifier.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,58 @@
+/*
+ * 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:
+ * ...
+ * Co-authors:
+ * ...
+ *
+*/
+
+#ifndef _PickupCollectionIdentifier_H__
+#define _PickupCollectionIdentifier_H_
+
+#include "PickupPrereqs.h"
+
+#include "pickup/PickupIdentifier.h"
+#include <set>
+
+namespace orxonox
+{
+
+ class _PickupExport PickupCollectionIdentifier : public PickupIdentifier
+ {
+
+ public:
+ PickupCollectionIdentifier(Pickupable* pickup);
+ ~PickupCollectionIdentifier();
+
+ virtual int compare(const PickupIdentifier* identifier) const;
+
+ void addPickup(const PickupIdentifier* identifier);
+
+ private:
+ std::set<const PickupIdentifier*, PickupIdentifierCompare> identifiers_;
+
+ };
+
+}
+
+#endif // _PickupCollectionIdentifier_H_
Deleted: code/trunk/src/modules/pickup/PickupManager.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupManager.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupManager.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,118 +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:
- * ...
- * Co-authors:
- * ...
- *
-*/
-
-/**
- @file
- @brief Implementation of the PickupManager class.
-*/
-
-#include "PickupManager.h"
-
-#include "core/CoreIncludes.h"
-#include "core/ScopedSingletonManager.h"
-#include "core/Identifier.h"
-#include "interfaces/PickupCarrier.h"
-#include "worldentities/pawns/Pawn.h"
-#include "PickupRepresentation.h"
-
-namespace orxonox
-{
-
- ManageScopedSingleton(PickupManager, ScopeID::Root, false);
-
- /**
- @brief
- Constructor. Registers the PickupManager and creates the default PickupRepresentation.
- */
- PickupManager::PickupManager()
- {
- this->defaultRepresentation_ = NULL;
- this->pickupCarrierStructure_ = NULL;
- RegisterRootObject(PickupManager);
-
- this->defaultRepresentation_ = new PickupRepresentation();
- }
-
- /**
- @brief
- Destructor.
- Destroys the default PickupRepresentation.
- */
- PickupManager::~PickupManager()
- {
- if(this->defaultRepresentation_ != NULL)
- this->defaultRepresentation_->destroy();
-
- if(this->pickupCarrierStructure_ != NULL)
- delete this->pickupCarrierStructure_;
- }
-
- /**
- @brief
- Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
- For every type of Pickupable (uniquely idnetified by a PickupIdentifier) there can be one (and just one) PickupRepresentation registered.
- @param identifier
- The PickupIdentifier identifying the Pickupable.
- @param representation
- A pointer to the PickupRepresentation.
- @return
- Returns true if successful and false if not.
- */
- //TODO: Make sure that either the PickupRepresentation is destroyed upon destruction of the PickupManager if the representation wasn't created with XMLPort.
- bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
- {
- if(this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a RepresentationRegistered.
- return false;
-
- this->representations_[identifier] = representation;
-
- COUT(4) << "PickupRepresentation " << representation << " registered with the PickupManager." << std::endl;
- return true;
- }
-
- /**
- @brief
- Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
- @param identifier
- The PickupIdentifier.
- @return
- Returns a pointer to the PickupRepresentation.
- */
- PickupRepresentation* PickupManager::getRepresentation(const PickupIdentifier* identifier)
- {
- std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
- if(it == this->representations_.end())
- {
- COUT(4) << "PickupManager::getRepresentation() returned default representation." << std::endl;
- return this->defaultRepresentation_;
- }
-
- return it->second;
- }
-
-}
Copied: code/trunk/src/modules/pickup/PickupManager.cc (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupManager.cc)
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.cc (rev 0)
+++ code/trunk/src/modules/pickup/PickupManager.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,118 @@
+/*
+ * 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:
+ * ...
+ * Co-authors:
+ * ...
+ *
+*/
+
+/**
+ @file
+ @brief Implementation of the PickupManager class.
+*/
+
+#include "PickupManager.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ScopedSingletonManager.h"
+#include "core/Identifier.h"
+#include "interfaces/PickupCarrier.h"
+#include "worldentities/pawns/Pawn.h"
+#include "PickupRepresentation.h"
+
+namespace orxonox
+{
+
+ ManageScopedSingleton(PickupManager, ScopeID::Root, false);
+
+ /**
+ @brief
+ Constructor. Registers the PickupManager and creates the default PickupRepresentation.
+ */
+ PickupManager::PickupManager()
+ {
+ this->defaultRepresentation_ = NULL;
+ this->pickupCarrierStructure_ = NULL;
+ RegisterRootObject(PickupManager);
+
+ this->defaultRepresentation_ = new PickupRepresentation();
+ }
+
+ /**
+ @brief
+ Destructor.
+ Destroys the default PickupRepresentation.
+ */
+ PickupManager::~PickupManager()
+ {
+ if(this->defaultRepresentation_ != NULL)
+ this->defaultRepresentation_->destroy();
+
+ if(this->pickupCarrierStructure_ != NULL)
+ delete this->pickupCarrierStructure_;
+ }
+
+ /**
+ @brief
+ Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
+ For every type of Pickupable (uniquely idnetified by a PickupIdentifier) there can be one (and just one) PickupRepresentation registered.
+ @param identifier
+ The PickupIdentifier identifying the Pickupable.
+ @param representation
+ A pointer to the PickupRepresentation.
+ @return
+ Returns true if successful and false if not.
+ */
+ //TODO: Make sure that either the PickupRepresentation is destroyed upon destruction of the PickupManager if the representation wasn't created with XMLPort.
+ bool PickupManager::registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation)
+ {
+ if(this->representations_.find(identifier) != this->representations_.end()) //!< If the Pickupable already has a RepresentationRegistered.
+ return false;
+
+ this->representations_[identifier] = representation;
+
+ COUT(4) << "PickupRepresentation " << representation << " registered with the PickupManager." << std::endl;
+ return true;
+ }
+
+ /**
+ @brief
+ Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
+ @param identifier
+ The PickupIdentifier.
+ @return
+ Returns a pointer to the PickupRepresentation.
+ */
+ PickupRepresentation* PickupManager::getRepresentation(const PickupIdentifier* identifier)
+ {
+ std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
+ if(it == this->representations_.end())
+ {
+ COUT(4) << "PickupManager::getRepresentation() returned default representation." << std::endl;
+ return this->defaultRepresentation_;
+ }
+
+ return it->second;
+ }
+
+}
Deleted: code/trunk/src/modules/pickup/PickupManager.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupManager.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupManager.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,92 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
-*/
-
-/**
- @file
- @brief Definition of the PickupManager class.
-*/
-
-#ifndef _PickupManager_H__
-#define _PickupManager_H__
-
-#include "PickupPrereqs.h"
-
-#include <map>
-#include "util/Singleton.h"
-#include "pickup/PickupIdentifier.h"
-#include "PickupRepresentation.h"
-
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
- //TODO: Actually utilize this.
- struct PickupCarrierNode
- {
- Identifier* identifier;
- std::set<PickupCarrierNode*> children;
- };
-
- /**
- @brief
- Manages Pickupables.
- In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the Pickup GUI.
- //TODO: Manage Pickup GUI.
- @author
- Damian 'Mozork' Frick
- */
- class _PickupExport PickupManager : public Singleton<PickupManager>, public OrxonoxClass
- {
- friend class Singleton<PickupManager>;
-
- public:
- PickupManager();
- virtual ~PickupManager();
-
- static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); }
-
- bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
- PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
-
- //TODO: Delete or utilitze this.
- //bool registerCarrier(Identifier* parent, )
-
- private:
- static PickupManager* singletonPtr_s;
-
- PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
- std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
-
- //TODO: Delete or utilize this.
- PickupCarrierNode* pickupCarrierStructure_;
-
- };
-
-}
-
-#endif // _PickupManager_H__
Copied: code/trunk/src/modules/pickup/PickupManager.h (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupManager.h)
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.h (rev 0)
+++ code/trunk/src/modules/pickup/PickupManager.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,92 @@
+/*
+ * 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 PickupManager class.
+*/
+
+#ifndef _PickupManager_H__
+#define _PickupManager_H__
+
+#include "PickupPrereqs.h"
+
+#include <map>
+#include "util/Singleton.h"
+#include "pickup/PickupIdentifier.h"
+#include "PickupRepresentation.h"
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ //TODO: Actually utilize this.
+ struct PickupCarrierNode
+ {
+ Identifier* identifier;
+ std::set<PickupCarrierNode*> children;
+ };
+
+ /**
+ @brief
+ Manages Pickupables.
+ In essence has two tasks to fulfill. Firstly it must link Pickupables (through their PickupIdentifiers) and their PickupRepresentations. Secondly it manages the Pickup GUI.
+ //TODO: Manage Pickup GUI.
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _PickupExport PickupManager : public Singleton<PickupManager>, public OrxonoxClass
+ {
+ friend class Singleton<PickupManager>;
+
+ public:
+ PickupManager();
+ virtual ~PickupManager();
+
+ static PickupManager& getInstance() { return Singleton<PickupManager>::getInstance(); }
+
+ bool registerRepresentation(const PickupIdentifier* identifier, PickupRepresentation* representation); //!< Registers a PickupRepresentation together with the PickupIdentifier of the Pickupable the PickupRepresentation represents.
+ PickupRepresentation* getRepresentation(const PickupIdentifier* identifier); //!< Get the PickupRepresentation representing the Pickupable with the input PickupIdentifier.
+
+ //TODO: Delete or utilitze this.
+ //bool registerCarrier(Identifier* parent, )
+
+ private:
+ static PickupManager* singletonPtr_s;
+
+ PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
+ std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
+
+ //TODO: Delete or utilize this.
+ PickupCarrierNode* pickupCarrierStructure_;
+
+ };
+
+}
+
+#endif // _PickupManager_H__
Deleted: code/trunk/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupPrereqs.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupPrereqs.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -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:
- * 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 PICKUP_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 DroppedPickup;
- class Pickup;
- class PickupCollection;
- class PickupCollectionIdentifier;
- class PickupManager;
- class PickupRepresentation;
- class PickupSpawner;
-
- //items
- class HealthPickup;
- class MetaPickup;
-
-}
-
-#endif /* _PickupPrereqs_H__ */
Copied: code/trunk/src/modules/pickup/PickupPrereqs.h (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupPrereqs.h)
===================================================================
--- code/trunk/src/modules/pickup/PickupPrereqs.h (rev 0)
+++ code/trunk/src/modules/pickup/PickupPrereqs.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -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:
+ * 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 PICKUP_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 DroppedPickup;
+ class Pickup;
+ class PickupCollection;
+ class PickupCollectionIdentifier;
+ class PickupManager;
+ class PickupRepresentation;
+ class PickupSpawner;
+
+ //items
+ class HealthPickup;
+ class MetaPickup;
+
+}
+
+#endif /* _PickupPrereqs_H__ */
Deleted: code/trunk/src/modules/pickup/PickupRepresentation.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupRepresentation.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupRepresentation.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,170 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
-*/
-
-#include "PickupRepresentation.h"
-
-#include "core/CoreIncludes.h"
-#include "graphics/Billboard.h"
-#include "util/StringUtils.h"
-#include "PickupManager.h"
-
-namespace orxonox
-{
-
- CreateFactory(PickupRepresentation);
-
- /**
- @brief
- Constructor. Registers the object and initializes its member variables.
- This is primarily for use of the PickupManager in creating a default PickupRepresentation.
- */
- //TODO: Not this as creator!!!
- PickupRepresentation::PickupRepresentation() : BaseObject(this)
- {
- this->spawnerRepresentation_ = NULL;
-
- RegisterObject(PickupRepresentation);
-
- this->initialize();
- }
-
- /**
- @brief
- Default Constructor. Registers the object and initializes its member variables.
- */
- PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator)
- {
- this->spawnerRepresentation_ = NULL;
-
- RegisterObject(PickupRepresentation);
-
- this->initialize();
- }
-
- /**
- @brief
- Destructor.
- */
- PickupRepresentation::~PickupRepresentation()
- {
- if(this->spawnerRepresentation_ != NULL)
- this->spawnerRepresentation_->destroy();
- }
-
- /**
- @brief
- Initializes the member variables of this PickupRepresentation.
- */
- void PickupRepresentation::initialize(void)
- {
- this->description_ = "This is a pickup.";
- this->name_ = "Pickup";
- this->spawnerTemplate_ = "";
- this->pickup_ = NULL;
- }
-
- /**
- @brief
- Method for creating a PickupRepresentation object through XML.
- */
- void PickupRepresentation::XMLPort(Element& xmlelement, XMLPort::Mode mode)
- {
- SUPER(PickupRepresentation, XMLPort, xmlelement, mode);
-
- XMLPortParam(PickupRepresentation, "name", setName, getName, xmlelement, mode);
- XMLPortParam(PickupRepresentation, "description", setDescription, getDescription, xmlelement, mode);
- XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode);
- XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode);
- XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode);
-
- PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); //!< Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.
-
- if(this->spawnerRepresentation_ != NULL)
- this->spawnerRepresentation_->setVisible(false);
-
- COUT(4) << "PickupRepresentation created: name: '" << this->name_ << "', description: '" << this->description_ << "', spawnerTemplate: '" << this->spawnerTemplate_ << "'." << std::endl;
- }
-
- /**
- @brief
- Get a spawnerRepresentation for a specific PickupSpawner.
- @param spawner
- A pointer to the PickupSpawner.
- @return
- Returns a pointer to the StaticEntity.
- */
- StaticEntity* PickupRepresentation::getSpawnerRepresentation(PickupSpawner* spawner)
- {
- if(this->spawnerRepresentation_ == NULL)
- {
- COUT(4) << "PickupRepresentation: No spawner representation found." << std::endl;
- if(this->spawnerTemplate_ == BLANKSTRING)
- {
- COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl;
- //!< If neither spawnerRepresentation nor spawnerTemplate was specified
- return this->getDefaultSpawnerRepresentation(spawner);
- }
- this->addTemplate(this->spawnerTemplate_);
- }
-
- StaticEntity* representation = this->spawnerRepresentation_;
- representation->setVisible(true);
-
- this->addTemplate(this->spawnerTemplate_);
- this->spawnerRepresentation_->setVisible(false);
-
- return representation;
- }
-
- /**
- @brief
- Get the default spawnerRepresentation for a specific PickupSpawner.
- Helper method of internal use.
- @param spawner
- A pointer to the PickupSpawner.
- @return
- Returns a pointer to the StaticEntity.
- */
- //TODO: Think of more elegant solution.
- StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner)
- {
- StaticEntity* representation = new StaticEntity(spawner);
- Billboard* sphere = new Billboard(spawner);
- sphere->setColour(ColourValue(0.95, 0.85, 0.27));
- sphere->setMaterial("Sphere2");
- sphere->setScale(0.1);
- Billboard* icon = new Billboard(spawner);
- icon->setColour(ColourValue(0.89, 0.79, 0.08));
- icon->setMaterial("Asterix");
- icon->setScale(0.5);
- sphere->attach(icon);
- representation->attach(sphere);
- return representation;
- }
-
-}
Copied: code/trunk/src/modules/pickup/PickupRepresentation.cc (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupRepresentation.cc)
===================================================================
--- code/trunk/src/modules/pickup/PickupRepresentation.cc (rev 0)
+++ code/trunk/src/modules/pickup/PickupRepresentation.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,170 @@
+/*
+ * 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:
+ * ...
+ *
+*/
+
+#include "PickupRepresentation.h"
+
+#include "core/CoreIncludes.h"
+#include "graphics/Billboard.h"
+#include "util/StringUtils.h"
+#include "PickupManager.h"
+
+namespace orxonox
+{
+
+ CreateFactory(PickupRepresentation);
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes its member variables.
+ This is primarily for use of the PickupManager in creating a default PickupRepresentation.
+ */
+ //TODO: Not this as creator!!!
+ PickupRepresentation::PickupRepresentation() : BaseObject(this)
+ {
+ this->spawnerRepresentation_ = NULL;
+
+ RegisterObject(PickupRepresentation);
+
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Default Constructor. Registers the object and initializes its member variables.
+ */
+ PickupRepresentation::PickupRepresentation(BaseObject* creator) : BaseObject(creator)
+ {
+ this->spawnerRepresentation_ = NULL;
+
+ RegisterObject(PickupRepresentation);
+
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ PickupRepresentation::~PickupRepresentation()
+ {
+ if(this->spawnerRepresentation_ != NULL)
+ this->spawnerRepresentation_->destroy();
+ }
+
+ /**
+ @brief
+ Initializes the member variables of this PickupRepresentation.
+ */
+ void PickupRepresentation::initialize(void)
+ {
+ this->description_ = "This is a pickup.";
+ this->name_ = "Pickup";
+ this->spawnerTemplate_ = "";
+ this->pickup_ = NULL;
+ }
+
+ /**
+ @brief
+ Method for creating a PickupRepresentation object through XML.
+ */
+ void PickupRepresentation::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(PickupRepresentation, XMLPort, xmlelement, mode);
+
+ XMLPortParam(PickupRepresentation, "name", setName, getName, xmlelement, mode);
+ XMLPortParam(PickupRepresentation, "description", setDescription, getDescription, xmlelement, mode);
+ XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode);
+ XMLPortObject(PickupRepresentation, Pickupable, "pickup", setPickup, getPickup, xmlelement, mode);
+ XMLPortObject(PickupRepresentation, StaticEntity, "spawner-representation", setSpawnerRepresentation, getSpawnerRepresentationIndex, xmlelement, mode);
+
+ PickupManager::getInstance().registerRepresentation(this->pickup_->getPickupIdentifier(), this); //!< Registers the PickupRepresentation with the PickupManager through the PickupIdentifier of the Pickupable it represents.
+
+ if(this->spawnerRepresentation_ != NULL)
+ this->spawnerRepresentation_->setVisible(false);
+
+ COUT(4) << "PickupRepresentation created: name: '" << this->name_ << "', description: '" << this->description_ << "', spawnerTemplate: '" << this->spawnerTemplate_ << "'." << std::endl;
+ }
+
+ /**
+ @brief
+ Get a spawnerRepresentation for a specific PickupSpawner.
+ @param spawner
+ A pointer to the PickupSpawner.
+ @return
+ Returns a pointer to the StaticEntity.
+ */
+ StaticEntity* PickupRepresentation::getSpawnerRepresentation(PickupSpawner* spawner)
+ {
+ if(this->spawnerRepresentation_ == NULL)
+ {
+ COUT(4) << "PickupRepresentation: No spawner representation found." << std::endl;
+ if(this->spawnerTemplate_ == BLANKSTRING)
+ {
+ COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl;
+ //!< If neither spawnerRepresentation nor spawnerTemplate was specified
+ return this->getDefaultSpawnerRepresentation(spawner);
+ }
+ this->addTemplate(this->spawnerTemplate_);
+ }
+
+ StaticEntity* representation = this->spawnerRepresentation_;
+ representation->setVisible(true);
+
+ this->addTemplate(this->spawnerTemplate_);
+ this->spawnerRepresentation_->setVisible(false);
+
+ return representation;
+ }
+
+ /**
+ @brief
+ Get the default spawnerRepresentation for a specific PickupSpawner.
+ Helper method of internal use.
+ @param spawner
+ A pointer to the PickupSpawner.
+ @return
+ Returns a pointer to the StaticEntity.
+ */
+ //TODO: Think of more elegant solution.
+ StaticEntity* PickupRepresentation::getDefaultSpawnerRepresentation(PickupSpawner* spawner)
+ {
+ StaticEntity* representation = new StaticEntity(spawner);
+ Billboard* sphere = new Billboard(spawner);
+ sphere->setColour(ColourValue(0.95, 0.85, 0.27));
+ sphere->setMaterial("Sphere2");
+ sphere->setScale(0.1);
+ Billboard* icon = new Billboard(spawner);
+ icon->setColour(ColourValue(0.89, 0.79, 0.08));
+ icon->setMaterial("Asterix");
+ icon->setScale(0.5);
+ sphere->attach(icon);
+ representation->attach(sphere);
+ return representation;
+ }
+
+}
Deleted: code/trunk/src/modules/pickup/PickupRepresentation.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupRepresentation.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupRepresentation.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,143 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
-*/
-
-#ifndef _PickupRepresentation_H__
-#define _PickupRepresentation_H__
-
-#include "PickupPrereqs.h"
-
-#include "core/XMLPort.h"
-#include "interfaces/Pickupable.h"
-#include "pickup/PickupIdentifier.h"
-#include "worldentities/StaticEntity.h"
-#include "PickupSpawner.h"
-
-#include "core/BaseObject.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- The PickupRepresentation class represents a specific pickup type (identified by its PickupIdentifier). It defines the information displayed in the GUI and how PickupSpawners that spawn the pickup type look like.
- They are created through XML and are registered with the PickupManager.
- */
- class _PickupExport PickupRepresentation : public BaseObject
- {
-
- public:
- PickupRepresentation(); //!< Constructor
- PickupRepresentation(BaseObject* creator); //!< Default constructor.
- virtual ~PickupRepresentation(); //!< Destructor.
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-
- /**
- @brief Set the name of the Pickupable represented by this PickupRepresentation.
- @param name The name.
- */
- inline void setName(const std::string& name)
- { this->name_ = name; }
- /**
- @brief Set the description of the Pickupable represented by this PickupRepresentation.
- @param description The Description.
- */
- inline void setDescription(const std::string& description)
- { this->description_ = description; }
- /**
- @brief Set the spawnerTemplate of the Pickupable represented by this PickupRepresentation.
- The spawnerTemplate is a name of a template defined in XML that defines the StaticEntity that is the spawnerRepresentation of this PickupRepresentation.
- @param spawnerTemplate The name of the template.
- */
- inline void setSpawnerTemplate(const std::string& spawnerTemplate)
- { this->spawnerTemplate_ = spawnerTemplate; }
- /**
- @brief Set the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
- This will be set by the spawnerTemplate. Setting it when creating the PickupRepresentation without creating a template and specifying its name will be futile, because through the course of the game many PickupSpawners for one specific pickup type may have to be created, thus the StaticEntity that is the spawnerRepresentation has to be generated (with the template) for every new PickupSpawner spawning the Pickupable represented by this PickupRepresentation. The spawnerRepresentation that is set here, however can only be used once.
- @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation.
- */
- inline void setSpawnerRepresentation(StaticEntity* representation)
- { this->spawnerRepresentation_ = representation; }
- /**
- @brief Set the Pickupable that is represented by this PickupRepresentation.
- @param pickup A pointer to the Pickupable.
- */
- inline void setPickup(Pickupable* pickup)
- { this->pickup_ = pickup; }
-
- /**
- @brief Get the name of the Pickupable represented by this PickupRepresentation.
- @return Returns the name.
- */
- inline const std::string& getName(void)
- { return this->name_; }
- /**
- @brief Get the description of the Pickupable represented by this PickupRepresentation.
- @return Returns the description.
- */
- inline const std::string& getDescription(void)
- { return this->description_; }
- /**
- @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
- @return Returns the name of the spawnerTemplate.
- */
- inline const std::string& getSpawnerTemplate(void)
- { return this->spawnerTemplate_; }
- /**
- @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
- @param index The index.
- @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL.
- */
- inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index)
- { if(index == 0) return this->spawnerRepresentation_; return NULL; }
- /**
- @brief Get the Pickupable represented by this PickupRepresentation.
- @param index The index.
- @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL.
- */
- inline const Pickupable* getPickup(unsigned int index)
- { if(index == 0) return this->pickup_; return NULL; }
-
- StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner.
-
- private:
- void initialize(void); //!< Initializes the member variables of this PickupRepresentation.
- StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner.
-
- std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation.
- std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation.
- std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation.
- StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation.
-
- Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
-
- };
-
-}
-
-#endif // _PickupRepresentation_H__
Copied: code/trunk/src/modules/pickup/PickupRepresentation.h (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupRepresentation.h)
===================================================================
--- code/trunk/src/modules/pickup/PickupRepresentation.h (rev 0)
+++ code/trunk/src/modules/pickup/PickupRepresentation.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,143 @@
+/*
+ * 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 _PickupRepresentation_H__
+#define _PickupRepresentation_H__
+
+#include "PickupPrereqs.h"
+
+#include "core/XMLPort.h"
+#include "interfaces/Pickupable.h"
+#include "pickup/PickupIdentifier.h"
+#include "worldentities/StaticEntity.h"
+#include "PickupSpawner.h"
+
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The PickupRepresentation class represents a specific pickup type (identified by its PickupIdentifier). It defines the information displayed in the GUI and how PickupSpawners that spawn the pickup type look like.
+ They are created through XML and are registered with the PickupManager.
+ */
+ class _PickupExport PickupRepresentation : public BaseObject
+ {
+
+ public:
+ PickupRepresentation(); //!< Constructor
+ PickupRepresentation(BaseObject* creator); //!< Default constructor.
+ virtual ~PickupRepresentation(); //!< Destructor.
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+ /**
+ @brief Set the name of the Pickupable represented by this PickupRepresentation.
+ @param name The name.
+ */
+ inline void setName(const std::string& name)
+ { this->name_ = name; }
+ /**
+ @brief Set the description of the Pickupable represented by this PickupRepresentation.
+ @param description The Description.
+ */
+ inline void setDescription(const std::string& description)
+ { this->description_ = description; }
+ /**
+ @brief Set the spawnerTemplate of the Pickupable represented by this PickupRepresentation.
+ The spawnerTemplate is a name of a template defined in XML that defines the StaticEntity that is the spawnerRepresentation of this PickupRepresentation.
+ @param spawnerTemplate The name of the template.
+ */
+ inline void setSpawnerTemplate(const std::string& spawnerTemplate)
+ { this->spawnerTemplate_ = spawnerTemplate; }
+ /**
+ @brief Set the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
+ This will be set by the spawnerTemplate. Setting it when creating the PickupRepresentation without creating a template and specifying its name will be futile, because through the course of the game many PickupSpawners for one specific pickup type may have to be created, thus the StaticEntity that is the spawnerRepresentation has to be generated (with the template) for every new PickupSpawner spawning the Pickupable represented by this PickupRepresentation. The spawnerRepresentation that is set here, however can only be used once.
+ @param representation A pointer to the StaticEntity that is the spawnerRepresentation of this PickupRepresentation.
+ */
+ inline void setSpawnerRepresentation(StaticEntity* representation)
+ { this->spawnerRepresentation_ = representation; }
+ /**
+ @brief Set the Pickupable that is represented by this PickupRepresentation.
+ @param pickup A pointer to the Pickupable.
+ */
+ inline void setPickup(Pickupable* pickup)
+ { this->pickup_ = pickup; }
+
+ /**
+ @brief Get the name of the Pickupable represented by this PickupRepresentation.
+ @return Returns the name.
+ */
+ inline const std::string& getName(void)
+ { return this->name_; }
+ /**
+ @brief Get the description of the Pickupable represented by this PickupRepresentation.
+ @return Returns the description.
+ */
+ inline const std::string& getDescription(void)
+ { return this->description_; }
+ /**
+ @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
+ @return Returns the name of the spawnerTemplate.
+ */
+ inline const std::string& getSpawnerTemplate(void)
+ { return this->spawnerTemplate_; }
+ /**
+ @brief Get the StaticEntity that defines how the PickupSpawner of the Pickupable represented by this PickupRepresentation looks like.
+ @param index The index.
+ @return Returns (for index = 0) a pointer to the StaticEntity. For index > 0 it returns NULL.
+ */
+ inline const StaticEntity* getSpawnerRepresentationIndex(unsigned int index)
+ { if(index == 0) return this->spawnerRepresentation_; return NULL; }
+ /**
+ @brief Get the Pickupable represented by this PickupRepresentation.
+ @param index The index.
+ @return Returns (for index = 0) a pointer to the Pickupable. For index > 0 it returns NULL.
+ */
+ inline const Pickupable* getPickup(unsigned int index)
+ { if(index == 0) return this->pickup_; return NULL; }
+
+ StaticEntity* getSpawnerRepresentation(PickupSpawner* spawner); //!< Get a spawnerRepresentation for a specific PickupSpawner.
+
+ private:
+ void initialize(void); //!< Initializes the member variables of this PickupRepresentation.
+ StaticEntity* getDefaultSpawnerRepresentation(PickupSpawner* spawner); //!< Get the default spawnerRepresentation for a specific PickupSpawner.
+
+ std::string name_; //!< The name of the Pickupable represented by this PickupRepresentation.
+ std::string description_; //!< The description of the Pickupable represented by this PickupRepresentation.
+ std::string spawnerTemplate_; //!< The name of the template of this PickupRepresentation.
+ StaticEntity* spawnerRepresentation_; //!< The spawnerRepresentation of this PickupRepresentation.
+
+ Pickupable* pickup_; //!< The Pickupable that is represented by this PickupRepresentation.
+
+ };
+
+}
+
+#endif // _PickupRepresentation_H__
Deleted: code/trunk/src/modules/pickup/PickupSpawner.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupSpawner.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupSpawner.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,360 +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:
- * Damian 'Mozork' Frick
- *
- */
-
-/**
- @file
- @brief Implementation of PickupSpawner.
-*/
-
-#include "PickupSpawner.h"
-
-#include "core/CoreIncludes.h"
-#include "core/Template.h"
-#include "core/XMLPort.h"
-#include "worldentities/pawns/Pawn.h"
-#include "PickupManager.h"
-#include "PickupRepresentation.h"
-
-namespace orxonox
-{
-
- CreateFactory(PickupSpawner);
-
- /**
- @brief
- Constructor. Creates a blank PickupSpawner.
- @param creator
- Pointer to the object which created this item.
- */
- PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator)
- {
- this->initialize();
-
- RegisterObject(PickupSpawner);
- }
-
- /**
- @brief
- Constructor, Creates a fully functional PickupSpawner.
- @param creator
- The creator of this PickupSpawner.
- @param pickup
- The Pickupable to be spawned by this PickupSpawner.
- @param triggerDistance
- The distance at which the PickupSpawner will trigger.
- @param respawnTime
- The minimum time between two spawns.
- @param maySpawnedItems
- The maximum number of items spawned by this PickupSpawner.
- */
- PickupSpawner::PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems) : StaticEntity(creator)
- {
- RegisterObject(PickupSpawner);
-
- this->initialize();
-
- this->pickup_ = pickup;
-
- this->triggerDistance_ = triggerDistance;
- this->respawnTime_ = respawnTime;
- this->setMaxSpawnedItems(maxSpawnedItems);
-
- if(this->pickup_ == NULL)
- {
- COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl;
- this->setActive(false);
- }
- else
- {
- PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
- this->attach(representation->getSpawnerRepresentation(this));
- }
- }
-
- /**
- @brief
- Registers the object and sets some default values.
- */
- void PickupSpawner::initialize(void)
- {
- this->pickup_ = NULL;
-
- this->triggerDistance_ = 20;
- this->respawnTime_ = 0;
- this->maxSpawnedItems_ = INF;
- this->spawnsRemaining_ = INF;
- }
-
- /**
- @brief
- Destructor.
- */
- PickupSpawner::~PickupSpawner()
- {
- if(this->pickup_ != NULL)
- this->pickup_->destroy();
- }
-
- /**
- @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", setPickupable, getPickupable, xmlelement, mode);
-
- XMLPortParam(PickupSpawner, "triggerDistance", setTriggerDistance, getTriggerDistance, xmlelement, mode);
- XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode);
- XMLPortParam(PickupSpawner, "maxSpawnedItems", setMaxSpawnedItems, getMaxSpawnedItems, xmlelement, mode);
-
- if(this->pickup_ == NULL)
- {
- COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl;
- this->setActive(false);
- }
- else
- {
- PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
- representation->setVisible(this->isActive());
- this->attach(representation->getSpawnerRepresentation(this));
- this->setActive(true);
- }
- }
-
- /**
- @brief
- Invoked when the activity has changed. Sets visibility of attached objects.
- */
- void PickupSpawner::changedActivity()
- {
- SUPER(PickupSpawner, changedActivity);
-
- this->setVisible(this->isActive());
- }
-
- /**
- @brief
- Tick, checks if any Pawn is close enough to trigger.
- @param dt
- Time since last tick.
- */
- //TODO: Replace this with a real DistanceTrigger? Or better with collisions?
- 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);
- }
- }
- }
- }
-
- /**
- @brief
- Sets the maximum number of spawned items.
- @param items
- The maximum number of spawned items to be set.
- */
- void PickupSpawner::setMaxSpawnedItems(int items)
- {
- this->maxSpawnedItems_ = items;
- this->spawnsRemaining_ = items;
- }
-
- /**
- @brief
- Decrements the number of remaining spawns.
- Sets the PickupSpawner to inactive for the duration of the respawnTime.
- Destroys the PickupSpawner if the number of remaining spawns has reached zero.
- */
- void PickupSpawner::decrementSpawnsRemaining(void)
- {
- if(this->spawnsRemaining_ != INF)
- {
- this->spawnsRemaining_--;
- }
- if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)
- {
- //TODO: Nicer? Does this even work?
- this->startRespawnTimer();
-
- this->setActive(false);
- this->fireEvent();
- }
- else
- {
- COUT(3) << "PickupSpawner empty, selfdestruct initialized." << std::endl;
- this->setActive(false);
- this->destroy();
- }
- }
-
- /**
- @brief
- Starts the respawn timer.
- */
- void PickupSpawner::startRespawnTimer(void)
- {
- this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
- }
-
- /**
- @brief
- Sets a Pickupable for the PickupSpawner to spawn.
- @param pickup
- The Pickupable to be set.
- */
- void PickupSpawner::setPickupable(Pickupable* pickup)
- {
- if(this->pickup_ != NULL)
- {
- COUT(1) << "In PickupSpawner: setPickupable called, with this->pickup_ already set." << std::endl;
- return;
- }
- if(pickup == NULL)
- {
- COUT(1) << "In PickupSpawner: Argument of setPickupable is NULL." << std::endl;
- return;
- }
-
- this->pickup_ = pickup;
- }
-
- /**
- @brief
- Get the Pickupable that is spawned by this PickupSpawner.
- @return
- Returns the Pickupable that is spawned by this PickupSpawner.
- */
- const Pickupable* PickupSpawner::getPickupable(void)
- {
- return this->pickup_;
- }
-
- /**
- @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.
- */
- //TODO: Make more generic -> without pawn.
- void PickupSpawner::trigger(Pawn* pawn)
- {
- if (this->isActive()) //!< Checks whether PickupSpawner is active.
- {
- COUT(3) << "PickupSpawner triggered and active." << std::endl;
-
- PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn);
- if(carrier == NULL)
- {
- COUT(1) << "This is bad. Pawn isn't PickupCarrier." << std::endl;
- return;
- }
-
- if(!carrier->isTarget(this->pickup_))
- {
- COUT(4) << "PickupSpawner triggered but Pawn wasn't a target of the Pickupable." << std::endl;
- return;
- }
-
- PickupCarrier* target = carrier->getTarget(this->pickup_);
- Pickupable* pickup = this->getPickup();
-
- if(target != NULL && pickup != NULL)
- {
- if(target->pickup(pickup))
- {
- this->decrementSpawnsRemaining();
- }
- else
- {
- pickup->destroy();
- }
- }
- else
- {
- //TODO: Really that severe?
- if(target == NULL)
- COUT(1) << "PickupSpawner: Pickupable has no target." << std::endl;
-
- if(pickup == NULL)
- {
- COUT(1) << "PickupSpawner: getPickup produced an error, no Pickupable created." << std::endl;
- }
- else
- {
- pickup->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/trunk/src/modules/pickup/PickupSpawner.cc (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupSpawner.cc)
===================================================================
--- code/trunk/src/modules/pickup/PickupSpawner.cc (rev 0)
+++ code/trunk/src/modules/pickup/PickupSpawner.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,360 @@
+/*
+ * 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/Template.h"
+#include "core/XMLPort.h"
+#include "worldentities/pawns/Pawn.h"
+#include "PickupManager.h"
+#include "PickupRepresentation.h"
+
+namespace orxonox
+{
+
+ CreateFactory(PickupSpawner);
+
+ /**
+ @brief
+ Constructor. Creates a blank PickupSpawner.
+ @param creator
+ Pointer to the object which created this item.
+ */
+ PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator)
+ {
+ this->initialize();
+
+ RegisterObject(PickupSpawner);
+ }
+
+ /**
+ @brief
+ Constructor, Creates a fully functional PickupSpawner.
+ @param creator
+ The creator of this PickupSpawner.
+ @param pickup
+ The Pickupable to be spawned by this PickupSpawner.
+ @param triggerDistance
+ The distance at which the PickupSpawner will trigger.
+ @param respawnTime
+ The minimum time between two spawns.
+ @param maySpawnedItems
+ The maximum number of items spawned by this PickupSpawner.
+ */
+ PickupSpawner::PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems) : StaticEntity(creator)
+ {
+ RegisterObject(PickupSpawner);
+
+ this->initialize();
+
+ this->pickup_ = pickup;
+
+ this->triggerDistance_ = triggerDistance;
+ this->respawnTime_ = respawnTime;
+ this->setMaxSpawnedItems(maxSpawnedItems);
+
+ if(this->pickup_ == NULL)
+ {
+ COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl;
+ this->setActive(false);
+ }
+ else
+ {
+ PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
+ this->attach(representation->getSpawnerRepresentation(this));
+ }
+ }
+
+ /**
+ @brief
+ Registers the object and sets some default values.
+ */
+ void PickupSpawner::initialize(void)
+ {
+ this->pickup_ = NULL;
+
+ this->triggerDistance_ = 20;
+ this->respawnTime_ = 0;
+ this->maxSpawnedItems_ = INF;
+ this->spawnsRemaining_ = INF;
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ PickupSpawner::~PickupSpawner()
+ {
+ if(this->pickup_ != NULL)
+ this->pickup_->destroy();
+ }
+
+ /**
+ @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", setPickupable, getPickupable, xmlelement, mode);
+
+ XMLPortParam(PickupSpawner, "triggerDistance", setTriggerDistance, getTriggerDistance, xmlelement, mode);
+ XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode);
+ XMLPortParam(PickupSpawner, "maxSpawnedItems", setMaxSpawnedItems, getMaxSpawnedItems, xmlelement, mode);
+
+ if(this->pickup_ == NULL)
+ {
+ COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl;
+ this->setActive(false);
+ }
+ else
+ {
+ PickupRepresentation* representation = PickupManager::getInstance().getRepresentation(this->pickup_->getPickupIdentifier());
+ representation->setVisible(this->isActive());
+ this->attach(representation->getSpawnerRepresentation(this));
+ this->setActive(true);
+ }
+ }
+
+ /**
+ @brief
+ Invoked when the activity has changed. Sets visibility of attached objects.
+ */
+ void PickupSpawner::changedActivity()
+ {
+ SUPER(PickupSpawner, changedActivity);
+
+ this->setVisible(this->isActive());
+ }
+
+ /**
+ @brief
+ Tick, checks if any Pawn is close enough to trigger.
+ @param dt
+ Time since last tick.
+ */
+ //TODO: Replace this with a real DistanceTrigger? Or better with collisions?
+ 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);
+ }
+ }
+ }
+ }
+
+ /**
+ @brief
+ Sets the maximum number of spawned items.
+ @param items
+ The maximum number of spawned items to be set.
+ */
+ void PickupSpawner::setMaxSpawnedItems(int items)
+ {
+ this->maxSpawnedItems_ = items;
+ this->spawnsRemaining_ = items;
+ }
+
+ /**
+ @brief
+ Decrements the number of remaining spawns.
+ Sets the PickupSpawner to inactive for the duration of the respawnTime.
+ Destroys the PickupSpawner if the number of remaining spawns has reached zero.
+ */
+ void PickupSpawner::decrementSpawnsRemaining(void)
+ {
+ if(this->spawnsRemaining_ != INF)
+ {
+ this->spawnsRemaining_--;
+ }
+ if(this->spawnsRemaining_ != 0 && this->respawnTime_ > 0)
+ {
+ //TODO: Nicer? Does this even work?
+ this->startRespawnTimer();
+
+ this->setActive(false);
+ this->fireEvent();
+ }
+ else
+ {
+ COUT(3) << "PickupSpawner empty, selfdestruct initialized." << std::endl;
+ this->setActive(false);
+ this->destroy();
+ }
+ }
+
+ /**
+ @brief
+ Starts the respawn timer.
+ */
+ void PickupSpawner::startRespawnTimer(void)
+ {
+ this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
+ }
+
+ /**
+ @brief
+ Sets a Pickupable for the PickupSpawner to spawn.
+ @param pickup
+ The Pickupable to be set.
+ */
+ void PickupSpawner::setPickupable(Pickupable* pickup)
+ {
+ if(this->pickup_ != NULL)
+ {
+ COUT(1) << "In PickupSpawner: setPickupable called, with this->pickup_ already set." << std::endl;
+ return;
+ }
+ if(pickup == NULL)
+ {
+ COUT(1) << "In PickupSpawner: Argument of setPickupable is NULL." << std::endl;
+ return;
+ }
+
+ this->pickup_ = pickup;
+ }
+
+ /**
+ @brief
+ Get the Pickupable that is spawned by this PickupSpawner.
+ @return
+ Returns the Pickupable that is spawned by this PickupSpawner.
+ */
+ const Pickupable* PickupSpawner::getPickupable(void)
+ {
+ return this->pickup_;
+ }
+
+ /**
+ @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.
+ */
+ //TODO: Make more generic -> without pawn.
+ void PickupSpawner::trigger(Pawn* pawn)
+ {
+ if (this->isActive()) //!< Checks whether PickupSpawner is active.
+ {
+ COUT(3) << "PickupSpawner triggered and active." << std::endl;
+
+ PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn);
+ if(carrier == NULL)
+ {
+ COUT(1) << "This is bad. Pawn isn't PickupCarrier." << std::endl;
+ return;
+ }
+
+ if(!carrier->isTarget(this->pickup_))
+ {
+ COUT(4) << "PickupSpawner triggered but Pawn wasn't a target of the Pickupable." << std::endl;
+ return;
+ }
+
+ PickupCarrier* target = carrier->getTarget(this->pickup_);
+ Pickupable* pickup = this->getPickup();
+
+ if(target != NULL && pickup != NULL)
+ {
+ if(target->pickup(pickup))
+ {
+ this->decrementSpawnsRemaining();
+ }
+ else
+ {
+ pickup->destroy();
+ }
+ }
+ else
+ {
+ //TODO: Really that severe?
+ if(target == NULL)
+ COUT(1) << "PickupSpawner: Pickupable has no target." << std::endl;
+
+ if(pickup == NULL)
+ {
+ COUT(1) << "PickupSpawner: getPickup produced an error, no Pickupable created." << std::endl;
+ }
+ else
+ {
+ pickup->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);
+ }
+}
Deleted: code/trunk/src/modules/pickup/PickupSpawner.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupSpawner.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/PickupSpawner.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,131 +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:
- * Damian 'Mozork' Frick
- *
- */
-
-/**
- @file
- @brief Definition of PickupSpawner.
-*/
-
-#ifndef _PickupSpawner_H__
-#define _PickupSpawner_H__
-
-#include "PickupPrereqs.h"
-
-#include <string>
-#include "interfaces/Pickupable.h"
-#include "tools/Timer.h"
-
-#include "tools/interfaces/Tickable.h"
-#include "worldentities/StaticEntity.h"
-
-namespace orxonox
-{
- /**
- @brief
- The PickupSpawner class is responsible for spawning pickups of a specific type.
- Forthermore it can be specified how long the time interval between spawning two items is and how many pickups are spawned at maximum, amongst other things.
- @author
- Daniel 'Huty' Haggenmueller
- Damian 'Mozork' Frick
- */
- class _PickupExport PickupSpawner : public StaticEntity, public Tickable
- {
- public:
- PickupSpawner(BaseObject* creator); //!< Default Constructor.
- PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems); //!< Constructor.
- virtual ~PickupSpawner(); //!< Destructor.
-
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML.
- virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).
- 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; }
-
- /**
- @brief Get the maximum number of items that will be spawned by this PickupSpawner.
- @return Returns the maximum number of items spawned by this PickupSpawner.
- */
- inline int getMaxSpawnedItems(void)
- { return this->maxSpawnedItems_; }
- void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items.
-
- protected:
- void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns.
-
- void startRespawnTimer(void);
-
- virtual Pickupable* getPickup(void); //!< Creates a new Pickupable.
-
- void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn.
- const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner.
-
- Pickupable* pickup_; //!< The pickup to be spawned.
-
- 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.
-
- 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.
-
- 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__ */
Copied: code/trunk/src/modules/pickup/PickupSpawner.h (from rev 6523, code/branches/pickup3/src/modules/pickup/PickupSpawner.h)
===================================================================
--- code/trunk/src/modules/pickup/PickupSpawner.h (rev 0)
+++ code/trunk/src/modules/pickup/PickupSpawner.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,131 @@
+/*
+ * 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 Definition of PickupSpawner.
+*/
+
+#ifndef _PickupSpawner_H__
+#define _PickupSpawner_H__
+
+#include "PickupPrereqs.h"
+
+#include <string>
+#include "interfaces/Pickupable.h"
+#include "tools/Timer.h"
+
+#include "tools/interfaces/Tickable.h"
+#include "worldentities/StaticEntity.h"
+
+namespace orxonox
+{
+ /**
+ @brief
+ The PickupSpawner class is responsible for spawning pickups of a specific type.
+ Forthermore it can be specified how long the time interval between spawning two items is and how many pickups are spawned at maximum, amongst other things.
+ @author
+ Daniel 'Huty' Haggenmueller
+ Damian 'Mozork' Frick
+ */
+ class _PickupExport PickupSpawner : public StaticEntity, public Tickable
+ {
+ public:
+ PickupSpawner(BaseObject* creator); //!< Default Constructor.
+ PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems); //!< Constructor.
+ virtual ~PickupSpawner(); //!< Destructor.
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML.
+ virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).
+ 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; }
+
+ /**
+ @brief Get the maximum number of items that will be spawned by this PickupSpawner.
+ @return Returns the maximum number of items spawned by this PickupSpawner.
+ */
+ inline int getMaxSpawnedItems(void)
+ { return this->maxSpawnedItems_; }
+ void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items.
+
+ protected:
+ void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns.
+
+ void startRespawnTimer(void);
+
+ virtual Pickupable* getPickup(void); //!< Creates a new Pickupable.
+
+ void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn.
+ const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner.
+
+ Pickupable* pickup_; //!< The pickup to be spawned.
+
+ 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.
+
+ 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.
+
+ 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__ */
Deleted: code/trunk/src/modules/pickup/items/CMakeLists.txt
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/CMakeLists.txt 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/items/CMakeLists.txt 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,4 +0,0 @@
-ADD_SOURCE_FILES(PICKUP_SRC_FILES
- HealthPickup.cc
- MetaPickup.cc
-)
Copied: code/trunk/src/modules/pickup/items/CMakeLists.txt (from rev 6523, code/branches/pickup3/src/modules/pickup/items/CMakeLists.txt)
===================================================================
--- code/trunk/src/modules/pickup/items/CMakeLists.txt (rev 0)
+++ code/trunk/src/modules/pickup/items/CMakeLists.txt 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,4 @@
+ADD_SOURCE_FILES(PICKUP_SRC_FILES
+ HealthPickup.cc
+ MetaPickup.cc
+)
Deleted: code/trunk/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/items/HealthPickup.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,382 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-#include "HealthPickup.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "util/StringUtils.h"
-
-#include "worldentities/pawns/Pawn.h"
-#include "pickup/PickupIdentifier.h"
-
-#include <sstream>
-
-namespace orxonox
-{
-
- /*static*/ const std::string HealthPickup::healthTypeLimited_s = "limited";
- /*static*/ const std::string HealthPickup::healthTypeTemporary_s = "temporary";
- /*static*/ const std::string HealthPickup::healthTypePermanent_s = "permanent";
-
- CreateFactory(HealthPickup);
-
- /**
- @brief
- Constructor. Registers the object and initializes the member variables.
- */
- HealthPickup::HealthPickup(BaseObject* creator) : Pickup(creator)
- {
- RegisterObject(HealthPickup);
-
- this->initialize();
- }
-
- /**
- @brief
- Destructor.
- */
- HealthPickup::~HealthPickup()
- {
-
- }
-
- /**
- @brief
- Initializes the member variables.
- */
- void HealthPickup::initialize(void)
- {
- this->health_ = 0;
- this->healthRate_ = 0;
- this->healthType_ = pickupHealthType::limited;
- this->maxHealthSave_ = 0;
- this->maxHealthOverwrite_ = 0;
-
- this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
- }
-
- /**
- @brief
- Initializes the PickupIdentifier of this pickup.
- */
- void HealthPickup::initializeIdentifier(void)
- {
- std::stringstream stream;
- stream << this->getHealth();
- std::string type1 = "health";
- std::string val1 = stream.str();
- this->pickupIdentifier_->addParameter(type1, val1);
-
- //TODO: Does this work, is val valid outside the function scope?
- std::string val2 = this->getHealthType();
- std::string type2 = "healthType";
- this->pickupIdentifier_->addParameter(type2, val2);
-
- stream.clear();
- stream << this->getHealthRate();
- std::string val3 = stream.str();
- std::string type3 = "healthRate";
- this->pickupIdentifier_->addParameter(type3, val3);
- }
-
- /**
- @brief
- Method for creating a HealthPickup object through XML.
- */
- void HealthPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
- {
- SUPER(HealthPickup, XMLPort, xmlelement, mode);
-
- XMLPortParam(HealthPickup, "health", setHealth, getHealth, xmlelement, mode);
- XMLPortParam(HealthPickup, "healthRate", setHealthRate, getHealthRate, xmlelement, mode);
- XMLPortParam(HealthPickup, "healthType", setHealthType, getHealthType, xmlelement, mode);
-
- if(!this->isContinuous())
- this->healthRate_ = 0.0;
-
- this->initializeIdentifier();
- }
-
- /**
- @brief
- Is called every tick.
- Does all the continuous stuff of this HealthPickup.
- @param dt
- The duration of the last tick.
- */
- void HealthPickup::tick(float dt)
- {
- if(this->isContinuous() && this->isUsed())
- {
- Pawn* pawn = this->carrierToPawnHelper();
- if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
- this->destroy();
-
- //! Calculate the health that is added this tick.
- float health = dt*this->getHealthRate();
- if(health > this->getHealth())
- health = this->getHealth();
- //! Calculate the health the Pawn will have once the health is added.
- float fullHealth = pawn->getHealth() + health;
- this->setHealth(this->getHealth()-health);
-
- switch(this->getHealthTypeDirect())
- {
- case pickupHealthType::permanent:
- if(pawn->getMaxHealth() < fullHealth)
- pawn->setMaxHealth(fullHealth);
- case pickupHealthType::limited:
- pawn->addHealth(health);
- break;
- case pickupHealthType::temporary:
- if(pawn->getMaxHealth() > fullHealth)
- {
- this->maxHealthSave_ = pawn->getMaxHealth();
- this->maxHealthOverwrite_ = fullHealth;
- pawn->setMaxHealth(fullHealth);
- }
- pawn->addHealth(health);
- break;
- default:
- COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
- }
-
- //! If all health has been transfered.
- if(this->getHealth() == 0)
- {
- this->setUsed(false);
- }
- }
- }
-
- /**
- @brief
- Is called when the pickup has transited from used to unused or the other way around.
- */
- void HealthPickup::changedUsed(void)
- {
- SUPER(HealthPickup, changedUsed);
-
- //! If the pickup is not picked up nothing must be done.
- if(!this->isPickedUp())
- return;
-
- //! If the pickup has transited to used.
- if(this->isUsed())
- {
- if(this->isOnce())
- {
- Pawn* pawn = this->carrierToPawnHelper();
- if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
- this->destroy();
-
- float health = 0;
- switch(this->getHealthTypeDirect())
- {
- case pickupHealthType::permanent:
- health = pawn->getHealth()+this->getHealth();
- if(pawn->getMaxHealth() < health)
- pawn->setMaxHealth(health);
- case pickupHealthType::limited:
- pawn->addHealth(this->getHealth());
- break;
- case pickupHealthType::temporary:
- health = pawn->getHealth()+this->getHealth();
- if(pawn->getMaxHealth() < health)
- {
- this->maxHealthSave_ = pawn->getMaxHealth();
- this->maxHealthOverwrite_ = health;
- pawn->setMaxHealth(health);
- }
- pawn->addHealth(this->getHealth());
- break;
- default:
- COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
- }
-
- //! The pickup has been used up.
- this->setUsed(false);
- }
- }
- else
- {
- if(this->getHealthTypeDirect() == pickupHealthType::temporary)
- {
- PickupCarrier* carrier = this->getCarrier();
- Pawn* pawn = dynamic_cast<Pawn*>(carrier);
-
- if(pawn == NULL)
- {
- COUT(1) << "Something went horribly wrong in Health Pickup. PickupCarrier is no Pawn." << std::endl;
- this->destroy();
- return;
- }
-
- if(pawn->getMaxHealth() == this->maxHealthOverwrite_)
- {
- pawn->setMaxHealth(this->maxHealthSave_);
- this->maxHealthOverwrite_ = 0;
- this->maxHealthSave_ = 0;
- }
- }
-
- //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
- if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0))
- {
- this->destroy();
- }
- }
- }
-
- /**
- @brief
- Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
- @return
- A pointer to the Pawn, or NULL if the conversion failed.
- */
- Pawn* HealthPickup::carrierToPawnHelper(void)
- {
- PickupCarrier* carrier = this->getCarrier();
- Pawn* pawn = dynamic_cast<Pawn*>(carrier);
-
- if(pawn == NULL)
- {
- COUT(1) << "Invalid PickupCarrier in HealthPickup." << std::endl;
- }
-
- return pawn;
- }
-
- /**
- @brief
- Creates a duplicate of the input OrxonoxClass.
- @param item
- A pointer to the Orxonox class.
- */
- void HealthPickup::clone(OrxonoxClass*& item)
- {
- if(item == NULL)
- item = new HealthPickup(this);
-
- SUPER(HealthPickup, clone, item);
-
- HealthPickup* pickup = dynamic_cast<HealthPickup*>(item);
- pickup->setHealth(this->getHealth());
- pickup->setHealthRate(this->getHealthRate());
- pickup->setHealthTypeDirect(this->getHealthTypeDirect());
-
- pickup->initializeIdentifier();
- }
-
- /**
- @brief
- Get the health type of this pickup.
- @return
- Returns the health type as a string.
- */
- const std::string& HealthPickup::getHealthType(void)
- {
- switch(this->getHealthTypeDirect())
- {
- case pickupHealthType::limited:
- return HealthPickup::healthTypeLimited_s;
- case pickupHealthType::temporary:
- return HealthPickup::healthTypeTemporary_s;
- case pickupHealthType::permanent:
- return HealthPickup::healthTypePermanent_s;
- default:
- COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
- return BLANKSTRING;
- }
- }
-
- /**
- @brief
- Sets the health.
- @param health
- The health.
- */
- void HealthPickup::setHealth(float health)
- {
- if(health >= 0.0f)
- {
- this->health_ = health;
- }
- else
- {
- COUT(1) << "Invalid health in HealthPickup." << std::endl;
- this->health_ = 0.0;
- }
- }
-
- /**
- @brief
- Set the rate at which health is transferred if the pickup is continuous.
- @param rate
- The rate.
- */
- void HealthPickup::setHealthRate(float rate)
- {
- if(rate >= 0)
- {
- this->healthRate_ = rate;
- }
- else
- {
- COUT(1) << "Invalid healthSpeed in HealthPickup." << std::endl;
- }
- }
-
- /**
- @brief
- Set the type of the HealthPickup.
- @param type
- The type as a string.
- */
- void HealthPickup::setHealthType(std::string type)
- {
- if(type == HealthPickup::healthTypeLimited_s)
- {
- this->setHealthTypeDirect(pickupHealthType::limited);
- }
- else if(type == HealthPickup::healthTypeTemporary_s)
- {
- this->setHealthTypeDirect(pickupHealthType::temporary);
- }
- else if(type == HealthPickup::healthTypePermanent_s)
- {
- this->setHealthTypeDirect(pickupHealthType::permanent);
- }
- else
- {
- COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
- }
- }
-
-}
Copied: code/trunk/src/modules/pickup/items/HealthPickup.cc (from rev 6523, code/branches/pickup3/src/modules/pickup/items/HealthPickup.cc)
===================================================================
--- code/trunk/src/modules/pickup/items/HealthPickup.cc (rev 0)
+++ code/trunk/src/modules/pickup/items/HealthPickup.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,382 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#include "HealthPickup.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/StringUtils.h"
+
+#include "worldentities/pawns/Pawn.h"
+#include "pickup/PickupIdentifier.h"
+
+#include <sstream>
+
+namespace orxonox
+{
+
+ /*static*/ const std::string HealthPickup::healthTypeLimited_s = "limited";
+ /*static*/ const std::string HealthPickup::healthTypeTemporary_s = "temporary";
+ /*static*/ const std::string HealthPickup::healthTypePermanent_s = "permanent";
+
+ CreateFactory(HealthPickup);
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes the member variables.
+ */
+ HealthPickup::HealthPickup(BaseObject* creator) : Pickup(creator)
+ {
+ RegisterObject(HealthPickup);
+
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ HealthPickup::~HealthPickup()
+ {
+
+ }
+
+ /**
+ @brief
+ Initializes the member variables.
+ */
+ void HealthPickup::initialize(void)
+ {
+ this->health_ = 0;
+ this->healthRate_ = 0;
+ this->healthType_ = pickupHealthType::limited;
+ this->maxHealthSave_ = 0;
+ this->maxHealthOverwrite_ = 0;
+
+ this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
+ }
+
+ /**
+ @brief
+ Initializes the PickupIdentifier of this pickup.
+ */
+ void HealthPickup::initializeIdentifier(void)
+ {
+ std::stringstream stream;
+ stream << this->getHealth();
+ std::string type1 = "health";
+ std::string val1 = stream.str();
+ this->pickupIdentifier_->addParameter(type1, val1);
+
+ //TODO: Does this work, is val valid outside the function scope?
+ std::string val2 = this->getHealthType();
+ std::string type2 = "healthType";
+ this->pickupIdentifier_->addParameter(type2, val2);
+
+ stream.clear();
+ stream << this->getHealthRate();
+ std::string val3 = stream.str();
+ std::string type3 = "healthRate";
+ this->pickupIdentifier_->addParameter(type3, val3);
+ }
+
+ /**
+ @brief
+ Method for creating a HealthPickup object through XML.
+ */
+ void HealthPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
+ {
+ SUPER(HealthPickup, XMLPort, xmlelement, mode);
+
+ XMLPortParam(HealthPickup, "health", setHealth, getHealth, xmlelement, mode);
+ XMLPortParam(HealthPickup, "healthRate", setHealthRate, getHealthRate, xmlelement, mode);
+ XMLPortParam(HealthPickup, "healthType", setHealthType, getHealthType, xmlelement, mode);
+
+ if(!this->isContinuous())
+ this->healthRate_ = 0.0;
+
+ this->initializeIdentifier();
+ }
+
+ /**
+ @brief
+ Is called every tick.
+ Does all the continuous stuff of this HealthPickup.
+ @param dt
+ The duration of the last tick.
+ */
+ void HealthPickup::tick(float dt)
+ {
+ if(this->isContinuous() && this->isUsed())
+ {
+ Pawn* pawn = this->carrierToPawnHelper();
+ if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ this->destroy();
+
+ //! Calculate the health that is added this tick.
+ float health = dt*this->getHealthRate();
+ if(health > this->getHealth())
+ health = this->getHealth();
+ //! Calculate the health the Pawn will have once the health is added.
+ float fullHealth = pawn->getHealth() + health;
+ this->setHealth(this->getHealth()-health);
+
+ switch(this->getHealthTypeDirect())
+ {
+ case pickupHealthType::permanent:
+ if(pawn->getMaxHealth() < fullHealth)
+ pawn->setMaxHealth(fullHealth);
+ case pickupHealthType::limited:
+ pawn->addHealth(health);
+ break;
+ case pickupHealthType::temporary:
+ if(pawn->getMaxHealth() > fullHealth)
+ {
+ this->maxHealthSave_ = pawn->getMaxHealth();
+ this->maxHealthOverwrite_ = fullHealth;
+ pawn->setMaxHealth(fullHealth);
+ }
+ pawn->addHealth(health);
+ break;
+ default:
+ COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
+ }
+
+ //! If all health has been transfered.
+ if(this->getHealth() == 0)
+ {
+ this->setUsed(false);
+ }
+ }
+ }
+
+ /**
+ @brief
+ Is called when the pickup has transited from used to unused or the other way around.
+ */
+ void HealthPickup::changedUsed(void)
+ {
+ SUPER(HealthPickup, changedUsed);
+
+ //! If the pickup is not picked up nothing must be done.
+ if(!this->isPickedUp())
+ return;
+
+ //! If the pickup has transited to used.
+ if(this->isUsed())
+ {
+ if(this->isOnce())
+ {
+ Pawn* pawn = this->carrierToPawnHelper();
+ if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ this->destroy();
+
+ float health = 0;
+ switch(this->getHealthTypeDirect())
+ {
+ case pickupHealthType::permanent:
+ health = pawn->getHealth()+this->getHealth();
+ if(pawn->getMaxHealth() < health)
+ pawn->setMaxHealth(health);
+ case pickupHealthType::limited:
+ pawn->addHealth(this->getHealth());
+ break;
+ case pickupHealthType::temporary:
+ health = pawn->getHealth()+this->getHealth();
+ if(pawn->getMaxHealth() < health)
+ {
+ this->maxHealthSave_ = pawn->getMaxHealth();
+ this->maxHealthOverwrite_ = health;
+ pawn->setMaxHealth(health);
+ }
+ pawn->addHealth(this->getHealth());
+ break;
+ default:
+ COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
+ }
+
+ //! The pickup has been used up.
+ this->setUsed(false);
+ }
+ }
+ else
+ {
+ if(this->getHealthTypeDirect() == pickupHealthType::temporary)
+ {
+ PickupCarrier* carrier = this->getCarrier();
+ Pawn* pawn = dynamic_cast<Pawn*>(carrier);
+
+ if(pawn == NULL)
+ {
+ COUT(1) << "Something went horribly wrong in Health Pickup. PickupCarrier is no Pawn." << std::endl;
+ this->destroy();
+ return;
+ }
+
+ if(pawn->getMaxHealth() == this->maxHealthOverwrite_)
+ {
+ pawn->setMaxHealth(this->maxHealthSave_);
+ this->maxHealthOverwrite_ = 0;
+ this->maxHealthSave_ = 0;
+ }
+ }
+
+ //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
+ if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0))
+ {
+ this->destroy();
+ }
+ }
+ }
+
+ /**
+ @brief
+ Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+ @return
+ A pointer to the Pawn, or NULL if the conversion failed.
+ */
+ Pawn* HealthPickup::carrierToPawnHelper(void)
+ {
+ PickupCarrier* carrier = this->getCarrier();
+ Pawn* pawn = dynamic_cast<Pawn*>(carrier);
+
+ if(pawn == NULL)
+ {
+ COUT(1) << "Invalid PickupCarrier in HealthPickup." << std::endl;
+ }
+
+ return pawn;
+ }
+
+ /**
+ @brief
+ Creates a duplicate of the input OrxonoxClass.
+ @param item
+ A pointer to the Orxonox class.
+ */
+ void HealthPickup::clone(OrxonoxClass*& item)
+ {
+ if(item == NULL)
+ item = new HealthPickup(this);
+
+ SUPER(HealthPickup, clone, item);
+
+ HealthPickup* pickup = dynamic_cast<HealthPickup*>(item);
+ pickup->setHealth(this->getHealth());
+ pickup->setHealthRate(this->getHealthRate());
+ pickup->setHealthTypeDirect(this->getHealthTypeDirect());
+
+ pickup->initializeIdentifier();
+ }
+
+ /**
+ @brief
+ Get the health type of this pickup.
+ @return
+ Returns the health type as a string.
+ */
+ const std::string& HealthPickup::getHealthType(void)
+ {
+ switch(this->getHealthTypeDirect())
+ {
+ case pickupHealthType::limited:
+ return HealthPickup::healthTypeLimited_s;
+ case pickupHealthType::temporary:
+ return HealthPickup::healthTypeTemporary_s;
+ case pickupHealthType::permanent:
+ return HealthPickup::healthTypePermanent_s;
+ default:
+ COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
+ return BLANKSTRING;
+ }
+ }
+
+ /**
+ @brief
+ Sets the health.
+ @param health
+ The health.
+ */
+ void HealthPickup::setHealth(float health)
+ {
+ if(health >= 0.0f)
+ {
+ this->health_ = health;
+ }
+ else
+ {
+ COUT(1) << "Invalid health in HealthPickup." << std::endl;
+ this->health_ = 0.0;
+ }
+ }
+
+ /**
+ @brief
+ Set the rate at which health is transferred if the pickup is continuous.
+ @param rate
+ The rate.
+ */
+ void HealthPickup::setHealthRate(float rate)
+ {
+ if(rate >= 0)
+ {
+ this->healthRate_ = rate;
+ }
+ else
+ {
+ COUT(1) << "Invalid healthSpeed in HealthPickup." << std::endl;
+ }
+ }
+
+ /**
+ @brief
+ Set the type of the HealthPickup.
+ @param type
+ The type as a string.
+ */
+ void HealthPickup::setHealthType(std::string type)
+ {
+ if(type == HealthPickup::healthTypeLimited_s)
+ {
+ this->setHealthTypeDirect(pickupHealthType::limited);
+ }
+ else if(type == HealthPickup::healthTypeTemporary_s)
+ {
+ this->setHealthTypeDirect(pickupHealthType::temporary);
+ }
+ else if(type == HealthPickup::healthTypePermanent_s)
+ {
+ this->setHealthTypeDirect(pickupHealthType::permanent);
+ }
+ else
+ {
+ COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
+ }
+ }
+
+}
Deleted: code/trunk/src/modules/pickup/items/HealthPickup.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/HealthPickup.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/items/HealthPickup.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,131 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _HealthPickup_H__
-#define _HealthPickup_H__
-
-#include "pickup/PickupPrereqs.h"
-
-#include <string>
-#include <worldentities/pawns/Pawn.h>
-#include "worldentities/StaticEntity.h"
-
-#include "pickup/Pickup.h"
-#include "tools/interfaces/Tickable.h"
-
-namespace orxonox {
-
- //! Enum for the type of the HealthPickup
- namespace pickupHealthType
- {
- enum Value
- {
- limited,
- temporary,
- permanent
- };
- }
-
- /**
- @brief
- A pickup that can do (dependent upon the parameters) lots of different things to the health of a Pawn.
- There are 4 parameters that can be chosen:
- 1) The health. The amount of health that (in a way dependent on the other parameters) is transfered to the Pawn.
- 2) The activation type: It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the health is transfered, either immediately after being picked up or only after the player uses it.
- 3) The duration type: It can be chosen to be either 'once' or 'continuous'. For 'once' the specified health is transfered once to the Pawn, for 'continuous' the set health is transfered over a span of time at a rate defined by the health rate parameter.
- 4) The health type: The health type can be chosen to be 'limited', 'temporary' or 'permanent'. 'limited' means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. 'permanent' means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way.
- @author
- Damian 'Mozork' Frick
- */
- class _PickupExport HealthPickup : public Pickup, public Tickable
- {
- public:
-
- HealthPickup(BaseObject* creator); //!< Constructor.
- virtual ~HealthPickup(); //!< Destructor.
-
- virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
- virtual void tick(float dt); //!< Is called every tick.
-
- virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
- virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
-
- /**
- @brief Get the health that is transfered to the Pawn upon usage of this pickup.
- @return Returns the health.
- */
- inline float getHealth(void)
- { return this->health_; }
- /**
- @brief Get the rate at which the health is transferred to the Pawn, if this pickup has duration type 'continuous'.
- @return Returns the rate.
- */
- inline float getHealthRate(void)
- { return this->healthRate_; }
-
- /**
- @brief Get the type of HealthPickup, this pickup is.
- @return Returns the health type as an enum.
- */
- inline pickupHealthType::Value getHealthTypeDirect(void)
- { return this->healthType_; }
- const std::string& getHealthType(void); //!< Get the health type of this pickup.
-
- protected:
- void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
-
- void setHealth(float health); //!< Sets the health.
- void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous.
-
- /**
- @brief Set the health type of this pickup.
- @param type The type of this pickup as an enum.
- */
- inline void setHealthTypeDirect(pickupHealthType::Value type)
- { this->healthType_ = type; }
- void setHealthType(std::string type); //!< Set the type of the HealthPickup.
-
- private:
- void initialize(void); //!< Initializes the member variables.
- Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
-
- float health_; //!< The health that is transferred to the Pawn.
- float healthRate_; //!< The rate at which the health is transferred.
- float maxHealthSave_; //!< Helper to remember what the actual maxHealth of the Pawn was before we changed it.
- float maxHealthOverwrite_; //!< Helper to remember with which value we overwrote the maxHealh, to detect if someone else changed it as well.
- pickupHealthType::Value healthType_; //!< The type of the HealthPickup.
-
- //! Strings for the health types.
- static const std::string healthTypeLimited_s;
- static const std::string healthTypeTemporary_s;
- static const std::string healthTypePermanent_s;
-
- };
-}
-
-#endif // _HealthPickup_H__
Copied: code/trunk/src/modules/pickup/items/HealthPickup.h (from rev 6523, code/branches/pickup3/src/modules/pickup/items/HealthPickup.h)
===================================================================
--- code/trunk/src/modules/pickup/items/HealthPickup.h (rev 0)
+++ code/trunk/src/modules/pickup/items/HealthPickup.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,131 @@
+/*
+ * 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 _HealthPickup_H__
+#define _HealthPickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include <string>
+#include <worldentities/pawns/Pawn.h>
+#include "worldentities/StaticEntity.h"
+
+#include "pickup/Pickup.h"
+#include "tools/interfaces/Tickable.h"
+
+namespace orxonox {
+
+ //! Enum for the type of the HealthPickup
+ namespace pickupHealthType
+ {
+ enum Value
+ {
+ limited,
+ temporary,
+ permanent
+ };
+ }
+
+ /**
+ @brief
+ A pickup that can do (dependent upon the parameters) lots of different things to the health of a Pawn.
+ There are 4 parameters that can be chosen:
+ 1) The health. The amount of health that (in a way dependent on the other parameters) is transfered to the Pawn.
+ 2) The activation type: It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the health is transfered, either immediately after being picked up or only after the player uses it.
+ 3) The duration type: It can be chosen to be either 'once' or 'continuous'. For 'once' the specified health is transfered once to the Pawn, for 'continuous' the set health is transfered over a span of time at a rate defined by the health rate parameter.
+ 4) The health type: The health type can be chosen to be 'limited', 'temporary' or 'permanent'. 'limited' means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. 'permanent' means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way.
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _PickupExport HealthPickup : public Pickup, public Tickable
+ {
+ public:
+
+ HealthPickup(BaseObject* creator); //!< Constructor.
+ virtual ~HealthPickup(); //!< Destructor.
+
+ virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
+ virtual void tick(float dt); //!< Is called every tick.
+
+ virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
+ virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
+
+ /**
+ @brief Get the health that is transfered to the Pawn upon usage of this pickup.
+ @return Returns the health.
+ */
+ inline float getHealth(void)
+ { return this->health_; }
+ /**
+ @brief Get the rate at which the health is transferred to the Pawn, if this pickup has duration type 'continuous'.
+ @return Returns the rate.
+ */
+ inline float getHealthRate(void)
+ { return this->healthRate_; }
+
+ /**
+ @brief Get the type of HealthPickup, this pickup is.
+ @return Returns the health type as an enum.
+ */
+ inline pickupHealthType::Value getHealthTypeDirect(void)
+ { return this->healthType_; }
+ const std::string& getHealthType(void); //!< Get the health type of this pickup.
+
+ protected:
+ void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
+
+ void setHealth(float health); //!< Sets the health.
+ void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous.
+
+ /**
+ @brief Set the health type of this pickup.
+ @param type The type of this pickup as an enum.
+ */
+ inline void setHealthTypeDirect(pickupHealthType::Value type)
+ { this->healthType_ = type; }
+ void setHealthType(std::string type); //!< Set the type of the HealthPickup.
+
+ private:
+ void initialize(void); //!< Initializes the member variables.
+ Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+
+ float health_; //!< The health that is transferred to the Pawn.
+ float healthRate_; //!< The rate at which the health is transferred.
+ float maxHealthSave_; //!< Helper to remember what the actual maxHealth of the Pawn was before we changed it.
+ float maxHealthOverwrite_; //!< Helper to remember with which value we overwrote the maxHealh, to detect if someone else changed it as well.
+ pickupHealthType::Value healthType_; //!< The type of the HealthPickup.
+
+ //! Strings for the health types.
+ static const std::string healthTypeLimited_s;
+ static const std::string healthTypeTemporary_s;
+ static const std::string healthTypePermanent_s;
+
+ };
+}
+
+#endif // _HealthPickup_H__
Deleted: code/trunk/src/modules/pickup/items/MetaPickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/MetaPickup.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/items/MetaPickup.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,161 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
-*/
-
-/**
- @file
- @brief Implementation of the MetaPickup class.
-*/
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "interfaces/PickupCarrier.h"
-#include "pickup/PickupIdentifier.h"
-
-#include "MetaPickup.h"
-
-namespace orxonox {
-
- CreateFactory(MetaPickup);
-
- /*static*/ const std::string MetaPickup::metaTypeNone_s = "none";
- /*static*/ const std::string MetaPickup::metaTypeUse_s = "use";
- /*static*/ const std::string MetaPickup::metaTypeDrop_s = "drop";
-
- /**
- @brief
- Constructor.
- */
- MetaPickup::MetaPickup(BaseObject* creator) : Pickup(creator)
- {
- RegisterObject(MetaPickup);
-
- this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier());
- this->setActivationTypeDirect(pickupActivationType::immediate);
- this->setDurationTypeDirect(pickupDurationType::once);
- this->metaType_ = pickupMetaType::none;
- }
-
- MetaPickup::~MetaPickup()
- {
-
- }
-
- void MetaPickup::initializeIdentifier(void)
- {
- std::string val = this->getMetaType();
- std::string type = "metaType";
- this->pickupIdentifier_->addParameter(type, val);
- }
-
- void MetaPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
- {
- SUPER(MetaPickup, XMLPort, xmlelement, mode);
-
- XMLPortParam(MetaPickup, "metaType", setMetaType, getMetaType, xmlelement, mode);
-
- this->initializeIdentifier();
- }
-
- void MetaPickup::changedUsed(void)
- {
- SUPER(MetaPickup, changedUsed);
-
- if(this->isUsed())
- {
- PickupCarrier* carrier = this->getCarrier();
- if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL)
- {
- std::set<Pickupable*> pickups = carrier->getPickups();
- for(std::set<Pickupable*>::iterator it = pickups.begin(); it != pickups.end(); it++)
- {
- Pickup* pickup = dynamic_cast<Pickup*>(*it);
- if(this->getMetaTypeDirect() == pickupMetaType::use)
- {
- if(pickup != NULL && pickup != this && pickup->isOnUse() && !pickup->isUsed())
- {
- pickup->setUsed(true);
- }
- }
- if(this->getMetaTypeDirect() == pickupMetaType::drop)
- {
- if(pickup != NULL && pickup != this)
- {
- carrier->drop(pickup);
- }
- }
- }
- }
- this->destroy();
- }
- }
-
- const std::string& MetaPickup::getMetaType(void)
- {
- switch(this->getMetaTypeDirect())
- {
- case pickupMetaType::none:
- return MetaPickup::metaTypeNone_s;
- case pickupMetaType::use:
- return MetaPickup::metaTypeUse_s;
- case pickupMetaType::drop:
- return MetaPickup::metaTypeDrop_s;
- default:
- return BLANKSTRING;
- }
- }
-
- void MetaPickup::setMetaType(const std::string& type)
- {
- if(type == MetaPickup::metaTypeNone_s)
- {
- this->setMetaTypeDirect(pickupMetaType::none);
- }
- else if(type == MetaPickup::metaTypeUse_s)
- {
- this->setMetaTypeDirect(pickupMetaType::use);
- }
- else if(type == MetaPickup::metaTypeDrop_s)
- {
- this->setMetaTypeDirect(pickupMetaType::drop);
- }
- }
-
- void MetaPickup::clone(OrxonoxClass*& item)
- {
- if(item == NULL)
- item = new MetaPickup(this);
-
- SUPER(MetaPickup, clone, item);
-
- MetaPickup* pickup = dynamic_cast<MetaPickup*>(item);
- pickup->setMetaTypeDirect(this->getMetaTypeDirect());
-
- pickup->initializeIdentifier();
- }
-
-}
Copied: code/trunk/src/modules/pickup/items/MetaPickup.cc (from rev 6523, code/branches/pickup3/src/modules/pickup/items/MetaPickup.cc)
===================================================================
--- code/trunk/src/modules/pickup/items/MetaPickup.cc (rev 0)
+++ code/trunk/src/modules/pickup/items/MetaPickup.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,161 @@
+/*
+ * 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 the MetaPickup class.
+*/
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "interfaces/PickupCarrier.h"
+#include "pickup/PickupIdentifier.h"
+
+#include "MetaPickup.h"
+
+namespace orxonox {
+
+ CreateFactory(MetaPickup);
+
+ /*static*/ const std::string MetaPickup::metaTypeNone_s = "none";
+ /*static*/ const std::string MetaPickup::metaTypeUse_s = "use";
+ /*static*/ const std::string MetaPickup::metaTypeDrop_s = "drop";
+
+ /**
+ @brief
+ Constructor.
+ */
+ MetaPickup::MetaPickup(BaseObject* creator) : Pickup(creator)
+ {
+ RegisterObject(MetaPickup);
+
+ this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier());
+ this->setActivationTypeDirect(pickupActivationType::immediate);
+ this->setDurationTypeDirect(pickupDurationType::once);
+ this->metaType_ = pickupMetaType::none;
+ }
+
+ MetaPickup::~MetaPickup()
+ {
+
+ }
+
+ void MetaPickup::initializeIdentifier(void)
+ {
+ std::string val = this->getMetaType();
+ std::string type = "metaType";
+ this->pickupIdentifier_->addParameter(type, val);
+ }
+
+ void MetaPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
+ {
+ SUPER(MetaPickup, XMLPort, xmlelement, mode);
+
+ XMLPortParam(MetaPickup, "metaType", setMetaType, getMetaType, xmlelement, mode);
+
+ this->initializeIdentifier();
+ }
+
+ void MetaPickup::changedUsed(void)
+ {
+ SUPER(MetaPickup, changedUsed);
+
+ if(this->isUsed())
+ {
+ PickupCarrier* carrier = this->getCarrier();
+ if(this->getMetaTypeDirect() != pickupMetaType::none && carrier != NULL)
+ {
+ std::set<Pickupable*> pickups = carrier->getPickups();
+ for(std::set<Pickupable*>::iterator it = pickups.begin(); it != pickups.end(); it++)
+ {
+ Pickup* pickup = dynamic_cast<Pickup*>(*it);
+ if(this->getMetaTypeDirect() == pickupMetaType::use)
+ {
+ if(pickup != NULL && pickup != this && pickup->isOnUse() && !pickup->isUsed())
+ {
+ pickup->setUsed(true);
+ }
+ }
+ if(this->getMetaTypeDirect() == pickupMetaType::drop)
+ {
+ if(pickup != NULL && pickup != this)
+ {
+ carrier->drop(pickup);
+ }
+ }
+ }
+ }
+ this->destroy();
+ }
+ }
+
+ const std::string& MetaPickup::getMetaType(void)
+ {
+ switch(this->getMetaTypeDirect())
+ {
+ case pickupMetaType::none:
+ return MetaPickup::metaTypeNone_s;
+ case pickupMetaType::use:
+ return MetaPickup::metaTypeUse_s;
+ case pickupMetaType::drop:
+ return MetaPickup::metaTypeDrop_s;
+ default:
+ return BLANKSTRING;
+ }
+ }
+
+ void MetaPickup::setMetaType(const std::string& type)
+ {
+ if(type == MetaPickup::metaTypeNone_s)
+ {
+ this->setMetaTypeDirect(pickupMetaType::none);
+ }
+ else if(type == MetaPickup::metaTypeUse_s)
+ {
+ this->setMetaTypeDirect(pickupMetaType::use);
+ }
+ else if(type == MetaPickup::metaTypeDrop_s)
+ {
+ this->setMetaTypeDirect(pickupMetaType::drop);
+ }
+ }
+
+ void MetaPickup::clone(OrxonoxClass*& item)
+ {
+ if(item == NULL)
+ item = new MetaPickup(this);
+
+ SUPER(MetaPickup, clone, item);
+
+ MetaPickup* pickup = dynamic_cast<MetaPickup*>(item);
+ pickup->setMetaTypeDirect(this->getMetaTypeDirect());
+
+ pickup->initializeIdentifier();
+ }
+
+}
Deleted: code/trunk/src/modules/pickup/items/MetaPickup.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/MetaPickup.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/pickup/items/MetaPickup.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,96 +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:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
-*/
-
-/**
- @file
- @brief Definition of the MetaPickup class.
-*/
-
-#ifndef _MetaPickup_H__
-#define _MetaPickup_H__
-
-#include "pickup/PickupPrereqs.h"
-
-#include "pickup/Pickup.h"
-
-namespace orxonox {
-
- //! The meta type, deciding what the pickup does exactly.
- namespace pickupMetaType
- {
- enum Value
- {
- none,
- use,
- drop
- };
- }
-
- /**
- @brief
- The MetaPickup is a pickup that can, depending on the parameters, either drop all pickups of the PickupCarrier that picks it up, or use all the unused pickups of the PickupCarrier, that picks it up. The parameter to set for this is the metaType and it can be used with the values 'none', 'drop' and 'use'.
- @author
- Damian 'Mozork' Frick
- */
- class _PickupExport MetaPickup : public Pickup
- {
-
- public:
- MetaPickup(BaseObject* creator);
- virtual ~MetaPickup();
-
- virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
-
- virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
- virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
-
- inline pickupMetaType::Value getMetaTypeDirect(void)
- { return this->metaType_; }
- const std::string& getMetaType(void);
-
- protected:
- void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
-
- inline void setMetaTypeDirect(pickupMetaType::Value type)
- { this->metaType_ = type; }
- void setMetaType(const std::string& type);
-
- private:
- void initialize(void); //!< Initializes the member variables.
-
- pickupMetaType::Value metaType_;
- static const std::string metaTypeNone_s;
- static const std::string metaTypeUse_s;
- static const std::string metaTypeDrop_s;
-
-
- };
-
-}
-
-#endif // _TestPickup_H__
Copied: code/trunk/src/modules/pickup/items/MetaPickup.h (from rev 6523, code/branches/pickup3/src/modules/pickup/items/MetaPickup.h)
===================================================================
--- code/trunk/src/modules/pickup/items/MetaPickup.h (rev 0)
+++ code/trunk/src/modules/pickup/items/MetaPickup.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,96 @@
+/*
+ * 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 MetaPickup class.
+*/
+
+#ifndef _MetaPickup_H__
+#define _MetaPickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include "pickup/Pickup.h"
+
+namespace orxonox {
+
+ //! The meta type, deciding what the pickup does exactly.
+ namespace pickupMetaType
+ {
+ enum Value
+ {
+ none,
+ use,
+ drop
+ };
+ }
+
+ /**
+ @brief
+ The MetaPickup is a pickup that can, depending on the parameters, either drop all pickups of the PickupCarrier that picks it up, or use all the unused pickups of the PickupCarrier, that picks it up. The parameter to set for this is the metaType and it can be used with the values 'none', 'drop' and 'use'.
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _PickupExport MetaPickup : public Pickup
+ {
+
+ public:
+ MetaPickup(BaseObject* creator);
+ virtual ~MetaPickup();
+
+ virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.
+
+ virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
+ virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
+
+ inline pickupMetaType::Value getMetaTypeDirect(void)
+ { return this->metaType_; }
+ const std::string& getMetaType(void);
+
+ protected:
+ void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
+
+ inline void setMetaTypeDirect(pickupMetaType::Value type)
+ { this->metaType_ = type; }
+ void setMetaType(const std::string& type);
+
+ private:
+ void initialize(void); //!< Initializes the member variables.
+
+ pickupMetaType::Value metaType_;
+ static const std::string metaTypeNone_s;
+ static const std::string metaTypeUse_s;
+ static const std::string metaTypeDrop_s;
+
+
+ };
+
+}
+
+#endif // _TestPickup_H__
Modified: code/trunk/src/modules/weapons/projectiles/Projectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/Projectile.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/weapons/projectiles/Projectile.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -123,8 +123,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/trunk/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/Rocket.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/modules/weapons/projectiles/Rocket.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -200,8 +200,9 @@
}
float dmg = this->damage_;
- if (this->owner_)
- dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
+ //TODO: This souldn't be necessary here.
+ //if (this->owner_)
+ // dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
Pawn* victim = orxonox_cast<Pawn*>(otherObject);
if (victim)
Modified: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/CMakeLists.txt 2010-03-15 14:27:09 UTC (rev 6524)
@@ -57,8 +57,6 @@
LevelManager.h
MoodManager.h
controllers/HumanController.h
- pickup/BaseItem.h
- pickup/PickupInventory.h
sound/SoundManager.h
DEFINE_SYMBOL
"ORXONOX_SHARED_BUILD"
Modified: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -116,6 +116,8 @@
// interfaces
class GametypeMessageListener;
class NotificationListener;
+ class Pickupable;
+ class PickupCarrier;
class PlayerTrigger;
class RadarListener;
class RadarViewable;
@@ -132,21 +134,9 @@
class Map;
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;
+ class PickupIdentifier;
//sound
class AmbientSound;
Modified: code/trunk/src/orxonox/interfaces/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/interfaces/CMakeLists.txt 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/interfaces/CMakeLists.txt 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,4 +1,5 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
InterfaceCompilation.cc
+ Pickupable.cc
RadarViewable.cc
)
Modified: code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -33,6 +33,7 @@
*/
#include "GametypeMessageListener.h"
+#include "PickupCarrier.h"
#include "PlayerTrigger.h"
#include "RadarListener.h"
#include "Rewardable.h"
@@ -50,8 +51,38 @@
{
RegisterRootObject(GametypeMessageListener);
}
+
+ //----------------------------
+ // PickupCarrier
+ //----------------------------
+ PickupCarrier::PickupCarrier()
+ {
+ RegisterRootObject(PickupCarrier);
+
+ }
+
+ PickupCarrier::~PickupCarrier()
+ {
+ for(std::set<Pickupable*>::iterator it = this->pickups_.begin(); it != this->pickups_.end(); it++)
+ {
+ (*it)->destroy();
+ }
+
+ this->pickups_.clear();
+ }
//----------------------------
+ // PlayerTrigger
+ //----------------------------
+ PlayerTrigger::PlayerTrigger()
+ {
+ RegisterRootObject(PlayerTrigger);
+
+ this->player_ = NULL;
+ this->isForPlayer_ = true;
+ }
+
+ //----------------------------
// RadarListener
//----------------------------
RadarListener::RadarListener()
@@ -82,15 +113,4 @@
{
RegisterRootObject(NotificationListener);
}
-
- //----------------------------
- // PlayerTrigger
- //----------------------------
- PlayerTrigger::PlayerTrigger()
- {
- RegisterRootObject(PlayerTrigger);
-
- this->player_ = NULL;
- this->isForPlayer_ = true;
- }
}
Copied: code/trunk/src/orxonox/interfaces/PickupCarrier.h (from rev 6523, code/branches/pickup3/src/orxonox/interfaces/PickupCarrier.h)
===================================================================
--- code/trunk/src/orxonox/interfaces/PickupCarrier.h (rev 0)
+++ code/trunk/src/orxonox/interfaces/PickupCarrier.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,190 @@
+/*
+ * 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 <list>
+#include <set>
+#include "Pickupable.h"
+#include "core/Identifier.h"
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+
+ class Pickup;
+ class HealthPickup;
+ class MetaPickup;
+
+ /**
+ @brief
+ The PickupCarrier interface provides the means, for any class implementing it, to possess Pickupables.
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass
+ {
+ friend class Pickupable; //!< The Pickupable has full acces to its PickupCarrier.
+ //TODO: Ugly workaround.
+ friend class Pickup;
+ friend class HealthPickup;
+ friend class MetaPickup;
+
+ public:
+ PickupCarrier(); //!< Constructor.
+ virtual ~PickupCarrier(); //!< Destructor.
+
+ /**
+ @brief Can be called to pick up a Pickupable.
+ @param pickup A pointer to the Pickupable.
+ @return Returns true if the Pickupable was picked up, false if not.
+ */
+ bool pickup(Pickupable* pickup)
+ {
+ bool pickedUp = this->pickups_.insert(pickup).second;
+ if(pickedUp)
+ {
+ COUT(4) << "Picked up Pickupable " << pickup->getIdentifier()->getName() << "(&" << pickup << ")." << std::endl;
+ pickup->pickedUp(this);
+ }
+ return pickedUp;
+ }
+
+ /**
+ @brief Can be called to drop a Pickupable.
+ @param pickup A pointer to the Pickupable.
+ @param drop If the Pickupable should just be removed from the PickupCarrier without further action, this can be set to false. true is default.
+ @return Returns true if the Pickupable has been dropped, false if not.
+ */
+ bool drop(Pickupable* pickup, bool drop = true)
+ {
+ bool dropped = this->pickups_.erase(pickup) == 1;
+ if(dropped && drop)
+ {
+ COUT(4) << "Dropping Pickupable " << pickup->getIdentifier()->getName() << "(&" << pickup << ")." << std::endl;
+ pickup->dropped();
+ }
+ return dropped;
+ }
+
+ /**
+ @brief Can be used to check whether the PickupCarrier or a child of his is a target ot the input Pickupable.
+ @param pickup A pointer to the Pickupable.
+ @return Returns true if the PickupCarrier or one of its children is a target, false if not.
+ */
+ //TODO: Use?
+ bool isTarget(const Pickupable* pickup)
+ {
+ if(pickup->isTarget(this)) //!< If the PickupCarrier itself is a target.
+ return true;
+
+ //! Go recursively through all children to check whether they are a target.
+ std::list<PickupCarrier*>* children = this->getCarrierChildren();
+ for(std::list<PickupCarrier*>::const_iterator it = children->begin(); it != children->end(); it++)
+ {
+ if((*it)->isTarget(pickup))
+ return true;
+ }
+
+ children->clear();
+ delete children;
+
+ return false;
+ }
+
+ /**
+ @brief Get the carrier that is both a child of the PickupCarrier (or the PickupCarrier itself) and a target of the input Pickupable.
+ @param pickup A pounter to the Pickupable.
+ @return Returns a pointer to the PickupCarrier that is the target of the input Pickupable.
+ */
+ PickupCarrier* getTarget(const Pickupable* pickup)
+ {
+ if(!this->isTarget(pickup))
+ return NULL;
+
+ if(pickup->isTarget(this)) //!< If the PickupCarrier itself is a target.
+ return this;
+
+ //! Go recursively through all children to check whether they are the target.
+ std::list<PickupCarrier*>* children = this->getCarrierChildren();
+ for(std::list<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
+ {
+ if(pickup->isTarget(*it))
+ return *it;
+ }
+
+ children->clear();
+ delete children;
+
+ return NULL;
+ }
+
+ protected:
+ /**
+ @brief Get all direct children of this PickupSpawner.
+ This method needs to be implemented by any direct derivative class of PickupCarrier.
+ @return Returns a pointer to a list of all direct children.
+ */
+ //TODO: Good return type? Maybe not const and destroyed in isTarget...
+ virtual std::list<PickupCarrier*>* getCarrierChildren(void) = 0;
+ /**
+ @brief Get the parent of this PickupSpawner
+ This method needs to be implemented by any direct derivative class of PickupCarrier.
+ @return Returns a pointer to the parent.
+ */
+ virtual PickupCarrier* getCarrierParent(void) = 0;
+ /**
+ @brief Get the (absolute) position of the PickupCarrier.
+ This method needs to be implemented by any direct derivative class of PickupCarrier.
+ @return Returns the position as a Vector3.
+ */
+ virtual const Vector3& getCarrierPosition(void) = 0;
+
+ /**
+ @brief Get all Pickupables this PickupCarrier has.
+ @return Returns the set of all Pickupables this PickupCarrier has.
+ */
+ std::set<Pickupable*>& getPickups(void)
+ { return this->pickups_; }
+
+ private:
+ std::set<Pickupable*> pickups_; //!< The list of Pickupables carried by this PickupCarrier.
+
+ };
+}
+
+#endif /* _PickupCarrier_H__ */
Copied: code/trunk/src/orxonox/interfaces/Pickupable.cc (from rev 6523, code/branches/pickup3/src/orxonox/interfaces/Pickupable.cc)
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.cc (rev 0)
+++ code/trunk/src/orxonox/interfaces/Pickupable.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,275 @@
+/*
+ * 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 the Pickupable class.
+*/
+
+#include "Pickupable.h"
+
+#include "core/Identifier.h"
+#include "core/CoreIncludes.h"
+#include "pickup/PickupIdentifier.h"
+#include "PickupCarrier.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Constructor. Registers the objects and initializes its member variables.
+ */
+ Pickupable::Pickupable()
+ {
+ this->used_ = false;
+ this->pickedUp_ = false;
+
+ RegisterRootObject(Pickupable);
+
+ this->carrier_ = NULL;
+
+ this->pickupIdentifier_ = new PickupIdentifier(this);
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ Pickupable::~Pickupable()
+ {
+ if(this->isUsed())
+ this->setUsed(false);
+
+ if(this->isPickedUp() && this->getCarrier() != NULL)
+ {
+ this->getCarrier()->drop(this, false);
+ this->setCarrier(NULL);
+ }
+ }
+
+ /**
+ @brief
+ Sets the Pickupable to used or unused, depending on the input.
+ @param used
+ If used is true the Pickupable is set to used, it is set to unused, otherwise.
+ @return
+ Returns true if the used state was changed, false if not.
+ */
+ bool Pickupable::setUsed(bool used)
+ {
+ if(this->used_ == used)
+ return false;
+
+ COUT(4) << "Pickupable (&" << this << ") set to used " << used << "." << std::endl;
+
+ this->used_ = used;
+ this->changedUsed();
+ return true;
+ }
+
+ /**
+ @brief
+ Get whether the given PickupCarrier is a target of this pickup.
+ @param carrier
+ The PickupCarrier of which it has to be determinde whether it is a target of this pickup.
+ @return
+ Returns true if the given PickupCarrier is a target.
+ */
+ bool Pickupable::isTarget(const PickupCarrier* carrier) const
+ {
+ return this->isTarget(carrier->getIdentifier());
+ }
+
+ /**
+ @brief
+ Get whether a given class, represented by the input Identifier, is a target of this pickup.
+ @param target
+ The Identifier of which it has to be determinde whether it is a target of this pickup.
+ @return
+ Returns true if the given Identifier is a target.
+ */
+ bool Pickupable::isTarget(Identifier* target) const
+ {
+ //! Iterate through all targets of this Pickupable.
+ for(std::list<Identifier*>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)
+ {
+ if(target->isA(*it))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ @brief
+ Add a PickupCarrier as target of this pickup.
+ @param target
+ The PickupCarrier to be added.
+ @return
+ Returns true if the target was added, false if not.
+ */
+ bool Pickupable::addTarget(PickupCarrier* target)
+ {
+ return this->addTarget(target->getIdentifier());
+ }
+
+ /**
+ @brief
+ Add a class, representetd by the input Identifier, as target of this pickup.
+ @param target
+ The Identifier to be added.
+ @return
+ Returns true if the target was added, false if not.
+ */
+ bool Pickupable::addTarget(Identifier* target)
+ {
+ if(this->isTarget(target)) //!< If the input target is already present in the list of targets.
+ return false;
+
+ COUT(4) << "Target " << target->getName() << " added to Pickupable (&" << this << ")." << std::endl;
+ this->targets_.push_back(target);
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the Pickupable to picked up.
+ This method will be called by the PickupCarrier picking the Pickupable up.
+ @param carrier
+ The PickupCarrier that picked the Pickupable up.
+ @return
+ Returns false if, for some reason, the pickup could not be picked up, e.g. it was picked up already.
+ */
+ bool Pickupable::pickedUp(PickupCarrier* carrier)
+ {
+ if(this->isPickedUp()) //!< If the Pickupable is already picked up.
+ return false;
+
+ COUT(4) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << std::endl;
+ this->setCarrier(carrier);
+ this->setPickedUp(true);
+ return true;
+ }
+
+ /**
+ @brief
+ Helper method to set the Pickupable to either picked up or not picked up.
+ @param pickedUp
+ The value this->pickedUp_ should be set to.
+ @return
+ Returns true if the pickedUp status was changed, false if not.
+ */
+ bool Pickupable::setPickedUp(bool pickedUp)
+ {
+ if(this->pickedUp_ == pickedUp)
+ return false;
+
+ COUT(4) << "Pickupable (&" << this << ") set to pickedUp " << pickedUp << "." << std::endl;
+
+ this->pickedUp_ = pickedUp;
+ this->changedPickedUp();
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the carrier of the pickup.
+ @param carrier
+ Sets the input PickupCarrier as the carrier of the pickup.
+ */
+ inline bool Pickupable::setCarrier(PickupCarrier* carrier)
+ {
+ if(this->carrier_ == carrier)
+ return false;
+
+ COUT(4) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << std::endl;
+
+ this->carrier_ = carrier;
+ this->changedCarrier();
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the Pickupable to not picked up or dropped.
+ This method will be called by the PickupCarrier dropping the Pickupable.
+ @return
+ Returns false if the pickup could not be dropped.
+ */
+ bool Pickupable::dropped(void)
+ {
+ if(!this->isPickedUp()) //!< If the Pickupable is not picked up.
+ return false;
+
+ COUT(4) << "Pickupable (&" << this << ") got dropped up by a PickupCarrier (&" << this->getCarrier() << ")." << std::endl;
+ this->setUsed(false);
+ this->setPickedUp(false);
+
+ bool created = this->createSpawner(this->getCarrier()->getCarrierPosition());
+
+ this->setCarrier(NULL);
+ //TODO: possible problem.
+ if(!created)
+ {
+ this->destroy();
+ }
+
+ return true;
+ }
+
+ /**
+ @brief
+ Creates a duplicate of the Pickupable.
+ @return
+ Returns the clone of this pickup as a pointer to a Pickupable.
+ */
+ Pickupable* Pickupable::clone(void)
+ {
+ OrxonoxClass* item = NULL;
+ this->clone(item);
+
+ Pickupable* pickup = dynamic_cast<Pickupable*>(item);
+
+ COUT(4) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << std::endl;
+ return pickup;
+ }
+
+ /**
+ @brief
+ Creates a duplicate of the input OrxonoxClass.
+ This method needs to be implemented by any Class inheriting from Pickupable.
+ @param item
+ A pointer to the OrxonoxClass that is to be duplicated.
+ */
+ //TODO: Specify how the implementation must be done in detail.
+ void Pickupable::clone(OrxonoxClass*& item)
+ {
+ SUPER(Pickupable, clone, item);
+ }
+
+}
Copied: code/trunk/src/orxonox/interfaces/Pickupable.h (from rev 6523, code/branches/pickup3/src/orxonox/interfaces/Pickupable.h)
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.h (rev 0)
+++ code/trunk/src/orxonox/interfaces/Pickupable.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,158 @@
+/*
+ * 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 <list>
+#include "core/Super.h"
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ An Interface (or more precisely an abstract class) to model and represent 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 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 Should be called when the pickup has transited 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 changdeUsed method.
+ */
+ virtual void changedUsed(void) {}
+
+ /**
+ @brief Get the carrier of the pickup.
+ @return Returns a pointer to the carrier of the pickup.
+ */
+ inline PickupCarrier* getCarrier(void)
+ { return this->carrier_; }
+ /**
+ @brief Should be called when the pickup has changed its PickupCarrier.
+ Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedCarrier); to their changedCarrier method.
+ */
+ virtual void changedCarrier(void) {}
+
+ /**
+ @brief Returns whether the Pickupable is currently picked up.
+ @return Returns true if the Pickupable is currently picked up, false if not.
+ */
+ inline bool isPickedUp(void)
+ { return this->pickedUp_; }
+ /**
+ @brief Should be called when the pickup has transited from picked up to dropped or the other way around.
+ Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedPickedUp); to their changedPickedUp method.
+ */
+ virtual void changedPickedUp(void) {}
+
+ //TODO: Better private, or protected?
+ bool pickedUp(PickupCarrier* carrier); //!< Sets the Pickupable to picked up.
+ bool dropped(void); //!< Sets the Pickupable to not picked up or dropped.
+
+ bool isTarget(const PickupCarrier* carrier) const; //!< Get whether the given PickupCarrier is a target of this pickup.
+ virtual bool isTarget(Identifier* identifier) const; //!< Get whether a given class, represented by the input Identifier, is a target of this pickup.
+ bool addTarget(PickupCarrier* target); //!< Add a PickupCarrier as target of this pickup.
+ bool addTarget(Identifier* identifier); //!< Add a class, representetd by the input Identifier, as target of this pickup.
+
+ Pickupable* clone(void); //!< Creates a duplicate of the Pickupable.
+ virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
+
+ /**
+ @brief Get the PickupIdentifier of this Pickupable.
+ @return Returns a pointer to the PickupIdentifier of this Pickupable.
+ */
+ virtual const PickupIdentifier* getPickupIdentifier(void)
+ { return this->pickupIdentifier_; }
+
+ virtual void destroy(void)
+ { delete this; }
+
+ //TODO: Make them work as protected.
+ bool setUsed(bool used); //!< Sets the Pickupable to used or unused, depending on the input.
+ bool setPickedUp(bool pickedUp); //!< Helper method to set the Pickupable to either picked up or not picked up.
+ bool setCarrier(PickupCarrier* carrier); //!< Sets the carrier of the pickup.
+
+ protected:
+ /**
+ @brief Helper method to initialize the PickupIdentifier.
+ */
+ //TODO: Really needed?
+ void initializeIdentifier(void) {}
+
+ /**
+ @brief Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
+ This method must be implemented by any class directly inheriting from Pickupable. It is most easily done by just creating a new DroppedPickup, e.g.:
+ DroppedPickup(BaseObject* creator, Pickupable* pickup, const Vector3& position, float triggerDistance);
+ @param position The position at which the PickupSpawner should be placed.
+ @return Returns true if a spawner was created, false if not.
+ */
+ virtual bool createSpawner(const Vector3& position) = 0;
+
+ //TODO: Move to private and create get method in protected.
+ PickupIdentifier* pickupIdentifier_; //!< The PickupIdentifier of this Pickupable.
+
+ private:
+
+ bool used_; //!< Whether the pickup is currently in use or not.
+ bool pickedUp_; //!< Whether the pickup is currently picked up or not.
+
+ PickupCarrier* carrier_; //!< The carrier of the pickup.
+ std::list<Identifier*> targets_; //!< The possible targets of this pickup.
+
+ };
+
+ SUPER_FUNCTION(10, Pickupable, changedUsed, false);
+ SUPER_FUNCTION(12, Pickupable, changedCarrier, false);
+ SUPER_FUNCTION(13, Pickupable, changedPickedUp, false);
+}
+
+#endif /* _Pickupable_H__ */
Modified: code/trunk/src/orxonox/items/Engine.cc
===================================================================
--- code/trunk/src/orxonox/items/Engine.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/items/Engine.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -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: Correct?
+ this->ship_->setAcceleration(this->ship_->getOrientation() * acceleration);
if (!this->ship_->getPermanentBoost())
this->ship_->setBoost(false);
Deleted: code/trunk/src/orxonox/pickup/BaseItem.cc
===================================================================
--- code/trunk/src/orxonox/pickup/BaseItem.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/BaseItem.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,109 +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 BaseItem (base-class for items/pickups).
-*/
-
-#include "BaseItem.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "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("");
- }
- //! Destructor.
- 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: code/trunk/src/orxonox/pickup/BaseItem.h
===================================================================
--- code/trunk/src/orxonox/pickup/BaseItem.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/BaseItem.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,150 +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 BaseItem (base-class for items/pickups).
-*/
-
-#ifndef _BaseItem_H__
-#define _BaseItem_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <string>
-#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 : public BaseObject
- {
-// 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: code/trunk/src/orxonox/pickup/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/pickup/CMakeLists.txt 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/CMakeLists.txt 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,13 +1,4 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
- BaseItem.cc
- DroppedItem.cc
- EquipmentItem.cc
- ModifierPickup.cc
- PassiveItem.cc
- PickupCollection.cc
- PickupInventory.cc
- PickupSpawner.cc
- UsableItem.cc
+ PickupIdentifier.cc
)
-ADD_SUBDIRECTORY(items)
Deleted: code/trunk/src/orxonox/pickup/DroppedItem.cc
===================================================================
--- code/trunk/src/orxonox/pickup/DroppedItem.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/DroppedItem.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,123 +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);
-
- 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;
- this->destroy();
- }
- }
- void DroppedItem::createTimer()
- {
- if (this->timeToLive_ > 0)
- {
- this->timer_.setTimer(this->timeToLive_, false, createExecutor(createFunctor(&DroppedItem::timerCallback, this)), false);
- }
- }
- void DroppedItem::timerCallback()
- {
- if (this->item_)
- {
- COUT(3) << "Delete DroppedItem with '" << this->item_->getPickupIdentifier() << '\'' << std::endl;
- this->item_->destroy();
- }
-
- this->destroy();
- }
-
- 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);
- }
-}
Deleted: code/trunk/src/orxonox/pickup/DroppedItem.h
===================================================================
--- code/trunk/src/orxonox/pickup/DroppedItem.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/DroppedItem.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,83 +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 "tools/Timer.h"
-#include "tools/interfaces/Tickable.h"
-#include "worldentities/StaticEntity.h"
-
-namespace orxonox
-{
- 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 timer_;
- };
-}
-
-#endif /* _DroppedItem_H__ */
Deleted: code/trunk/src/orxonox/pickup/EquipmentItem.cc
===================================================================
--- code/trunk/src/orxonox/pickup/EquipmentItem.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/EquipmentItem.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,47 +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 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);
- }
-}
Deleted: code/trunk/src/orxonox/pickup/EquipmentItem.h
===================================================================
--- code/trunk/src/orxonox/pickup/EquipmentItem.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/EquipmentItem.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,54 +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 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__ */
Deleted: code/trunk/src/orxonox/pickup/ModifierPickup.cc
===================================================================
--- code/trunk/src/orxonox/pickup/ModifierPickup.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/ModifierPickup.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,205 +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 ModifierPickup (temporary(?) pickup for testing).
-*/
-
-#include "ModifierPickup.h"
-
-#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "worldentities/pawns/Pawn.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::Value, 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)
- {
- Executor* executor = createExecutor(createFunctor(&ModifierPickup::timerCallback, this));
- executor->setDefaultValues(pawn);
- this->timer_.setTimer(this->duration_, false, 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::Value, 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();
-
- this->destroy();
-
- 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::Value type) const
- {
- std::map<ModifierType::Value, 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::Value type) const
- {
- std::map<ModifierType::Value, 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::Value type, float value)
- {
- if (this->additiveModifiers_.find(type) == this->additiveModifiers_.end())
- this->additiveModifiers_.insert( std::pair<ModifierType::Value, 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::Value type, float value)
- {
- if (this->multiplicativeModifiers_.find(type) == this->multiplicativeModifiers_.end())
- this->multiplicativeModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) );
- else
- this->multiplicativeModifiers_[type] = value;
- }
-}
Deleted: code/trunk/src/orxonox/pickup/ModifierPickup.h
===================================================================
--- code/trunk/src/orxonox/pickup/ModifierPickup.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/ModifierPickup.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,146 +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 ModifierPickup (temporary(?) pickup for testing).
-*/
-
-#ifndef _ModifierPickup_H__
-#define _ModifierPickup_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <climits>
-#include <map>
-
-#include "tools/Timer.h"
-#include "ModifierType.h"
-#include "PassiveItem.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::Value type) const; //!< Get the additive modifier for a given ModifierType.
- float getMultiplicativeModifier(ModifierType::Value type) const; //!< Get the multiplicative modifier for a given ModifierType.
- void setAdditiveModifier(ModifierType::Value type, float value); //!< Set the additive modifier for a given ModifierType.
- void setMultiplicativeModifier(ModifierType::Value type, float value); //!< Set the multiplicative modifier for a given ModifierType
-
- std::map<ModifierType::Value, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType.
- std::map<ModifierType::Value, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType.
-
- float duration_; //!< Duration of this pickup's effect (0 for unlimited).
- Timer timer_; //!< Timer used if the pickup's effect has a time limit.
- };
-}
-
-#endif /* _ModifierPickup_H__ */
Deleted: code/trunk/src/orxonox/pickup/ModifierType.h
===================================================================
--- code/trunk/src/orxonox/pickup/ModifierType.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/ModifierType.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,55 +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 Contains enumeration for different types of modifiers.
-*/
-
-#ifndef _ModifierType_H__
-#define _ModifierType_H__
-
-#include "OrxonoxPrereqs.h"
-
-namespace orxonox
-{
- namespace ModifierType
- {
- /**
- @brief Gives the available types for modifiers.
- */
- enum Value
- {
- Unknown = 0,
- Damage,
- Acceleration
- };
- }
-}
-
-#endif /* _ModifierType_H__ */
Deleted: code/trunk/src/orxonox/pickup/PassiveItem.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PassiveItem.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/PassiveItem.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,42 +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 "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);
- }
-}
Deleted: code/trunk/src/orxonox/pickup/PassiveItem.h
===================================================================
--- code/trunk/src/orxonox/pickup/PassiveItem.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/PassiveItem.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,54 +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 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__ */
Deleted: code/trunk/src/orxonox/pickup/PickupCollection.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PickupCollection.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/PickupCollection.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,377 +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 PickupCollection.
-*/
-
-#include "PickupCollection.h"
-
-#include "core/CoreIncludes.h"
-#include "EquipmentItem.h"
-#include "PassiveItem.h"
-#include "UsableItem.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::Value, float>::iterator, std::multimap<ModifierType::Value, 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_ = orxonox_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 (static_cast<int>(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::Value type, float value)
- {
- this->additiveModifiers_.insert( std::pair<ModifierType::Value, 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::Value type)
- {
- float v = 0.0f;
-
- modifier_range range = this->additiveModifiers_.equal_range(type);
-
- for (std::multimap<ModifierType::Value, 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::Value type, float value)
- {
- modifier_range range = this->additiveModifiers_.equal_range(type);
- for (std::multimap<ModifierType::Value, 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::Value type, float value)
- {
- this->multiplicativeModifiers_.insert( std::pair<ModifierType::Value, 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::Value type)
- {
- float v = 1.0f;
-
- modifier_range range = this->multiplicativeModifiers_.equal_range(type);
- for (std::multimap<ModifierType::Value, 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::Value type, float value)
- {
- modifier_range range = this->multiplicativeModifiers_.equal_range(type);
- for (std::multimap<ModifierType::Value, 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::Value 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::Value 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(orxonox_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(orxonox_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(orxonox_cast<UsableItem*>(it->second));
- }
-
- return ret;
- }
-}
Deleted: code/trunk/src/orxonox/pickup/PickupCollection.h
===================================================================
--- code/trunk/src/orxonox/pickup/PickupCollection.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/PickupCollection.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,122 +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 PickupCollection.
-*/
-
-#ifndef _PickupCollection_H__
-#define _PickupCollection_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <deque>
-#include <map>
-#include <string>
-
-#include "util/Math.h"
-#include "ModifierType.h"
-
-namespace orxonox
-{
- /**
- @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::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.
- */
- 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::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).
- };
-}
-
-#endif /* _PickupCollection_H__ */
Copied: code/trunk/src/orxonox/pickup/PickupIdentifier.cc (from rev 6523, code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.cc)
===================================================================
--- code/trunk/src/orxonox/pickup/PickupIdentifier.cc (rev 0)
+++ code/trunk/src/orxonox/pickup/PickupIdentifier.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -0,0 +1,116 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#include "PickupIdentifier.h"
+
+#include "core/CoreIncludes.h"
+#include "interfaces/Pickupable.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Constructor. Registers the object and initializes member variables.
+ */
+ PickupIdentifier::PickupIdentifier(Pickupable* pickup)
+ {
+ RegisterRootObject(PickupIdentifier);
+
+ this->pickup_ = pickup;
+ }
+
+ PickupIdentifier::~PickupIdentifier()
+ {
+
+ }
+
+ /**
+ @brief
+ Compares two PickupIdentifiers and returns 0 if a == b, <0 if a < b and >0 if a > b for a.compare(b).
+ @param identifier
+ Pointer to the second PickupIdentifier, b.
+ @return
+ Returns an integer. 0 if the two compared PickupIdentifiers are the same, <0 if a < b and >0 if a > b.
+ */
+ int PickupIdentifier::compare(const PickupIdentifier* identifier) const
+ {
+ //! If the classIdentifiers are not the same (meaning the PickupIdentifiers identify different classes), the obviously the two Pickupables identified by the PickupIdentifiers cannot be the same. An ordering is established through the alphabetical ordering of the respective classnames.
+ if(!identifier->pickup_->getIdentifier()->isExactlyA(this->pickup_->getIdentifier()))
+ return this->pickup_->getIdentifier()->getName().compare(identifier->pickup_->getIdentifier()->getName());
+
+ //! If the class is the same for both PickupIdentifiers we go on to check the parameters of the class.
+ //! If the two have a different number of parameters then obviusly something is very wrong.
+ if(!(this->parameters_.size() == identifier->parameters_.size()))
+ {
+ COUT(1) << "Something went wrong in PickupIdentifier!" << std::endl;
+ return this->parameters_.size()-identifier->parameters_.size();
+ }
+
+ //! We iterate through all parameters and compar their values (which are strings). The first parameter is the most significant. The ordering is once again established by the alphabetical comparison of the two value strings.
+ for(std::map<std::string, std::string>::const_iterator it = this->parameters_.begin(); it != this->parameters_.end(); it++)
+ {
+ //!< If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong.
+ if(identifier->parameters_.find(it->first) == identifier->parameters_.end())
+ {
+ COUT(1) << "Something went wrong in PickupIdentifier!" << std::endl;
+ return -1;
+ }
+ if(identifier->parameters_.find(it->first)->second != it->second)
+ return it->second.compare(identifier->parameters_.find(it->first)->second);
+ }
+
+ return false;
+ }
+
+ /**
+ @brief
+ Add a parameter to the PickupIdentifier.
+ @param name
+ The name of the parameter.
+ @param value
+ The value of the parameter.
+ @return
+ Returns false if the parameter already existed, true if not.
+ */
+ bool PickupIdentifier::addParameter(std::string & name, std::string & value)
+ {
+ COUT(4) << "PickupIdentifier " << name << ", " << value << std::endl;
+
+ if(!(this->parameters_.find(name) == this->parameters_.end()))
+ {
+ COUT(4) << "Request for adding a parameter that already exists for the PickupIdentififer was denied. name: '" << name << "', value: '" << value << "'."<< std::endl;
+ return false;
+ }
+
+ this->parameters_[name] = value;
+
+ return true;
+ }
+
+}
Copied: code/trunk/src/orxonox/pickup/PickupIdentifier.h (from rev 6523, code/branches/pickup3/src/orxonox/pickup/PickupIdentifier.h)
===================================================================
--- code/trunk/src/orxonox/pickup/PickupIdentifier.h (rev 0)
+++ code/trunk/src/orxonox/pickup/PickupIdentifier.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -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 _PickupIdentifier_H__
+#define _PickupIdentifier_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <string>
+#include "core/Identifier.h"
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The purpose of the PickupIdentifier class is to identify different types of pickups allthough they are of the same class.
+ This allows for more generic classes (or pickups in this case) that can be a number of different pickup types and can be identified as such without the need for a lot of different classes. An example is the HealthPickup class that encompasses a wide variety of different types of health pickups, e.g a HealthPickup that adds 10 health every second for 10 seconds or a HealthPickup that adds 100 health as soon as it is picked up, a.s.o.
+ To that purpose this class provides functionality to compare two PickupIdentifier (and since all Pickupables have an Identifier through that Pickupables can be compared). It als provides functionality to add parameters that distinguish between different types of pickups in the same pickup class.
+ Lastly a struct is provided that can be used in stl containers to establish a strictly lesser ordering between PickupIdentifiers (and thus Pickupables).
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _OrxonoxExport PickupIdentifier : virtual public OrxonoxClass
+ {
+
+ public:
+ PickupIdentifier(Pickupable* pickup); //!< Constructor.
+ ~PickupIdentifier(); //!< Destructor.
+
+ virtual int compare(const PickupIdentifier* identifier) const; //!< Compares two PickupIdentifiers and returns 0 if a == b, <0 if a < b and >0 if a > b for a.compare(b).
+
+ bool addParameter(std::string & name, std::string & value); //!< Add a parameter to the PickupIdentifier.
+
+ private:
+ Pickupable* pickup_; //!< The Pickupable the PickupIdentififer is for.
+ std::map<std::string, std::string> parameters_; //!< The parameters identifying the type of the pickup beyond the class.
+
+ };
+
+ /**
+ @brief
+ Struct that overloads the compare operation between two PickupIdentifier pointers.
+ */
+ struct PickupIdentifierCompare
+ {
+ bool operator() (const PickupIdentifier* lhs, const PickupIdentifier* rhs) const
+ { return lhs->compare(rhs) < 0; }
+ };
+
+}
+
+#endif // _PickupIdentifier_H__
Deleted: code/trunk/src/orxonox/pickup/PickupInventory.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PickupInventory.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/PickupInventory.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,348 +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 "PickupInventory.h"
-
-#include <CEGUIImage.h>
-#include <CEGUIImageset.h>
-#include <CEGUIImagesetManager.h>
-#include <CEGUIWindow.h>
-#include <CEGUIWindowManager.h>
-#include <elements/CEGUITabControl.h>
-
-#include "core/ConsoleCommand.h"
-#include "core/GUIManager.h"
-#include "core/input/InputManager.h"
-#include "controllers/HumanController.h"
-#include "worldentities/pawns/Pawn.h"
-
-#include "EquipmentItem.h"
-#include "PassiveItem.h"
-#include "UsableItem.h"
-
-
-namespace orxonox
-{
- SetConsoleCommandShortcut(PickupInventory, toggleInventory);
-
- 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::hideGUI("PickupInventory");
- }
- else
- {
- GUIManager::showGUI("PickupInventory");
- }
- 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 "";
-
- const 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.0f + x * 70), CEGUI::UDim(0, 5.0f + y * 90)));
- frame->setSize(CEGUI::UVector2(CEGUI::UDim(0, 65), CEGUI::UDim(0, 65)));
- frame->setRiseOnClickEnabled(false);
- frame->setVisible(false);
-
- CEGUI::Window* text = winMgr->createWindow("TaharezLook/StaticText", "orxonox/Inventory/Title/" + id);
- text->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 5.0f + x * 70), CEGUI::UDim(0, 70.0f + 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.0f + x * 70), CEGUI::UDim(0, 8.0f + y * 90)));
- btn->setSize(CEGUI::UVector2(CEGUI::UDim(0, 59), CEGUI::UDim(0, 59)));
- btn->subscribeScriptedEvent("Clicked", "PickupInventory.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);
-
- const 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);
- }
-}
Deleted: code/trunk/src/orxonox/pickup/PickupInventory.h
===================================================================
--- code/trunk/src/orxonox/pickup/PickupInventory.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/PickupInventory.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,98 +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 Declaration of static class for the inventory GUI window.
-*/
-
-#ifndef _PickupInventory_H__
-#define _PickupInventory_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <CEGUIForwardRefs.h>
-#include "core/BaseObject.h"
-
-// tolua_begin
-namespace orxonox
-{
- /**
- @brief Static class for the inventory GUI window.
- @author Daniel 'Huty' Haggenmueller
- */
- 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: code/trunk/src/orxonox/pickup/PickupSpawner.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PickupSpawner.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/PickupSpawner.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,188 +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)
- {
- 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 = 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::showGUI("PickupInventory");
- GUIManager::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 = orxonox_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)
- {
- this->respawnTimer_.setTimer(this->respawnTime_, false, createExecutor(createFunctor(&PickupSpawner::respawnTimerCallback, this)));
-
- this->setActive(false);
- this->fireEvent();
- }
- }
- else
- newObject->destroy();
- }
- }
- }
- /**
- @brief Invoked by the timer, re-activates the PickupSpawner.
- */
- void PickupSpawner::respawnTimerCallback()
- {
- COUT(3) << "PickupSpawner reactivated." << std::endl;
-
- this->setActive(true);
- }
-}
Deleted: code/trunk/src/orxonox/pickup/PickupSpawner.h
===================================================================
--- code/trunk/src/orxonox/pickup/PickupSpawner.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/PickupSpawner.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,120 +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:
- 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 respawnTimer_; //!< Timer used for re-activating.
- };
-}
-
-#endif /* _PickupSpawner_H__ */
Deleted: code/trunk/src/orxonox/pickup/UsableItem.cc
===================================================================
--- code/trunk/src/orxonox/pickup/UsableItem.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/UsableItem.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,47 +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 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);
- }
-}
Deleted: code/trunk/src/orxonox/pickup/UsableItem.h
===================================================================
--- code/trunk/src/orxonox/pickup/UsableItem.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/pickup/UsableItem.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -1,60 +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 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__ */
Modified: code/trunk/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -80,6 +80,10 @@
this->node_->setPosition(Vector3::ZERO);
this->node_->setOrientation(Quaternion::IDENTITY);
+
+ // Activity and visibility memory.
+ this->bActiveMem_ = true;
+ this->bVisibleMem_ = true;
// Default behaviour does not include physics
@@ -200,6 +204,50 @@
// Attach to parent if necessary
registerVariable(this->parentID_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::networkcallback_parentChanged));
}
+
+ /**
+ @brief
+ When the activity is changed, it is changed for all attached objects as well.
+ */
+ void WorldEntity::changedActivity(void)
+ {
+ SUPER(WorldEntity, changedActivity);
+
+ for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
+ {
+ if(!this->isActive())
+ {
+ (*it)->bActiveMem_ = (*it)->isActive();
+ (*it)->setActive(this->isActive());
+ }
+ else
+ {
+ (*it)->setActive((*it)->bActiveMem_);
+ }
+ }
+ }
+
+ /**
+ @brief
+ When the visibility is changed, it is changed for all attached objects as well.
+ */
+ void WorldEntity::changedVisibility(void)
+ {
+ SUPER(WorldEntity, changedVisibility);
+
+ for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
+ {
+ if(!this->isVisible())
+ {
+ (*it)->bVisibleMem_ = (*it)->isVisible();
+ (*it)->setVisible(this->isVisible());
+ }
+ else
+ {
+ (*it)->setVisible((*it)->bVisibleMem_);
+ }
+ }
+ }
/**
@brief
Modified: code/trunk/src/orxonox/worldentities/WorldEntity.h
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -104,6 +104,9 @@
static const Vector3 RIGHT;
static const Vector3 DOWN;
static const Vector3 UP;
+
+ virtual void changedActivity(void);
+ virtual void changedVisibility(void);
virtual void setPosition(const Vector3& position) = 0;
inline void setPosition(float x, float y, float z)
@@ -230,6 +233,9 @@
unsigned int parentID_;
std::set<WorldEntity*> children_;
bool bDeleteWithParent_;
+
+ bool bActiveMem_;
+ bool bVisibleMem_;
/////////////
Modified: code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Pawn.cc 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/worldentities/pawns/Pawn.cc 2010-03-15 14:27:09 UTC (rev 6524)
@@ -70,7 +70,8 @@
this->aimPosition_ = Vector3::ZERO;
- this->getPickups().setOwner(this);
+ //TODO: Remove.
+ //this->getPickups().setOwner(this);
if (GameMode::isMaster())
{
@@ -295,10 +296,11 @@
this->spawneffect();
}
- void Pawn::dropItems()
- {
- this->getPickups().clear();
- }
+//TODO: Remove.
+// void Pawn::dropItems()
+// {
+// this->getPickups().clear();
+// }
/* WeaponSystem:
Modified: code/trunk/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/Pawn.h 2010-03-15 14:07:21 UTC (rev 6523)
+++ code/trunk/src/orxonox/worldentities/pawns/Pawn.h 2010-03-15 14:27:09 UTC (rev 6524)
@@ -32,13 +32,13 @@
#include "OrxonoxPrereqs.h"
#include <string>
+#include "interfaces/PickupCarrier.h"
#include "interfaces/RadarViewable.h"
#include "worldentities/ControllableEntity.h"
-#include "pickup/PickupCollection.h"
namespace orxonox
{
- class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable
+ class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable, public PickupCarrier
{
friend class WeaponSystem;
@@ -108,11 +108,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();
@@ -134,7 +135,14 @@
bool bAlive_;
- PickupCollection pickups_;
+ //TODO: Remove.
+ //PickupCollection pickups_;
+ virtual std::list<PickupCarrier*>* getCarrierChildren(void)
+ { return new std::list<PickupCarrier*>(); }
+ virtual PickupCarrier* getCarrierParent(void)
+ { return NULL; }
+ virtual const Vector3& getCarrierPosition(void)
+ { return this->getWorldPosition(); };
float health_;
float maxHealth_;
More information about the Orxonox-commit
mailing list