public void FilterCards(Entity mountedModule, ModuleBehaviourType slotType)
 {
     if (this.currentTankPartItem != null)
     {
         ModuleCardItemUIComponent[] componentsInChildren = base.GetComponentsInChildren <ModuleCardItemUIComponent>(true);
         bool flag = false;
         ModuleCardItemUIComponent[] componentArray2 = componentsInChildren;
         int index = 0;
         while (true)
         {
             if (index < componentArray2.Length)
             {
                 ModuleCardItemUIComponent component = componentArray2[index];
                 if (!component.gameObject.activeSelf || !component.GetComponent <ToggleListItemComponent>().Toggle.isOn)
                 {
                     index++;
                     continue;
                 }
                 flag = (component.Type == slotType) && (((component.TankPart != TankPartModuleType.WEAPON) || (this.currentTankPartItem.Type != TankPartItem.TankPartItemType.Turret)) ? ((component.TankPart == TankPartModuleType.TANK) && (this.currentTankPartItem.Type == TankPartItem.TankPartItemType.Hull)) : true);
             }
             foreach (ModuleCardItemUIComponent component2 in componentsInChildren)
             {
                 bool flag2 = ((component2.TankPart != TankPartModuleType.WEAPON) || (this.currentTankPartItem.Type != TankPartItem.TankPartItemType.Turret)) ? ((component2.TankPart == TankPartModuleType.TANK) && (this.currentTankPartItem.Type == TankPartItem.TankPartItemType.Hull)) : true;
                 component2.gameObject.SetActive(flag2);
                 if (flag2 && (((mountedModule != null) && ReferenceEquals(component2.ModuleEntity, mountedModule)) || ((mountedModule == null) && (!flag && (component2.Type == slotType)))))
                 {
                     component2.GetComponent <ToggleListItemComponent>().Toggle.isOn = true;
                     flag = true;
                 }
             }
             this.upgradeModuleTrigger.Triggered();
             return;
         }
     }
 }
示例#2
0
        private void SelectMountedModuleCard(ModuleCardItemUIComponent moduleCardItemUi, ModuleGroupComponent userModuleGroup, Optional <SelectedSlotWithModuleNode> selectedSlot)
        {
            ToggleListItemComponent component = moduleCardItemUi.GetComponent <ToggleListItemComponent>();

            if (selectedSlot.IsPresent() && (selectedSlot.Get().moduleGroup.Key == userModuleGroup.Key))
            {
                component.Toggle.isOn = true;
            }
            else if (component.Toggle.isOn)
            {
                component.OnValueChangedListener();
            }
        }
        public void AddCard(Entity entity)
        {
            int index = Mathf.Min(entity.GetComponent <ModuleTierComponent>().TierNumber, this.tiersUi.Length - 1);
            ModuleCardItemUIComponent moduleCardItem = Instantiate <ModuleCardItemUIComponent>(this.moduleCardItemUiComponentPrefab);

            this.tiersUi[index].AddCard(moduleCardItem);
            if (entity.HasComponent <ModuleCardItemUIComponent>())
            {
                entity.RemoveComponent <ModuleCardItemUIComponent>();
            }
            if (entity.HasComponent <ToggleListItemComponent>())
            {
                entity.RemoveComponent <ToggleListItemComponent>();
            }
            entity.AddComponent(moduleCardItem);
            entity.AddComponent(moduleCardItem.GetComponent <ToggleListItemComponent>());
        }