public bool OnUpdate()
        {
            bool key = LazyManager <InputManager> .Current.GetKey(LazyManager <VoxelTycoon.Settings> .Current.MultipleModeKey);

            if (this._deactivate && !key)
            {
                return(true);
            }
            Building building = null;

            if (!InputHelper.OverUI)
            {
                building = ObjectRaycaster.Get <Building>((Component comp) => comp is Store || comp is Lab);
            }
            else
            {
                GameObject gameObject = InputHelper.GetUIGameObjectUnderPointer();
                if (gameObject != null)
                {
                    DemandIndicator demandInd;
                    if ((demandInd = gameObject.GetComponent <DemandIndicator>()) != null)
                    {
                        CityDemand demand = Traverse.Create(demandInd).Field <CityDemand>("_demand").Value;
                        if (demand != null && demand.Store)
                        {
                            building = demand.Store;
                        }
                    }
                }
            }
            if (building != null)
            {
                if (this._building != building)
                {
                    if (this._building != null)
                    {
                        this._building.SetTint(null);
                    }
                    this._building = building;
                    this._canPick  = this.CanPick(building);
                    if (_canPick)
                    {
                        this._tooltip.Background = new PanelColor(DemandPickerTool.ReadyToPickTooltipColor, 0f);
                        this._tooltip.Text       = LazyManager <LocaleManager> .Current.Locale.GetString("schedule_stopwatch/add_building_for_demand");
                    }
                    else
                    {
                        this._tooltip.Background = new PanelColor(DemandPickerTool.WrongReadyToPickHighlightColor, 0f);
                        this._tooltip.Text       = LazyManager <LocaleManager> .Current.Locale.GetString("schedule_stopwatch/already_added");

                        building.SetTint(new Color?(WrongReadyToPickHighlightColor));
                    }
                }
                if (_canPick)
                {
                    UIManager.Current.SetCursor(Cursors.Pointer);
                    if (InputHelper.MouseDown)
                    {
                        this.OnBuildingPicked?.Invoke(building);
                        Manager <SoundManager> .Current.PlayOnce(R.Audio.Click, null);

                        if (_indicatorEntered)
                        {
                            _disableIndicatorUntilExit = true;
                        }
                        if (!key)
                        {
                            return(true);
                        }
                        DisabledNodes?.Add(building as IStorageNetworkNode);
                        LazyManager <BuildingTintManager> .Current.SetDefaultColor(building, null);

                        building.SetTint(null);
                        this._deactivate = true;
                    }
                }
            }
            else
            {
                if (this._building != null)
                {
                    this._building.SetTint(null);
                    this._building = null;
                }
                this._tooltip.Background = new PanelColor(DemandPickerTool.PickingTooltipColor, 0f);
                this._tooltip.Text       = LazyManager <LocaleManager> .Current.Locale.GetString("schedule_stopwatch/pick_store_or_lab");
            }
            this._tooltip.RectTransform.anchoredPosition = (new Vector2(Input.mousePosition.x, Input.mousePosition.y) + new Vector2(-10f, -16f)) / UIManager.Current.Scale;
            this._tooltip.ClampPositionToScreen();
            return(InputHelper.MouseDown && !key);
        }
예제 #2
0
 private static void AddCityDemand(CityDemand demand, Dictionary <Item, int> demandsList)
 {
     RecipeHelper.AddItem(demandsList, demand.Item, demand.Demand);
 }