[Orxonox-commit 1800] r6518 - in code/branches/pickup3: data/levels src/modules/pickup src/modules/pickup/items src/orxonox/interfaces
dafrick at orxonox.net
dafrick at orxonox.net
Fri Mar 12 08:56:04 CET 2010
Author: dafrick
Date: 2010-03-12 08:56:04 +0100 (Fri, 12 Mar 2010)
New Revision: 6518
Added:
code/branches/pickup3/src/modules/pickup/items/MetaPickup.cc
code/branches/pickup3/src/modules/pickup/items/MetaPickup.h
Removed:
code/branches/pickup3/src/modules/pickup/items/TestPickup.cc
code/branches/pickup3/src/modules/pickup/items/TestPickup.h
Modified:
code/branches/pickup3/data/levels/pickup.oxw
code/branches/pickup3/src/modules/pickup/PickupPrereqs.h
code/branches/pickup3/src/modules/pickup/items/CMakeLists.txt
code/branches/pickup3/src/orxonox/interfaces/PickupCarrier.h
Log:
Renamed TestPickup to MetaPickup.
Modified: code/branches/pickup3/data/levels/pickup.oxw
===================================================================
--- code/branches/pickup3/data/levels/pickup.oxw 2010-03-12 07:42:18 UTC (rev 6517)
+++ code/branches/pickup3/data/levels/pickup.oxw 2010-03-12 07:56:04 UTC (rev 6518)
@@ -24,13 +24,13 @@
<PickupSpawner position="-100,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
<pickup>
- <TestPickup testType="drop" />
+ <MetaPickup metaType="drop" />
</pickup>
</PickupSpawner>
<PickupSpawner position="-75,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
<pickup>
- <TestPickup testType="use" />
+ <MetaPickup metaType="use" />
</pickup>
</PickupSpawner>
Modified: code/branches/pickup3/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/PickupPrereqs.h 2010-03-12 07:42:18 UTC (rev 6517)
+++ code/branches/pickup3/src/modules/pickup/PickupPrereqs.h 2010-03-12 07:56:04 UTC (rev 6518)
@@ -75,7 +75,7 @@
//items
class HealthPickup;
- class TestPickup;
+ class MetaPickup;
}
Modified: code/branches/pickup3/src/modules/pickup/items/CMakeLists.txt
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/CMakeLists.txt 2010-03-12 07:42:18 UTC (rev 6517)
+++ code/branches/pickup3/src/modules/pickup/items/CMakeLists.txt 2010-03-12 07:56:04 UTC (rev 6518)
@@ -1,4 +1,4 @@
ADD_SOURCE_FILES(PICKUP_SRC_FILES
HealthPickup.cc
- TestPickup.cc
+ MetaPickup.cc
)
Copied: code/branches/pickup3/src/modules/pickup/items/MetaPickup.cc (from rev 6517, code/branches/pickup3/src/modules/pickup/items/TestPickup.cc)
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/MetaPickup.cc (rev 0)
+++ code/branches/pickup3/src/modules/pickup/items/MetaPickup.cc 2010-03-12 07:56:04 UTC (rev 6518)
@@ -0,0 +1,152 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+*/
+
+#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";
+
+ 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/branches/pickup3/src/modules/pickup/items/MetaPickup.h (from rev 6515, code/branches/pickup3/src/modules/pickup/items/TestPickup.h)
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/MetaPickup.h (rev 0)
+++ code/branches/pickup3/src/modules/pickup/items/MetaPickup.h 2010-03-12 07:56:04 UTC (rev 6518)
@@ -0,0 +1,85 @@
+/*
+ * 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 _MetaPickup_H__
+#define _MetaPickup_H__
+
+#include "pickup/PickupPrereqs.h"
+
+#include "pickup/Pickup.h"
+
+namespace orxonox {
+
+ namespace pickupMetaType
+ {
+ enum Value
+ {
+ none,
+ use,
+ drop
+ };
+ }
+
+ class _PickupExport MetaPickup : public Pickup
+ {
+ friend class PickupCarrier;
+
+ 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__
Deleted: code/branches/pickup3/src/modules/pickup/items/TestPickup.cc
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/TestPickup.cc 2010-03-12 07:42:18 UTC (rev 6517)
+++ code/branches/pickup3/src/modules/pickup/items/TestPickup.cc 2010-03-12 07:56:04 UTC (rev 6518)
@@ -1,152 +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 "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "interfaces/PickupCarrier.h"
-#include "pickup/PickupIdentifier.h"
-
-#include "TestPickup.h"
-
-namespace orxonox {
-
- CreateFactory(TestPickup);
-
- /*static*/ const std::string TestPickup::testTypeNone_s = "none";
- /*static*/ const std::string TestPickup::testTypeUse_s = "use";
- /*static*/ const std::string TestPickup::testTypeDrop_s = "drop";
-
- TestPickup::TestPickup(BaseObject* creator) : Pickup(creator)
- {
- RegisterObject(TestPickup);
-
- this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier());
- this->setActivationTypeDirect(pickupActivationType::immediate);
- this->setDurationTypeDirect(pickupDurationType::once);
- this->testType_ = pickupTestType::none;
- }
-
- TestPickup::~TestPickup()
- {
-
- }
-
- void TestPickup::initializeIdentifier(void)
- {
- std::string val = this->getTestType();
- std::string type = "testType";
- this->pickupIdentifier_->addParameter(type, val);
- }
-
- void TestPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
- {
- SUPER(TestPickup, XMLPort, xmlelement, mode);
-
- XMLPortParam(TestPickup, "testType", setTestType, getTestType, xmlelement, mode);
-
- this->initializeIdentifier();
- }
-
- void TestPickup::changedUsed(void)
- {
- SUPER(TestPickup, changedUsed);
-
- if(this->isUsed())
- {
- PickupCarrier* carrier = this->getCarrier();
- if(this->getTestTypeDirect() != pickupTestType::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->getTestTypeDirect() == pickupTestType::use)
- {
- if(pickup != NULL && pickup != this && pickup->isOnUse() && !pickup->isUsed())
- {
- pickup->setUsed(true);
- }
- }
- if(this->getTestTypeDirect() == pickupTestType::drop)
- {
- if(pickup != NULL && pickup != this)
- {
- carrier->drop(pickup);
- }
- }
- }
- }
- this->destroy();
- }
- }
-
- const std::string& TestPickup::getTestType(void)
- {
- switch(this->getTestTypeDirect())
- {
- case pickupTestType::none:
- return TestPickup::testTypeNone_s;
- case pickupTestType::use:
- return TestPickup::testTypeUse_s;
- case pickupTestType::drop:
- return TestPickup::testTypeDrop_s;
- default:
- return BLANKSTRING;
- }
- }
-
- void TestPickup::setTestType(const std::string& type)
- {
- if(type == TestPickup::testTypeNone_s)
- {
- this->setTestTypeDirect(pickupTestType::none);
- }
- else if(type == TestPickup::testTypeUse_s)
- {
- this->setTestTypeDirect(pickupTestType::use);
- }
- else if(type == TestPickup::testTypeDrop_s)
- {
- this->setTestTypeDirect(pickupTestType::drop);
- }
- }
-
- void TestPickup::clone(OrxonoxClass*& item)
- {
- if(item == NULL)
- item = new TestPickup(this);
-
- SUPER(TestPickup, clone, item);
-
- TestPickup* pickup = dynamic_cast<TestPickup*>(item);
- pickup->setTestTypeDirect(this->getTestTypeDirect());
-
- pickup->initializeIdentifier();
- }
-
-}
Deleted: code/branches/pickup3/src/modules/pickup/items/TestPickup.h
===================================================================
--- code/branches/pickup3/src/modules/pickup/items/TestPickup.h 2010-03-12 07:42:18 UTC (rev 6517)
+++ code/branches/pickup3/src/modules/pickup/items/TestPickup.h 2010-03-12 07:56:04 UTC (rev 6518)
@@ -1,85 +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 _TestPickup_H__
-#define _TestPickup_H__
-
-#include "pickup/PickupPrereqs.h"
-
-#include "pickup/Pickup.h"
-
-namespace orxonox {
-
- namespace pickupTestType
- {
- enum Value
- {
- none,
- use,
- drop
- };
- }
-
- class _PickupExport TestPickup : public Pickup
- {
- friend class PickupCarrier;
-
- public:
- TestPickup(BaseObject* creator);
- virtual ~TestPickup();
-
- 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 pickupTestType::Value getTestTypeDirect(void)
- { return this->testType_; }
- const std::string& getTestType(void);
-
- protected:
- void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
-
- inline void setTestTypeDirect(pickupTestType::Value type)
- { this->testType_ = type; }
- void setTestType(const std::string& type);
-
- private:
- void initialize(void); //!< Initializes the member variables.
-
- pickupTestType::Value testType_;
- static const std::string testTypeNone_s;
- static const std::string testTypeUse_s;
- static const std::string testTypeDrop_s;
-
-
- };
-
-}
-
-#endif // _TestPickup_H__
Modified: code/branches/pickup3/src/orxonox/interfaces/PickupCarrier.h
===================================================================
--- code/branches/pickup3/src/orxonox/interfaces/PickupCarrier.h 2010-03-12 07:42:18 UTC (rev 6517)
+++ code/branches/pickup3/src/orxonox/interfaces/PickupCarrier.h 2010-03-12 07:56:04 UTC (rev 6518)
@@ -48,7 +48,7 @@
class Pickup;
class HealthPickup;
- class TestPickup;
+ class MetaPickup;
/**
@brief
@@ -62,7 +62,7 @@
//TODO: Ugly workaround.
friend class Pickup;
friend class HealthPickup;
- friend class TestPickup;
+ friend class MetaPickup;
public:
PickupCarrier(); //!< Constructor.
More information about the Orxonox-commit
mailing list