Esempio n. 1
0
 /// <summary>
 /// Override Action.CompareTo
 /// </summary>
 public override int CompareTo(ActionAbstract argActionToCompare)
 {
     if (Object == (argActionToCompare as ActionObtainResLog).Object)
     {
         return(0);
     }
     return(1);
 }
Esempio n. 2
0
 /// <summary>
 /// Override Action.CompareTo
 /// </summary>
 public override int CompareTo(ActionAbstract argActionToCompare)
 {
     if (BuildingLocation == (argActionToCompare as ActionBuildShelterCamp).BuildingLocation)
     {
         return(0);
     }
     return(1);
 }
Esempio n. 3
0
        /// <summary>
        /// Getting the action object for current participants and action type
        /// </summary>
        /// <param name="argActionType">Action type</param>
        /// <param name="argCurrentInfo">Action info (need for optimisation)</param>
        /// <param name="argSubject">Subject</param>
        /// <param name="argObject">Object</param>
        /// <param name="argParams">Action params</param>
        /// <returns>Action object</returns>
        public static ActionAbstract GetActionForCurrentParticipants(Type argActionType, ActionInfoAttribute argCurrentInfo, Agent argSubject, Agent argObject, params object[] argParams)
        {
            logger.Trace("Getting action for action type {0}, subject: {1}, object: {2}", argActionType, argSubject.Name, argObject != null ? argObject.Name : "none");

            if (!argActionType.IsSubclassOf(typeof(ActionAbstract)))
            {
                logger.Error("Trying to get action for none-action type: {0}!", argActionType);
                return(null);
            }

            ActionAbstract result = null;             //Action to return

            if (argCurrentInfo.RequiresObject)
            {
                Dictionary <Type, Dictionary <Type, Func <Agent, Agent, object[], ActionAbstract> > > subjectTypeDictionary; //supportive vars
                Dictionary <Type, Func <Agent, Agent, object[], ActionAbstract> > objectTypeDictionary;                      //supportive vars
                Func <Agent, Agent, object[], ActionAbstract> actionFunc;                                                    //supportive vars

                BinaryActionsDataBase.TryGetValue(argActionType, out subjectTypeDictionary);
                subjectTypeDictionary.TryGetValue(argSubject.GetType(), out objectTypeDictionary);
                objectTypeDictionary.TryGetValue(argObject.GetType(), out actionFunc);

                result = actionFunc(argSubject, argObject, argParams);
            }
            else
            {
                Dictionary <Type, Func <Agent, object[], ActionAbstract> > subjectTypeDictionary; //supportive vars
                Func <Agent, object[], ActionAbstract> actionFunc;                                //supportive vars

                UnaryActionsDataBase.TryGetValue(argActionType, out subjectTypeDictionary);
                subjectTypeDictionary.TryGetValue(argSubject.GetType(), out actionFunc);

                result = actionFunc(argSubject, argParams);
            }

            logger.Debug("Get action for {0}", argActionType);

            return(result);
        }
Esempio n. 4
0
 public override int CompareTo(ActionAbstract argActionToCompare)
 {
     return(1);            //Action isn't conflict
 }