private void FilterAbilities(long tick, List <BossSpawnAbilities> phaseAbilities) { foreach (var ability in phaseAbilities) { var t = ConditionManager.GetType(); var method = t.GetMethod(ability.Condition); _logger.Debug($"Checking condition: {ability.Condition} "); var conditionTrue = (bool)method.Invoke(ConditionManager, null); if (conditionTrue) { // If the ability is not in the ability tracker, add it if (!AbilityTracker.ContainsKey(ability)) { lock (AbilityTracker) { AbilityTracker.Add(ability, TCPManager.GetTimeStamp() + NEXT_ATTACK_COOLDOWN); } _logger.Debug($"Adding ability to the tracker : {AbilityTracker.Count} {ability.Name} 0"); } else // If this ability is already in the abilitytracker -- can probably remove this as it should be removed on execution. { long nextInvocation = 0; // If it's next invocation > now, dont add. AbilityTracker.TryGetValue(ability, out nextInvocation); if (nextInvocation > tick) { // Do nothing } } } } }
private void FilterAbilities(long tick) { foreach (var ability in Abilities) { var t = ConditionManager.GetType(); var method = t.GetMethod(ability.Condition); _logger.Debug($"Checking condition: {ability.Condition} "); if (method == null) { _logger.Error($"Method is null: {ability.Condition} "); return; } var conditionTrue = (bool)method.Invoke(ConditionManager, null); if (conditionTrue) { // If the ability is not in the ability tracker, add it if (!AbilityTracker.ContainsKey(ability)) { lock (AbilityTracker) { AbilityTracker.Add(ability, 0); } _logger.Debug($"Adding ability to the tracker : {AbilityTracker.Count} {ability.Name} 0"); } else // If this ability is already in the abilitytracker -- can probably remove this as it should be removed on execution. { long nextInvocation = 0; // If it's next invocation > now, dont add. AbilityTracker.TryGetValue(ability, out nextInvocation); if (nextInvocation > tick) { // Do nothing } } } else { // Condition is no longer true - remove it from the AbilityTracker AbilityTracker.Remove(ability); } } }