SMAPI/StardewModdingAPI/Events/Game.cs

60 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StardewModdingAPI.Events
{
public static class GameEvents
{
public static event EventHandler GameLoaded = delegate { };
public static event EventHandler Initialize = delegate { };
public static event EventHandler LoadContent = delegate { };
public static event EventHandler UpdateTick = delegate { };
public static void InvokeGameLoaded()
{
GameLoaded.Invoke(null, EventArgs.Empty);
}
public static void InvokeInitialize()
{
try
{
Initialize.Invoke(null, EventArgs.Empty);
}
catch (Exception ex)
{
Log.Error("An exception occured in XNA Initialize: " + ex.ToString());
}
}
public static void InvokeLoadContent()
{
try
{
LoadContent.Invoke(null, EventArgs.Empty);
}
catch (Exception ex)
{
Log.Error("An exception occured in XNA LoadContent: " + ex.ToString());
}
}
public static void InvokeUpdateTick()
{
try
{
Program.IsGameReferenceDirty = true;
var test = Program.gamePtr;
UpdateTick.Invoke(null, EventArgs.Empty);
}
catch (Exception ex)
{
Log.Error("An exception occured in XNA UpdateTick: " + ex.ToString());
}
}
}
}