Beispiel #1
0
        public override void Entry(IModHelper helper)
        {
            _helper  = helper;
            _monitor = Monitor;

            Helper.Events.Input.ButtonPressed            += this.InputEvents_ButtonPressed;
            Helper.Events.GameLoop.GameLaunched          += OnGameLaunched;
            Helper.Events.GameLoop.OneSecondUpdateTicked += this.GameEvents_UpdateTick;
            Helper.Events.GameLoop.DayStarted            += delegate { addiction = AddictionState.Clean; };
        }
Beispiel #2
0
        private void GameEvents_UpdateTick(object sender, EventArgs e)
        {
            if (updateTicks-- > 0)
            {
                return;
            }
            updateTicks = 60;

            removeDrinkBuff(true);

            // Wait till the buff runs out.
            if (Game1.buffsDisplay.hasBuff(kBuffWhich))
            {
                return;
            }

            // Find an IV bag with coffee remaining.
            IntravenousCoffeeTool ivTool = Game1.player.items.Find(
                (i) => (i is IntravenousCoffeeTool iv && iv.hasCoffee()))
                                           as IntravenousCoffeeTool;

            if (ivTool != null)
            {
                // Consume some coffee.
                ivTool.consumeCoffee();
                addBuff(1, kCoffeeDurationMillis, "+1 Speed", "Coffee Drip");
                this.addiction = AddictionState.Addicted;  // caffeine's a hell of a drug
                removeDrinkBuff(false);
            }
            else if (this.addiction == AddictionState.Addicted)
            {
                // Ran out of coffee. Go into withdrawal.
                addBuff(-1, kWithdrawalDurationMillis, "-1 Speed", "Coffee Withdrawal");
                this.addiction = AddictionState.Withdrawal;
            }
            else if (this.addiction == AddictionState.Withdrawal)
            {
                // Withdrawal buff wore off (also happens when player sleeps). We made it.
                this.addiction = AddictionState.Clean;
            }
        }