public static DetourEvent TryToAddDrinkBuffCallback(BuffsDisplayAccessor accessor, BuffAccessor buff) { var @event = new TryToAddDrinkBuffCallbackEvent(new BuffsDisplay(WrappedGame, accessor), new Buff(WrappedGame, buff)); FireEvent(@event); return(@event); }
public void UpdateCallback(TryToAddDrinkBuffCallbackEvent @event) { //As always, do nothing if we're disabled. if (!ModConfig.EnablePlugin) { return; } //The @event.Buff is the current Buff we are considering (it is normally just a health buff, and a buff to "Stats"). //We can check the Source, and apply another buff if that source is "Mead" or "Vodka". if (@event.Buff.Source.Contains("Mead") || @event.Buff.Source.Contains("Vodka")) { //Here, we use the BuffDelegate. This *would* cause our save files to crash... except that buffs are never saved. //Alternatively, you could use the Activator to make an actual Buff (not just a Proxy Buff). //Here, "17" is the magic buff code for "Tipsy". Buff buff = @event.Proxy <BuffAccessor, Buff>(new BuffDelegate(17)); //We want Vodka tipsiness to last a lot longer. if (@event.Buff.Source.Contains("Vodka")) { buff.MillisecondsDuration *= 10; } //Finally, we add it to the current "BuffsDisplay", which is sufficient for StardewValley to start tracking it. @event.BuffsDisplay.AddOtherBuff(buff); } //Note that we DO NOT set @event.ReturnEarly; we want the original function to continue processing the underlying buff like normal. }