[Orxonox-commit 6897] r11518 - in code/branches/ScriptableController_HS17/src: libraries/core orxonox orxonox/worldentities
kohlia at orxonox.net
kohlia at orxonox.net
Mon Oct 30 16:05:02 CET 2017
Author: kohlia
Date: 2017-10-30 16:05:01 +0100 (Mon, 30 Oct 2017)
New Revision: 11518
Modified:
code/branches/ScriptableController_HS17/src/libraries/core/BaseObject.h
code/branches/ScriptableController_HS17/src/orxonox/CMakeLists.txt
code/branches/ScriptableController_HS17/src/orxonox/Level.cc
code/branches/ScriptableController_HS17/src/orxonox/Level.h
code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.cc
code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.h
code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.cc
code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.h
Log:
Nothing to see yet, really.
Modified: code/branches/ScriptableController_HS17/src/libraries/core/BaseObject.h
===================================================================
--- code/branches/ScriptableController_HS17/src/libraries/core/BaseObject.h 2017-10-30 15:05:01 UTC (rev 11517)
+++ code/branches/ScriptableController_HS17/src/libraries/core/BaseObject.h 2017-10-30 15:05:01 UTC (rev 11518)
@@ -57,6 +57,7 @@
class Scene;
class Gametype;
class Level;
+ class ScriptableController;
/// The BaseObject is the parent of all classes representing an instance in the game.
class _CoreExport BaseObject : public OrxonoxClass
@@ -191,6 +192,8 @@
static void loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier);
+ virtual void registerToScriptableController(ScriptableController *controller) {}
+
protected:
void addEventState(const std::string& name, EventState* container);
EventState* getEventState(const std::string& name) const;
Modified: code/branches/ScriptableController_HS17/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/CMakeLists.txt 2017-10-30 15:05:01 UTC (rev 11517)
+++ code/branches/ScriptableController_HS17/src/orxonox/CMakeLists.txt 2017-10-30 15:05:01 UTC (rev 11518)
@@ -51,6 +51,7 @@
ADD_SUBDIRECTORY(interfaces)
ADD_SUBDIRECTORY(items)
ADD_SUBDIRECTORY(overlays)
+ADD_SUBDIRECTORY(scriptablecontroller)
ADD_SUBDIRECTORY(sound)
ADD_SUBDIRECTORY(weaponsystem)
ADD_SUBDIRECTORY(worldentities)
Modified: code/branches/ScriptableController_HS17/src/orxonox/Level.cc
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/Level.cc 2017-10-30 15:05:01 UTC (rev 11517)
+++ code/branches/ScriptableController_HS17/src/orxonox/Level.cc 2017-10-30 15:05:01 UTC (rev 11518)
@@ -41,6 +41,7 @@
#include "gametypes/Gametype.h"
#include "overlays/OverlayGroup.h"
#include "LevelManager.h"
+#include "scriptablecontroller/scriptable_controller.h"
namespace orxonox
{
@@ -78,8 +79,16 @@
XMLPortParam(Level, "plugins", setPluginsString, getPluginsString, xmlelement, mode);
XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
+ XMLPortParamLoadOnly(Level, "script", setScript, xmlelement, mode);
+
XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
+
+ if(this->level_script_ != "")
+ {
+ this->controller_.reset(new ScriptableController());
+ this->controller_->runScript(this->level_script_);
+ }
}
void Level::registerVariables()
@@ -167,6 +176,8 @@
void Level::addObject(BaseObject* object)
{
this->objects_.push_back(object);
+ if(this->controller_.get() != nullptr)
+ object->registerToScriptableController(this->controller_.get());
}
BaseObject* Level::getObject(unsigned int index) const
Modified: code/branches/ScriptableController_HS17/src/orxonox/Level.h
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/Level.h 2017-10-30 15:05:01 UTC (rev 11517)
+++ code/branches/ScriptableController_HS17/src/orxonox/Level.h 2017-10-30 15:05:01 UTC (rev 11518)
@@ -41,6 +41,8 @@
namespace orxonox
{
+ class ScriptableController;
+
class _OrxonoxExport Level : public BaseObject, public Synchronisable, public Context
{
public:
@@ -77,14 +79,20 @@
void networkcallback_applyXMLFile();
+ inline void setScript(const std::string &script)
+ { this->level_script_ = script; }
+
+
std::string pluginsString_;
std::list<PluginReference*> plugins_;
-
std::string gametype_;
std::string xmlfilename_;
XMLFile* xmlfile_;
std::list<BaseObject*> objects_;
std::map<std::string,MeshLodInformation*> lodInformation_;
+
+ std::unique_ptr<ScriptableController> controller_;
+ std::string level_script_;
};
}
Modified: code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.cc 2017-10-30 15:05:01 UTC (rev 11517)
+++ code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.cc 2017-10-30 15:05:01 UTC (rev 11518)
@@ -43,6 +43,7 @@
#include "graphics/Camera.h"
#include "worldentities/CameraPosition.h"
#include "overlays/OverlayGroup.h"
+#include "scriptablecontroller/scriptable_controller.h"
namespace orxonox
{
@@ -336,6 +337,11 @@
this->setTarget( orxonox_cast<WorldEntity*>(Synchronisable::getSynchronisable(targetID)) );
}
+ void ControllableEntity::registerToScriptableController(ScriptableController *controller)
+ {
+ controller->registerControllableEntity(this->id_, this);
+ }
+
void ControllableEntity::setPlayer(PlayerInfo* player)
{
if (!player)
Modified: code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.h
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.h 2017-10-30 15:05:01 UTC (rev 11517)
+++ code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.h 2017-10-30 15:05:01 UTC (rev 11518)
@@ -175,6 +175,8 @@
inline int getTeam() const
{ return this->team_; }
+ virtual void registerToScriptableController(ScriptableController *controller) override;
+
protected:
virtual void preDestroy() override;
Modified: code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.cc 2017-10-30 15:05:01 UTC (rev 11517)
+++ code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.cc 2017-10-30 15:05:01 UTC (rev 11518)
@@ -44,6 +44,7 @@
#include "core/XMLPort.h"
#include "Scene.h"
#include "collisionshapes/WorldEntityCollisionShape.h"
+#include "scriptablecontroller/scriptable_controller.h"
namespace orxonox
{
@@ -78,6 +79,7 @@
this->parent_ = nullptr;
this->parentID_ = OBJECTID_UNKNOWN;
this->bDeleteWithParent_ = true;
+ this->id_ = -1;
this->node_->setPosition(Vector3::ZERO);
this->node_->setOrientation(Quaternion::IDENTITY);
@@ -159,6 +161,7 @@
XMLPortParamTemplate(WorldEntity, "orientation", setOrientation, getOrientation, xmlelement, mode, const Quaternion&);
XMLPortParamTemplate(WorldEntity, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&);
XMLPortParam (WorldEntity, "scale", setScale, getScale, xmlelement, mode);
+ XMLPortParamLoadOnly(WorldEntity, "id", setID, xmlelement, mode);
XMLPortParamLoadOnly(WorldEntity, "lookat", lookAt_xmlport, xmlelement, mode);
XMLPortParamLoadOnly(WorldEntity, "direction", setDirection_xmlport, xmlelement, mode);
XMLPortParamLoadOnly(WorldEntity, "yaw", yaw_xmlport, xmlelement, mode);
@@ -274,6 +277,11 @@
}
}
+ void WorldEntity::registerToScriptableController(ScriptableController *controller)
+ {
+ controller->registerWorldEntity(this->id_, this);
+ }
+
/**
@brief
Network function that object this instance to its correct parent.
Modified: code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.h
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.h 2017-10-30 15:05:01 UTC (rev 11517)
+++ code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.h 2017-10-30 15:05:01 UTC (rev 11518)
@@ -110,6 +110,11 @@
virtual void changedActivity(void) override;
virtual void changedVisibility(void) override;
+ inline void setID(int id)
+ { this->id_ = id; }
+
+ virtual void registerToScriptableController(ScriptableController *controller) override;
+
virtual void setPosition(const Vector3& position) = 0;
inline void setPosition(float x, float y, float z)
{ this->setPosition(Vector3(x, y, z)); }
@@ -441,6 +446,7 @@
virtual bool isCollisionTypeLegal(CollisionType type) const = 0;
btRigidBody* physicalBody_; //!< Bullet rigid body. Everything physical is applied to this instance.
+ int id_; //!< Used by the ScriptableController to identify objects
private:
void recalculateMassProps();
More information about the Orxonox-commit
mailing list