예제 #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);
     }
 }
예제 #2
0
    private void FinishConstruction(UtilityConnections connections)
    {
        Rotatable   component   = GetComponent <Rotatable>();
        Orientation orientation = ((UnityEngine.Object)component != (UnityEngine.Object)null) ? component.GetOrientation() : Orientation.Neutral;
        int         num         = Grid.PosToCell(base.transform.GetLocalPosition());

        UnmarkArea();
        BuildingDef def              = building.Def;
        int         cell             = num;
        Orientation orientation2     = orientation;
        Storage     resource_storage = storage;

        Tag[]      selected_elements = selectedElementsTags;
        float      temperature       = initialTemperature;
        float      time       = GameClock.Instance.GetTime();
        GameObject gameObject = def.Build(cell, orientation2, resource_storage, selected_elements, temperature, true, time);

        gameObject.transform.rotation = base.transform.rotation;
        Rotatable component2 = gameObject.GetComponent <Rotatable>();

        if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
        {
            component2.SetOrientation(orientation);
        }
        KAnimGraphTileVisualizer component3 = GetComponent <KAnimGraphTileVisualizer>();

        if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
        {
            KAnimGraphTileVisualizer component4 = gameObject.GetComponent <KAnimGraphTileVisualizer>();
            component4.Connections = connections;
            component3.skipCleanup = true;
        }
        KSelectable component5 = GetComponent <KSelectable>();

        if ((UnityEngine.Object)component5 != (UnityEngine.Object)null && component5.IsSelected && (UnityEngine.Object)gameObject.GetComponent <KSelectable>() != (UnityEngine.Object)null)
        {
            component5.Unselect();
            if (PlayerController.Instance.ActiveTool.name == "SelectTool")
            {
                ((SelectTool)PlayerController.Instance.ActiveTool).SelectNextFrame(gameObject.GetComponent <KSelectable>(), false);
            }
        }
        storage.ConsumeAllIgnoringDisease();
        finished = true;
        this.DeleteObject();
    }