Ejemplo n.º 1
0
        /// <summary>
        /// When this event is completed, it marks the robot as in transit, sending it
        /// to the nearest available site. Ideally this should chain - a limitation of the
        /// current implementation is that there needs to be at least one site per robot
        /// </summary>
        /// <param name="world">State of the simulation at the time the event is fired</param>
        public override void Run(State world)
        {
            world.baseStation.chargingStationsInUse -= 1;
            MiningSite site = world.sites.First(s => s.available);

            robot.state = RobotState.inTransit;
            robot.batteryPowerConsumed = 0;
            site.available             = false;

            float arrivalTime = world.time + robot.getArrivalTime(site.distance);
            var   e           = new AtMiningSiteEvent(robot, site, arrivalTime);

            world.eventQueue.Enqueue(e, e.GetTime());
        }
 public OreMiningCompleteEvent(MiningSite site, Robot robot, float time)
 {
     this.site  = site;
     this.robot = robot;
     this.time  = time;
 }
 public AtMiningSiteEvent(Robot r, MiningSite s, float time)
 {
     robot     = r;
     site      = s;
     this.time = time;
 }