summaryrefslogtreecommitdiff
path: root/StardewModdingAPI/Inheritance/SGame.cs
diff options
context:
space:
mode:
Diffstat (limited to 'StardewModdingAPI/Inheritance/SGame.cs')
-rw-r--r--StardewModdingAPI/Inheritance/SGame.cs75
1 files changed, 75 insertions, 0 deletions
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs
new file mode 100644
index 00000000..61a0f390
--- /dev/null
+++ b/StardewModdingAPI/Inheritance/SGame.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Input;
+using StardewValley;
+using StardewValley.Minigames;
+
+namespace StardewModdingAPI.Inheritance
+{
+ public class SGame : Game1
+ {
+ public static FieldInfo[] StaticFields { get { return Thing(); } }
+
+ public static FieldInfo[] Thing()
+ {
+ return typeof(Game1).GetFields();
+ }
+
+ public KeyboardState KStateNow { get; private set; }
+ public KeyboardState KStatePrior { get; private set; }
+
+ public Keys[] CurrentlyPressedKeys { get; private set; }
+ public Keys[] PreviouslyPressedKeys { get; private set; }
+
+ public Keys[] FramePressedKeys
+ {
+ get { return CurrentlyPressedKeys.Where(x => !PreviouslyPressedKeys.Contains(x)).ToArray(); }
+ }
+
+ protected override void Initialize()
+ {
+ Program.Log("XNA Initialize");
+ Events.InvokeInitialize();
+ base.Initialize();
+ }
+
+ protected override void LoadContent()
+ {
+ Program.Log("XNA LoadContent");
+ Events.InvokeLoadContent();
+ base.LoadContent();
+ }
+
+ protected override void Update(GameTime gameTime)
+ {
+ KStateNow = Keyboard.GetState();
+ CurrentlyPressedKeys = KStateNow.GetPressedKeys();
+
+ foreach (Keys k in FramePressedKeys)
+ Events.InvokeKeyPressed(k);
+
+ if (KStateNow != KStatePrior)
+ {
+ Events.InvokeKeyboardChanged(KStateNow);
+ }
+
+ Events.InvokeUpdateTick();
+ base.Update(gameTime);
+
+ KStatePrior = KStateNow;
+ PreviouslyPressedKeys = CurrentlyPressedKeys;
+ }
+
+ protected override void Draw(GameTime gameTime)
+ {
+ Events.InvokeDrawTick();
+ base.Draw(gameTime);
+ }
+ }
+} \ No newline at end of file