public HeroContainer(Hero hero, bool isAlly, OverlayInformation main) { var itemString = hero.HeroId.ToString().Remove(0, 14); main.Context.Value.TextureManager.LoadFromFile(hero.HeroId.ToString(), $@"{GamePath}\game\dota\materials\ensage_ui\miniheroes\png\{itemString}.png"); /*Log.Warn($"Texture Name: {itemString}"); * Log.Warn($"GamePath: {$@"{GamePath}\game\dota\materials\ensage_ui\miniheroes\png\{itemString}.png"}");*/ //$@"resource\flash3\images\heroes\miniheroes\{hero.HeroId}.png"); Name = hero.Name; Id = hero.Player == null ? 0 : hero.Player.Id; HolderHelper = new Holder(); IsAlly = isAlly; Main = main; IsOwner = hero.Equals(ObjectManager.LocalHero); Hero = hero; //Ultimate = hero.Spellbook.Spells.First(x => x.AbilityType == AbilityType.Ultimate); LastTimeUnderVision = Game.RawGameTime; Items = new List <AbilityHolder>(); DangItems = new List <AbilityHolder>(); InvisBreakerItems = new List <AbilityHolder>(); Abilities2 = new List <AbilityHolder>(); foreach (var ability in GetAllAbilities) { var holder = HolderHelper.GetOrCreate(ability); //new AbilityHolder(ability); Abilities2.Add(holder); if (holder.IsUltimate) { Ultimate = holder; } Log.Info($"{ability.Name} -> {(ability.AbilityType == AbilityType.Basic ? "basic" : "ultimate")}"); } HeroInventory = Hero.Inventory; /*_manager = new InventoryManager(new EnsageServiceContext(hero)); * //manager.CollectionChanged += ManagerOnCollectionChanged; * _manager.CollectionChanged += (sender, args) => * { * //Items.Clear(); * DangItems.Clear(); * Items = _manager.Inventory.Items.ToList(); * Networth = 0; * var tmpAgh = hero.HasAghanimsScepter(); * * if (!AghanimState && tmpAgh || AghanimState && !tmpAgh) * { * RefreshAbilities(); * } * AghanimState = tmpAgh; * foreach (var item in Items) * { * Networth += item.Cost; * try * { * if (DangeItemList.Contains(item.Id)) * DangItems.Add(item); * } * catch (Exception e) * { * Console.WriteLine("GEGE -> "+e); * } * } * };*/ UpdateInfo(); UpdateItems(); UpdateManager.Subscribe(UpdateItems, 500); UpdateManager.Subscribe(UpdateInfo, 250); UpdateManager.Subscribe(FlushChecker, 1000); var dividedWeStand = hero.Spellbook.SpellR as DividedWeStand; if (dividedWeStand != null && hero.HeroId == HeroId.npc_dota_hero_meepo && dividedWeStand.UnitIndex > 0) { DontDraw = true; } HeroId = hero.HeroId; if (HeroId == HeroId.npc_dota_hero_rubick || HeroId == HeroId.npc_dota_hero_doom_bringer /* || * classId == ClassId.CDOTA_Unit_Hero_Invoker*/|| HeroId == HeroId.npc_dota_hero_morphling) { UpdateManager.Subscribe(AbilityUpdater, 750); } /*Main.Context.Value.AbilityDetector.AbilityCasted += (sender, args) => * { * Game.PrintMessage(args.Ability.Ability.Name); * }; * Main.Context.Value.AbilityDetector.AbilityCastStarted += (sender, args) => * { * Game.PrintMessage(args.Ability.Ability.Name); * };*/ }
public HeroContainer(Hero hero, bool isAlly, OverlayInformation main) { Name = hero.Name; Id = hero.Player == null ? 0 : hero.Player.Id; HolderHelper = new Holder(); IsAlly = isAlly; Main = main; IsOwner = hero.Equals(ObjectManager.LocalHero); Hero = hero; //Ultimate = hero.Spellbook.Spells.First(x => x.AbilityType == AbilityType.Ultimate); LastTimeUnderVision = Game.RawGameTime; Items = new List <AbilityHolder>(); DangItems = new List <AbilityHolder>(); Abilities2 = new List <AbilityHolder>(); foreach (var ability in GetAllAbilities) { var holder = HolderHelper.GetOrCreate(ability);//new AbilityHolder(ability); Abilities2.Add(holder); if (holder.IsUltimate) { Ultimate = holder; } Log.Info($"{ability.Name} -> {(ability.AbilityType == AbilityType.Basic ? "basic" : "ultimate")}"); } HeroInventory = Hero.Inventory; /*_manager = new InventoryManager(new EnsageServiceContext(hero)); * //manager.CollectionChanged += ManagerOnCollectionChanged; * _manager.CollectionChanged += (sender, args) => * { * //Items.Clear(); * DangItems.Clear(); * Items = _manager.Inventory.Items.ToList(); * Networth = 0; * var tmpAgh = hero.HasAghanimsScepter(); * * if (!AghanimState && tmpAgh || AghanimState && !tmpAgh) * { * RefreshAbilities(); * } * AghanimState = tmpAgh; * foreach (var item in Items) * { * Networth += item.Cost; * try * { * if (DangeItemList.Contains(item.Id)) * DangItems.Add(item); * } * catch (Exception e) * { * Console.WriteLine("GEGE -> "+e); * } * } * };*/ UpdateInfo(); UpdateItems(); UpdateManager.Subscribe(UpdateItems, 500); UpdateManager.Subscribe(UpdateInfo, 250); UpdateManager.Subscribe(FlushChecker, 1000); var dividedWeStand = hero.Spellbook.SpellR as DividedWeStand; if (dividedWeStand != null && hero.ClassId == ClassId.CDOTA_Unit_Hero_Meepo && dividedWeStand.UnitIndex > 0) { DontDraw = true; } ClassId = hero.ClassId; if (ClassId == ClassId.CDOTA_Unit_Hero_Rubick || ClassId == ClassId.CDOTA_Unit_Hero_DoomBringer /* || * classId == ClassId.CDOTA_Unit_Hero_Invoker*/) { UpdateManager.Subscribe(AbilityUpdater, 750); } /*Main.Context.Value.AbilityDetector.AbilityCasted += (sender, args) => * { * Game.PrintMessage(args.Ability.Ability.Name); * }; * Main.Context.Value.AbilityDetector.AbilityCastStarted += (sender, args) => * { * Game.PrintMessage(args.Ability.Ability.Name); * };*/ }