Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2017, 2:37:50 PM (7 years ago)
Author:
patricwi
Message:

merged scriptable controller but not tested

Location:
code/branches/Presentation_HS17
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/branches/Presentation_HS17

  • code/branches/Presentation_HS17/src/orxonox/CMakeLists.txt

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

    r11071 r11686  
    4242#include "overlays/OverlayGroup.h"
    4343#include "LevelManager.h"
     44#include "scriptablecontroller/scriptable_controller.h"
    4445
    4546namespace orxonox
     
    5657        this->xmlfilename_ = this->getFilename();
    5758        this->xmlfile_ = nullptr;
     59        this->controller_.reset(new ScriptableController());
    5860    }
    5961
     
    7880        XMLPortParam(Level, "plugins",  setPluginsString,  getPluginsString,  xmlelement, mode);
    7981        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
     82
     83        XMLPortParamLoadOnly(Level, "script", setScript, xmlelement, mode);
    8084
    8185        XMLPortObject(Level, MeshLodInformation, "lodinformation", addLodInfo, getLodInfo, xmlelement, mode);
  • code/branches/Presentation_HS17/src/orxonox/Level.h

    r11071 r11686  
    4242namespace orxonox
    4343{
     44    class ScriptableController;
     45
    4446    class _OrxonoxExport Level : public BaseObject, public Synchronisable, public Context
    4547    {
     
    5456
    5557            MeshLodInformation* getLodInfo(std::string meshName) const;
     58
     59            inline ScriptableController *getScriptableController(void)
     60                { return this->controller_.get(); }
     61
     62            inline const std::string &getScript(void)
     63                { return this->level_script_; }
    5664
    5765
     
    7886            void networkcallback_applyXMLFile();
    7987
     88            inline void setScript(const std::string &script)
     89                { this->level_script_ = script; }
     90
     91
    8092            std::string                    pluginsString_;
    8193            std::list<PluginReference*>    plugins_;
    82 
    8394            std::string                    gametype_;
    8495            std::string                    xmlfilename_;
     
    8697            std::list<BaseObject*>         objects_;
    8798            std::map<std::string,MeshLodInformation*>  lodInformation_;
     99
     100            std::unique_ptr<ScriptableController> controller_;
     101            std::string           level_script_;
    88102    };
    89103}
  • code/branches/Presentation_HS17/src/orxonox/infos/GametypeInfo.cc

    r11099 r11686  
    4343#include "interfaces/GametypeMessageListener.h"
    4444#include "interfaces/NotificationListener.h"
     45#include "scriptablecontroller/scriptable_controller.h"
     46#include "Level.h"
    4547
    4648#include "PlayerInfo.h"
     
    7678        this->spawned_ = false;
    7779        this->readyToSpawn_ = false;
     80        this->isFirstSpawn_ = true;
    7881
    7982        this->registerVariables();
     
    310313        {
    311314            if(this->hasStarted() && !this->hasEnded())
    312 
    313315                this->setSpawnedHelper(player, true);
     316        }
     317
     318        // TODO We might want to handle the subsequent spawns as well somehow
     319        if(player->isHumanPlayer() && player->isLocalPlayer() && this->isFirstSpawn_)
     320        {
     321            this->isFirstSpawn_ = false;
     322            this->getLevel()->getScriptableController()->setPlayer(player);
     323
     324            // This handles paths relative to the 'level' directory
     325            std::string script = this->getLevel()->getScript();
     326            if(script.at(0) != '/')
     327                script = "../levels/" + script; // Not very dynamic
     328            this->getLevel()->getScriptableController()->runScript(script);
    314329        }
    315330    }
  • code/branches/Presentation_HS17/src/orxonox/infos/GametypeInfo.h

    r11358 r11686  
    8383            inline bool isStartCountdownRunning() const
    8484                { return this->bStartCountdownRunning_; }
    85            
     85
    8686            void changedStartCountdownRunning(void); // Is called when the start countdown has been either started or stopped.
    8787
     
    168168            bool spawned_; //!< Whether the local Player is currently spawned.
    169169            bool readyToSpawn_; //!< Whether the local Player is ready to spawn.
     170            bool isFirstSpawn_;
    170171    };
    171172}
  • code/branches/Presentation_HS17/src/orxonox/infos/HumanPlayer.cc

    r11071 r11686  
    3838#include "gametypes/Gametype.h"
    3939#include "overlays/OverlayGroup.h"
     40#include "Level.h"
     41#include "scriptablecontroller/scriptable_controller.h"
    4042
    4143namespace orxonox
  • code/branches/Presentation_HS17/src/orxonox/items/ShipPart.cc

    r11099 r11686  
    4242#include "items/PartDestructionEvent.h"
    4343#include "chat/ChatManager.h"
     44#include "Level.h"
     45#include "scriptablecontroller/scriptable_controller.h"
    4446
    4547
     
    215217            }
    216218        }
     219
     220        // This is a bit hacky, but it takes away damage control from the pawn, so it has to handle
     221        // that as well.
     222        this->getLevel()->getScriptableController()->pawnHit(parent_, originator, parent_->getHealth(), parent_->getShieldHealth());
     223
    217224        if (this->health_ < 0)
    218225            this->death();
  • code/branches/Presentation_HS17/src/orxonox/worldentities/ControllableEntity.cc

    r11071 r11686  
    3939
    4040#include "Scene.h"
     41#include "Level.h"
    4142#include "infos/PlayerInfo.h"
    4243#include "controllers/NewHumanController.h"
     
    6768        this->camera_ = nullptr;
    6869        this->xmlcontroller_ = nullptr;
    69         //this->controller_ = nullptr;
    7070        this->reverseCamera_ = nullptr;
    7171        this->bDestroyWhenPlayerLeft_ = false;
  • code/branches/Presentation_HS17/src/orxonox/worldentities/ControllableEntity.h

    r11071 r11686  
    175175            inline int getTeam() const
    176176                { return this->team_; }
     177
    177178
    178179        protected:
  • code/branches/Presentation_HS17/src/orxonox/worldentities/MobileEntity.cc

    r11071 r11686  
    3636
    3737#include "Scene.h"
     38#include "Level.h"
     39#include "scriptablecontroller/scriptable_controller.h"
    3840
    3941namespace orxonox
     
    7274                this->setAngularVelocity(rotationAxis.normalisedCopy() * rotationRate.valueRadians());
    7375        }
     76
     77        if(!this->id_.empty() && this->getLevel() != nullptr)
     78            this->getLevel()->getScriptableController()->registerMobileEntity(this->id_, this);
    7479    }
    7580
  • code/branches/Presentation_HS17/src/orxonox/worldentities/WorldEntity.cc

    r11083 r11686  
    4444#include "core/XMLPort.h"
    4545#include "Scene.h"
     46#include "Level.h"
    4647#include "collisionshapes/WorldEntityCollisionShape.h"
     48#include "scriptablecontroller/scriptable_controller.h"
    4749
    4850namespace orxonox
     
    7981        this->parentID_ = OBJECTID_UNKNOWN;
    8082        this->bDeleteWithParent_ = true;
     83        this->id_ = -1;
    8184
    8285        this->node_->setPosition(Vector3::ZERO);
     
    160163        XMLPortParamTemplate(WorldEntity, "scale3D",     setScale3D,     getScale3D,     xmlelement, mode, const Vector3&);
    161164        XMLPortParam        (WorldEntity, "scale",       setScale,       getScale,       xmlelement, mode);
     165        XMLPortParamLoadOnly(WorldEntity, "id",          setID,                xmlelement, mode);
    162166        XMLPortParamLoadOnly(WorldEntity, "lookat",      lookAt_xmlport,       xmlelement, mode);
    163167        XMLPortParamLoadOnly(WorldEntity, "direction",   setDirection_xmlport, xmlelement, mode);
     
    181185        // Attached collision shapes
    182186        XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode);
     187
     188        if(!this->id_.empty() && this->getLevel() != nullptr)
     189            this->getLevel()->getScriptableController()->registerWorldEntity(this->id_, this);
    183190    }
    184191
  • code/branches/Presentation_HS17/src/orxonox/worldentities/WorldEntity.h

    r11099 r11686  
    110110            virtual void changedActivity(void) override;
    111111            virtual void changedVisibility(void) override;
     112
     113            inline std::string getID(void)
     114                { return this->id_; }
     115
     116            inline void setID(std::string id)
     117                { this->id_ = id; }
    112118
    113119            virtual void setPosition(const Vector3& position) = 0;
     
    442448
    443449            btRigidBody*  physicalBody_; //!< Bullet rigid body. Everything physical is applied to this instance.
     450            std::string   id_;           //!< Used by the ScriptableController to identify objects
    444451
    445452        private:
  • code/branches/Presentation_HS17/src/orxonox/worldentities/pawns/Pawn.cc

    r11679 r11686  
    5050#include "sound/WorldSound.h"
    5151#include "core/object/ObjectListIterator.h"
     52#include "Level.h"
     53#include "scriptablecontroller/scriptable_controller.h"
    5254
    5355#include "controllers/FormationController.h"
     
    160162
    161163        XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode );
     164
     165        if(!this->id_.empty() && this->getLevel() != nullptr)
     166            this->getLevel()->getScriptableController()->registerPawn(this->id_, this);
    162167    }
    163168
     
    282287        {
    283288            // Health-damage cannot be absorbed by shields.
    284             // Shield-damage only reduces shield health. 
     289            // Shield-damage only reduces shield health.
    285290            // Normal damage can be (partially) absorbed by shields.
    286291
     
    302307                this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
    303308            }
     309            this->getLevel()->getScriptableController()->pawnHit(this, originator, this->health_, this->shieldHealth_);
    304310
    305311            this->lastHitOriginator_ = originator;
     
    402408            }
    403409        }
     410
     411        this->getLevel()->getScriptableController()->pawnKilled(this);
    404412    }
    405413    void Pawn::goWithStyle()
     
    625633        {
    626634            // delete all debug models
    627             for(Model* model : debugWeaponSlotModels_) 
     635            for(Model* model : debugWeaponSlotModels_)
    628636            {
    629637                model->destroy();
Note: See TracChangeset for help on using the changeset viewer.