Exemplo n.º 1
0
        internal void Initialize()
        {
            Environment.Initialize();
            try
            {
                Implementation.OnRocketImplementationInitialized += () =>
                {
                    gameObject.TryAddComponent <TaskDispatcher>();
                    gameObject.TryAddComponent <AutomaticShutdownWatchdog>();
                    if (Settings.Instance.RCON.Enabled)
                    {
                        gameObject.TryAddComponent <RCONServer>();
                    }
                };

                Settings    = new XMLFileAsset <RocketSettings>(Environment.SettingsFile);
                Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations);
                defaultTranslations.AddUnknownEntries(Translation);
                Permissions = gameObject.TryAddComponent <RocketPermissionsManager>();
                Plugins     = gameObject.TryAddComponent <RocketPluginManager>();
                Commands    = gameObject.TryAddComponent <RocketCommandManager>();

                if (Settings.Instance.MaxFrames < 10 && Settings.Instance.MaxFrames != -1)
                {
                    Settings.Instance.MaxFrames = 10;
                }
                Application.targetFrameRate = Settings.Instance.MaxFrames;

                OnRockedInitialized.TryInvoke();
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
Exemplo n.º 2
0
        internal void Initialize()
        {
            try
            {
                Settings    = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile);
                Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations);
                defaultTranslations.AddUnknownEntries(Translation);
                Events = gameObject.TryAddComponent <UnturnedEvents>();

                gameObject.TryAddComponent <UnturnedPermissions>();
                gameObject.TryAddComponent <UnturnedChat>();
                gameObject.TryAddComponent <UnturnedCommands>();

                gameObject.TryAddComponent <AutomaticSaveWatchdog>();

                bindDelegates();

                RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) =>
                {
                    try
                    {
                        plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>();
                    }
                    catch (Exception ex)
                    {
                        Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + ".");
                        cancelLoading = true;
                    }
                };

                RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) =>
                {
                    plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>();
                };

                R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly());

                try
                {
                    R.Plugins.OnPluginsLoaded += () =>
                    {
                        SteamGameServer.SetKeyValue("rocketplugins", String.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray()));
                    };


                    SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    SteamGameServer.SetBotPlayerCount(1);
                }
                catch (Exception ex)
                {
                    Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message);
                }

                OnRocketImplementationInitialized.TryInvoke();
            }
            catch (Exception ex)
            {
                Core.Logging.Logger.LogException(ex);
            }
        }
Exemplo n.º 3
0
        internal void Initialize()
        {
            Environment.Initialize();
            try
            {
                Implementation.OnRocketImplementationInitialized += () =>
                {
                    gameObject.TryAddComponent <TaskDispatcher>();
                    gameObject.TryAddComponent <AutomaticShutdownWatchdog>();
                    if (Settings.Instance.RCON.Enabled)
                    {
                        gameObject.TryAddComponent <RCONServer>();
                    }
                };

                Settings = new XMLFileAsset <RocketSettings>(Environment.SettingsFile);
                var settings = Settings.Instance;
                Translation = new XMLFileAsset <TranslationList>(string.Format(Environment.TranslationFile, settings.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations);
                defaultTranslations.AddUnknownEntries(Translation);
                Permissions = gameObject.TryAddComponent <RocketPermissionsManager>();
                //Plugins = gameObject.TryAddComponent<RocketPluginManager>();
                Plugins = new RocketPluginManager();
                RocketPluginManager.Awake();
                Commands = new RocketCommandManager();
                Commands.Awake();
                // Load Commands from Rocket.Core.Commands.
                Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly());

                if (settings.MaxFrames < 10 && settings.MaxFrames != -1)
                {
                    settings.MaxFrames = 10;
                }
                Application.targetFrameRate = settings.MaxFrames;

                OnRockedInitialized.TryInvoke();

                Plugins.loadPlugins();
            }
            catch (Exception ex)
            {
                Logging.Logger.LogException(ex);
            }
        }
Exemplo n.º 4
0
        internal void Initialize()
        {
            try
            {
                Settings    = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile);
                Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations);
                defaultTranslations.AddUnknownEntries(Translation);
                Events = gameObject.TryAddComponent <UnturnedEvents>();

                gameObject.TryAddComponent <UnturnedPermissions>();
                gameObject.TryAddComponent <UnturnedChat>();
                gameObject.TryAddComponent <UnturnedCommands>();

                gameObject.TryAddComponent <AutomaticSaveWatchdog>();

                bindDelegates();

                RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) =>
                {
                    try
                    {
                        plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>();
                    }
                    catch (Exception ex)
                    {
                        Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + ".");
                        cancelLoading = true;
                    }
                };

                RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) =>
                {
                    plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>();
                };

                R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly());

                try
                {
                    R.Plugins.OnPluginsLoaded += () =>
                    {
                        IPluginAdvertising   pluginAdvertising = PluginAdvertising.Get();
                        List <IRocketPlugin> rocketPlugins     = R.Plugins.GetPlugins();
                        List <string>        pluginNames       = new List <string>(rocketPlugins.Count);
                        foreach (IRocketPlugin plugin in rocketPlugins)
                        {
                            if (plugin != null && !string.IsNullOrEmpty(plugin.Name))
                            {
                                pluginNames.Add(plugin.Name);
                            }
                        }
                        pluginAdvertising.AddPlugins(pluginNames);
                    };

                    SteamGameServer.SetKeyValue("unturned", Provider.APP_VERSION);
                    SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString());
                }
                catch (Exception ex)
                {
                    Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message);
                }

                OnRocketImplementationInitialized.TryInvoke();
            }
            catch (Exception ex)
            {
                Core.Logging.Logger.LogException(ex);
            }
        }
Exemplo n.º 5
0
        internal void Initialize()
        {
            try
            {
                Settings    = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile);
                Translation = new XMLFileAsset <TranslationList>(string.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations);
                defaultTranslations.AddUnknownEntries(Translation);
                //Events = gameObject.TryAddComponent<UnturnedEvents>();
                Events = new UnturnedEvents();
                Events.Awake();
                //gameObject.TryAddComponent<UnturnedPermissions>();
                //gameObject.TryAddComponent<UnturnedChat>();
                SDG.Unturned.ChatManager.onChatted += UnturnedChat.handleChat;
                //gameObject.TryAddComponent<UnturnedCommands>();
                foreach (Command vanillaCommand in Commander.commands)
                {
                    R.Commands.Register(new UnturnedCommands.UnturnedVanillaCommand(vanillaCommand), vanillaCommand.command.ToLower(), Core.Serialization.CommandPriority.Low);
                }
                gameObject.TryAddComponent <AutomaticSaveWatchdog>();

                bindDelegates();

                RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) =>
                {
                    try
                    {
                        plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>();
                    }
                    catch (Exception ex)
                    {
                        Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + ".");
                        cancelLoading = true;
                    }
                };

                RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) =>
                {
                    plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>();
                };

                R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly());

                try
                {
                    if (!Settings.Instance.HidePlugins)
                    {
                        R.Plugins.OnPluginsLoaded += () =>
                        {
                            var plugs = R.Plugins.GetPlugins();
                            var names = new string[plugs.Count];
                            for (int i = 0; i < names.Length; i++)
                            {
                                names[i] = plugs[i].Name;
                            }
                            SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", names));
                        };
                    }
                    if (Settings.Instance.ClampMaxPlayers)
                    {
                        Level.onPreLevelLoaded += ClampMaxPlayers;
                    }

                    SteamGameServer.SetKeyValue("unturned", Provider.APP_VERSION);
                    SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString());
                    SteamGameServer.SetBotPlayerCount(1);
                }
                catch (Exception ex)
                {
                    Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message);
                }

                OnRocketImplementationInitialized.TryInvoke();
            }
            catch (Exception ex)
            {
                Core.Logging.Logger.LogException(ex);
            }
        }