private LeagueOfLegendsModule(int ledCount, LightingMode mode, AbilityCastPreference castMode) { // League of Legends integration Initialization // Init Item Attributes ItemUtils.Init(); ItemCooldownController.Init(); this.preferredCastMode = castMode; // LED Initialization lightingMode = mode; this.leds = new Led[ledCount]; for (int i = 0; i < ledCount; i++) { leds[i] = new Led(); } // Load animation module animationModule = AnimationModule.Create(this.leds.Length); animationModule.NewFrameReady += OnNewFrameReceived; CurrentLEDSource = animationModule; PlayLoadingAnimation(); WaitForGameInitialization(); }
private void SetModuleForItem(Item item) { ItemAttributes attrs = ItemUtils.GetItemAttributes(item.ItemID); // decide and create item module accordingly. Type itemType = ItemControllers.FirstOrDefault( x => item.ItemID == (x.GetCustomAttribute(typeof(ItemAttribute)) as ItemAttribute).ItemID); if (itemType != null) { if (ItemModules[item.Slot] == null || !(ItemModules[item.Slot].GetType().IsAssignableFrom(itemType))) { ItemModules[item.Slot]?.Dispose(); ItemModules[item.Slot] = itemType.GetMethod("Create") .Invoke(null, new object[] { this.leds.Length, this.gameState, item.Slot, this.lightingMode, this.preferredCastMode }) as ItemModule; ItemModules[item.Slot].RequestActivation += OnItemActivated; ItemModules[item.Slot].NewFrameReady += OnNewFrameReceived; ItemCooldownController.AssignItemIdToSlot(item.Slot, item.ItemID); if (item.ItemID == WardingTotemModule.ITEM_ID) { WardingTotemModule.Current = ItemModules[item.Slot] as WardingTotemModule; // HACK to make it accessible to HUDModule } // TODO: Show an item buy animation here? } ItemModules[item.Slot].UpdateGameState(gameState); } else { ItemModules[item.Slot]?.Dispose(); ItemModules[item.Slot] = null; } }
public void Dispose() { masterCancelToken.Cancel(); animationModule.StopCurrentAnimation(); championModule?.Dispose(); for (int i = 0; i < ItemModules.Length; i++) { ItemModules[i]?.Dispose(); ItemModules[i] = null; } ItemUtils.Dispose(); ItemCooldownController.Dispose(); }
protected ItemModule(int itemID, int itemSlot, GameState state, LightingMode preferredMode) { LightingMode = preferredMode; ItemAttributes = ItemUtils.GetItemAttributes(itemID); GameState = state; this._ItemID = itemID; this.itemSlot = itemSlot; this.activationKey = GetKeyForItemSlot(itemSlot); // TODO: Handle key rebinds... // Should this be needed for all items modules? Only active ones KeyboardHookService.Instance.OnMouseClicked += OnMouseClick; // TODO. Abstract this to league of legends module, so it pairs with summoner spells and items. KeyboardHookService.Instance.OnKeyPressed += OnKeyPress; KeyboardHookService.Instance.OnKeyReleased += OnKeyRelease; }