//
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
namespace MUnique.OpenMU.GameLogic;
using System.Collections.Concurrent;
using MUnique.OpenMU.GameLogic.MiniGames;
using MUnique.OpenMU.GameLogic.Views;
using MUnique.OpenMU.Interfaces;
using MUnique.OpenMU.Pathfinding;
using MUnique.OpenMU.Persistence;
using MUnique.OpenMU.PlugIns;
///
/// The context of the game.
///
public interface IGameContext
{
///
/// Occurs when a game map got created.
///
event EventHandler? GameMapCreated;
///
/// Occurs when a game map got removed.
///
event EventHandler? GameMapRemoved;
///
/// Gets the global experience rate.
///
float ExperienceRate { get; }
///
/// Gets the global master experience rate.
///
float MasterExperienceRate { get; }
///
/// Gets a value indicating whether PVP is enabled.
///
bool PvpEnabled { get; }
///
/// Gets the repository provider. Used to retrieve data, e.g. from a database.
///
IPersistenceContextProvider PersistenceContextProvider { get; }
///
/// Gets the item power up factory.
///
IItemPowerUpFactory ItemPowerUpFactory { get; }
///
/// Gets the configuration.
///
GameConfiguration Configuration { get; }
///
/// Gets the experience table. Index is the player level, value the needed experience to reach that level.
///
long[] ExperienceTable { get; }
///
/// Gets the master experience table. Index is the player level, value the needed experience to reach that level.
///
long[] MasterExperienceTable { get; }
///
/// Gets the configuration change mediator.
///
IConfigurationChangeMediator ConfigurationChangeMediator { get; }
///
/// Gets the plug in manager.
///
PlugInManager PlugInManager { get; }
///
/// Gets the feature plug ins.
///
FeaturePlugInContainer FeaturePlugIns { get; }
///
/// Gets the offline player manager which tracks active offline players.
///
Offline.OfflinePlayerManager OfflinePlayerManager { get; }
///
/// Gets the players count of the game.
///
int PlayerCount { get; }
///
/// Gets the logger factory.
///
ILoggerFactory LoggerFactory { get; }
///
/// Gets the drop generator.
///
IDropGenerator DropGenerator { get; }
///
/// Gets the object pool for path finders.
///
IObjectPool PathFinderPool { get; }
///
/// Gets the duel room manager.
///
DuelRoomManager DuelRoomManager { get; }
///
/// Gets the state of the active self defenses. The datetime holds the timestamp when self-defense ends.
///
ConcurrentDictionary<(Player Attacker, Player Defender), DateTime> SelfDefenseState { get; }
///
/// Gets the party manager which handles party creation and persistence.
///
IPartyManager PartyManager { get; }
///
/// Gets the initialized maps which are hosted on this context.
///
ValueTask> GetMapsAsync();
///
/// Gets the players.
///
ValueTask> GetPlayersAsync();
///
/// Adds the player to the game.
///
/// The player.
ValueTask AddPlayerAsync(Player player);
///
/// Removes the player from the game.
///
/// The player.
ValueTask RemovePlayerAsync(Player player);
///
/// Gets the maps which is meant to be hosted by the game.
///
/// The map identifier.
/// If set to true, the map is created if it doesn't exist yet.
///
/// The hosted GameMap instance.
///
ValueTask GetMapAsync(ushort mapId, bool createIfNotExists = true);
///
/// Gets the mini game map which is meant to be hosted by the game.
///
/// The mini game definition.
/// The requesting player.
///
/// The state of the mini game which contains the hosted GameMap instance.
///
ValueTask GetMiniGameAsync(MiniGameDefinition miniGameDefinition, Player requester);
///
/// Removes the mini game instance from the context.
///
/// The context of the mini game.
ValueTask RemoveMiniGameAsync(MiniGameContext miniGameContext);
///
/// Gets the player object by character name.
///
/// The character name.
/// The player object.
Player? GetPlayerByCharacterName(string name);
///
/// Sends a global message to all players of the game with the specified message type.
///
/// The message.
/// Type of the message.
ValueTask SendGlobalMessageAsync(string message, MessageType messageType);
///
/// Sends a global message to all players of the game with the specified message type.
///
/// Type of the message.
/// The message resource key.
/// The parameters for the message.
ValueTask ShowGlobalLocalizedMessageAsync(MessageType messageType, string messageKey, params object?[] arguments);
///
/// Sends a global chat message to all players of the game with the specified message type.
///
/// The sender.
/// The message.
/// Type of the message.
ValueTask SendGlobalChatMessageAsync(string sender, string message, ChatMessageType messageType);
///
/// Sends a golden global notification to all players of the game.
///
/// The message.
ValueTask SendGlobalNotificationAsync(string message);
///
/// Executes an action for each player.
///
/// The action which is executed.
///
/// Please avoid doing actions which may lead to the connected-state of the players.
///
ValueTask ForEachPlayerAsync(Func action);
}