private void OnGameLaunched(object sender, GameLaunchedEventArgs e) { IntravenousCoffeeTool tool = new IntravenousCoffeeTool(); CustomObjectData.newObject("mpcomplete.IntravenousCoffee.Tool", IntravenousCoffeeTool.texture, Color.White, tool.Name, tool.description, 0, customType: typeof(IntravenousCoffeeTool)); // Add it to the Hospital shop. new InventoryItem(tool, 10000, 1).addToShop( (ShopMenu shop) => true //(ShopMenu shop) => shop.getForSale().Exists( // (ISalable item) => item.Name == "Energy Tonic" || item.Name == "Muscle Remedy" //) ); }
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; } }