Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11518 for code


Ignore:
Timestamp:
Oct 30, 2017, 4:05:01 PM (7 years ago)
Author:
kohlia
Message:

Nothing to see yet, really.

Location:
code/branches/ScriptableController_HS17/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ScriptableController_HS17/src/libraries/core/BaseObject.h

    r11071 r11518  
    5858    class Gametype;
    5959    class Level;
     60    class ScriptableController;
    6061
    6162    /// The BaseObject is the parent of all classes representing an instance in the game.
     
    191192
    192193            static void loadAllEventStates(Element& xmlelement, XMLPort::Mode mode, BaseObject* object, Identifier* identifier);
     194
     195            virtual void registerToScriptableController(ScriptableController *controller) {}
    193196
    194197        protected:
  • code/branches/ScriptableController_HS17/src/orxonox/CMakeLists.txt

    r11356 r11518  
    5252ADD_SUBDIRECTORY(items)
    5353ADD_SUBDIRECTORY(overlays)
     54ADD_SUBDIRECTORY(scriptablecontroller)
    5455ADD_SUBDIRECTORY(sound)
    5556ADD_SUBDIRECTORY(weaponsystem)
  • code/branches/ScriptableController_HS17/src/orxonox/Level.cc

    r11071 r11518  
    4242#include "overlays/OverlayGroup.h"
    4343#include "LevelManager.h"
     44#include "scriptablecontroller/scriptable_controller.h"
    4445
    4546namespace orxonox
     
    7980        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
    8081
     82        XMLPortParamLoadOnly(Level, "script", setScript, xmlelement, mode);
     83
    8184        XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
    8285        XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
     86
     87        if(this->level_script_ != "")
     88        {
     89            this->controller_.reset(new ScriptableController());
     90            this->controller_->runScript(this->level_script_);
     91        }
    8392    }
    8493
     
    168177    {
    169178        this->objects_.push_back(object);
     179        if(this->controller_.get() != nullptr)
     180            object->registerToScriptableController(this->controller_.get());
    170181    }
    171182
  • code/branches/ScriptableController_HS17/src/orxonox/Level.h

    r11071 r11518  
    4242namespace orxonox
    4343{
     44    class ScriptableController;
     45
    4446    class _OrxonoxExport Level : public BaseObject, public Synchronisable, public Context
    4547    {
     
    7880            void networkcallback_applyXMLFile();
    7981
     82            inline void setScript(const std::string &script)
     83                { this->level_script_ = script; }
     84
     85
    8086            std::string                    pluginsString_;
    8187            std::list<PluginReference*>    plugins_;
    82 
    8388            std::string                    gametype_;
    8489            std::string                    xmlfilename_;
     
    8691            std::list<BaseObject*>         objects_;
    8792            std::map<std::string,MeshLodInformation*>  lodInformation_;
     93
     94            std::unique_ptr<ScriptableController> controller_;
     95            std::string                           level_script_;
    8896    };
    8997}
  • code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.cc

    r11071 r11518  
    4444#include "worldentities/CameraPosition.h"
    4545#include "overlays/OverlayGroup.h"
     46#include "scriptablecontroller/scriptable_controller.h"
    4647
    4748namespace orxonox
     
    337338    }
    338339
     340    void ControllableEntity::registerToScriptableController(ScriptableController *controller)
     341    {
     342        controller->registerControllableEntity(this->id_, this);
     343    }
     344
    339345    void ControllableEntity::setPlayer(PlayerInfo* player)
    340346    {
  • code/branches/ScriptableController_HS17/src/orxonox/worldentities/ControllableEntity.h

    r11071 r11518  
    175175            inline int getTeam() const
    176176                { return this->team_; }
     177
     178            virtual void registerToScriptableController(ScriptableController *controller) override;
    177179
    178180        protected:
  • code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.cc

    r11083 r11518  
    4545#include "Scene.h"
    4646#include "collisionshapes/WorldEntityCollisionShape.h"
     47#include "scriptablecontroller/scriptable_controller.h"
    4748
    4849namespace orxonox
     
    7980        this->parentID_ = OBJECTID_UNKNOWN;
    8081        this->bDeleteWithParent_ = true;
     82        this->id_ = -1;
    8183
    8284        this->node_->setPosition(Vector3::ZERO);
     
    160162        XMLPortParamTemplate(WorldEntity, "scale3D",     setScale3D,     getScale3D,     xmlelement, mode, const Vector3&);
    161163        XMLPortParam        (WorldEntity, "scale",       setScale,       getScale,       xmlelement, mode);
     164        XMLPortParamLoadOnly(WorldEntity, "id",          setID,                xmlelement, mode);
    162165        XMLPortParamLoadOnly(WorldEntity, "lookat",      lookAt_xmlport,       xmlelement, mode);
    163166        XMLPortParamLoadOnly(WorldEntity, "direction",   setDirection_xmlport, xmlelement, mode);
     
    275278    }
    276279
     280    void WorldEntity::registerToScriptableController(ScriptableController *controller)
     281    {
     282        controller->registerWorldEntity(this->id_, this);
     283    }
     284
    277285    /**
    278286    @brief
  • code/branches/ScriptableController_HS17/src/orxonox/worldentities/WorldEntity.h

    r11099 r11518  
    110110            virtual void changedActivity(void) override;
    111111            virtual void changedVisibility(void) override;
     112
     113            inline void setID(int id)
     114                { this->id_ = id; }
     115
     116            virtual void registerToScriptableController(ScriptableController *controller) override;
    112117
    113118            virtual void setPosition(const Vector3& position) = 0;
     
    442447
    443448            btRigidBody*  physicalBody_; //!< Bullet rigid body. Everything physical is applied to this instance.
     449            int           id_;           //!< Used by the ScriptableController to identify objects
    444450
    445451        private:
Note: See TracChangeset for help on using the changeset viewer.