summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/SGameRunner.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-22 21:05:04 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-01-22 21:05:04 -0500
commitd0dc3ea6f6d03e6aabdab5f5f10a60177f0e53b6 (patch)
tree02896d970c7650d8f7c8b84f54e53eddab88b4ca /src/SMAPI/Framework/SGameRunner.cs
parent5953fc3bd083ae0a579d2da1ad833e6163848086 (diff)
parent733750fdc4f5d16069d95880144619c0e31e8a89 (diff)
downloadSMAPI-d0dc3ea6f6d03e6aabdab5f5f10a60177f0e53b6.tar.gz
SMAPI-d0dc3ea6f6d03e6aabdab5f5f10a60177f0e53b6.tar.bz2
SMAPI-d0dc3ea6f6d03e6aabdab5f5f10a60177f0e53b6.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Framework/SGameRunner.cs')
-rw-r--r--src/SMAPI/Framework/SGameRunner.cs22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/SGameRunner.cs b/src/SMAPI/Framework/SGameRunner.cs
index ae06f513..45e7369c 100644
--- a/src/SMAPI/Framework/SGameRunner.cs
+++ b/src/SMAPI/Framework/SGameRunner.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Framework.Events;
@@ -49,6 +50,13 @@ namespace StardewModdingAPI.Framework
/*********
** Public methods
*********/
+ /// <summary>The singleton instance.</summary>
+ public static SGameRunner Instance => (SGameRunner)GameRunner.instance;
+
+
+ /*********
+ ** Public methods
+ *********/
/// <summary>Construct an instance.</summary>
/// <param name="monitor">Encapsulates monitoring and logging for SMAPI.</param>
/// <param name="reflection">Simplifies access to private game code.</param>
@@ -99,15 +107,24 @@ namespace StardewModdingAPI.Framework
}
/// <inheritdoc />
- public override void RemoveGameInstance(Game1 instance)
+ public override void RemoveGameInstance(Game1 gameInstance)
{
- base.RemoveGameInstance(instance);
+ base.RemoveGameInstance(gameInstance);
if (this.gameInstances.Count <= 1)
EarlyConstants.LogScreenId = null;
this.UpdateForSplitScreenChanges();
}
+ /// <summary>Get the screen ID for a given player ID, if the player is local.</summary>
+ /// <param name="playerId">The player ID to check.</param>
+ public int? GetScreenId(long playerId)
+ {
+ return this.gameInstances
+ .FirstOrDefault(p => ((SGame)p).PlayerId == playerId)
+ ?.instanceId;
+ }
+
/*********
** Protected methods
@@ -136,6 +153,7 @@ namespace StardewModdingAPI.Framework
this.OnGameUpdating(gameTime, () => base.Update(gameTime));
}
+ /// <summary>Update metadata when a split screen is added or removed.</summary>
private void UpdateForSplitScreenChanges()
{
HashSet<int> oldScreenIds = new HashSet<int>(Context.ActiveScreenIds);