using System;
namespace StardewModdingAPI.Events
{
/// Events raised when the game changes state.
public static class GameEvents
{
/*********
** Events
*********/
/// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called during .
public static event EventHandler Initialize = delegate { };
/// Raised during launch after configuring Stardew Valley, loading it into memory, and opening the game window. The window is still blank by this point.
public static event EventHandler GameLoaded = delegate { };
/// Raised before XNA loads or reloads graphics resources. Called during .
public static event EventHandler LoadContent = delegate { };
/// Raised during the first game update tick.
public static event EventHandler FirstUpdateTick = delegate { };
/// Raised when the game updates its state (≈60 times per second).
public static event EventHandler UpdateTick = delegate { };
/// Raised every other tick (≈30 times per second).
public static event EventHandler SecondUpdateTick = delegate { };
/// Raised every fourth tick (≈15 times per second).
public static event EventHandler FourthUpdateTick = delegate { };
/// Raised every eighth tick (≈8 times per second).
public static event EventHandler EighthUpdateTick = delegate { };
/// Raised every 15th tick (≈4 times per second).
public static event EventHandler QuarterSecondTick = delegate { };
/// Raised every 30th tick (≈twice per second).
public static event EventHandler HalfSecondTick = delegate { };
/// Raised every 60th tick (≈once per second).
public static event EventHandler OneSecondTick = delegate { };
/*********
** Internal methods
*********/
/// Raise a event.
internal static void InvokeGameLoaded()
{
GameEvents.GameLoaded.Invoke(null, EventArgs.Empty);
}
/// Raise an event.
internal static void InvokeInitialize()
{
try
{
GameEvents.Initialize.Invoke(null, EventArgs.Empty);
}
catch (Exception ex)
{
Log.AsyncR("An exception occured in XNA Initialize: " + ex);
}
}
/// Raise a event.
internal static void InvokeLoadContent()
{
try
{
GameEvents.LoadContent.Invoke(null, EventArgs.Empty);
}
catch (Exception ex)
{
Log.AsyncR("An exception occured in XNA LoadContent: " + ex);
}
}
/// Raise an event.
internal static void InvokeUpdateTick()
{
try
{
GameEvents.UpdateTick.Invoke(null, EventArgs.Empty);
}
catch (Exception ex)
{
Log.AsyncR("An exception occured in XNA UpdateTick: " + ex);
}
}
/// Raise a event.
internal static void InvokeSecondUpdateTick()
{
GameEvents.SecondUpdateTick.Invoke(null, EventArgs.Empty);
}
/// Raise a event.
internal static void InvokeFourthUpdateTick()
{
GameEvents.FourthUpdateTick.Invoke(null, EventArgs.Empty);
}
/// Raise a event.
internal static void InvokeEighthUpdateTick()
{
GameEvents.EighthUpdateTick.Invoke(null, EventArgs.Empty);
}
/// Raise a event.
internal static void InvokeQuarterSecondTick()
{
GameEvents.QuarterSecondTick.Invoke(null, EventArgs.Empty);
}
/// Raise a event.
internal static void InvokeHalfSecondTick()
{
GameEvents.HalfSecondTick.Invoke(null, EventArgs.Empty);
}
/// Raise a event.
internal static void InvokeOneSecondTick()
{
GameEvents.OneSecondTick.Invoke(null, EventArgs.Empty);
}
/// Raise a event.
internal static void InvokeFirstUpdateTick()
{
GameEvents.FirstUpdateTick.Invoke(null, EventArgs.Empty);
}
}
}