Пример #1
0
        public void OnTick()
        {
            var zone = shareManager.Get(this.player);

            if (zone == null)
            {
                return;
            }
            ILocation center = zone.GetClosestWalkable(player.world, player.status.entity.location.ToLocation(), true);

            if (center == null)
            {
                return;
            }

            var map = player.functions.AsyncMoveToLocation(center, token, ZMO);

            map.Completed += areaMap => {
                shareManager.RegisterReached(this.player);
                busy = false;
            };
            map.Cancelled += (areaMap, cuboid) => {
                busy = false;
            };
            busy = true;
            map.Start();
        }
Пример #2
0
 public ShareEntity Get(int id)
 {
     _manager.ClearBrokenRuleMessages();
     return(_manager.Get(id));
 }
Пример #3
0
        private ILocation FindNext()
        {
            //Get the area from the radius.
            IRadius playerRadius = shareManager.Get(player);

            if (playerRadius == null)
            {
                return(null);
            }

            //Search from top to bottom.
            //(As that is easier to manager)
            ILocation closest  = null;
            double    distance = int.MaxValue;

            for (int y = (int)playerRadius.start.y + playerRadius.height; y >= (int)playerRadius.start.y; y--)
            {
                if (closest == null)
                {
                    for (int x = playerRadius.start.x; x <= playerRadius.start.x + playerRadius.xSize; x++)
                    {
                        for (int z = playerRadius.start.z; z <= playerRadius.start.z + playerRadius.zSize; z++)
                        {
                            var tempLocation = new Location(x, y, z);
                            //Check if the block is valid for mining.
                            if (player.world.GetBlockId(x, y, z) == 0)
                            {
                                continue;
                            }
                            if (broken.ContainsKey(tempLocation) &&
                                broken[tempLocation].Subtract(DateTime.Now).TotalSeconds < -15)
                            {
                                continue;
                            }
                            if (ignore?.Contains(player.world.GetBlockId(x, y, z)) == true)
                            {
                                continue;
                            }

                            // Check if this block is safe to mine.
                            if (!IsSafe(tempLocation))
                            {
                                continue;
                            }

                            if (closest == null)
                            {
                                distance = tempLocation.Distance(player.status.entity.location.ToLocation(0));
                                closest  = new Location(x, y, z);
                            }
                            else if (tempLocation.Distance(player.status.entity.location.ToLocation(0)) < distance)
                            {
                                distance = tempLocation.Distance(player.status.entity.location.ToLocation(0));
                                closest  = tempLocation;
                            }
                        }
                    }
                }
            }

            return(closest);
        }