diff --git a/StardewModdingAPI/Constants.cs b/StardewModdingAPI/Constants.cs
index 071f0435..0ddae033 100644
--- a/StardewModdingAPI/Constants.cs
+++ b/StardewModdingAPI/Constants.cs
@@ -35,7 +35,7 @@ namespace StardewModdingAPI
public const int MinorVersion = 38;
- public const int PatchVersion = 1;
+ public const int PatchVersion = 3;
public const string Build = "Alpha";
diff --git a/StardewModdingAPI/Events/Game.cs b/StardewModdingAPI/Events/Game.cs
index 60531dd8..ac630ba9 100644
--- a/StardewModdingAPI/Events/Game.cs
+++ b/StardewModdingAPI/Events/Game.cs
@@ -11,6 +11,7 @@ namespace StardewModdingAPI.Events
public static event EventHandler GameLoaded = delegate { };
public static event EventHandler Initialize = delegate { };
public static event EventHandler LoadContent = delegate { };
+ public static event EventHandler FirstUpdateTick = delegate { };
///
/// Fires every update (1/60 of a second)
///
@@ -110,5 +111,10 @@ namespace StardewModdingAPI.Events
{
OneSecondTick.Invoke(null, EventArgs.Empty);
}
+
+ public static void InvokeFirstUpdateTick()
+ {
+ FirstUpdateTick.Invoke(null, EventArgs.Empty);
+ }
}
}
diff --git a/StardewModdingAPI/Extensions.cs b/StardewModdingAPI/Extensions.cs
index 28eb2d7d..d4b582b7 100644
--- a/StardewModdingAPI/Extensions.cs
+++ b/StardewModdingAPI/Extensions.cs
@@ -2,6 +2,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
@@ -59,11 +60,42 @@ namespace StardewModdingAPI
hash ^= v.GetHashCode();
}
return hash;
- }
+ }
- public static T Cast(this object o) where T : StardewValley.Object
+ public static T Cast(this object o) where T : class
{
return o as T;
}
+
+ public static FieldInfo[] GetPrivateFields(this object o)
+ {
+ return o.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic);
+ }
+
+ public static FieldInfo GetBaseFieldInfo(this Type t, string name)
+ {
+ return t.GetField(name, BindingFlags.Instance | BindingFlags.NonPublic);
+ }
+
+ public static T GetBaseFieldValue(this Type t, object o, string name) where T : class
+ {
+ return t.GetBaseFieldInfo(name).GetValue(o) as T;
+ }
+
+ /*
+ public static T GetBaseFieldValue(this object o, string name) where T : class
+ {
+ return o.GetType().GetBaseFieldInfo(name).GetValue(o) as T;
+ }*/
+
+ public static object GetBaseFieldValue(this object o, string name)
+ {
+ return o.GetType().GetBaseFieldInfo(name).GetValue(o);
+ }
+
+ public static void SetBaseFieldValue (this object o, string name, object newValue)
+ {
+ o.GetType().GetBaseFieldInfo(name).SetValue(o, newValue);
+ }
}
}
\ No newline at end of file
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs
index 9082d695..53d9df59 100644
--- a/StardewModdingAPI/Inheritance/SGame.cs
+++ b/StardewModdingAPI/Inheritance/SGame.cs
@@ -174,6 +174,13 @@ namespace StardewModdingAPI.Inheritance
public Farmer PreviousFarmer { get; private set; }
public Int32 CurrentUpdateTick { get; private set; }
+ public bool FirstUpdate { get; private set; }
+
+ public RenderTarget2D Screen
+ {
+ get { return typeof (Game1).GetBaseFieldValue(Program.gamePtr, "screen"); }
+ set { typeof (Game1).SetBaseFieldValue("screen", value); }
+ }
private static SGame instance;
public static SGame Instance { get { return instance; } }
@@ -183,6 +190,7 @@ namespace StardewModdingAPI.Inheritance
public SGame()
{
instance = this;
+ FirstUpdate = true;
/*
#if DEBUG
@@ -255,6 +263,11 @@ namespace StardewModdingAPI.Inheritance
}
Events.GameEvents.InvokeUpdateTick();
+ if (FirstUpdate)
+ {
+ GameEvents.InvokeFirstUpdateTick();
+ FirstUpdate = false;
+ }
if (CurrentUpdateTick % 2 == 0)
Events.GameEvents.InvokeSecondUpdateTick();
@@ -278,7 +291,6 @@ namespace StardewModdingAPI.Inheritance
if (CurrentUpdateTick >= 60)
CurrentUpdateTick = 0;
-
PreviouslyPressedKeys = CurrentlyPressedKeys;
for(PlayerIndex i = PlayerIndex.One; i <= PlayerIndex.Four; i++)
{