-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The intention is to move it to MP API as a way to provide a way for other mods to interact with the session manager. Currently needs a little bit more documentation (currently all documentation was moved from SessionManager).
- Loading branch information
1 parent
d1d5810
commit ceb1a83
Showing
2 changed files
with
52 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Collections.Generic; | ||
using Multiplayer.Client.Persistent; | ||
using Verse; | ||
|
||
namespace Multiplayer.Client.Experimental; | ||
|
||
public interface ISessionManagerAPI | ||
{ | ||
IReadOnlyList<ISession> AllSessions { get; } | ||
IReadOnlyList<IExposableSession> ExposableSessions { get; } | ||
IReadOnlyList<ISemiPersistentSession> SemiPersistentSessions { get; } | ||
IReadOnlyList<ITickingSession> TickingSessions { get; } | ||
bool AnySessionActive { get; } | ||
|
||
/// <summary> | ||
/// Adds a new session to the list of active sessions. | ||
/// </summary> | ||
/// <param name="session">The session to try to add to active sessions.</param> | ||
/// <returns><see langword="true"/> if the session was added to active ones, <see langword="false"/> if there was a conflict between sessions.</returns> | ||
bool AddSession(ISession session); | ||
|
||
/// <summary> | ||
/// Tries to get a conflicting session (through the use of <see cref="ISessionWithCreationRestrictions"/>) or, if there was none, returns the input <paramref name="session"/>. | ||
/// </summary> | ||
/// <param name="session">The session to try to add to active sessions.</param> | ||
/// <returns>A session that was conflicting with the input one, or the input itself if there were no conflicts. It may be of a different type than the input.</returns> | ||
ISession GetOrAddSessionAnyConflict(ISession session); | ||
|
||
/// <summary> | ||
/// Tries to get a conflicting session (through the use of <see cref="ISessionWithCreationRestrictions"/>) or, if there was none, returns the input <paramref name="session"/>. | ||
/// </summary> | ||
/// <param name="session">The session to try to add to active sessions.</param> | ||
/// <returns>A session that was conflicting with the input one if it's the same type (<c>other is T</c>), null if it's a different type, or the input itself if there were no conflicts.</returns> | ||
T GetOrAddSession<T>(T session) where T : ISession; | ||
|
||
/// <summary> | ||
/// Tries to remove a session from active ones. | ||
/// </summary> | ||
/// <param name="session">The session to try to remove from the active sessions.</param> | ||
/// <returns><see langword="true"/> if successfully removed from <see cref="AllSessions"/>. Doesn't correspond to if it was successfully removed from other lists of sessions.</returns> | ||
bool RemoveSession(ISession session); | ||
|
||
T GetFirstOfType<T>() where T : ISession; | ||
|
||
T GetFirstWithId<T>(int id) where T : ISession; | ||
|
||
ISession GetFirstWithId(int id); | ||
|
||
bool IsAnySessionCurrentlyPausing(Map map); // Is it necessary for the API? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters