Example #1
0
        private static void TriggerOnDetectSkillshot(
            SpellDatabaseEntry spellDatabaseEntry,
            Obj_AI_Base caster,
            SkillshotDetectionType detectionType,
            Vector2 start,
            Vector2 end,
            int time,
            MissileClient missile = null)
        {
            Skillshot skillshot = null;

            switch (spellDatabaseEntry.SpellType)
            {
            case SpellType.SkillshotMissileArc:
                skillshot = new SkillshotMissileArc(spellDatabaseEntry);
                break;

            case SpellType.SkillshotMissileCircle:
                skillshot = new SkillshotMissileCircle(spellDatabaseEntry);
                break;

            case SpellType.SkillshotMissileLine:
                skillshot = new SkillshotMissileLine(spellDatabaseEntry);
                break;

            case SpellType.SkillshotCircle:
                skillshot = new SkillshotCircle(spellDatabaseEntry);
                break;

            case SpellType.SkillshotCone:
                skillshot = new SkillshotCone(spellDatabaseEntry);
                break;

            case SpellType.SkillshotLine:
                skillshot = new SkillshotLine(spellDatabaseEntry);
                break;

            case SpellType.SkillshotRing:
                skillshot = new SkillshotRing(spellDatabaseEntry);
                break;
            }

            if (skillshot == null)
            {
                return;
            }

            var type =
                Type.GetType(
                    $"LeagueSharp.SDK.Core.Wrappers.Spells.Detector.Skillshots_{skillshot.SData.ChampionName}{skillshot.SData.Slot}");

            if (type != null)
            {
                skillshot = (Skillshot)Activator.CreateInstance(type);
            }

            skillshot.DetectionType = detectionType;
            skillshot.Caster        = caster;
            skillshot.StartPosition = start;
            skillshot.EndPosition   = end;
            skillshot.StartTime     = time;

            if (missile != null)
            {
                try
                {
                    ((SkillshotMissile)skillshot).Missile = missile;
                }
                catch (Exception)
                {
                    LogManager.GetCurrentClassLogger()
                    .Warn(
                        $"Wrong SpellType for SkillShot {skillshot.SData.SpellName}, a missile type was expected but instead got a {missile.GetType().Name}.");
                }
            }

            if (!skillshot.Process())
            {
                return;
            }

            TriggerOnDetectSkillshot(skillshot);
        }
Example #2
0
        private static void TriggerOnDetectSkillshot(SpellDatabaseEntry spellDatabaseEntry, Obj_AI_Base caster, SkillshotDetectionType detectionType, Vector2 start, Vector2 end, int time, MissileClient missile = null)
        {
            Skillshot skillshot = null;

            switch (spellDatabaseEntry.SpellType)
            {
                case SpellType.SkillshotMissileArc:
                    skillshot = new SkillshotMissileArc(spellDatabaseEntry);
                    break;
                case SpellType.SkillshotMissileCircle:
                    skillshot = new SkillshotMissileCircle(spellDatabaseEntry);
                    break;
                case SpellType.SkillshotMissileLine:
                    skillshot = new SkillshotMissileLine(spellDatabaseEntry);
                    break;
                case SpellType.SkillshotCircle:
                    skillshot = new SkillshotCircle(spellDatabaseEntry);
                    break;
                case SpellType.SkillshotCone:
                    skillshot = new SkillshotCone(spellDatabaseEntry);
                    break;
                case SpellType.SkillshotLine:
                    skillshot = new SkillshotLine(spellDatabaseEntry);
                    break;
                case SpellType.SkillshotRing:
                    skillshot = new SkillshotRing(spellDatabaseEntry);
                    break;
            }
            
            if (skillshot == null)
            {
                return;
            }

            var type =
                    Type.GetType(
                        $"LeagueSharp.SDK.Core.Wrappers.Spells.Detector.Skillshots_{skillshot.SData.ChampionName}{skillshot.SData.Slot}");
            if (type != null)
            {
                skillshot = (Skillshot)Activator.CreateInstance(type);
            }

            skillshot.DetectionType = detectionType;
            skillshot.Caster = caster;
            skillshot.StartPosition = start;
            skillshot.EndPosition = end;
            skillshot.StartTime = time;

            if (missile != null)
            {
                try
                {
                    ((SkillshotMissile)skillshot).Missile = missile;
                }
                catch (Exception ex)
                {
                    Logging.Write()(Enumerations.LogLevel.Warn, "Wrong SpellType for Skillshot {0}, a Missile Type was expected", skillshot.SData.SpellName);
                }
                
            }

            if (!skillshot.Process())
            {
                return;
            }

            TriggerOnDetectSkillshot(skillshot);
        }