Exemple #1
0
 public void UpdateEnvironmentSettings()
 {
     Terrain.LowerLimit = (float)RegionSettings.TerrainLowerLimit;
     Terrain.RaiseLimit = (float)RegionSettings.TerrainRaiseLimit;
     if (RegionSettings.UseEstateSun)
     {
         uint       estateID;
         EstateInfo estate;
         if (EstateService.RegionMap.TryGetValue(ID, out estateID) &&
             EstateService.TryGetValue(estateID, out estate))
         {
             Environment.FixedSunPosition = estate.SunPosition;
             Environment.IsSunFixed       = (estate.Flags & RegionOptionFlags.SunFixed) != 0;
         }
     }
     else
     {
         Environment.FixedSunPosition = RegionSettings.SunPosition;
         Environment.IsSunFixed       = RegionSettings.IsSunFixed;
     }
 }
        public override void TriggerEstateUpdate()
        {
            uint       estateID;
            EstateInfo estateInfo;

            try /* we need a fail protection here */
            {
                if (EstateService.RegionMap.TryGetValue(ID, out estateID) &&
                    EstateService.TryGetValue(estateID, out estateInfo))
                {
                    lock (m_EstateDataUpdateLock)
                    {
                        m_EstateData = estateInfo;
                    }
                }
            }
            catch (Exception e)
            {
                m_Log.WarnFormat("Exception when accessing EstateService: {0}: {1}\n{2}",
                                 e.GetType().FullName,
                                 e.Message,
                                 e.StackTrace);
            }

            foreach (IAgent agent in Agents)
            {
                var viewerAgent = agent as ViewerAgent;
                if (viewerAgent != null)
                {
                    SendRegionInfo(viewerAgent);

                    ParcelInfo pInfo;
                    if (Parcels.TryGetValue(viewerAgent.GlobalPosition, out pInfo))
                    {
                        viewerAgent.SendUpdatedParcelInfo(pInfo, ID);
                    }
                }
            }
            UpdateEnvironmentSettings();
        }
        protected SceneImplementation(
            SceneImplementationFactory sceneParams,
            RegionInfo ri)
            : base(ri.Size.X, ri.Size.Y)
        {
            SceneCapabilities.Add("ProductInfoRequest", new ProductInfoRequestCapability(this));
            m_Scenes     = sceneParams.Scenes;
            m_HttpServer = sceneParams.HttpServer;
            if (sceneParams.AssetService == null)
            {
                throw new ArgumentNullException("persistentAssetService");
            }
            if (sceneParams.GridService == null)
            {
                throw new ArgumentNullException("gridService");
            }
            if (ri == null)
            {
                throw new ArgumentNullException(nameof(ri));
            }
            if (sceneParams.AvatarNameServices == null)
            {
                throw new ArgumentNullException("avatarNameServices");
            }
            if (sceneParams.SimulationDataStorage == null)
            {
                throw new ArgumentNullException("simulationDataStorage");
            }
            if (sceneParams.EstateService == null)
            {
                throw new ArgumentNullException("estateService");
            }
            if (sceneParams.m_CapabilitiesConfig == null)
            {
                throw new ArgumentNullException("capabilitiesConfig");
            }
            if (sceneParams.RegionStorage == null)
            {
                throw new ArgumentNullException("regionStorage");
            }

            #region Setup services
            m_ChatService           = sceneParams.ChatFactory.Instantiate(ri.ID);
            RegionStorage           = sceneParams.RegionStorage;
            GroupsNameService       = sceneParams.GroupsNameService;
            GroupsService           = sceneParams.GroupsService;
            m_NeighborService       = sceneParams.NeighborService;
            m_SimulationDataStorage = sceneParams.SimulationDataStorage;
            PersistentAssetService  = sceneParams.AssetService;
            TemporaryAssetService   = sceneParams.AssetCacheService;
            GridService             = sceneParams.GridService;
            ExperienceService       = sceneParams.ExperienceService;
            ExperienceNameService   = sceneParams.ExperienceNameService;
            EstateService           = sceneParams.EstateService;
            /* next line is there to break the circular dependencies */
            TryGetScene = m_Scenes.TryGetValue;

            UserAgentServicePlugins.AddRange(sceneParams.UserAgentServicePlugins);
            AssetServicePlugins.AddRange(sceneParams.AssetServicePlugins);
            InventoryServicePlugins.AddRange(sceneParams.InventoryServicePlugins);

            #endregion

            #region Setup Region Data
            ID                        = ri.ID;
            GatekeeperURI             = ri.GridURI;
            Access                    = ri.Access;
            ID                        = ri.ID;
            Name                      = ri.Name;
            Owner                     = ri.Owner;
            GridPosition              = ri.Location;
            ProductName               = ri.ProductName;
            RegionPort                = ri.ServerPort;
            m_ExternalHostNameService = sceneParams.ExternalHostNameService;
            #endregion

            /* load estate flags cache */
            uint       estateID;
            EstateInfo estate;
            if (EstateService.RegionMap.TryGetValue(ID, out estateID) &&
                EstateService.TryGetValue(estateID, out estate))
            {
                m_EstateData = estate;
            }
            else
            {
                throw new ArgumentException("Could not load estate data");
            }

            m_RestartObject    = new RestartObject(m_Scenes, this, sceneParams, sceneParams.RegionStorage);
            m_IMService        = sceneParams.IMService;
            m_UDPServer        = new UDPCircuitsManager(new IPAddress(0), (int)ri.ServerPort, sceneParams.IMService, m_ChatService, this, sceneParams.PortControlServices);
            CapabilitiesConfig = sceneParams.m_CapabilitiesConfig;
            foreach (AvatarNameServiceInterface avNameService in sceneParams.AvatarNameServices)
            {
                AvatarNameServices.Add(avNameService);
            }

            Terrain     = new TerrainController(this);
            Environment = new EnvironmentController(this, sceneParams.WindModelFactory);

            if (sceneParams.PathfindingServiceFactory != null)
            {
                PathfindingService = sceneParams.PathfindingServiceFactory.Instantiate(this);
            }

            m_IMRouter = sceneParams.IMRouter;
            m_IMRouter.SceneIM.Add(IMSend);
            OnRemove += RemoveScene;
            m_UDPServer.Start();

            ScriptThreadPool = sceneParams.ScriptWorkerThreadPoolFactory.InstantiateThreadPool(ID);
        }