public List <GroupData> GetCraftGroups()
        {
            CraftStation station = CraftStation.GetNearestInRange(transform.position);

            if (station != null)
            {
                return(new List <GroupData>(station.craft_groups));
            }
            else
            {
                return(new List <GroupData>(craft_groups));
            }
        }
Beispiel #2
0
        public static CraftStation GetNearestInRange(Vector3 pos)
        {
            float        min_dist = 99f;
            CraftStation nearest  = null;

            foreach (CraftStation station in station_list)
            {
                if (station.buildable == null || !station.buildable.IsBuilding())
                {
                    float dist = (pos - station.transform.position).magnitude;
                    if (dist < min_dist && dist < station.range)
                    {
                        min_dist = dist;
                        nearest  = station;
                    }
                }
            }
            return(nearest);
        }
Beispiel #3
0
        protected override void RefreshPanel()
        {
            base.RefreshPanel();

            PlayerCharacter player = GetPlayer();

            if (player != null)
            {
                CraftStation station = player.Crafting.GetCraftStation();
                if (current_staton != station)
                {
                    current_staton = station;
                    RefreshCategories();
                }
            }

            //Gamepad auto controls
            PlayerControls controls    = PlayerControls.Get(GetPlayerID());
            CraftSubPanel  sub_panel   = CraftSubPanel.Get(GetPlayerID());
            UISlotPanel    focus_panel = UISlotPanel.GetFocusedPanel();

            if (focus_panel != this && focus_panel != sub_panel && !TheUI.Get().IsBlockingPanelOpened() &&
                controls.IsGamePad() && player != null && !player.Crafting.IsBuildMode())
            {
                Focus();
                CraftInfoPanel.Get(GetPlayerID())?.Hide();
            }
            if (focus_panel == this)
            {
                selection_index = Mathf.Clamp(selection_index, 0, CountActiveSlots() - 1);

                UISlot slot = GetSelectSlot();
                if (prev_slot != slot || !sub_panel.IsVisible())
                {
                    OnClick(slot);
                    sub_panel.selection_index = 0;
                    prev_slot = slot;
                }
            }
        }
        public CraftStation GetCraftStation()
        {
            CraftStation station = CraftStation.GetNearestInRange(transform.position);

            return(station);
        }