Esempio n. 1
0
        /// <summary>Creates a game connection object for the tourist AI class.</summary>
        /// <returns>A new <see cref="TouristAIConnection{TouristAI, Citizen}"/> object.</returns>
        public static TouristAIConnection <TouristAI, Citizen> GetTouristAIConnection()
        {
            try
            {
                GetRandomTargetTypeDelegate getRandomTargetType
                    = FastDelegate.Create <TouristAI, GetRandomTargetTypeDelegate>("GetRandomTargetType");

                GetLeavingReasonDelegate getLeavingReason
                    = FastDelegate.Create <TouristAI, GetLeavingReasonDelegate>("GetLeavingReason");

                AddTouristVisitDelegate addTouristVisit
                    = FastDelegate.Create <TouristAI, AddTouristVisitDelegate>("AddTouristVisit");

                DoRandomMoveDelegate doRandomMove
                    = FastDelegate.Create <TouristAI, DoRandomMoveDelegate>("DoRandomMove");

                FindEvacuationPlaceDelegate findEvacuationPlace
                    = FastDelegate.Create <TouristAI, FindEvacuationPlaceDelegate>("FindEvacuationPlace");

                FindVisitPlaceDelegate findVisitPlace
                    = FastDelegate.Create <TouristAI, FindVisitPlaceDelegate>("FindVisitPlace");

                GetEntertainmentReasonDelegate getEntertainmentReason
                    = FastDelegate.Create <TouristAI, GetEntertainmentReasonDelegate>("GetEntertainmentReason");

                GetEvacuationReasonDelegate getEvacuationReason
                    = FastDelegate.Create <TouristAI, GetEvacuationReasonDelegate>("GetEvacuationReason");

                GetShoppingReasonDelegate getShoppingReason
                    = FastDelegate.Create <TouristAI, GetShoppingReasonDelegate>("GetShoppingReason");

                StartMovingDelegate startMoving
                    = FastDelegate.Create <TouristAI, StartMovingDelegate>("StartMoving");

                return(new TouristAIConnection <TouristAI, Citizen>(
                           getRandomTargetType,
                           getLeavingReason,
                           addTouristVisit,
                           doRandomMove,
                           findEvacuationPlace,
                           findVisitPlace,
                           getEntertainmentReason,
                           getEvacuationReason,
                           getShoppingReason,
                           startMoving));
            }
            catch (Exception e)
            {
                Log.Error("The 'Real Time' mod failed to create a delegate for type 'TouristAI', no method patching for the class: " + e);
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>Creates a game connection object for the tourist AI class.</summary>
        /// <returns>A new <see cref="TouristAIConnection{TouristAI, Citizen}"/> object.</returns>
        public static TouristAIConnection<TouristAI, Citizen> GetTouristAIConnection()
        {
            try
            {
                GetRandomTargetTypeDelegate getRandomTargetType
                    = FastDelegateFactory.Create<GetRandomTargetTypeDelegate>(typeof(TouristAI), "GetRandomTargetType", instanceMethod: true);

                GetLeavingReasonDelegate getLeavingReason
                    = FastDelegateFactory.Create<GetLeavingReasonDelegate>(typeof(TouristAI), "GetLeavingReason", instanceMethod: true);

                AddTouristVisitDelegate addTouristVisit
                    = FastDelegateFactory.Create<AddTouristVisitDelegate>(typeof(TouristAI), "AddTouristVisit", instanceMethod: true);

                DoRandomMoveDelegate doRandomMove
                    = FastDelegateFactory.Create<DoRandomMoveDelegate>(typeof(TouristAI), "DoRandomMove", instanceMethod: true);

                FindEvacuationPlaceDelegate findEvacuationPlace
                    = FastDelegateFactory.Create<FindEvacuationPlaceDelegate>(typeof(TouristAI), "FindEvacuationPlace", instanceMethod: true);

                FindVisitPlaceDelegate findVisitPlace
                    = FastDelegateFactory.Create<FindVisitPlaceDelegate>(typeof(TouristAI), "FindVisitPlace", instanceMethod: true);

                GetEntertainmentReasonDelegate getEntertainmentReason
                    = FastDelegateFactory.Create<GetEntertainmentReasonDelegate>(typeof(TouristAI), "GetEntertainmentReason", instanceMethod: true);

                GetEvacuationReasonDelegate getEvacuationReason
                    = FastDelegateFactory.Create<GetEvacuationReasonDelegate>(typeof(TouristAI), "GetEvacuationReason", instanceMethod: true);

                GetShoppingReasonDelegate getShoppingReason
                    = FastDelegateFactory.Create<GetShoppingReasonDelegate>(typeof(TouristAI), "GetShoppingReason", instanceMethod: true);

                StartMovingDelegate startMoving
                    = FastDelegateFactory.Create<StartMovingDelegate>(typeof(TouristAI), "StartMoving", instanceMethod: true);

                return new TouristAIConnection<TouristAI, Citizen>(
                    getRandomTargetType,
                    getLeavingReason,
                    addTouristVisit,
                    doRandomMove,
                    findEvacuationPlace,
                    findVisitPlace,
                    getEntertainmentReason,
                    getEvacuationReason,
                    getShoppingReason,
                    startMoving);
            }
            catch (Exception e)
            {
                Log.Error("The 'Real Time' mod failed to create a delegate for type 'TouristAI', no method patching for the class: " + e);
                return null;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TouristAIConnection{TAI, TCitizen}" /> class.
 /// </summary>
 /// <param name="getRandomTargetType">A method that corresponds to the AI's original <c>GetRandomTargetType</c> method.</param>
 /// <param name="getLeavingReason">A method that corresponds to the AI's original <c>GetLeavingReason</c> method.</param>
 /// <param name="addTouristVisit">A method that corresponds to the AI's original <c>AddTouristVisit</c> method.</param>
 /// <param name="doRandomMove">A method that corresponds to the AI's original <c>RandomMove</c> method.</param>
 /// <param name="findEvacuationPlace">A method that corresponds to the AI's original <c>FindEvacuationPlace</c> method.</param>
 /// <param name="findVisitPlace">A method that corresponds to the AI's original <c>FindVisitPlace</c> method.</param>
 /// <param name="getEntertainmentReason">A method that corresponds to the AI's original <c>GetEntertainmentReason</c> method.</param>
 /// <param name="getEvacuationReason">A method that corresponds to the AI's original <c>GetEvacuationReason</c> method.</param>
 /// <param name="getShoppingReason">A method that corresponds to the AI's original <c>GetShoppingReason</c> method.</param>
 /// <param name="startMoving">A method that corresponds to the AI's original <c>StartMoving</c> method specifying a
 /// target building ID.</param>
 /// <exception cref="ArgumentNullException">Thrown when any argument is null.</exception>
 public TouristAIConnection(
     GetRandomTargetTypeDelegate getRandomTargetType,
     GetLeavingReasonDelegate getLeavingReason,
     AddTouristVisitDelegate addTouristVisit,
     DoRandomMoveDelegate doRandomMove,
     FindEvacuationPlaceDelegate findEvacuationPlace,
     FindVisitPlaceDelegate findVisitPlace,
     GetEntertainmentReasonDelegate getEntertainmentReason,
     GetEvacuationReasonDelegate getEvacuationReason,
     GetShoppingReasonDelegate getShoppingReason,
     StartMovingDelegate startMoving)
     : base(doRandomMove, findEvacuationPlace, findVisitPlace, getEntertainmentReason, getEvacuationReason, getShoppingReason, startMoving)
 {
     GetRandomTargetType = getRandomTargetType ?? throw new ArgumentNullException(nameof(getRandomTargetType));
     GetLeavingReason    = getLeavingReason ?? throw new ArgumentNullException(nameof(getLeavingReason));
     AddTouristVisit     = addTouristVisit ?? throw new ArgumentNullException(nameof(addTouristVisit));
 }