Ejemplo n.º 1
0
 /// <summary>
 /// Resets all statistics.
 /// </summary>
 public void ResetStatistics()
 {
     StatNumberOfPickups          = 0;
     StatNumberOfSetdowns         = 0;
     StatNumCollisions            = 0;
     StatDistanceTraveled         = 0;
     StatDistanceEstimated        = 0;
     StatDistanceRequestedOptimal = 0;
     StatAssignedTasks            = 0;
     StatTotalTimeMoving          = 0;
     StatTotalTimeQueueing        = 0;
     StatLastTask         = BotTaskType.None;
     StatLastState        = BotStateType.Rest;
     StatLastWaypoint     = null;
     StatTotalTaskTimes   = new Dictionary <BotTaskType, double>(Enum.GetValues(typeof(BotTaskType)).Cast <BotTaskType>().ToDictionary(k => k, v => 0.0));
     StatTotalStateTimes  = new Dictionary <BotStateType, double>(Enum.GetValues(typeof(BotStateType)).Cast <BotStateType>().ToDictionary(k => k, v => 0.0));
     StatTotalTaskCounts  = new Dictionary <BotTaskType, int>(Enum.GetValues(typeof(BotTaskType)).Cast <BotTaskType>().ToDictionary(k => k, v => 0));
     StatTotalStateCounts = new Dictionary <BotStateType, int>(Enum.GetValues(typeof(BotStateType)).Cast <BotStateType>().ToDictionary(k => k, v => 0));
 }
Ejemplo n.º 2
0
 public BaseState(BotStateType currentState, EventCommon eventCommon)
 {
     this.currentState = currentState;
     this.eventCommon  = eventCommon;
 }
 public BotStateHandlerAttribute(BotStateType botStateType)
 {
     BotStateType = botStateType;
 }
Ejemplo n.º 4
0
        public static bool TryGetStateHandler(this IEnumerable <IBotStateHandler> stateHandlers, BotStateType botStateType, out IBotStateHandler botStateHandler)
        {
            if (stateHandlers is null)
            {
                throw new ArgumentNullException(nameof(stateHandlers));
            }

            if (botStateType is BotStateType.None)
            {
                botStateHandler = null;
                return(false);
            }

            foreach (var item in stateHandlers)
            {
                if (Attribute.IsDefined(item.GetType(), typeof(BotStateHandlerAttribute)))
                {
                    var stateHandlerAttributes = (BotStateHandlerAttribute[])Attribute.GetCustomAttributes(item.GetType(), typeof(BotStateHandlerAttribute));
                    var attribute = stateHandlerAttributes.FirstOrDefault(x => x.BotStateType == botStateType);
                    if (attribute is not null)
                    {
                        botStateHandler = item;
                        return(true);
                    }
                }
            }

            botStateHandler = null;
            return(false);
        }