using System.Collections.Generic;
using System.Linq;
using Omegasis.AutoSpeed.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
namespace Omegasis.AutoSpeed
{
/// The mod entry point.
public class AutoSpeed : Mod
{
/*********
**Static Fields
*********/
///
/// All of the speed that is added together for auto speed. This is used for mod authors to hook in their speed boosts before auto speed applies the default speed boost.
///
public Dictionary combinedAddedSpeed;
/*********
** Fields
*********/
/// The mod configuration.
private ModConfig Config;
///
/// A static reference to expose public fields.
///
public static AutoSpeed Instance;
/*********
** Public methods
*********/
/// The mod entry point, called after the mod is first loaded.
/// Provides simplified APIs for writing mods.
public override void Entry(IModHelper helper)
{
helper.Events.GameLoop.UpdateTicked += this.OnUpdateTicked;
this.Config = helper.ReadConfig();
this.combinedAddedSpeed = new Dictionary();
Instance = this;
}
///
/// Returns a copy of the mods' api.
///
///
public override object GetApi()
{
return new AutoSpeedAPI();
}
/*********
** Private methods
*********/
/// Raised after the game state is updated (≈60 times per second).
/// The event sender.
/// The event arguments.
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
if (Context.IsPlayerFree)
{
int addedSpeed = this.combinedAddedSpeed.Values.Sum();
Game1.player.addedSpeed = this.Config.Speed+addedSpeed;
}
}
}
}