Beispiel #1
0
    protected virtual void OnAreaChange(SelectionTracker.OnAreaChangeArgs args)
    {
        Vector2Int startPosition   = Utils.WorldToGrid(args.startMousePosition);
        Vector2Int currentPosition = Utils.WorldToGrid(args.currentMousePosition);

        int width  = Mathf.Abs(currentPosition.x - startPosition.x) + 1;
        int height = Mathf.Abs(currentPosition.y - startPosition.y) + 1;

        Vector2Int start = startPosition;

        fidt17.Utils.IntRectangle rect;

        if (width >= height)
        {
            Vector2Int end = new Vector2Int(currentPosition.x, startPosition.y);
            rect = new fidt17.Utils.IntRectangle(start, end);
        }
        else
        {
            Vector2Int end = new Vector2Int(startPosition.x, currentPosition.y);
            rect = new fidt17.Utils.IntRectangle(start, end);
        }

        if (args.dragEnded)
        {
            CreateJobs();
        }

        if (_selectionArea?.CompareTo(rect) == false || _selectionArea == null)
        {
            _selectionArea = rect;
            GetNewPlans();
        }
    }
    protected virtual void OnAreaChange(SelectionTracker.OnAreaChangeArgs args)
    {
        if (_selectionArea?.CompareTo(args.rectangle) == false || _selectionArea == null)
        {
            _selectionArea = args.rectangle;
            GetNewTrees();
        }

        if (args.dragEnded)
        {
            CreateJobs();
        }
    }
Beispiel #3
0
    protected virtual void OnAreaChange(SelectionTracker.OnAreaChangeArgs args)
    {
        if (_selectionArea?.CompareTo(args.rectangle) == false || _selectionArea == null)
        {
            _selectionArea = args.rectangle;
            DrawSelectionArea(args.startMousePosition, args.currentMousePosition);
        }

        if (args.dragEnded)
        {
            StockpileCreator.CreateStockpileOnTiles(GetTilesInArea());
            GameObject.Destroy(_area?.gameObject);
        }
    }