#pragma once #include "util/RunStateOwner.h" namespace RBX { class BaseScript; class ModuleScript; // Interface for Instances that turn in-game Scripts on and off // Implementations can add/remove the script from ScriptContext class RBXInterface IScriptFilter { friend class BaseScript; protected: // If script should run - pass back the IScriptOwner who should run it, otherwise NULL virtual bool scriptShouldRun(BaseScript* script) = 0; }; extern const char *const sRuntimeScriptService; class RuntimeScriptService : public DescribedNonCreatable , public Service { private: typedef DescribedNonCreatable Super; public: RuntimeScriptService():isRunning(false) { } void runScript(BaseScript* script); void releaseScript(BaseScript* script); protected: virtual void onServiceProvider(ServiceProvider* oldProvider, ServiceProvider* newProvider); private: rbx::signals::scoped_connection runTransitionConnection; std::set > pendingScripts; // holds Scripts that are waiting for "Run" std::set > runningScripts; bool isRunning; void onRunTransition(RunTransition event) { onRunState(event.newState); } void onRunState(RunState state); }; }