Exemplo n.º 1
0
        public DiscordInstance(DiscordSettings settings)
        {
            this.settings   = settings;
            activityEnabled = true;

            Priority = 0;
        }
Exemplo n.º 2
0
        public DiscordInstance CreateInstance(DiscordSettings settings)
        {
            DiscordInstance instance = new DiscordInstance(settings);

            if (Config.Instance.ModStates.TryGetValue(settings.modId, out var state))
            {
                while (_activeInstances.Any(x => x.Priority == state.Priority))
                {
                    state.Priority++;
                }

                instance.Priority        = state.Priority;
                instance.activityEnabled = state.Active;
                Config.Instance.ModStates[settings.modId] = state;
            }
            else
            {
                instance.Priority        = _activeInstances.Count == 0 ? 0 : _activeInstances.Max(x => x.Priority) + 1;
                instance.activityEnabled = true;

                Config.Instance.ModStates.Add(instance.settings.modId, new ModState()
                {
                    Active = true, Priority = instance.Priority
                });
            }

            Config.Instance.Save();

            _activeInstances.Add(instance);

            Settings.instance.UpdateModsList();

            return(instance);
        }