// Handle when Mining Level Changes
        public void mineLevelChanged(object sender, WarpedEventArgs e)
        {
            //BNC_Core.Logger.Log("Warped", LogLevel.Info);
            if (e.NewLocation is MineShaft mine)
            {
                if (shouldUpdateAugment(e))
                //if (true)
                {
                    if (TwitchIntergration.isConnected())
                    {
                        //BNC_Core.Logger.Log("connected", LogLevel.Info);
                        if (!TwitchIntergration.hasAugPollStarted)
                        {
                            TwitchIntergration.StartAugPoll(getRandomBuff(3, true));
                        }
                    }
                    else
                    {
                        BaseAugment aug = getRandomBuff(1)[0];
                        aug.isMineOnly = true;
                        AddAugmentQueue(aug);
                        Game1.addHUDMessage(new HUDMessage(aug.DisplayName + ": " + aug.desc, null));
                    }
                }
            }

            if (_augmentQueue.Count() > 0)
            {
                UpdateLocation(e);
            }
        }
        private void AddAugment(BaseAugment augment)
        {
            var type = augment.id;

            _nameToAugments.Add(type, augment);
            BNC_Core.Logger.Log($"Added Augment: {type}", LogLevel.Debug);
        }
예제 #3
0
        private static void EndAugPoll()
        {
            if (Config.ShowDebug())
            {
                BNC_Core.Logger.Log($"Poll has ended!", LogLevel.Info);
            }
            currentTick = Config.getVotingTime();
            timer.Stop();
            hasAugPollStarted = false;

            if (Config.ShowDebug())
            {
                BNC_Core.Logger.Log($"Time to tally the votes!", LogLevel.Info);
            }

            BaseAugment selectedId = null;
            int         votecount  = -1;

            foreach (KeyValuePair <BaseAugment, int> vote in augmentvotes)
            {
                if (vote.Value > votecount)
                {
                    votecount  = vote.Value;
                    selectedId = vote.Key;
                }
            }

            if (selectedId != null)
            {
                if (Config.ShowDebug())
                {
                    BNC_Core.Logger.Log($"Chat has selected {selectedId.DisplayName} : vote# {votecount}", LogLevel.Info);
                }

                BNC_Core.augmentManager.AddAugmentQueue(selectedId);

                sendMessage($"Chat has spoken! Selected {selectedId.DisplayName}!");

                if (selectedId.DisplayName != null)
                {
                    Game1.addHUDMessage(new HUDMessage(selectedId.DisplayName, null));
                }
            }
            else if (Config.ShowDebug())
            {
                BNC_Core.Logger.Log($"Error: {selectedId} Buff was null", LogLevel.Info);
            }

            augvotes.Clear();
        }
        // Used to get a random augment
        public BaseAugment[] getRandomBuff(int count, bool isMineOnly = false)
        {
            List <BaseAugment> list       = Enumerable.ToList(_nameToAugments.Values);
            List <BaseAugment> returnList = new List <BaseAugment>();

            while (returnList.Count < 3)
            {
                int         num  = Game1.random.Next(list.Count);
                BaseAugment item = list[num];
                item.isMineOnly = isMineOnly;
                if (item != null && !returnList.Contains(item))
                {
                    returnList.Add(item);
                }
            }
            return(returnList.ToArray());
        }
 public void AddAugmentQueue(BaseAugment augment)
 {
     _augmentQueue.Enqueue(augment);
 }