예제 #1
0
        ////////////////

        public void UpdateBuffTimes()
        {
            ISet <int> activeBuffTypes = new HashSet <int>();

            for (int i = 0; i < this.player.buffType.Length; i++)
            {
                int buffType = this.player.buffType[i];
                int buffTime = this.player.buffTime[i];

                if (buffType <= 0)
                {
                    continue;
                }

                activeBuffTypes.Add(buffType);

                if (!this.MaxBuffTimes.ContainsKey(buffType))
                {
                    this.MaxBuffTimes[buffType] = buffTime;
                }

                if (buffTime == 1 && this.BuffLocks.Contains(buffType))
                {
                    if (BetterBuffHelpers.CanRefreshBuffAt(this.player, i))
                    {
                        BetterBuffHelpers.RefreshBuffAt(this.player, i);
                    }
                }
            }

            foreach (int buffType in this.MaxBuffTimes.Keys.ToList())
            {
                if (!activeBuffTypes.Contains(buffType))
                {
                    if (this.MaxBuffTimes.ContainsKey(buffType))
                    {
                        this.MaxBuffTimes.Remove(buffType);
                    }
                    if (this.BuffLocks.Contains(buffType))
                    {
                        this.BuffLocks.Remove(buffType);
                    }

                    continue;
                }
            }
        }
예제 #2
0
        ////////////////

        public override void PreUpdate()
        {
            this.UpdateBuffTimes();

            if (this.player.whoAmI == Main.myPlayer)
            {
                if (Main.mouseLeftRelease && Main.mouseLeft)
                {
                    if (!this.IsLeftClickAndRelease && !Main.playerInventory)
                    {
                        var mouse = new Rectangle(Main.mouseX, Main.mouseY, 1, 1);

                        foreach (var kv in BetterBuffHelpers.GetBuffIconRectanglesByPosition(true))
                        {
                            int pos = kv.Key;

                            if (kv.Value.Intersects(mouse))
                            {
                                if (!BetterBuffHelpers.CanRefreshBuffAt(this.player, pos))
                                {
                                    continue;
                                }

                                if (this.player.controlTorch)
                                {
                                    this.ToggleBuffLock(pos);
                                }
                                else if (this.player.buffType[pos] != BuffID.PotionSickness)
                                {
                                    BetterBuffHelpers.RefreshBuffAt(this.player, pos);
                                }
                                break;
                            }
                        }
                    }

                    this.IsLeftClickAndRelease = true;
                }
                else
                {
                    this.IsLeftClickAndRelease = false;
                }
            }
        }