示例#1
0
        internal static TrainAIConnection GetConnection()
        {
            try {
                UpdatePathTargetPositionsDelegate updatePathTargetPositionsDelegate =
                    TranspilerUtil.CreateDelegate <UpdatePathTargetPositionsDelegate>(
                        typeof(TrainAI),
                        "UpdatePathTargetPositions",
                        true);
                GetNoiseLevelDelegate getNoiseLevelDelegate =
                    TranspilerUtil.CreateDelegate <GetNoiseLevelDelegate>(
                        typeof(TrainAI),
                        "GetNoiseLevel",
                        true);
                GetMaxSpeedDelegate getMaxSpeedDelegate =
                    TranspilerUtil.CreateDelegate <GetMaxSpeedDelegate>(
                        typeof(TrainAI),
                        "GetMaxSpeed",
                        false);
                CalculateMaxSpeedDelegate calculateMaxSpeedDelegate =
                    TranspilerUtil.CreateDelegate <CalculateMaxSpeedDelegate>(
                        typeof(TrainAI),
                        "CalculateMaxSpeed",
                        false);
                ReverseDelegate reverseDelegate =
                    TranspilerUtil.CreateDelegate <ReverseDelegate>(
                        typeof(TrainAI),
                        "Reverse",
                        false);
                CalculateTargetSpeedTrainDelegate calculateTargetSpeedDelegate =
                    TranspilerUtil.CreateDelegate <CalculateTargetSpeedTrainDelegate>(
                        typeof(TrainAI),
                        "CalculateTargetSpeed",
                        true);
                CheckOverlapDelegate checkOverlapDelegate =
                    TranspilerUtil.CreateDelegate <CheckOverlapDelegate>(
                        typeof(TrainAI),
                        "CheckOverlap",
                        false);
                ForceTrafficLightsDelegate forceTrafficLightsDelegate =
                    TranspilerUtil.CreateDelegate <ForceTrafficLightsDelegate>(
                        typeof(TrainAI),
                        "ForceTrafficLights",
                        true);

                return(new TrainAIConnection(
                           updatePathTargetPositionsDelegate,
                           getNoiseLevelDelegate,
                           getMaxSpeedDelegate,
                           calculateMaxSpeedDelegate,
                           reverseDelegate,
                           calculateTargetSpeedDelegate,
                           checkOverlapDelegate,
                           forceTrafficLightsDelegate));
            } catch (Exception e) {
                Log.Error(e.Message);
                return(null);
            }
        }
示例#2
0
 public static void Prepare()
 {
     UpdatePathTargetPositions = GameConnectionManager.Instance.TrainAIConnection.UpdatePathTargetPositions;
     GetNoiseLevel             = GameConnectionManager.Instance.TrainAIConnection.GetNoiseLevel;
     GetMaxSpeed          = GameConnectionManager.Instance.TrainAIConnection.GetMaxSpeed;
     CalculateMaxSpeed    = GameConnectionManager.Instance.TrainAIConnection.CalculateMaxSpeed;
     Reverse              = GameConnectionManager.Instance.TrainAIConnection.Reverse;
     CalculateTargetSpeed = GameConnectionManager.Instance.TrainAIConnection.CalculateTargetSpeed;
 }
示例#3
0
 internal TrainAIConnection(UpdatePathTargetPositionsDelegate updatePathTargetPositionsDelegate,
                            GetNoiseLevelDelegate getNoiseLevelDelegate,
                            GetMaxSpeedDelegate getMaxSpeedDelegate,
                            CalculateMaxSpeedDelegate calculateMaxSpeedDelegate,
                            ReverseDelegate reverseDelegate,
                            CalculateTargetSpeedTrainDelegate calculateTargetSpeedDelegate,
                            CheckOverlapDelegate checkOverlapDelegate)
 {
     UpdatePathTargetPositions = updatePathTargetPositionsDelegate ?? throw new ArgumentNullException(nameof(updatePathTargetPositionsDelegate));
     GetNoiseLevel             = getNoiseLevelDelegate ?? throw new ArgumentNullException(nameof(getNoiseLevelDelegate));
     GetMaxSpeed          = getMaxSpeedDelegate ?? throw new ArgumentNullException(nameof(getMaxSpeedDelegate));
     CalculateMaxSpeed    = calculateMaxSpeedDelegate ?? throw new ArgumentNullException(nameof(calculateMaxSpeedDelegate));
     Reverse              = reverseDelegate ?? throw new ArgumentNullException(nameof(reverseDelegate));
     CalculateTargetSpeed = calculateTargetSpeedDelegate ?? throw new ArgumentNullException(nameof(calculateTargetSpeedDelegate));
     CheckOverlap         = checkOverlapDelegate ?? throw new ArgumentNullException(nameof(checkOverlapDelegate));
 }