Esempio n. 1
0
 public void VacateArea(RectInt area, string areaName)
 {
     foreach (Minion minion in minions)
     {
         if (!minion.hasWork && area.Contains(minion.pos))
         {
             JobTransient.AssignWork(minion, "MapVacate",
                                     new TaskGoTo(this, $"Vacating {areaName}.", PathCfg.Vacate(area)));
         }
     }
 }
Esempio n. 2
0
 public Vec2I[] GetPath(Vec2I start, PathCfg cfg)
 => map.nav.GetPath(start, cfg);
Esempio n. 3
0
        private IEnumerable <Task> WanderTasks(Vec2I pos)
        {
            yield return(new TaskGoTo(game, "Wandering.", PathCfg.Point(pos)));

            yield return(new TaskWaitDuration(game, "Wandering.", 1f));
        }
Esempio n. 4
0
        public IEnumerable <Task> GetHaulTasks()
        {
            var itemClaim = query.TaskClaim(haulRemaining);

            yield return(itemClaim);

            var haulClaim = new TaskClaim(game,
                                          (work) => {
                BB.AssertNotNull(itemClaim.claim);
                ItemClaim item = itemClaim.claim;
                if (item.amt > haulRemaining)
                {
                    return(null);
                }

                amtClaimed += item.amt;
                return(new ClaimLambda(() => amtClaimed -= item.amt));
            });

            yield return(haulClaim);

            yield return(new TaskGoTo(game, taskDesc, PathCfg.Point(itemClaim.claim.pos)));

            yield return(new TaskPickupItem(itemClaim));

            yield return(new TaskGoTo(game, taskDesc, dst));

            yield return(new TaskLambda(game, "dropoff item",
                                        (work) =>
            {
                if (!work.agent.carryingItem)
                {
                    return false;
                }

                work.Unclaim(haulClaim);

                Item item = work.agent.RemoveItem();

                // Should never happen
                int haulAmt = itemClaim.claim.amt;
                if (haulAmt > haulRemaining)
                {
                    haulAmt = haulRemaining;
                }

                if (item.info.amt > haulAmt)
                {
                    game.DropItems(
                        game.Tile(work.agent.pos),
                        item.info.WithAmount(item.info.amt - haulAmt).Enumerate());
                }
                // Also should never happen
                else if (item.info.amt < haulAmt)
                {
                    haulAmt = item.info.amt;
                }

                item.Destroy();

                amtStored += haulAmt;
                return true;
            }));
        }
Esempio n. 5
0
 public TaskGoTo(Game game, string description, PathCfg cfg)
     : base(game, description, cfg)
 {
 }
Esempio n. 6
0
 public ItemQueryCfg(ItemDef def, int amt, PathCfg dst)
     : this(new ItemFilter(def), amt, dst)
 {
 }
Esempio n. 7
0
 public ItemQueryCfg(ItemFilter filter, int amt, PathCfg dst)
 {
     this.filter = filter;
     this.amt    = amt;
     this.dst    = dst;
 }