Aurora.Modules.CityBuilder.CityModule.Initialize C# (CSharp) Метод

Initialize() публичный Метод

This method is during the startup of the Aurora server, It is called just after the HTTP server has started and before any shared modules or regions have been loaded.
public Initialize ( ISimulationBase openSim ) : void
openSim ISimulationBase
Результат void
        public void Initialize(ISimulationBase openSim)
        {
            //  Display a startup message, save the passed 'server instance?', obtain the
            // scene manager and scene graph for this server instance and obtain the interface
            // used to access region information, regardless of whether the storage method is
            // file, web or MySQL based in reality. Finally call an internal method that installs
            // the command console commands and alters some internal properties, indicating that
            // the module is loaded, enabled and ready for use.
            m_log.Info("[CITY BUILDER]: Version 0.0.0.10 ");

            //  Store the supplied simulation base to for future use.
            simulationBase = openSim;
            //  Store the configuration source (I presume all contents of all ini files).
            configSource = simulationBase.ConfigSource;
            //  Store the configuration section specifically used by City Builder.
            cityConfig = configSource.Configs["CityBuilder"];

            //  Obtain the default user account service, do the same for the estate/parcel too.
            m_UserAccountService = simulationBase.ApplicationRegistry.RequestModuleInterface<IUserAccountService>();

            //  Register the ICityModule interface with the simulation base.
            simulationBase.ApplicationRegistry.RegisterModuleInterface<ICityModule>(this);
            m_log.Info("[CITY BUILDER]: ICityModule interface registered with simulation base.");

            //  If we have a configuration source for City Builder then set the specified internal properties else default them.
            if (cityConfig != null)
            {
                //  Configuration file is present or it is included within one of the other configuration
                // file that control aurora obtain the specified values or use hardcoded defaults.
                m_log.Info("[CITY BUILDER]: Configuration found, stored.");

                //  Construct Land data to be used for the entire city and any occupied regions.
                m_DefaultUserAccount = null;
                // Construct the estate settings for the city.
                m_DefaultEstate = null;

                startPort = cityConfig.GetInt("DefaultStartPort", startPort);

                m_fEnabled = cityConfig.GetBoolean("Enabled", m_fEnabled);

                m_fInitialised = false;
                citySeed = CityModule.randomValue(257);
                cityName = cityConfig.GetString("DefaultCityName", "CityVille");
                cityOwner = cityConfig.GetString("DefaultCityOwner", "Cobra ElDiablo");
                m_DefaultUserName = cityOwner;
                m_DefaultUserEmail = cityConfig.GetString("DefaultUserEmail", "");
                m_DefaultUserPword = cityConfig.GetString("DefaultUserPassword", "");
                CityEstate = cityConfig.GetString("DefaultCityEstate", "Liquid Silicon Developments");
                m_DefaultEstateOwner = cityOwner;
                m_DefaultEstatePassword = cityConfig.GetString("DefaultEstatePassword", "");
                cityDensities = new List<float>();
                m_DefaultStartLocation = new Vector2(9500, 9500);
                startPort = cityConfig.GetInt("DefaultStartPort", 9500);
            }
            else
            {
                m_log.Info("[CITY BUILDER]: No configuration data found.");

                m_DefaultUserAccount = null;
                m_DefaultEstate = null;

                m_fEnabled = false;
                m_fInitialised = false;
                citySeed = CityModule.randomValue(257);
                cityName = string.Empty;
                cityOwner = string.Empty;
                CityEstate = string.Empty;
                //  Configuration for the plugin.
                //  Configuration source from Aurora.
                cityConfig = new ConfigBase("CityBuilder",configSource);
                cityDensities = new List<float>();
                m_DefaultStartLocation = new Vector2(9500, 9500);
                // automatically disable the module if a configuration is not found. You can
                // manually enable the module and then set its internal properties before using
                // it via the server command console prompt.
                m_fEnabled = false;
            }

            cityDensities.Add(0.85f);
            cityDensities.Add(0.75f);
            cityDensities.Add(0.65f);
            cityDensities.Add(0.45f);
            //  Install the module, does not alter the enabled flag! This allows for the plugin
            // to install some commands for the main servers console but prevents any use of
            // the plugin until the internal properties are set correctly.
            InstallModule();
        }