Optimize a lot of checks for emptiness
This commit is contained in:
parent
d0e5d89e04
commit
284b0b2d7b
@ -85,7 +85,7 @@ namespace DiIiS_NA.LoginServer.AccountsSystem
|
||||
public static Account GetAccountByDiscordId(ulong discordId)
|
||||
{
|
||||
List<DBAccount> dbAcc = DBSessions.SessionQueryWhere<DBAccount>(dba => dba.DiscordId == discordId).ToList();
|
||||
if (dbAcc.Count() == 0)
|
||||
if (!dbAcc.Any())
|
||||
{
|
||||
Logger.Warn("GetAccountByDiscordId {0}: DBAccount is null!", discordId);
|
||||
return null;
|
||||
|
||||
@ -1197,7 +1197,7 @@ public class GameAccount : PersistentRPCObject
|
||||
|
||||
public uint AchievementPoints
|
||||
{
|
||||
get { return (uint)Achievements.Where(a => a.Completion != -1).Count() * 10U; }
|
||||
get { return (uint)Achievements.Count(a => a.Completion != -1) * 10U; }
|
||||
}
|
||||
|
||||
public bool IsLoggedIn { get; set; }
|
||||
|
||||
@ -14,10 +14,7 @@ namespace DiIiS_NA.LoginServer.AccountsSystem
|
||||
|
||||
public static readonly ConcurrentDictionary<ulong, GameAccount> LoadedGameAccounts = new();
|
||||
|
||||
public static int TotalAccounts
|
||||
{
|
||||
get { return DBSessions.SessionQuery<DBGameAccount>().Count(); }
|
||||
}
|
||||
public static int TotalAccounts => DBSessions.SessionQuery<DBGameAccount>().Count;
|
||||
|
||||
public static void PreLoadGameAccounts()
|
||||
{
|
||||
|
||||
@ -70,7 +70,7 @@ namespace DiIiS_NA.LoginServer.FriendsSystem
|
||||
Logger.MethodTrace($": owner {owner.PersistentID}, target {target.PersistentID}");
|
||||
try
|
||||
{
|
||||
if (DBSessions.SessionQueryWhere<DBAccountLists>(dbl => dbl.ListOwner.Id == owner.PersistentID && dbl.ListTarget.Id == target.PersistentID && dbl.Type == "IGNORE").Count() > 0) return;
|
||||
if (DBSessions.SessionQueryWhere<DBAccountLists>(dbl => dbl.ListOwner.Id == owner.PersistentID && dbl.ListTarget.Id == target.PersistentID && dbl.Type == "IGNORE").Any()) return;
|
||||
|
||||
var blockRecord = new DBAccountLists
|
||||
{
|
||||
|
||||
@ -19,7 +19,7 @@ namespace DiIiS_NA.LoginServer.GamesSystem
|
||||
{
|
||||
get
|
||||
{
|
||||
return GameCreators.Values.Where(game => game.PlayersCount > 0).Count();
|
||||
return GameCreators.Values.Count(game => game.PlayersCount > 0);
|
||||
}
|
||||
set { }
|
||||
}
|
||||
|
||||
@ -33,11 +33,11 @@ namespace DiIiS_NA.Core.Discord.Modules
|
||||
}
|
||||
|
||||
|
||||
if (registerInfo.Count() == 3)
|
||||
if (registerInfo.Length == 3)
|
||||
{
|
||||
if (!email.Contains('@'))
|
||||
{
|
||||
await ReplyAsync($"<@{Context.User.Id}> " + string.Format("'{0}' is not a valid email address.", email));
|
||||
await ReplyAsync($"<@{Context.User.Id}> " + $"'{email}' is not a valid email address.");
|
||||
return;
|
||||
}
|
||||
if (!IsValid(email))
|
||||
|
||||
@ -178,7 +178,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem
|
||||
lock (client.ServiceLock)
|
||||
{
|
||||
Logger.MethodTrace($"id {achievementId}");
|
||||
if (client.Account.GameAccount.Achievements.Where(a => a.AchievementId == achievementId && a.Completion != -1).Count() > 0) return;
|
||||
if (client.Account.GameAccount.Achievements.Any(a => a.AchievementId == achievementId && a.Completion != -1)) return;
|
||||
DBAchievements achievement = null;
|
||||
var achs = DBSessions.SessionQueryWhere<DBAchievements>(dbi =>
|
||||
dbi.DBGameAccount.Id == client.Account.GameAccount.PersistentID);
|
||||
@ -218,7 +218,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem
|
||||
|
||||
if (IsHardcore(achievementId))
|
||||
{
|
||||
if (achs.Where(a => a.CompleteTime != -1 && a.IsHardcore == true).Count() >= 30) //31 in total
|
||||
if (achs.Count(a => a.CompleteTime != -1 && a.IsHardcore) >= 30) //31 in total
|
||||
{
|
||||
var toons = DBSessions.SessionQueryWhere<DBToon>(dbt => dbt.DBGameAccount.Id == client.Account.GameAccount.PersistentID && dbt.isHardcore == true && dbt.Archieved == false);
|
||||
}
|
||||
@ -308,7 +308,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem
|
||||
}
|
||||
|
||||
var ach_data = _achievements.AchievementList.Single(a => a.Id == definition.ParentAchievementId);
|
||||
if (!ach_data.HasSupersedingAchievementId || client.Account.GameAccount.Achievements.Where(a => a.AchievementId == ach_data.SupersedingAchievementId && a.Completion > 0).Count() > 0)
|
||||
if (!ach_data.HasSupersedingAchievementId || client.Account.GameAccount.Achievements.Any(a => a.AchievementId == ach_data.SupersedingAchievementId && a.Completion > 0))
|
||||
UpdateSnapshot(client, 0, criteriaId);
|
||||
}
|
||||
else
|
||||
@ -380,14 +380,14 @@ namespace DiIiS_NA.GameServer.AchievementSystem
|
||||
{
|
||||
if (additionalQuantity == 0) return;
|
||||
Logger.MethodTrace($"id {achievementId}");
|
||||
if (client.Account.GameAccount.Achievements.Where(a => a.AchievementId == achievementId && a.Completion != -1).Count() > 0) return;
|
||||
if (client.Account.GameAccount.Achievements.Any(a => a.AchievementId == achievementId && a.Completion != -1)) return;
|
||||
|
||||
ulong mainCriteriaId = GetMainCriteria(achievementId);
|
||||
var aa = client.Account.GameAccount.AchievementCriteria;
|
||||
D3.Achievements.CriteriaUpdateRecord mainCriteria;
|
||||
lock (client.Account.GameAccount.AchievementCriteria)
|
||||
{
|
||||
mainCriteria = client.Account.GameAccount.AchievementCriteria.Where(c => c.CriteriaId32AndFlags8 == (uint)mainCriteriaId).FirstOrDefault();
|
||||
mainCriteria = client.Account.GameAccount.AchievementCriteria.FirstOrDefault(c => c.CriteriaId32AndFlags8 == (uint)mainCriteriaId);
|
||||
}
|
||||
if (mainCriteria == null)
|
||||
mainCriteria = D3.Achievements.CriteriaUpdateRecord.CreateBuilder()
|
||||
@ -531,7 +531,7 @@ namespace DiIiS_NA.GameServer.AchievementSystem
|
||||
(c.AdvanceEvent.Id == 105 && c.AdvanceEvent.Comparand == actorId64)).ToList();
|
||||
|
||||
if (!isHardcore)
|
||||
criterias = criterias.Where(c => c.AdvanceEvent.ModifierList.Where(m => m.NecessaryCondition == 306).Count() == 0).ToList();
|
||||
criterias = criterias.Where(c => c.AdvanceEvent.ModifierList.All(m => m.NecessaryCondition != 306)).ToList();
|
||||
|
||||
criterias = criterias.Where(c => c.AdvanceEvent.ModifierList.Single(m => m.NecessaryCondition == 103).Comparand == type64).ToList();
|
||||
|
||||
|
||||
@ -13,14 +13,14 @@ namespace DiIiS_NA.GameServer.ClientSystem.Base
|
||||
public ConnectionDataEventArgs(IConnection connection, IEnumerable<byte> data)
|
||||
: base(connection)
|
||||
{
|
||||
Data = data ?? new byte[0];
|
||||
Data = data ?? Array.Empty<byte>();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Connection.RemoteEndPoint != null
|
||||
? string.Format("{0}: {1} bytes", Connection.RemoteEndPoint, Data.Count())
|
||||
: string.Format("Not Connected: {0} bytes", Data.Count());
|
||||
? $"{Connection.RemoteEndPoint}: {Data.Count()} bytes"
|
||||
: $"Not Connected: {Data.Count()} bytes";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ namespace DiIiS_NA.GameServer.ClientSystem.Base
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_newSockets.Count() == 0)
|
||||
if (!_newSockets.Any())
|
||||
return;
|
||||
|
||||
lock (_newSockets)
|
||||
|
||||
@ -33,7 +33,7 @@ namespace DiIiS_NA.GameServer.CommandManager
|
||||
[Command("add", "Allows you to add a new user account.\nUsage: account add <email> <password> <battletag> [userlevel]", Account.UserLevels.GM)]
|
||||
public string Add(string[] @params, BattleClient invokerClient)
|
||||
{
|
||||
if (@params.Count() < 3)
|
||||
if (@params.Length < 3)
|
||||
return "Invalid arguments. Type 'help account add' to get help.";
|
||||
|
||||
var email = @params[0];
|
||||
@ -41,7 +41,7 @@ namespace DiIiS_NA.GameServer.CommandManager
|
||||
var battleTagName = @params[2];
|
||||
var userLevel = Account.UserLevels.User;
|
||||
|
||||
if (@params.Count() == 4)
|
||||
if (@params.Length == 4)
|
||||
{
|
||||
var level = @params[3].ToLower();
|
||||
switch (level)
|
||||
@ -88,7 +88,7 @@ namespace DiIiS_NA.GameServer.CommandManager
|
||||
[Command("setpassword", "Allows you to set a new password for account\nUsage: account setpassword <email> <password>", Account.UserLevels.GM)]
|
||||
public string SetPassword(string[] @params, BattleClient invokerClient)
|
||||
{
|
||||
if (@params.Count() < 2)
|
||||
if (@params.Length < 2)
|
||||
return "Invalid arguments. Type 'help account setpassword' to get help.";
|
||||
|
||||
var email = @params[0];
|
||||
@ -109,7 +109,7 @@ namespace DiIiS_NA.GameServer.CommandManager
|
||||
[Command("setbtag", "Allows you to change battle tag for account\nUsage: account setbtag <email> <newname>", Account.UserLevels.GM)]
|
||||
public string SetBTag(string[] @params, BattleClient invokerClient)
|
||||
{
|
||||
if (@params.Count() < 2)
|
||||
if (@params.Length < 2)
|
||||
return "Invalid arguments. Type 'help account setbtag' to get help.";
|
||||
|
||||
var email = @params[0];
|
||||
@ -127,7 +127,7 @@ namespace DiIiS_NA.GameServer.CommandManager
|
||||
[Command("setuserlevel", "Allows you to set a new user level for account\nUsage: account setuserlevel <email> <user level>.\nAvailable user levels: owner, admin, gm, user.", Account.UserLevels.GM)]
|
||||
public string SetLevel(string[] @params, BattleClient invokerClient)
|
||||
{
|
||||
if (@params.Count() < 2)
|
||||
if (@params.Length < 2)
|
||||
return "Invalid arguments. Type 'help account setuserlevel' to get help.";
|
||||
|
||||
var email = @params[0];
|
||||
@ -170,7 +170,7 @@ namespace DiIiS_NA.GameServer.CommandManager
|
||||
[DefaultCommand(Account.UserLevels.GM)]
|
||||
public string Mute(string[] @params, BattleClient invokerClient)
|
||||
{
|
||||
if (@params.Count() < 2)
|
||||
if (@params.Length < 2)
|
||||
return "Invalid arguments. Type 'help mute' to get help.";
|
||||
|
||||
var bTagName = @params[0];
|
||||
@ -196,7 +196,7 @@ namespace DiIiS_NA.GameServer.CommandManager
|
||||
{
|
||||
if(@params == null)
|
||||
return "Wrong game tag. Example: !tag mytag";
|
||||
if (@params.Count() != 1)
|
||||
if (@params.Length != 1)
|
||||
return "Invalid arguments. Enter one string tag.";
|
||||
|
||||
string Tag = @params[0];
|
||||
|
||||
@ -175,7 +175,7 @@ namespace DiIiS_NA.GameServer.CommandManager
|
||||
bool found = false;
|
||||
var @params = parameters.Split(' ');
|
||||
var group = @params[0];
|
||||
var command = @params.Count() > 1 ? @params[1] : string.Empty;
|
||||
var command = @params.Length > 1 ? @params[1] : string.Empty;
|
||||
|
||||
foreach (var pair in CommandGroups.Where(pair => group == pair.Key.Name))
|
||||
{
|
||||
|
||||
@ -301,7 +301,7 @@ public class SpawnCommand : CommandGroup
|
||||
actorSNO = 6652;
|
||||
|
||||
|
||||
if (@params.Count() > 1)
|
||||
if (@params.Length > 1)
|
||||
if (!int.TryParse(@params[1], out amount))
|
||||
amount = 1;
|
||||
if (amount > 100) amount = 100;
|
||||
@ -563,7 +563,7 @@ public class ItemCommand : CommandGroup
|
||||
return "You need to specify a valid item name!";
|
||||
|
||||
|
||||
if (@params.Count() == 1 || !int.TryParse(@params[1], out amount))
|
||||
if (@params.Length == 1 || !int.TryParse(@params[1], out amount))
|
||||
amount = 1;
|
||||
|
||||
if (amount > 100) amount = 100;
|
||||
@ -605,7 +605,7 @@ public class ItemCommand : CommandGroup
|
||||
if (type == null)
|
||||
return "The type given is not a valid item type.";
|
||||
|
||||
if (@params.Count() == 1 || !int.TryParse(@params[1], out amount))
|
||||
if (@params.Length == 1 || !int.TryParse(@params[1], out amount))
|
||||
amount = 1;
|
||||
|
||||
if (amount > 100) amount = 100;
|
||||
@ -766,7 +766,7 @@ public class ConversationCommand : CommandGroup
|
||||
if (invokerClient.InGameClient == null)
|
||||
return "You can only invoke this command while in-game.";
|
||||
|
||||
if (@params.Count() != 1)
|
||||
if (@params.Length != 1)
|
||||
return "Invalid arguments. Type 'help conversation' to get help.";
|
||||
|
||||
try
|
||||
@ -875,7 +875,7 @@ public class ModifySpeedCommand : CommandGroup
|
||||
if (@params == null)
|
||||
return Fallback();
|
||||
|
||||
if (@params.Count() != 1)
|
||||
if (@params.Length != 1)
|
||||
return "Invalid arguments. Type 'help text public' to get help.";
|
||||
|
||||
var questId = int.Parse(@params[0]);
|
||||
@ -897,7 +897,7 @@ public class ModifySpeedCommand : CommandGroup
|
||||
if (@params == null)
|
||||
return Fallback();
|
||||
|
||||
if (@params.Count() != 2)
|
||||
if (@params.Length != 2)
|
||||
return "Invalid arguments. Type 'help text public' to get help.";
|
||||
|
||||
var eventId = int.Parse(@params[0]);
|
||||
|
||||
@ -436,10 +436,10 @@ namespace DiIiS_NA.GameServer.Core
|
||||
|
||||
public Item GetItemByDynId(Player plr, uint dynId)
|
||||
{
|
||||
if (Items.Values.Where(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId).Count() > 0)
|
||||
if (Items.Values.Any(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId))
|
||||
return Items.Values.Single(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId);
|
||||
else
|
||||
return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -197,11 +197,10 @@ namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
|
||||
if (PresetPowers.Count > 0)
|
||||
{
|
||||
//int power = this.PresetPowers[RandomHelper.Next(this.PresetPowers.Count)].Key;
|
||||
List<int> availablePowers = Enumerable.ToList(PresetPowers.Where(p => (p.Value.CooldownTimer == null || p.Value.CooldownTimer.TimedOut) && PowerLoader.HasImplementationForPowerSNO(p.Key)).Select(p => p.Key));
|
||||
if (availablePowers.Where(p => p != 30592).Count() > 0)
|
||||
return availablePowers.Where(p => p != 30592).ToList()[RandomHelper.Next(availablePowers.Where(p => p != 30592).ToList().Count())];
|
||||
else
|
||||
if (availablePowers.Contains(30592))
|
||||
List<int> availablePowers = PresetPowers.Where(p => (p.Value.CooldownTimer == null || p.Value.CooldownTimer.TimedOut) && PowerLoader.HasImplementationForPowerSNO(p.Key)).Select(p => p.Key).ToList();
|
||||
if (availablePowers.Any(p => p != 30592))
|
||||
return availablePowers.Where(p => p != 30592).ToList()[RandomHelper.Next(availablePowers.Count(p => p != 30592))];
|
||||
if (availablePowers.Contains(30592))
|
||||
return 30592; //melee attack
|
||||
}
|
||||
|
||||
|
||||
@ -59,7 +59,7 @@ namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
|
||||
}
|
||||
var monsterData = (DiIiS_NA.Core.MPQ.FileFormats.Monster)MPQStorage.Data.Assets[SNOGroup.Monster][body.ActorData.MonsterSNO].Data;
|
||||
_mpqPowerCount = monsterData.SkillDeclarations.Count(e => e.SNOPower != -1);
|
||||
for (int i = 0; i < monsterData.SkillDeclarations.Count(); i++)
|
||||
for (int i = 0; i < monsterData.SkillDeclarations.Length; i++)
|
||||
{
|
||||
if (monsterData.SkillDeclarations[i].SNOPower == -1) continue;
|
||||
if (PowerLoader.HasImplementationForPowerSNO(monsterData.SkillDeclarations[i].SNOPower))
|
||||
@ -437,7 +437,7 @@ namespace DiIiS_NA.GameServer.GSSystem.AISystem.Brains
|
||||
var availablePowers = PresetPowers.Where(p => (p.Value.CooldownTimer == null || p.Value.CooldownTimer.TimedOut) && PowerLoader.HasImplementationForPowerSNO(p.Key)).Select(p => p.Key).ToList();
|
||||
if (availablePowers.Count(p => p != 30592) > 0)
|
||||
{
|
||||
int SelectedPower = availablePowers.Where(p => p != 30592).ToList()[RandomHelper.Next(availablePowers.Where(p => p != 30592).ToList().Count())];
|
||||
int SelectedPower = availablePowers.Where(p => p != 30592).ToList()[RandomHelper.Next(availablePowers.Count(p => p != 30592))];
|
||||
//if(SelectedPower == 73824)
|
||||
//if(SkeletonKingWhirlwind)
|
||||
return SelectedPower;
|
||||
|
||||
@ -31,7 +31,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
|
||||
_collapsed = true;
|
||||
|
||||
World.Game.SideQuestGizmo = this;
|
||||
World.Game.QuestManager.LaunchSideQuest(eventIds[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, eventIds.Count())], true);
|
||||
World.Game.QuestManager.LaunchSideQuest(eventIds[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, eventIds.Count)], true);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
@ -35,7 +35,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations
|
||||
_collapsed = true;
|
||||
|
||||
World.Game.SideQuestGizmo = this;
|
||||
World.Game.QuestManager.LaunchSideQuest(eventIds[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, eventIds.Count())], true);
|
||||
World.Game.QuestManager.LaunchSideQuest(eventIds[DiIiS_NA.Core.Helpers.Math.FastRandom.Instance.Next(0, eventIds.Count)], true);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
@ -34,12 +34,12 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem.Implementations.Minions
|
||||
|
||||
LifeTime = TickTimer.WaitSeconds(world.Game, lifetime);
|
||||
|
||||
if (Master != null && context.ScriptFormula(1) < (Master as Player).Followers.Values.Where(f => f == SNO).Count())
|
||||
if (Master != null && context.ScriptFormula(1) < (Master as Player).Followers.Values.Count(f => f == SNO))
|
||||
{
|
||||
if (Master is Player)
|
||||
{
|
||||
var rem = new List<uint>();
|
||||
foreach (var fol in (Master as Player).Followers.Where(f => f.Key != GlobalID).Take((Master as Player).Followers.Values.Where(f => f == SNO).Count() - (int)context.ScriptFormula(1)))
|
||||
foreach (var fol in (Master as Player).Followers.Where(f => f.Key != GlobalID).Take((Master as Player).Followers.Values.Count(f => f == SNO) - (int)context.ScriptFormula(1)))
|
||||
if (fol.Value == SNO)
|
||||
rem.Add(fol.Key);
|
||||
foreach (var rm in rem)
|
||||
|
||||
@ -208,9 +208,9 @@ namespace DiIiS_NA.GameServer.GSSystem.ActorSystem
|
||||
if (ConversationList != null)
|
||||
{
|
||||
var suitable_entries = ConversationList.AmbientConversationListEntries.Where(entry => entry.SpecialEventFlag == World.Game.CurrentAct).ToList();
|
||||
if (suitable_entries.Count() > 0)
|
||||
if (suitable_entries.Count > 0)
|
||||
{
|
||||
var random_conv = suitable_entries[FastRandom.Instance.Next(suitable_entries.Count())];
|
||||
var random_conv = suitable_entries[FastRandom.Instance.Next(suitable_entries.Count)];
|
||||
player.Conversations.StartConversation(random_conv.SNOConversation);
|
||||
if (ForceConversationSNO == Conversations[0].ConversationSNO) ForceConversationSNO = -1;
|
||||
}
|
||||
|
||||
@ -1726,7 +1726,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
|
||||
|
||||
public bool WorldCleared(WorldSno worldSNO)
|
||||
{
|
||||
return _worlds[worldSNO].Actors.Values.OfType<Monster>().Where(m => m.OriginalLevelArea != -1 && !m.Dead).Count() < 5;
|
||||
return _worlds[worldSNO].Actors.Values.OfType<Monster>().Count(m => m.OriginalLevelArea != -1 && !m.Dead) < 5;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -32,7 +32,7 @@ namespace DiIiS_NA.GameServer.GSSystem.GameSystem
|
||||
|
||||
public static GameUpdateThread FindWorker()
|
||||
{
|
||||
return UpdateWorkers.OrderBy(t => t.Games.Count()).First();
|
||||
return UpdateWorkers.OrderBy(t => t.Games.Count).First();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -941,7 +941,7 @@ namespace DiIiS_NA.D3_GameServer.GSSystem.GameSystem
|
||||
if (QuestManager.Game.GetWorld(world).CheckLocationForFlag(SP, Scene.NavCellFlags.AllowWalk))
|
||||
break;
|
||||
}
|
||||
QuestManager.Game.GetWorld(world).SpawnMonster((ActorSno)GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee[FastRandom.Instance.Next(GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee.Count())], SP);
|
||||
QuestManager.Game.GetWorld(world).SpawnMonster((ActorSno)GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee[FastRandom.Instance.Next(GameServer.GSSystem.GeneratorsSystem.SpawnGenerator.Spawns[LevelArea].melee.Count)], SP);
|
||||
MonsterCount++;
|
||||
}
|
||||
} //Нужен дополнительный спаун монстров, их мало
|
||||
|
||||
@ -335,7 +335,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
|
||||
data.NumberOfCompletionSteps);
|
||||
foreach (var step in data.QuestSteps)
|
||||
{
|
||||
int nextID = step.StepObjectiveSets.Count() > 0
|
||||
int nextID = step.StepObjectiveSets.Any()
|
||||
? step.StepObjectiveSets.First().FollowUpStepID
|
||||
: -1;
|
||||
Logger.Info("Step [{0}] {1} -> {2}", step.ID, step.Name, nextID);
|
||||
@ -1168,7 +1168,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
|
||||
//var found = false;
|
||||
//ItemTable itemDefinition = null;
|
||||
|
||||
if (pool.Count() == 0) return null;
|
||||
if (pool.Count == 0) return null;
|
||||
List<ItemTable> pool_filtered = pool.Where(it =>
|
||||
it.SNOActor != -1 &&
|
||||
it.WeaponDamageMin != 100.0f &&
|
||||
@ -1222,7 +1222,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
|
||||
).ToList();
|
||||
//*/
|
||||
|
||||
if (pool_filtered.Count() == 0) return null;
|
||||
if (pool_filtered.Count == 0) return null;
|
||||
|
||||
|
||||
ItemTable selected = pool_filtered[FastRandom.Instance.Next(0, pool_filtered.Count() - 1)];
|
||||
@ -1234,7 +1234,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
|
||||
//var found = false;
|
||||
//ItemTable itemDefinition = null;
|
||||
|
||||
if (pool.Count() == 0) return null;
|
||||
if (pool.Count == 0) return null;
|
||||
List<ItemTable> pool_filtered = pool.Where(it =>
|
||||
it.SNOActor != -1 &&
|
||||
it.WeaponDamageMin != 100.0f &&
|
||||
@ -1262,7 +1262,7 @@ namespace DiIiS_NA.GameServer.GSSystem.ItemsSystem
|
||||
(it.Cost == 0)) && // i hope it catches all lore with npc spawned /xsochor
|
||||
!(!GBIDHandlers.ContainsKey(it.Hash) && !AllowedItemTypes.Contains(it.ItemTypesGBID))
|
||||
).ToList();
|
||||
if (pool_filtered.Count() == 0) return null;
|
||||
if (pool_filtered.Count == 0) return null;
|
||||
|
||||
ItemTable selected = pool_filtered[FastRandom.Instance.Next(0, pool_filtered.Count() - 1)];
|
||||
return selected;
|
||||
|
||||
@ -282,7 +282,7 @@ namespace DiIiS_NA.GameServer.GSSystem.MapSystem
|
||||
BuffManager.Update();
|
||||
PowerManager.Update();
|
||||
|
||||
if (tickCounter % 6 == 0 && _flippyTimers.Count() > 0)
|
||||
if (tickCounter % 6 == 0 && _flippyTimers.Any())
|
||||
{
|
||||
UpdateFlippy(tickCounter);
|
||||
}
|
||||
@ -1033,7 +1033,7 @@ namespace DiIiS_NA.GameServer.GSSystem.MapSystem
|
||||
else
|
||||
{
|
||||
_flippyTimers.Dequeue().Dequeue().Invoke();
|
||||
if (_flippyTimers.Count() > 0)
|
||||
if (_flippyTimers.Any())
|
||||
_flippyTimers.Peek().Dequeue().Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
|
||||
|
||||
public Item GetItemByDynId(Player plr, uint dynId)
|
||||
{
|
||||
if (Items.Values.Where(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId).Count() > 0)
|
||||
if (Items.Values.Any(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId))
|
||||
return Items.Values.Single(it => it.IsRevealedToPlayer(plr) && it.DynamicID(plr) == dynId);
|
||||
else
|
||||
return null;
|
||||
|
||||
@ -286,9 +286,9 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
|
||||
{
|
||||
string itemType = originalItem.ItemDefinition.Name.Substring(3);
|
||||
if (itemType.Contains("1HWeapon"))
|
||||
itemType = OneHandedWeapons[FastRandom.Instance.Next(OneHandedWeapons.Count())];
|
||||
itemType = OneHandedWeapons[FastRandom.Instance.Next(OneHandedWeapons.Count)];
|
||||
if (itemType.Contains("2HWeapon"))
|
||||
itemType = TwoHandedWeapons[FastRandom.Instance.Next(TwoHandedWeapons.Count())];
|
||||
itemType = TwoHandedWeapons[FastRandom.Instance.Next(TwoHandedWeapons.Count)];
|
||||
if (itemType.Contains("Pants"))
|
||||
itemType = "Legs";
|
||||
_inventoryGrid.AddItem(ItemGenerator.GetRandomItemOfType(_owner, ItemGroup.FromString(itemType)));
|
||||
@ -739,15 +739,15 @@ namespace DiIiS_NA.GameServer.GSSystem.PlayerSystem
|
||||
_owner.GrantAchievement(74987243307126);
|
||||
|
||||
var items = GetEquippedItems();
|
||||
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "Belt_Barbarian")).Count() > 0 && (items.Where(item => ItemGroup.IsSubType(item.ItemType, "MightyWeapon1H")).Count() > 0 || items.Where(item => ItemGroup.IsSubType(item.ItemType, "MightyWeapon2H")).Count() > 0)) //barb
|
||||
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "Belt_Barbarian")) && (items.Any(item => ItemGroup.IsSubType(item.ItemType, "MightyWeapon1H")) || items.Any(item => ItemGroup.IsSubType(item.ItemType, "MightyWeapon2H")))) //barb
|
||||
_owner.GrantAchievement(74987243307046);
|
||||
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "Cloak")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "HandXbow")).Count() > 0) //dh
|
||||
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "Cloak")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "HandXbow"))) //dh
|
||||
_owner.GrantAchievement(74987243307058);
|
||||
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "SpiritStone_Monk")).Count() > 0 && (items.Where(item => ItemGroup.IsSubType(item.ItemType, "FistWeapon")).Count() > 0 || items.Where(item => ItemGroup.IsSubType(item.ItemType, "CombatStaff")).Count() > 0)) //monk
|
||||
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "SpiritStone_Monk")) && (items.Any(item => ItemGroup.IsSubType(item.ItemType, "FistWeapon")) || items.Any(item => ItemGroup.IsSubType(item.ItemType, "CombatStaff")))) //monk
|
||||
_owner.GrantAchievement(74987243307544);
|
||||
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "VoodooMask")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "CeremonialDagger")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "Mojo")).Count() > 0) //wd
|
||||
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "VoodooMask")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "CeremonialDagger")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "Mojo"))) //wd
|
||||
_owner.GrantAchievement(74987243307561);
|
||||
if (items.Where(item => ItemGroup.IsSubType(item.ItemType, "WizardHat")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "Wand")).Count() > 0 && items.Where(item => ItemGroup.IsSubType(item.ItemType, "Orb")).Count() > 0) //wiz
|
||||
if (items.Any(item => ItemGroup.IsSubType(item.ItemType, "WizardHat")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "Wand")) && items.Any(item => ItemGroup.IsSubType(item.ItemType, "Orb"))) //wiz
|
||||
_owner.GrantAchievement(74987243307582);
|
||||
}
|
||||
|
||||
|
||||
@ -4645,8 +4645,7 @@ public class Player : Actor, IMessageConsumer, IUpdateable
|
||||
public void GrantAchievement(ulong id)
|
||||
{
|
||||
if (_unlockedAchievements.Contains(id)) return;
|
||||
if (InGameClient.BnetClient.Account.GameAccount.Achievements
|
||||
.Where(a => a.AchievementId == id && a.Completion != -1).Count() > 0) return;
|
||||
if (InGameClient.BnetClient.Account.GameAccount.Achievements.Any(a => a.AchievementId == id && a.Completion != -1)) return;
|
||||
if (_unlockedAchievements.Contains(id)) return;
|
||||
_unlockedAchievements.Add(id);
|
||||
try
|
||||
|
||||
@ -302,7 +302,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
var targets = GetEnemiesInRadius(User.Position, ScriptFormula(18)).Actors;
|
||||
Actor target = null;
|
||||
|
||||
if (targets.Count() > 0)
|
||||
if (targets.Any())
|
||||
target = targets[Rand.Next(targets.Count())];
|
||||
|
||||
var position = target == null ? RandomDirection(User.Position, 1f, 15f) : target.Position;
|
||||
|
||||
@ -1350,7 +1350,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
|
||||
if (Rune_A > 0) //Barrage
|
||||
{
|
||||
if (dash.Targets.Actors.Count() > 0)
|
||||
if (dash.Targets.Actors.Any())
|
||||
AddBuff(dash.Targets.GetClosestTo(TargetPosition), new DashingBarrageDotBuff());
|
||||
}
|
||||
|
||||
@ -3114,7 +3114,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
Target.Attributes[GameAttribute.Damage_Weapon_Percent_Bonus] -= _unityDamageBonus;
|
||||
Target.Attributes[GameAttribute.Damage_Percent_All_From_Skills] -= _unityDamageBonus;
|
||||
|
||||
_unityDamageBonus = 0.05f * Target.GetActorsInRange<Player>(ScriptFormula(0)).Count();
|
||||
_unityDamageBonus = 0.05f * Target.GetActorsInRange<Player>(ScriptFormula(0)).Count;
|
||||
|
||||
Target.Attributes[GameAttribute.Damage_Weapon_Percent_Bonus] += _unityDamageBonus;
|
||||
Target.Attributes[GameAttribute.Damage_Percent_All_From_Skills] += _unityDamageBonus;
|
||||
@ -3657,7 +3657,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
if (Rune_B > 0) //Water Ally
|
||||
{
|
||||
var targets = GetEnemiesInRadius(petAlly.Position, 20f, 7).Actors;
|
||||
if (targets.Count() <= 0) yield break;
|
||||
if (!targets.Any()) yield break;
|
||||
|
||||
foreach (var target in targets)
|
||||
{
|
||||
|
||||
@ -2316,7 +2316,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
if (!HasBuff<GargantuanEnrageCDBuff>(Target))
|
||||
{
|
||||
var targets = GetEnemiesInRadius(Target.Position, 10f);
|
||||
if (targets.Actors.Count >= 5 || targets.Actors.Where(a => a is Boss || a is Champion || a is Rare || a is Unique).Count() > 1)
|
||||
if (targets.Actors.Count >= 5 || targets.Actors.Count(a => a is Boss or Champion or Rare or Unique) > 1)
|
||||
{
|
||||
AddBuff(Target, new GargantuanEnrageCDBuff());
|
||||
AddBuff(Target, new GargantuanEnrageBuff());
|
||||
@ -2704,7 +2704,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
if (payload is HitPayload && payload.Target == Target)
|
||||
{
|
||||
Player usr = (Target as Player);
|
||||
float dmg = (payload as HitPayload).TotalDamage * ScriptFormula(9) / usr.Followers.Values.Where(a => a == ActorSno._wd_zombiedog).Count();
|
||||
float dmg = (payload as HitPayload).TotalDamage * ScriptFormula(9) / usr.Followers.Values.Count(a => a == ActorSno._wd_zombiedog);
|
||||
(payload as HitPayload).TotalDamage *= 1 - ScriptFormula(9);
|
||||
//List<Actor> dogs = GetAlliesInRadius(Target.Position, 100f).Actors.Where(a => a.ActorSNO.Id == 51353).ToList();
|
||||
foreach (var dog in GetAlliesInRadius(Target.Position, 100f).Actors.Where(a => a.SNO == ActorSno._wd_zombiedog))
|
||||
@ -2738,7 +2738,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
if (payload is HitPayload && payload.Context.User == Target)
|
||||
{
|
||||
Player master = (Target as ZombieDog).Master as Player;
|
||||
float heal = (payload as HitPayload).TotalDamage * ScriptFormula(8) / (master.Followers.Values.Where(a => a == ActorSno._wd_zombiedog).Count() + 1);
|
||||
float heal = (payload as HitPayload).TotalDamage * ScriptFormula(8) / (master.Followers.Values.Count(a => a == ActorSno._wd_zombiedog) + 1);
|
||||
(payload as HitPayload).TotalDamage *= 1 - ScriptFormula(9);
|
||||
master.AddHP(heal);
|
||||
foreach (var dog in GetAlliesInRadius(Target.Position, 100f).Actors.Where(a => a.SNO == ActorSno._wd_zombiedog))
|
||||
|
||||
@ -724,7 +724,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
|
||||
Vector3D[] spawnPoints = PowerMath.GenerateSpreadPositions(TgtPosition, TgtPosition + new Vector3D(3f, 0, 0), 120, 3);
|
||||
|
||||
for (int i = 0; i < spawnPoints.Count(); i++)
|
||||
for (int i = 0; i < spawnPoints.Length; i++)
|
||||
{
|
||||
if (!User.World.CheckLocationForFlag(spawnPoints[i], DiIiS_NA.Core.MPQ.FileFormats.Scene.NavCellFlags.AllowWalk))
|
||||
continue;
|
||||
@ -801,7 +801,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
Actor curTarget = target;
|
||||
Actor nextTarget = null;
|
||||
var c = 0;
|
||||
while (targets.Count() < 3)
|
||||
while (targets.Count < 3)
|
||||
{
|
||||
nextTarget = GetEnemiesInRadius(curTarget.Position, 6f).Actors.FirstOrDefault(a => !targets.Contains(a));
|
||||
if (nextTarget == null) break;
|
||||
@ -1980,7 +1980,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Implementations
|
||||
AddBuff(hitPayload.Target, new ShatterDebuff(User, ScriptFormula(14), WaitSeconds(2f)));
|
||||
}
|
||||
if (Rune_E > 0) //Deep Freeze
|
||||
if (nova.Targets.Actors.Count() > ScriptFormula(13))
|
||||
if (nova.Targets.Actors.Count > ScriptFormula(13))
|
||||
if (!HasBuff<DeepFreezeChCBuff>(User))
|
||||
AddBuff(User, new DeepFreezeChCBuff(ScriptFormula(18), WaitSeconds(ScriptFormula(19))));
|
||||
};
|
||||
|
||||
@ -141,7 +141,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem.Payloads
|
||||
float additionalCritChance = chcBonus;
|
||||
|
||||
if (user is Player && (user as Player).SkillSet.HasPassive(338859)) //Single Out
|
||||
if (target.GetMonstersInRange(20f).Where(m => m != target).Count() == 0)
|
||||
if (target.GetMonstersInRange(20f).All(m => m == target))
|
||||
additionalCritChance += 0.25f;
|
||||
|
||||
//Wizard -> Spectral Blade -> Ice Blades
|
||||
|
||||
@ -256,7 +256,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
|
||||
|
||||
var targets = Context.GetEnemiesInRadius(ChainCurrent.Position, ChainRadius);
|
||||
targets.Actors.Remove(ChainCurrent);
|
||||
if (targets.Actors.Count() == 0)
|
||||
if (!targets.Actors.Any())
|
||||
{
|
||||
Destroy();
|
||||
return;
|
||||
@ -266,7 +266,7 @@ namespace DiIiS_NA.GameServer.GSSystem.PowerSystem
|
||||
nextProj.Position.Z += 5f;
|
||||
|
||||
nextProj.ChainCurrent = ChainCurrent;
|
||||
nextProj.ChainNextPos = targets.Actors[PowerContext.Rand.Next(targets.Actors.Count())].Position;
|
||||
nextProj.ChainNextPos = targets.Actors[PowerContext.Rand.Next(targets.Actors.Count)].Position;
|
||||
|
||||
nextProj.ChainTargetsRemain = ChainTargetsRemain;
|
||||
nextProj.ChainIteration = ChainIteration + 1;
|
||||
|
||||
@ -56,7 +56,7 @@ namespace DiIiS_NA.GameServer.GSSystem.QuestSystem.QuestEvents.Implementations
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
var rand_pos = ActorsVector3D[FastRandom.Instance.Next(ActorsVector3D.Count())];
|
||||
var rand_pos = ActorsVector3D[FastRandom.Instance.Next(ActorsVector3D.Count)];
|
||||
world.SpawnMonster(ActorSno._ghost_jail_prisoner, rand_pos);
|
||||
ActorsVector3D.Remove(rand_pos);
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ namespace DiIiS_NA
|
||||
var cpuTime = proc.TotalProcessorTime;
|
||||
var text =
|
||||
$"{name} | " +
|
||||
$"{PlayerManager.OnlinePlayers.Count()} onlines in {PlayerManager.OnlinePlayers.Count(s => s.InGameClient?.Player?.World != null)} worlds | " +
|
||||
$"{PlayerManager.OnlinePlayers.Count} onlines in {PlayerManager.OnlinePlayers.Count(s => s.InGameClient?.Player?.World != null)} worlds | " +
|
||||
$"Memory: {totalMemory:0.000} GB | " +
|
||||
$"CPU Time: {cpuTime.ToSmallText()} | " +
|
||||
$"Uptime: {uptime.ToSmallText()}";
|
||||
|
||||
Loading…
Reference in New Issue
user.block.title