Player/World broadcast

This commit is contained in:
Lucca Faria Ferri 2023-01-31 13:41:35 -08:00
parent 602a42042a
commit ef89b0b732
2 changed files with 52 additions and 4 deletions

View File

@ -402,8 +402,56 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
GameManager.Games.Remove(GameId);
}
}));
}
/// <summary>
/// Executes an action to all players in the game.
/// </summary>
/// <param name="action">Action to execute</param>
public void BroadcastPlayers(Action<GameClient, Player> action)
{
foreach (var player in Players)
{
action(player.Key, player.Value);
}
}
/// <summary>
/// Executes an action to all players in the game where the predicate is true.
/// </summary>
/// <param name="predicate">Predicate to check</param>
/// <param name="action">Action to execute</param>
public void BroadcastPlayers(Func<GameClient, Player, bool> predicate, Action<GameClient, Player> action)
{
foreach (var player in Players.Where(s=>predicate(s.Key, s.Value)))
{
action(player.Key, player.Value);
}
}
/// <summary>
/// Executes an action to all worlds in the game.
/// </summary>
/// <param name="action">Action to execute</param>
public void BroadcastWorlds(Action<World> action)
{
foreach (var world in Worlds)
{
action(world);
}
}
/// <summary>
/// Executes an action to all worlds in the game.
/// </summary>
/// <param name="predicate">Predicate to check</param>
/// <param name="action">Action to execute</param>
public void BroadcastWorlds(Func<World, bool> predicate, Action<World> action)
{
foreach (var world in Worlds.Where(predicate))
{
action(world);
}
}
#region update & tick managment

View File

@ -197,7 +197,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
{
int xpReward = (int)(Quests[Game.CurrentQuest].RewardXp * Game.XpModifier);
int goldReward = (int)(Quests[Game.CurrentQuest].RewardGold * Game.GoldModifier);
if (Game.CurrentQuest != 312429)
if (Game.CurrentQuest != 312429) // open world quest
{
player.InGameClient.SendMessage(new QuestStepCompleteMessage()
{
@ -433,14 +433,14 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
onDone);
}
public void LaunchQuestTimer(int questId, float duration, Action<int> onDone, int Meterid = 0)
public void LaunchQuestTimer(int questId, float duration, Action<int> onDone, int masterId = 0)
{
foreach (var player in Game.Players.Values)
{
player.InGameClient.SendMessage(new QuestMeterMessage()
{
snoQuest = questId,
annMeter = Meterid,
annMeter = masterId,
flMeter = 1f
});
};
@ -455,7 +455,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
player.InGameClient.SendMessage(new QuestMeterMessage()
{
snoQuest = questId,
annMeter = Meterid,
annMeter = masterId,
flMeter = (QuestTimerEstimate / duration)
});
};