예제 #1
0
        public void AddRegion(Scene scene)
        {
            if (ConfigSource.Configs[ScriptEngineName] == null)
            {
                ConfigSource.AddConfig(ScriptEngineName);
            }

            _scriptConfigSource = ConfigSource.Configs[ScriptEngineName];

            _enabled = _scriptConfigSource.GetBoolean("Enabled", true);

            if (!_enabled)
            {
                return;
            }

            IWorldComm comms = scene.RequestModuleInterface <IWorldComm>();

            if (comms == null)
            {
                _log.Error("[Phlox]: Script engine can not start, no worldcomm module found");
                return;
            }

            comms.SetWorkArrivedDelegate(this.WorkArrived);

            _scene = scene;

            _exeScheduler = new ExecutionScheduler(this.WorkArrived, this, comms);
            _stateManager = new StateManager(_exeScheduler);
            _exeScheduler.StateManager = _stateManager;

            _scriptLoader = new ScriptLoader(scene.CommsManager.AssetCache, _exeScheduler, this.WorkArrived, this);
            _scriptLoader.StateManager = _stateManager;

            _masterScheduler = new MasterScheduler(_exeScheduler, _scriptLoader, _stateManager);
            _stateManager.MMasterScheduler = _masterScheduler;
            _eventRouter = new EventRouter(this);

            _scene.EventManager.OnRezScript               += new EventManager.NewRezScript(EventManager_OnRezScript);
            _scene.EventManager.OnRemoveScript            += new EventManager.RemoveScript(EventManager_OnRemoveScript);
            _scene.EventManager.OnReloadScript            += new EventManager.ReloadScript(EventManager_OnReloadScript);
            _scene.EventManager.OnScriptReset             += new EventManager.ScriptResetDelegate(EventManager_OnScriptReset);
            _scene.EventManager.OnGetScriptRunning        += new EventManager.GetScriptRunning(EventManager_OnGetScriptRunning);
            _scene.EventManager.OnStartScript             += new EventManager.StartScript(EventManager_OnStartScript);
            _scene.EventManager.OnStopScript              += new EventManager.StopScript(EventManager_OnStopScript);
            _scene.EventManager.OnCompileScript           += new EventManager.CompileScript(EventManager_OnCompileScript);
            _scene.EventManager.OnGroupCrossedToNewParcel += new EventManager.GroupCrossedToNewParcelDelegate(EventManager_OnGroupCrossedToNewParcel);
            _scene.EventManager.OnSOGOwnerGroupChanged    += new EventManager.SOGOwnerGroupChangedDelegate(EventManager_OnSOGOwnerGroupChanged);
            _scene.EventManager.OnCrossedAvatarReady      += OnCrossedAvatarReady;
            _scene.EventManager.OnGroupBeginInTransit     += EventManager_OnGroupBeginInTransit;
            _scene.EventManager.OnGroupEndInTransit       += EventManager_OnGroupEndInTransit;

            _masterScheduler.Start();

            _scene.StackModuleInterface <IScriptModule>(this);

            Phlox.Util.Preloader.Preload();
        }
예제 #2
0
        public void AddRegion(Scene scene)
        {
            if (ConfigSource.Configs[ScriptEngineName] == null)
                ConfigSource.AddConfig(ScriptEngineName);

            _scriptConfigSource = ConfigSource.Configs[ScriptEngineName];

            _enabled = _scriptConfigSource.GetBoolean("Enabled", true);
            
            if (!_enabled) return;

            IWorldComm comms = scene.RequestModuleInterface<IWorldComm>();
            if (comms == null)
            {
                _log.Error("[Phlox]: Script engine can not start, no worldcomm module found");
                return;
            }

            comms.SetWorkArrivedDelegate(this.WorkArrived);

            _scene = scene;
            
            _exeScheduler = new ExecutionScheduler(this.WorkArrived, this, comms);
            _stateManager = new StateManager(_exeScheduler);
            _exeScheduler.StateManager = _stateManager;

            _scriptLoader = new ScriptLoader(scene.CommsManager.AssetCache, _exeScheduler, this.WorkArrived, this);
            _scriptLoader.StateManager = _stateManager;

            _masterScheduler = new MasterScheduler(_exeScheduler, _scriptLoader, _stateManager);
            _stateManager.MMasterScheduler = _masterScheduler;
            _eventRouter = new EventRouter(this);

            _scene.EventManager.OnRezScript += new EventManager.NewRezScript(EventManager_OnRezScript);
            _scene.EventManager.OnRemoveScript += new EventManager.RemoveScript(EventManager_OnRemoveScript);
            _scene.EventManager.OnReloadScript += new EventManager.ReloadScript(EventManager_OnReloadScript);
            _scene.EventManager.OnScriptReset += new EventManager.ScriptResetDelegate(EventManager_OnScriptReset);
            _scene.EventManager.OnGetScriptRunning += new EventManager.GetScriptRunning(EventManager_OnGetScriptRunning);
            _scene.EventManager.OnStartScript += new EventManager.StartScript(EventManager_OnStartScript);
            _scene.EventManager.OnStopScript += new EventManager.StopScript(EventManager_OnStopScript);
            _scene.EventManager.OnCompileScript += new EventManager.CompileScript(EventManager_OnCompileScript);
            _scene.EventManager.OnGroupCrossedToNewParcel += new EventManager.GroupCrossedToNewParcelDelegate(EventManager_OnGroupCrossedToNewParcel);
            _scene.EventManager.OnSOGOwnerGroupChanged += new EventManager.SOGOwnerGroupChangedDelegate(EventManager_OnSOGOwnerGroupChanged);
            _scene.EventManager.OnCrossedAvatarReady += OnCrossedAvatarReady;
            _scene.EventManager.OnGroupBeginInTransit += EventManager_OnGroupBeginInTransit;
            _scene.EventManager.OnGroupEndInTransit += EventManager_OnGroupEndInTransit;

            _masterScheduler.Start();

            _scene.StackModuleInterface<IScriptModule>(this);

            Phlox.Util.Preloader.Preload();
        }