Dwarrowdelf.Client.Stockpile.FindEmptyLocation C# (CSharp) Method

FindEmptyLocation() public method

public FindEmptyLocation ( bool &ok ) : IntVector3
ok bool
return IntVector3
        public IntVector3 FindEmptyLocation(out bool ok)
        {
            int min = GetMinStack();

            var loc = this.Area.Range().FirstOrDefault(p => GetStack(p) == min);

            if (loc != new IntVector3())
            {
                ok = true;
                return loc;
            }

            ok = false;
            return new IntVector3();
        }

Usage Example

Beispiel #1
0
        protected override IAssignment PrepareNextAssignment()
        {
            IAssignment assignment;

            switch (m_state)
            {
            case State.MoveToItem:
                assignment = new MoveAssignment(this, this.Item.Environment, this.Item.Location, DirectionSet.Exact);
                break;

            case State.CarryItem:
                assignment = new CarryItemAssignment(this, this.Item);
                break;

            case State.HaulToStockpile:
                if (!m_stockpile.Area.Contains(this.Worker.Location))
                {
                    assignment = new HaulToAreaAssignment(this, m_stockpile.Environment, m_stockpile.Area.ToIntGrid3(), DirectionSet.Exact, this.Item);
                }
                else
                {
                    bool ok;
                    var  l = m_stockpile.FindEmptyLocation(out ok);
                    if (!ok)
                    {
                        throw new Exception();
                    }

                    assignment = new HaulAssignment(this, m_stockpile.Environment, l, DirectionSet.Exact, this.Item);
                }
                break;

            case State.DropItem:
                assignment = new DropItemAssignment(this, this.Item);
                break;

            default:
                throw new Exception();
            }

            return(assignment);
        }