private UserSkillInfo GetOrPlaceholder(UserEntity user, int skillId)
        {
            if (user == null)
                throw new ArgumentNullException("user");

            var existing = GetOrNull(user, skillId);
            if (existing != null)
                return existing;

            return new UserSkillInfo(skillId, user.RaceGenderClass, "Unknown " + skillId);
        }
        // skillIds are reused across races and class, so we need a RaceGenderClass to disambiguate them
        public UserSkillInfo GetOrNull(UserEntity user, int skillId)
        {
            var raceGenderClass = user.RaceGenderClass;
            foreach (var rgc in raceGenderClass.Fallbacks())
            {
                if (!_userSkilldata.ContainsKey(rgc))
                    continue;

                UserSkillInfo skill;
                if(!_userSkilldata[rgc].TryGetValue(skillId, out skill))
                    continue;

                return skill;
            }
            return null;
        }
Esempio n. 3
0
        // skillIds are reused across races and class, so we need a RaceGenderClass to disambiguate them
        public Skill Get(UserEntity user, EachSkillResultServerMessage message)
        {
            var skillId = message.SkillId;

            //check if we have an override first

            var overrideCollection = message.IsHeal ? _healSkillIdOverrides : _damageSkillIdOverrides;
            if (overrideCollection.ContainsKey(user.RaceGenderClass.Class))
            {   //check class specific overrides
                var skill = overrideCollection[user.RaceGenderClass.Class].FirstOrDefault(s => s.Id == skillId);
                //check common overrides
                if (skill == null && overrideCollection.ContainsKey(PlayerClass.Common))
                {
                    skill = overrideCollection[PlayerClass.Common].FirstOrDefault(s => s.Id == skillId);
                }

                if (skill != null)
                    return skill;
            }

            var raceGenderClass = user.RaceGenderClass;
            var comparer = new Helpers.ProjectingEqualityComparer<Skill, int>(x => x.Id);
            foreach (var rgc2 in raceGenderClass.Fallbacks())
            {
                if (!_userSkilldata.ContainsKey(rgc2))
                    continue;

                var searchSkill = new UserSkill(skillId, raceGenderClass, null);

                var index = _userSkilldata[rgc2].BinarySearch(searchSkill, comparer);
                if (index < 0)
                    index = ~index - 1;
                if (index < 0)
                    continue;

                var item = _userSkilldata[rgc2][index];
                return item;
            }
            return null;
        }
Esempio n. 4
0
        // skillIds are reused across races and class, so we need a RaceGenderClass to disambiguate them
        public UserSkill Get(UserEntity user, int skillId)
        {
            var raceGenderClass = user.RaceGenderClass;
            var comparer = new Helpers.ProjectingEqualityComparer<Skill, int>(x => x.Id);
            foreach (var rgc2 in raceGenderClass.Fallbacks())
            {
                if (!_userSkilldata.ContainsKey(rgc2))
                    continue;

                var searchSkill = new UserSkill(skillId, raceGenderClass, null);

                var index = _userSkilldata[rgc2].BinarySearch(searchSkill, comparer);
                if (index < 0)
                    index = ~index - 1;
                if (index < 0)
                    continue;

                var item = _userSkilldata[rgc2][index];
                return item;
            }
            return null;
        }
 public string GetName(UserEntity user, int skillId)
 {
     return GetOrPlaceholder(user, skillId).Name;
 }
Esempio n. 6
0
 public Player(UserEntity user)
 {
     _user = user;
 }
Esempio n. 7
0
        public IEnumerable<Tera.Game.Skill> SkillsIdBySource(UserEntity source, Entity target, bool timed)
        {
            IEnumerable<Tera.Game.Skill> result;

            if (timed || target == null)
            {
                result = from skills in SourceTargetSkill[source].Values
                    from skill in skills
                    select
                        SkillResult.GetSkill(source, skill.Pet, skill.SkillId, skill.HotDot,
                            NetworkController.Instance.EntityTracker, BasicTeraData.Instance.SkillDatabase,
                            BasicTeraData.Instance.HotDotDatabase, BasicTeraData.Instance.PetSkillDatabase);

                return result.Distinct();
            }

            result = from skills in SourceTargetSkill[source][target]
                select
                    SkillResult.GetSkill(source, skills.Pet, skills.SkillId, skills.HotDot,
                        NetworkController.Instance.EntityTracker, BasicTeraData.Instance.SkillDatabase,
                        BasicTeraData.Instance.HotDotDatabase, BasicTeraData.Instance.PetSkillDatabase);
            return result.Distinct();
        }