forked from MUnique/OpenMU
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IGameContext.cs
143 lines (120 loc) · 4.45 KB
/
IGameContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// <copyright file="IGameContext.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>
namespace MUnique.OpenMU.GameLogic;
using MUnique.OpenMU.GameLogic.MiniGames;
using MUnique.OpenMU.Interfaces;
using MUnique.OpenMU.Pathfinding;
using MUnique.OpenMU.Persistence;
using MUnique.OpenMU.PlugIns;
/// <summary>
/// The context of the game.
/// </summary>
public interface IGameContext
{
/// <summary>
/// Occurs when a game map got created.
/// </summary>
event EventHandler<GameMap>? GameMapCreated;
/// <summary>
/// Occurs when a game map got removed.
/// </summary>
event EventHandler<GameMap>? GameMapRemoved;
/// <summary>
/// Gets the global experience rate.
/// </summary>
float ExperienceRate { get; }
/// <summary>
/// Gets the repository provider. Used to retrieve data, e.g. from a database.
/// </summary>
IPersistenceContextProvider PersistenceContextProvider { get; }
/// <summary>
/// Gets the item power up factory.
/// </summary>
IItemPowerUpFactory ItemPowerUpFactory { get; }
/// <summary>
/// Gets the configuration.
/// </summary>
GameConfiguration Configuration { get; }
/// <summary>
/// Gets the plug in manager.
/// </summary>
PlugInManager PlugInManager { get; }
/// <summary>
/// Gets the feature plug ins.
/// </summary>
FeaturePlugInContainer FeaturePlugIns { get; }
/// <summary>
/// Gets the players count of the game.
/// </summary>
int PlayerCount { get; }
/// <summary>
/// Gets the logger factory.
/// </summary>
ILoggerFactory LoggerFactory { get; }
/// <summary>
/// Gets the drop generator.
/// </summary>
IDropGenerator DropGenerator { get; }
/// <summary>
/// Gets the object pool for path finders.
/// </summary>
IObjectPool<PathFinder> PathFinderPool { get; }
/// <summary>
/// Gets the initialized maps which are hosted on this context.
/// </summary>
IEnumerable<GameMap> Maps { get; }
/// <summary>
/// Adds the player to the game.
/// </summary>
/// <param name="player">The player.</param>
ValueTask AddPlayerAsync(Player player);
/// <summary>
/// Gets the maps which is meant to be hosted by the game.
/// </summary>
/// <param name="mapId">The map identifier.</param>
/// <param name="createIfNotExists">If set to <c>true</c>, the map is created if it doesn't exist yet.</param>
/// <returns>
/// The hosted GameMap instance.
/// </returns>
ValueTask<GameMap?> GetMapAsync(ushort mapId, bool createIfNotExists = true);
/// <summary>
/// Gets the mini game map which is meant to be hosted by the game.
/// </summary>
/// <param name="miniGameDefinition">The mini game definition.</param>
/// <param name="requester">The requesting player.</param>
/// <returns>
/// The state of the mini game which contains the hosted GameMap instance.
/// </returns>
ValueTask<MiniGameContext> GetMiniGameAsync(MiniGameDefinition miniGameDefinition, Player requester);
/// <summary>
/// Removes the mini game instance from the context.
/// </summary>
/// <param name="miniGameContext">The context of the mini game.</param>
void RemoveMiniGame(MiniGameContext miniGameContext);
/// <summary>
/// Gets the player object by character name.
/// </summary>
/// <param name="name">The character name.</param>
/// <returns>The player object.</returns>
Player? GetPlayerByCharacterName(string name);
/// <summary>
/// Sends a global message to all players of the game with the specified message type.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="messageType">Type of the message.</param>
ValueTask SendGlobalMessageAsync(string message, MessageType messageType);
/// <summary>
/// Sends a golden global notification to all players of the game.
/// </summary>
/// <param name="message">The message.</param>
ValueTask SendGlobalNotificationAsync(string message);
/// <summary>
/// Executes an action for each player.
/// </summary>
/// <param name="action">The action which is executed.</param>
/// <remarks>
/// Please avoid doing actions which may lead to the connected-state of the players.
/// </remarks>
ValueTask ForEachPlayerAsync(Func<Player, Task> action);
}