Exemplo n.º 1
0
 public void Select(KSelectable new_selected, bool skipSound = false)
 {
     if (!((Object)new_selected == (Object)previousSelection))
     {
         previousSelection = new_selected;
         if ((Object)selected != (Object)null)
         {
             selected.Unselect();
         }
         GameObject gameObject = null;
         if ((Object)new_selected != (Object)null)
         {
             SelectToolHoverTextCard component = GetComponent <SelectToolHoverTextCard>();
             if ((Object)component != (Object)null)
             {
                 int currentSelectedSelectableIndex     = component.currentSelectedSelectableIndex;
                 int recentNumberOfDisplayedSelectables = component.recentNumberOfDisplayedSelectables;
                 if (recentNumberOfDisplayedSelectables != 0)
                 {
                     currentSelectedSelectableIndex = (currentSelectedSelectableIndex + 1) % recentNumberOfDisplayedSelectables;
                     if (!skipSound)
                     {
                         if (recentNumberOfDisplayedSelectables == 1)
                         {
                             KFMOD.PlayOneShot(GlobalAssets.GetSound("Select_empty", false));
                         }
                         else
                         {
                             EventInstance instance = KFMOD.BeginOneShot(GlobalAssets.GetSound("Select_full", false), Vector3.zero);
                             instance.setParameterValue("selection", (float)currentSelectedSelectableIndex);
                             SoundEvent.EndOneShot(instance);
                         }
                         playedSoundThisFrame = true;
                     }
                 }
             }
             if ((Object)new_selected == (Object)hover)
             {
                 ClearHover();
             }
             new_selected.Select();
             gameObject = new_selected.gameObject;
             selectMarker.SetTargetTransform(gameObject.transform);
             selectMarker.gameObject.SetActive(!new_selected.DisableSelectMarker);
         }
         else if ((Object)selectMarker != (Object)null)
         {
             selectMarker.gameObject.SetActive(false);
         }
         selected = new_selected;
         Game.Instance.Trigger(-1503271301, gameObject);
     }
 }