Ejemplo n.º 1
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            base.OnLevelLoaded(mode);
            if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame)
            {
                ReplacePathManager();
                CustomCarAI.RedirectCalls(m_redirectionStates);
                CustomPassengerCarAI.RedirectCalls(m_redirectionStates);
                CustomCargoTruckAI.RedirectCalls(m_redirectionStates);

                if (Instance == null)
                {
                    Instance = this;
                }

                UI = ToolsModifierControl.toolController.gameObject.AddComponent <UIBase>();
                TrafficPriority.leftHandDrive = Singleton <SimulationManager> .instance.m_metaData.m_invertTraffic == SimulationMetaData.MetaBool.True;
                RoadCustomizerTool            = AddTool <CSL_Traffic.RoadCustomizerTool>(ToolsModifierControl.toolController);
                ToolsModifierControl.SetTool <DefaultTool>();
            }
        }
 public static void StartGasTransfer(ushort vehicleID, ref Vehicle data, TransferManager.TransferReason material, TransferManager.TransferOffer offer)
 {
     if ((material == (TransferManager.TransferReason) 113) || (material == (TransferManager.TransferReason) 112))
     {
         if (data.Info.m_vehicleAI is CargoTruckAI)
         {
             CargoTruckAI AI = (CargoTruckAI)data.Info.m_vehicleAI;
             MainDataStore.preTranferReason[vehicleID]  = data.m_transferType;
             MainDataStore.TargetGasBuilding[vehicleID] = offer.Building;
             data.m_transferType = 113;
             if (offer.Building == data.m_targetBuilding)
             {
                 DebugLog.LogToFileOnly("Error: Transfer fuel cargotruck do not need fuel");
             }
             if (data.m_flags.IsFlagSet(Vehicle.Flags.Created) && !data.m_flags.IsFlagSet(Vehicle.Flags.Deleted) && !data.m_flags.IsFlagSet(Vehicle.Flags.Arriving) && (data.m_cargoParent == 0) && data.m_flags.IsFlagSet(Vehicle.Flags.Spawned) && !data.m_flags.IsFlagSet(Vehicle.Flags.GoingBack) && data.m_targetBuilding != 0 && !data.m_flags.IsFlagSet(Vehicle.Flags.Parking))
             {
                 if ((Vector3.Distance(data.GetLastFramePosition(), Singleton <BuildingManager> .instance.m_buildings.m_buffer[data.m_targetBuilding].m_position) > CanNotStartGasTransferDistance) && (FindCargoStation(data.GetLastFramePosition(), ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportShip) == 0) && (FindCargoStation(data.GetLastFramePosition(), ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportPlane) == 0) && (FindCargoStation(data.GetLastFramePosition(), ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTrain) == 0))
                 {
                     AI.SetTarget(vehicleID, ref data, offer.Building);
                 }
                 //else
                 //{
                 //DebugLog.LogToFileOnly("Info: Cargo is near target position, do not go to gas station now.");
                 //}
             }
             //else
             //{
             //    DebugLog.LogToFileOnly("Warning: Not a valid CargoTruckAI");
             //}
         }
         else if (data.Info.m_vehicleAI is PassengerCarAI)
         {
             PassengerCarAI AI = (PassengerCarAI)data.Info.m_vehicleAI;
             MainDataStore.preTranferReason[vehicleID] = data.m_transferType;
             if (data.m_targetBuilding == 0)
             {
                 MainDataStore.TargetGasBuilding[vehicleID] = offer.Building;
                 data.m_transferType = 112;
                 if (data.m_flags.IsFlagSet(Vehicle.Flags.Created) && !data.m_flags.IsFlagSet(Vehicle.Flags.Deleted) && !data.m_flags.IsFlagSet(Vehicle.Flags.Arriving) && (data.m_cargoParent == 0) && data.m_flags.IsFlagSet(Vehicle.Flags.Spawned) && !data.m_flags.IsFlagSet(Vehicle.Flags.GoingBack) && !data.m_flags.IsFlagSet(Vehicle.Flags.Parking))
                 {
                     ushort citizen = CustomCarAI.GetDriverInstance(vehicleID, ref data);
                     if (Singleton <CitizenManager> .instance.m_instances.m_buffer[citizen].m_targetBuilding != 0)
                     {
                         if ((Vector3.Distance(data.GetLastFramePosition(), Singleton <BuildingManager> .instance.m_buildings.m_buffer[Singleton <CitizenManager> .instance.m_instances.m_buffer[citizen].m_targetBuilding].m_position) > CanNotStartGasTransferDistance) && (FindCargoStation(data.GetLastFramePosition(), ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportShip) == 0) && (FindCargoStation(data.GetLastFramePosition(), ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportPlane) == 0) && (FindCargoStation(data.GetLastFramePosition(), ItemClass.Service.PublicTransport, ItemClass.SubService.PublicTransportTrain) == 0))
                         {
                             AI.SetTarget(vehicleID, ref data, offer.Building);
                         }
                         //else
                         //{
                         //DebugLog.LogToFileOnly("Info: PassengerCar is near target position, do not go to gas station now.");
                         //}
                     }
                     //else
                     //{
                     //    DebugLog.LogToFileOnly("Warning: No targetBuilding for citizen");
                     //}
                 }
                 //else
                 //{
                 //    DebugLog.LogToFileOnly("Warning: Not a valid PassengerCarAI");
                 //}
             }
             //else
             //{
             //    DebugLog.LogToFileOnly("Error: PassengerCarAI should not have targetBuilding");
             //}
         }
     }
 }