Exemple #1
0
        /// <summary>Creates a game connection object for the resident AI class.</summary>
        /// <returns>A new <see cref="ResidentAIConnection{ResidentAI, Citizen}"/> object.</returns>
        public static ResidentAIConnection <ResidentAI, Citizen> GetResidentAIConnection()
        {
            try
            {
                DoRandomMoveDelegate doRandomMove
                    = FastDelegateFactory.Create <DoRandomMoveDelegate>(typeof(ResidentAI), "DoRandomMove", instanceMethod: true);

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

                FindHospitalDelegate findHospital
                    = FastDelegateFactory.Create <FindHospitalDelegate>(typeof(ResidentAI), "FindHospital", instanceMethod: true);

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

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

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

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

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

                StartMovingWithOfferDelegate startMovingWithOffer
                    = FastDelegateFactory.Create <StartMovingWithOfferDelegate>(typeof(ResidentAI), "StartMoving", instanceMethod: true);

                AttemptAutodidactDelegate attemptAutodidact
                    = FastDelegateFactory.Create <AttemptAutodidactDelegate>(typeof(ResidentAI), "AttemptAutodidact", instanceMethod: true);

                return(new ResidentAIConnection <ResidentAI, Citizen>(
                           doRandomMove,
                           findEvacuationPlace,
                           findHospital,
                           findVisitPlace,
                           getEntertainmentReason,
                           getEvacuationReason,
                           getShoppingReason,
                           startMoving,
                           startMovingWithOffer,
                           attemptAutodidact));
            }
            catch (Exception e)
            {
                Log.Error("The 'Real Time' mod failed to create a delegate for type 'ResidentAI', no method patching for the class: " + e);
                return(null);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResidentAIConnection{TAI, TCitizen}"/> class.
 /// </summary>
 /// <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="findHospital">
 /// A method that corresponds to the AI's original <c>FindHospital</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>
 /// <param name="startMovingWithOffer">
 /// A method that corresponds to the AI's original <c>StartMoving</c> method specifying a
 /// transfer offer.
 /// </param>
 /// <param name="attemptAutodidact">
 /// A method that corresponds to the AI's original <c>AttemptAutodidact</c> method
 /// that updates the citizen's education level after visiting a library.
 /// </param>
 /// <exception cref="ArgumentNullException">Thrown when any argument is null.</exception>
 public ResidentAIConnection(
     DoRandomMoveDelegate doRandomMove,
     FindEvacuationPlaceDelegate findEvacuationPlace,
     FindHospitalDelegate findHospital,
     FindVisitPlaceDelegate findVisitPlace,
     GetEntertainmentReasonDelegate getEntertainmentReason,
     GetEvacuationReasonDelegate getEvacuationReason,
     GetShoppingReasonDelegate getShoppingReason,
     StartMovingDelegate startMoving,
     StartMovingWithOfferDelegate startMovingWithOffer,
     AttemptAutodidactDelegate attemptAutodidact)
     : base(doRandomMove, findEvacuationPlace, findVisitPlace, getEntertainmentReason, getEvacuationReason, getShoppingReason, startMoving)
 {
     FindHospital         = findHospital ?? throw new ArgumentNullException(nameof(findHospital));
     StartMovingWithOffer = startMovingWithOffer ?? throw new ArgumentNullException(nameof(startMovingWithOffer));
     AttemptAutodidact    = attemptAutodidact ?? throw new ArgumentNullException(nameof(attemptAutodidact));
 }