示例#1
0
		public bool Start (AcceptorTask acceptTask) {
			
			if (!Enabled || !acceptTask.Enabled) {
				return false;
			}

			this.acceptTask = acceptTask;
			acceptTask.Binder.Add (this, settings.BindCapacity);
			return true;
		}
示例#2
0
 public static AcceptorTask GetAcceptor(PerformerTask task, ITaskAcceptor acceptor)
 {
     // TODO: linq
     foreach (var acceptorTask in acceptor.AcceptableTasks.EnabledTasks)
     {
         AcceptorTask a = acceptorTask.Value;
         if (task.GetType() == a.AcceptedTask)
         {
             return(a);
         }
     }
     return(null);
 }
示例#3
0
        public static AcceptorTask GetPair(PerformerTask task, ITaskAcceptor acceptor, bool mustBeEnabled = true)
        {
            // TODO: linq
            Dictionary <System.Type, AcceptorTask> tasks = mustBeEnabled
                                ? acceptor.AcceptableTasks.EnabledTasks
                                : acceptor.AcceptableTasks.ActiveTasks;

            foreach (var acceptorTask in tasks)
            {
                AcceptorTask a = acceptorTask.Value;
                if (a.GetType() == task.Settings.Pair)
                {
                    return(a);
                }
            }
            return(null);
        }
示例#4
0
        // Returns a task for the for the performer to perform
        public static MatchResult GetPerformable(ITaskPerformer performer, ITaskAcceptor acceptor, bool mustBeEnabled = true)
        {
            List <PerformerTask> matches = mustBeEnabled
                                ? GetEnabled(performer, acceptor)
                                : GetActive(performer, acceptor);

            if (matches.Count == 0)
            {
                return(null);
            }

            // Prioritizes tasks that don't require a pair, or whose pair exists between the acceptors
            foreach (PerformerTask task in matches)
            {
                AcceptorTask acceptorTask = GetAcceptor(task, acceptor);
                if (task.Settings.Pair == null)
                {
                    return(new MatchResult(task, false, acceptorTask));
                }
            }

            return(new MatchResult(matches[0], true, GetAcceptor(matches[0], acceptor)));
        }
示例#5
0
        // Tries to find a pair for the provided match
        public static MatchResult GetPerformable(MatchResult match, ITaskPerformer performer, ITaskAcceptor acceptor)
        {
            if (match == null)
            {
                return(null);
            }

            AcceptorTask pair = GetPair(match.Match, acceptor);

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

            foreach (PerformerTask performerTask in GetEnabled(performer, acceptor))
            {
                if (pair.AcceptedTask == performerTask.GetType())
                {
                    return(new MatchResult(performerTask, true, pair));
                }
            }
            return(null);
        }
示例#6
0
 public MatchResult(PerformerTask match, bool needsPair, AcceptorTask acceptor)
 {
     Match     = match;
     NeedsPair = needsPair;
     Acceptor  = acceptor;
 }
示例#7
0
 public BindingHandler(AcceptorTask task)
 {
     this.task = task;
     // TODO: would probably be better to have this set initially
     // bindLimit = DataManager.GetPerformerPairSettings (task.GetType ()).BindCapacity;
 }