Exemple #1
0
        public void openDepotInfo(ushort buildingID)
        {
            isLoading = true;
            WorldInfoPanel.HideAllWorldInfoPanels();

            m_buildingIdSelecionado          = default(InstanceID);
            m_buildingIdSelecionado.Building = buildingID;

            DepotAI depotAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI;

            if (depotAI == null)
            {
                return;
            }
            depotNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID));

            lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f);
            lineTransportIconTypeLabel.height           = 20;
            lineTransportIconTypeLabel.backgroundSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(depotAI.m_transportInfo.m_transportType);

            Show();
            m_controller.defaultListingLinesPanel.Hide();

            updateCheckboxes();

            isLoading = false;
        }
Exemple #2
0
 public static bool CanAddVehicle(ushort depotID, ref Building depot, TransportInfo transportInfo)
 {
     if (depot.Info == null)
     {
         return(false);
     }
     if (depot.Info.m_buildingAI is DepotAI)
     {
         DepotAI buildingAi = depot.Info.m_buildingAI as DepotAI;
         if (transportInfo.m_vehicleType == buildingAi.m_transportInfo?.m_vehicleType ||
             transportInfo.m_vehicleType == buildingAi.m_secondaryTransportInfo?.m_vehicleType)
         {
             int num = (PlayerBuildingAI.GetProductionRate(100,
                                                           Singleton <EconomyManager> .instance.GetBudget(buildingAi.m_info.m_class)) *
                        buildingAi.m_maxVehicleCount + 99) / 100;
             return(buildingAi.GetVehicleCount(depotID, ref depot) < num);
         }
     }
     if (depot.Info.m_buildingAI is ShelterAI)
     {
         ShelterAI buildingAi = depot.Info.m_buildingAI as ShelterAI;
         int       num        = (PlayerBuildingAI.GetProductionRate(100, Singleton <EconomyManager> .instance.GetBudget(buildingAi.m_info.m_class)) * buildingAi.m_evacuationBusCount + 99) / 100;
         int       count      = 0;
         int       cargo      = 0;
         int       capacity   = 0;
         int       outside    = 0;
         CommonBuildingAIReverseDetour.CalculateOwnVehicles(buildingAi, depotID, ref depot, buildingAi.m_transportInfo.m_vehicleReason, ref count, ref cargo, ref capacity, ref outside);
         return(count < num);
     }
     return(false);
 }
Exemple #3
0
        public void RefreshData()
        {
            Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[this.m_buildingID];

            m_depotName.text = Singleton <BuildingManager> .instance.GetBuildingName(this.m_buildingID, default(InstanceID));

            byte districtID = Singleton <DistrictManager> .instance.GetDistrict(b.m_position);

            string districtName = districtID == 0 ? Locale.Get("TLM_DISTRICT_NONE") : Singleton <DistrictManager> .instance.GetDistrictName(districtID);

            m_districtName.text = districtName;
            if (!(b.Info.GetAI() is ShelterAI))
            {
                m_prefixesServed.relativePosition = new Vector2(340, 0);
                //prefix
                m_prefixesServed.text = TLMLineUtils.getPrefixesServedString(m_buildingID, secondary);
                DepotAI       buildingAI    = b.Info.GetAI() as DepotAI;
                List <string> prefixOptions = TLMUtils.getDepotPrefixesOptions(TransportSystemDefinition.from(secondary ? buildingAI.m_secondaryTransportInfo : buildingAI.m_transportInfo).toConfigIndex());
                prefixOptions.Add(Locale.Get("TLM_REGIONAL"));
                if (m_prefixOptions.items.Length != prefixOptions.Count)
                {
                    m_prefixOptions.items = prefixOptions.ToArray();
                    onChangePrefixSelected(m_prefixOptions.selectedIndex);
                }
            }
            m_isDirty = false;
        }
        public static bool CanAddVehicle(ushort depotID, ref Building depot)
        {
            DepotAI buildingAi = depot.Info.m_buildingAI as DepotAI;
            int     num        = (PlayerBuildingAI.GetProductionRate(100, Singleton <EconomyManager> .instance.GetBudget(buildingAi.m_info.m_class)) * buildingAi.m_maxVehicleCount + 99) / 100;

            return(buildingAi.GetVehicleCount(depotID, ref depot) < num);
        }
Exemple #5
0
        private void updateCheckboxes()
        {
            bool oldIsLoading = isLoading;

            isLoading = true;
            DepotAI       depotAI            = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building].Info.GetAI() as DepotAI;
            List <string> prefixOptions      = TLMUtils.getDepotPrefixesOptions(TLMCW.getConfigIndexForTransportInfo(m_secondary ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo));
            var           prefixesServedList = TLMDepotAI.getPrefixesServedByDepot(m_buildingIdSelecionado.Building, m_secondary);

            for (uint i = 0; i <= 64; i++)
            {
                if (i < prefixOptions.Count)
                {
                    prefixesCheckboxes[i].isVisible = true;
                    prefixesCheckboxes[i].isChecked = prefixesServedList.Contains(i);
                    prefixesCheckboxes[i].text      = prefixOptions[(int)i];
                }
                else
                {
                    prefixesCheckboxes[i].isVisible = false;
                }
            }
            prefixesCheckboxes[65].isChecked = prefixesServedList.Contains(65);
            isLoading = oldIsLoading;
        }
        public static bool IsValidDepot(ref Building building, out ItemClass.SubService subService)
        {
            subService = ItemClass.SubService.None;
            if ((Object)building.Info == (Object)null)
            {
                return(false);
            }
            DepotAI buildingAi = building.Info.m_buildingAI as DepotAI;

            if ((Object)buildingAi == (Object)null || (building.m_flags & Building.Flags.Created) == Building.Flags.None || buildingAi.m_maxVehicleCount == 0)
            {
                return(false);
            }
            subService = building.Info.m_class.m_subService;
            switch (subService)
            {
            case ItemClass.SubService.PublicTransportBus:
            case ItemClass.SubService.PublicTransportMetro:
            case ItemClass.SubService.PublicTransportTrain:
            case ItemClass.SubService.PublicTransportShip:
            case ItemClass.SubService.PublicTransportPlane:
            case ItemClass.SubService.PublicTransportTram:
                return(true);

            default:
                return(false);
            }
        }
Exemple #7
0
        private static Dictionary <ushort, List <uint> > getDictionaryFromConfigString(string s, TransportSystemDefinition tsd)
        {
            Dictionary <ushort, List <uint> > saida = new Dictionary <ushort, List <uint> >();
            var tempArray = s.Split(COMMA.ToCharArray());
            var bm        = Singleton <BuildingManager> .instance;

            foreach (string i in tempArray)
            {
                var kv = i.Split(SEPARATOR.ToCharArray());
                if (kv.Length == 2)
                {
                    ushort key;

                    if (ushort.TryParse(kv[0], out key))
                    {
                        DepotAI buildingAI = bm.m_buildings.m_buffer[key].Info.GetAI() as DepotAI;
                        if (buildingAI != null && tsd.isFromSystem(buildingAI))
                        {
                            saida[key] = new List <uint>();
                            var subtempArray = kv[1].Split(SUBCOMMA.ToCharArray());
                            foreach (string j in subtempArray)
                            {
                                uint value;
                                if (uint.TryParse(j, out value))
                                {
                                    saida[key].Add(value);
                                }
                            }
                        }
                    }
                }
            }
            return(saida);
        }
Exemple #8
0
        private static bool StartTransferPre(
            DepotAI __instance,
            ref ushort buildingID, ref Building data,
            TransferManager.TransferReason reason,
            TransferManager.TransferOffer offer)
        {
            var lineID = offer.TransportLine;
            //TODO: fish boats?
            //TODO: also check reason? - see DepotAI
            var info = TransportManager.instance.m_lines.m_buffer[lineID].Info;

            if (lineID <= 0 || info?.m_class == null || info.m_class.m_service == ItemClass.Service.Disaster)
            {
                return(true); //if it's not a proper transport line, let's not modify the behavior
            }

            var depot = CachedTransportLineData._lineData[lineID].Depot;

            if (!DepotUtil.ValidateDepotAndFindNewIfNeeded(lineID, ref depot, info))
            {
                if (depot == 0)
                {
                    Debug.LogWarning($"IPT2: No proper depot was found for line {lineID}!");
                    CachedTransportLineData.ClearEnqueuedVehicles(lineID);
                    return(false);
                }

                Debug.LogWarning($"IPT2: Invalid or no depot was selected for line {lineID}, resetting to : {depot}!");
                CachedTransportLineData.ClearEnqueuedVehicles(lineID);
                return(false);
            }


            if (depot == buildingID)
            {
                if (SimHelper.SimulationTime < CachedTransportLineData.GetNextSpawnTime(lineID))
                {
                    return(false); //if we need to wait before spawn, let's wait
                }

                if (!DepotUtil.CanAddVehicle(depot, ref BuildingManager.instance.m_buildings.m_buffer[depot], info))
                {
                    CachedTransportLineData.ClearEnqueuedVehicles(lineID);
                    return(false);
                }

                CachedTransportLineData.SetNextSpawnTime(lineID, SimHelper.SimulationTime + OptionsWrapper <Settings> .Options.SpawnTimeInterval);
            }
            else
            {
                Debug.Log("IPT2: Redirecting from " + buildingID + " to " + depot);
                __instance.StartTransfer(depot, ref BuildingManager.instance.m_buildings.m_buffer[depot], reason,
                                         offer);
                return(false);
            }

            return(true);
        }
Exemple #9
0
        public void closeDepotInfo(UIComponent component, UIMouseEventParameter eventParam)
        {
            BuildingInfo basicInfo = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building].Info;
            DepotAI      basicAI   = basicInfo.GetAI() as DepotAI;

            Hide();
            m_controller.defaultListingLinesPanel.Show();
            TLMPublicTransportDetailPanel.instance.SetActiveTab(TLMPublicTransportDetailPanel.tabSystemOrder.Length + Array.IndexOf(TLMPublicTransportDetailPanel.tabSystemOrder, TLMCW.getConfigIndexForTransportInfo(basicAI.m_transportInfo)));
        }
Exemple #10
0
        public void closeDepotInfo(UIComponent component, UIMouseEventParameter eventParam)
        {
            BuildingInfo basicInfo = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building].Info;
            DepotAI      basicAI   = basicInfo.GetAI() as DepotAI;

            Hide();

            TLMPublicTransportManagementPanel.instance?.OpenAt(UiCategoryTab.DepotListing, TransportSystemDefinition.from(basicAI));
        }
Exemple #11
0
        public static bool StartTransfer(DepotAI __instance, ushort buildingID, ref Building data, TransferManager.TransferReason reason, TransferManager.TransferOffer offer)
        {
            if (!managedReasons.Contains(reason) || offer.TransportLine == 0)
            {
                return(true);
            }

            TLMUtils.doLog("START TRANSFER!!!!!!!!");
            TransportInfo m_transportInfo = __instance.m_transportInfo;
            BuildingInfo  m_info          = __instance.m_info;

            if (TLMSingleton.instance != null && TLMSingleton.debugMode)
            {
                TLMUtils.doLog("m_info {0} | m_transportInfo {1} | Line: {2}", m_info.name, m_transportInfo.name, offer.TransportLine);
            }


            if (reason == m_transportInfo.m_vehicleReason || (__instance.m_secondaryTransportInfo != null && reason == __instance.m_secondaryTransportInfo.m_vehicleReason))
            {
                VehicleInfo randomVehicleInfo = null;
                var         tsd = TransportSystemDefinition.from(__instance.m_transportInfo);

                TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[offer.TransportLine];
                TransportInfo.TransportType t = tl.Info.m_transportType;

                if (TLMLineUtils.hasPrefix(ref tl))
                {
                    setRandomBuildingByPrefix(tsd, tl.m_lineNumber / 1000u, ref buildingID);
                }
                else
                {
                    setRandomBuildingByPrefix(tsd, 0, ref buildingID);
                }

                TLMUtils.doLog("randomVehicleInfo");
                randomVehicleInfo = doModelDraw(offer.TransportLine);
                if (randomVehicleInfo == null)
                {
                    randomVehicleInfo = Singleton <VehicleManager> .instance.GetRandomVehicleInfo(ref Singleton <SimulationManager> .instance.m_randomizer, m_info.m_class.m_service, m_info.m_class.m_subService, m_info.m_class.m_level);
                }
                if (randomVehicleInfo != null)
                {
                    TLMUtils.doLog("randomVehicleInfo != null");
                    Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles;
                    __instance.CalculateSpawnPosition(buildingID, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID], ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out Vector3 position, out Vector3 vector);
                    if (Singleton <VehicleManager> .instance.CreateVehicle(out ushort vehicleID, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, reason, false, true))
                    {
                        TLMUtils.doLog("CreatedVehicle!!!");
                        randomVehicleInfo.m_vehicleAI.SetSource(vehicleID, ref vehicles.m_buffer[(int)vehicleID], buildingID);
                        randomVehicleInfo.m_vehicleAI.StartTransfer(vehicleID, ref vehicles.m_buffer[(int)vehicleID], reason, offer);
                    }
                    return(false);
                }
            }
            return(true);
        }
Exemple #12
0
        public static TransportSystemDefinition from(PrefabAI buildingAI)
        {
            DepotAI depotAI = buildingAI as DepotAI;

            if (depotAI == null)
            {
                return(null);
            }
            return(from(depotAI.m_transportInfo));
        }
Exemple #13
0
        public void openDepotInfo(ushort buildingID, bool secondary)
        {
            isLoading = true;
            WorldInfoPanel.HideAllWorldInfoPanels();

            m_buildingIdSelecionado          = default(InstanceID);
            m_buildingIdSelecionado.Building = buildingID;

            DepotAI depotAI = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI;

            if (depotAI == null)
            {
                return;
            }
            depotNameField.text = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID));

            bool hasPrimary   = depotAI.m_transportInfo != null && depotAI.m_maxVehicleCount > 0;
            bool hasSecondary = depotAI.m_secondaryTransportInfo != null && depotAI.m_maxVehicleCount2 > 0;

            if (!hasPrimary && !hasSecondary)
            {
                closeDepotInfo(null, null);
                return;
            }

            m_secondary = !hasPrimary || (secondary && hasSecondary);
            TransportInfo currentTransportInfo = m_secondary ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo;
            TransportInfo otherInfo            = !m_secondary && depotAI.m_secondaryTransportInfo != null ? depotAI.m_secondaryTransportInfo : depotAI.m_transportInfo;

            var tsd = TransportSystemDefinition.from(currentTransportInfo);

            depotInfoPanel.color = Color.Lerp(TLMCW.getColorForTransportType(tsd.toConfigIndex()), Color.white, 0.5f);

            lineTransportIconTypeLabel.relativePosition = new Vector3(10f, 12f);
            lineTransportIconTypeLabel.height           = 20;
            lineTransportIconTypeLabel.normalBgSprite   = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType);
            lineTransportIconTypeLabel.disabledBgSprite = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType);
            lineTransportIconTypeLabel.focusedBgSprite  = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(currentTransportInfo.m_transportType);
            lineTransportIconTypeLabel.hoveredBgSprite  = PublicTransportWorldInfoPanel.GetVehicleTypeIcon(otherInfo.m_transportType);
            if (depotAI.m_secondaryTransportInfo != null)
            {
                lineTransportIconTypeLabel.tooltip = string.Format(Locale.Get("TLM_SEE_OTHER_DEPOT"), TLMConfigWarehouse.getNameForTransportType(TransportSystemDefinition.from(otherInfo).toConfigIndex()));
            }
            else
            {
                lineTransportIconTypeLabel.tooltip = "";
            }

            Show();
            m_controller.defaultListingLinesPanel.Hide();

            updateCheckboxes();

            isLoading = false;
        }
Exemple #14
0
        public static void removeAllPrefixesFromDepot(ushort buildingID)
        {
            var     bm         = Singleton <BuildingManager> .instance;
            DepotAI buildingAI = bm.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI;

            if (buildingAI != null)
            {
                var tsd = TransportSystemDefinition.from(buildingAI.m_info.m_class.m_subService, buildingAI.m_transportInfo.m_vehicleType);
                var dic = getConfigForTransportType(tsd);
                dic[buildingID] = new List <uint>();
                saveConfigForTransportType(tsd, dic);
            }
        }
Exemple #15
0
        public static List <ushort> getAllDepotsFromCity(TransportSystemDefinition tsd)
        {
            List <ushort> saida     = new List <ushort>();
            var           bm        = Singleton <BuildingManager> .instance;
            var           buildings = bm.GetServiceBuildings(ItemClass.Service.PublicTransport);

            foreach (ushort i in buildings)
            {
                DepotAI buildingAI = bm.m_buildings.m_buffer[i].Info.GetAI() as DepotAI;
                if (buildingAI != null && tsd.isFromSystem(buildingAI))
                {
                    saida.Add(i);
                }
            }
            return(saida);
        }
Exemple #16
0
        public static void addAllPrefixesToDepot(ushort buildingID)
        {
            var     bm         = Singleton <BuildingManager> .instance;
            DepotAI buildingAI = bm.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI;

            if (buildingAI != null)
            {
                var tsd = TransportSystemDefinition.from(buildingAI.m_info.m_class.m_subService, buildingAI.m_transportInfo.m_vehicleType);
                var dic = getConfigForTransportType(tsd);
                if (dic.ContainsKey(buildingID))
                {
                    dic.Remove(buildingID);
                }
                saveConfigForTransportType(tsd, dic);
            }
        }
Exemple #17
0
        public static List <ushort> getAllDepotsFromCity()
        {
            List <ushort> saida     = new List <ushort>();
            var           bm        = Singleton <BuildingManager> .instance;
            var           buildings = bm.GetServiceBuildings(ItemClass.Service.PublicTransport);

            foreach (ushort i in buildings)
            {
                DepotAI            buildingAI  = bm.m_buildings.m_buffer[i].Info.GetAI() as DepotAI;
                TransportStationAI buildingAI2 = bm.m_buildings.m_buffer[i].Info.GetAI() as TransportStationAI;
                if (buildingAI != null && (buildingAI2 == null || buildingAI2.m_transportInfo.m_transportType != TransportInfo.TransportType.Bus))
                {
                    saida.Add(i);
                }
            }
            return(saida);
        }
        public static List <uint> getPrefixesServedByDepot(ushort buildingID)
        {
            var     bm         = Singleton <BuildingManager> .instance;
            var     buildings  = bm.GetServiceBuildings(ItemClass.Service.PublicTransport);
            DepotAI buildingAI = bm.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI;

            if (buildingAI != null)
            {
                var tsd = TransportSystemDefinition.from(buildingAI.m_info.m_class.m_subService, buildingAI.m_transportInfo.m_vehicleType);
                var dic = getConfigForTransportType(tsd);
                if (!dic.ContainsKey(buildingID))
                {
                    return(defaultPrefixList);
                }
                return(dic[buildingID]);
            }
            return(null);
        }
Exemple #19
0
        public static void addPrefixToDepot(ushort buildingID, uint prefix)
        {
            var     bm         = Singleton <BuildingManager> .instance;
            DepotAI buildingAI = bm.m_buildings.m_buffer[buildingID].Info.GetAI() as DepotAI;

            if (buildingAI != null)
            {
                var tsd = TransportSystemDefinition.from(buildingAI.m_info.m_class.m_subService, buildingAI.m_transportInfo.m_vehicleType);
                var dic = getConfigForTransportType(tsd);
                if (!dic.ContainsKey(buildingID))
                {
                    dic[buildingID] = new List <uint>(defaultPrefixList);
                }
                dic[buildingID].Add(prefix);

                saveConfigForTransportType(tsd, dic);
            }
        }
Exemple #20
0
 void requestCloseDoors()
 {
     if (m_bInDepot)
     {
         // Based on the prev move of the train. it will request the door that should be closed
         if (m_nPrevMove == UP)
         {
             // Up means F doors need to be closed
             if (r_Depot.isFOpen)
             {
                 r_Depot.closeFDepotDoor();
             }
         }
         else if (m_nPrevMove == DOWN)
         {
             // Down means B doors need to be closed
             if (r_Depot.isBOpen)
             {
                 r_Depot.closeBDepotDoor();
             }
         }
     }
     else if (r_Depot != null)
     {
         if (m_nPrevMove == DOWN)
         {
             // Up means F doors need to be closed
             if (r_Depot.isFOpen)
             {
                 r_Depot.closeFDepotDoor();
             }
         }
         else if (m_nPrevMove == UP)
         {
             // Down means B doors need to be closed
             if (r_Depot.isBOpen)
             {
                 r_Depot.closeBDepotDoor();
             }
         }
         r_Depot = null;
     }
 }
Exemple #21
0
        public static bool StartTransfer(DepotAI __instance, ushort buildingID, TransferManager.TransferReason reason, TransferManager.TransferOffer offer)
        {
            if (!m_managedReasons.Contains(reason) || offer.TransportLine == 0)
            {
                return(true);
            }

            TLMUtils.doLog("START TRANSFER!!!!!!!!");
            TransportInfo m_transportInfo = __instance.m_transportInfo;
            BuildingInfo  m_info          = __instance.m_info;

            TLMUtils.doLog("m_info {0} | m_transportInfo {1} | Line: {2}", m_info.name, m_transportInfo.name, offer.TransportLine);


            if (reason == m_transportInfo.m_vehicleReason || (__instance.m_secondaryTransportInfo != null && reason == __instance.m_secondaryTransportInfo.m_vehicleReason))
            {
                var tsd = TransportSystemDefinition.From(__instance.m_transportInfo);

                Instance.SetRandomBuilding(ref tsd, offer.TransportLine, ref buildingID);

                TLMUtils.doLog("randomVehicleInfo");
                VehicleInfo randomVehicleInfo = DoModelDraw(offer.TransportLine);
                if (randomVehicleInfo == null)
                {
                    randomVehicleInfo = Singleton <VehicleManager> .instance.GetRandomVehicleInfo(ref Singleton <SimulationManager> .instance.m_randomizer, m_info.m_class.m_service, m_info.m_class.m_subService, m_info.m_class.m_level);
                }
                if (randomVehicleInfo != null)
                {
                    TLMUtils.doLog("randomVehicleInfo != null");
                    Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles;
                    __instance.CalculateSpawnPosition(buildingID, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID], ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out Vector3 position, out Vector3 vector);
                    if (Singleton <VehicleManager> .instance.CreateVehicle(out ushort vehicleID, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, reason, false, true))
                    {
                        TLMUtils.doLog("CreatedVehicle!!!");
                        randomVehicleInfo.m_vehicleAI.SetSource(vehicleID, ref vehicles.m_buffer[vehicleID], buildingID);
                        randomVehicleInfo.m_vehicleAI.StartTransfer(vehicleID, ref vehicles.m_buffer[vehicleID], reason, offer);
                    }
                    return(false);
                }
            }
            return(true);
        }
        public void RefreshData()
        {
            if (Singleton <BuildingManager> .exists)
            {
                m_prefixesServedList = TLMDepotAI.getPrefixesServedByDepot(m_buildingID, secondary);
                if (m_prefixesServedList == null)
                {
                    GameObject.Destroy(gameObject); return;
                }
                bool isRowVisible;

                isRowVisible = TLMPublicTransportDetailPanel.instance.isOnCurrentPrefixFilter(m_prefixesServedList);

                if (!isRowVisible)
                {
                    GetComponent <UIComponent>().isVisible = false;
                    return;
                }
                GetComponent <UIComponent>().isVisible = true;
                Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[this.m_buildingID];
                this.m_depotName.text = Singleton <BuildingManager> .instance.GetBuildingName(this.m_buildingID, default(InstanceID));

                byte districtID = Singleton <DistrictManager> .instance.GetDistrict(b.m_position);

                string districtName = districtID == 0 ? Locale.Get("TLM_DISTRICT_NONE") : Singleton <DistrictManager> .instance.GetDistrictName(districtID);

                this.m_districtName.text = districtName;

                //prefix
                this.m_prefixesServed.text = TLMLineUtils.getPrefixesServedAbstract(this.m_buildingID, secondary);
                DepotAI       buildingAI    = b.Info.GetAI() as DepotAI;
                List <string> prefixOptions = TLMUtils.getDepotPrefixesOptions(TLMCW.getConfigIndexForTransportInfo(secondary ? buildingAI.m_secondaryTransportInfo : buildingAI.m_transportInfo));
                prefixOptions.Add(Locale.Get("TLM_REGIONAL"));
                if (this.m_prefixOptions.items.Length != prefixOptions.Count)
                {
                    this.m_prefixOptions.items = prefixOptions.ToArray();
                    onChangePrefixSelected(m_prefixOptions.selectedIndex);
                }
            }
        }
        public static ushort StartTransfer(ushort buildingID, ref Building data, TransferManager.TransferReason reason, TransferManager.TransferOffer offer, string prefabName)
        {
            SimulationManager instance1  = Singleton <SimulationManager> .instance;
            VehicleManager    instance2  = Singleton <VehicleManager> .instance;
            ushort            vehicle    = 0;
            DepotAI           buildingAi = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)buildingID].Info.m_buildingAI as DepotAI;

            if (reason == buildingAi.m_transportInfo.m_vehicleReason)
            {
                VehicleInfo vehicleInfo = VehicleManagerMod.GetVehicleInfo(ref instance1.m_randomizer, buildingAi.m_info.m_class, offer.TransportLine, prefabName);
                if ((Object)vehicleInfo != (Object)null)
                {
                    Vector3 position;
                    Vector3 target;
                    buildingAi.CalculateSpawnPosition(buildingID, ref data, ref instance1.m_randomizer, vehicleInfo, out position, out target);
                    if (instance2.CreateVehicle(out vehicle, ref instance1.m_randomizer, vehicleInfo, position, reason, false, true))
                    {
                        vehicleInfo.m_vehicleAI.SetSource(vehicle, ref instance2.m_vehicles.m_buffer[(int)vehicle], buildingID);
                        vehicleInfo.m_vehicleAI.StartTransfer(vehicle, ref instance2.m_vehicles.m_buffer[(int)vehicle], reason, offer);
                    }
                }
            }
            return(vehicle);
        }
Exemple #24
0
        public void updateBidings()
        {
            BuildingInfo basicInfo = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building].Info;
            DepotAI      basicAI   = basicInfo.GetAI() as DepotAI;

            if (basicAI == null)
            {
                closeDepotInfo(null, null);
                return;
            }

            TransportStationAI stationAI = basicInfo.GetAI() as TransportStationAI;
            HarborAI           harborAI  = basicInfo.GetAI() as HarborAI;


            vehiclesInUseLabel.text = LocaleFormatter.FormatGeneric("TRANSPORT_LINE_VEHICLECOUNT", new object[] { basicAI.GetVehicleCount(m_buildingIdSelecionado.Building, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building]).ToString() });
            if (stationAI != null)
            {
                passengersLastWeek.isVisible = true;
                int passengerCount = stationAI.GetPassengerCount(m_buildingIdSelecionado.Building, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building]);
                passengersLastWeek.text = LocaleFormatter.FormatGeneric("AIINFO_PASSENGERS_SERVICED", new object[] { passengerCount });
            }
            else
            {
                passengersLastWeek.isVisible = false;
            }

            upkeepCost.text = LocaleFormatter.FormatUpkeep(basicAI.GetResourceRate(m_buildingIdSelecionado.Building, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)m_buildingIdSelecionado.Building], EconomyManager.Resource.Maintenance), false);

            uint num         = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building].m_citizenUnits;
            int  num2        = 0;
            int  num3        = 0;
            int  unskill     = 0;
            int  oneSchool   = 0;
            int  twoSchool   = 0;
            int  threeSchool = 0;

            CitizenManager instance = Singleton <CitizenManager> .instance;

            while (num != 0u)
            {
                uint nextUnit = instance.m_units.m_buffer[(int)((UIntPtr)num)].m_nextUnit;
                if ((ushort)(instance.m_units.m_buffer[(int)((UIntPtr)num)].m_flags & CitizenUnit.Flags.Work) != 0)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        uint citizen = instance.m_units.m_buffer[(int)((UIntPtr)num)].GetCitizen(i);
                        if (citizen != 0u && !instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)].Dead && (instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)].m_flags & Citizen.Flags.MovingIn) == Citizen.Flags.None)
                        {
                            num3++;
                            switch (instance.m_citizens.m_buffer[(int)((UIntPtr)citizen)].EducationLevel)
                            {
                            case Citizen.Education.Uneducated:
                                unskill++;
                                break;

                            case Citizen.Education.OneSchool:
                                oneSchool++;
                                break;

                            case Citizen.Education.TwoSchools:
                                twoSchool++;
                                break;

                            case Citizen.Education.ThreeSchools:
                                threeSchool++;
                                break;
                            }
                        }
                    }
                }
                num = nextUnit;
                if (++num2 > 524288)
                {
                    CODebugBase <LogChannel> .Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);

                    break;
                }
            }

            workerChart.SetValues(new int[] { unskill, oneSchool, twoSchool, threeSchool }, new int[] { basicAI.m_workPlaceCount0, basicAI.m_workPlaceCount1, basicAI.m_workPlaceCount2, basicAI.m_workPlaceCount3 });
        }
Exemple #25
0
        public void StartTransfer(ushort buildingID, ref Building data, TransferManager.TransferReason reason, TransferManager.TransferOffer offer)
        {
            if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
            {
                TLMUtils.doLog("START TRANSFER!!!!!!!!");
            }
            DepotAI       ai = ((DepotAI)data.Info.GetAI());
            TransportInfo m_transportInfo = ((DepotAI)data.Info.GetAI()).m_transportInfo;
            BuildingInfo  m_info          = ((DepotAI)data.Info.GetAI()).m_info;

            if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
            {
                TLMUtils.doLog("m_info {0} | m_transportInfo {1} | Line: {2}", m_info.name, m_transportInfo.name, offer.TransportLine);
            }

            if (reason == m_transportInfo.m_vehicleReason)
            {
                VehicleInfo randomVehicleInfo = null;
                var         tsd = TransportSystemDefinition.from(ai.m_transportInfo.m_class.m_subService, ai.m_transportInfo.m_vehicleType);

                if (offer.TransportLine != 0)
                {
                    TransportLine tl = Singleton <TransportManager> .instance.m_lines.m_buffer[offer.TransportLine];
                    TransportInfo.TransportType t = tl.Info.m_transportType;
                    randomVehicleInfo = doModelDraw(tl);
                    if (TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.getConfigIndexForTransportInfo(tl.Info) | TLMConfigWarehouse.ConfigIndex.PREFIX) != (int)ModoNomenclatura.Nenhum)
                    {
                        setRandomBuildingByPrefix(tsd, tl.m_lineNumber / 1000u, ref buildingID);
                    }
                    else
                    {
                        setRandomBuildingByPrefix(tsd, 0, ref buildingID);
                    }
                }
                else
                {
                    setRandomBuildingByPrefix(tsd, 65, ref buildingID);
                }

                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("randomVehicleInfo");
                }
                if (randomVehicleInfo == null)
                {
                    randomVehicleInfo = Singleton <VehicleManager> .instance.GetRandomVehicleInfo(ref Singleton <SimulationManager> .instance.m_randomizer, m_info.m_class.m_service, m_info.m_class.m_subService, m_info.m_class.m_level);
                }
                if (randomVehicleInfo != null)
                {
                    if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                    {
                        TLMUtils.doLog("randomVehicleInfo != null");
                    }
                    Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles;
                    Vector3           position;
                    Vector3           vector;
                    this.CalculateSpawnPosition(buildingID, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID], ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out position, out vector);
                    ushort num;
                    if (Singleton <VehicleManager> .instance.CreateVehicle(out num, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, reason, false, true))
                    {
                        if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                        {
                            TLMUtils.doLog("CreatedVehicle!!!");
                        }
                        randomVehicleInfo.m_vehicleAI.SetSource(num, ref vehicles.m_buffer[(int)num], buildingID);
                        randomVehicleInfo.m_vehicleAI.StartTransfer(num, ref vehicles.m_buffer[(int)num], reason, offer);
                    }
                }
            }
            else
            {
                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("nor StartTransferCommonBuildingAI");
                }
                StartTransferCommonBuildingAI(buildingID, ref data, reason, offer);
            }
        }
 public static bool IsValidDepot(ref Building building,
                                 ref TransportInfo transportInfo,
                                 out ItemClass.Service service,
                                 out ItemClass.SubService subService,
                                 out ItemClass.Level level)
 {
     service    = ItemClass.Service.None;
     subService = ItemClass.SubService.None;
     level      = ItemClass.Level.None;
     if (building.Info == null || (building.m_flags & Building.Flags.Created) == Building.Flags.None)
     {
         return(false);
     }
     if (building.Info.m_buildingAI is DepotAI)
     {
         DepotAI buildingAi = building.Info.m_buildingAI as DepotAI;
         if (transportInfo != null && buildingAi.m_transportInfo.m_vehicleType != transportInfo.m_vehicleType)  //TODO(earalov): allow to serve as depot for secondary vehicle type
         {
             return(false);
         }
         if (transportInfo == null)
         {
             transportInfo = buildingAi.m_transportInfo;
         }
         if (buildingAi.m_maxVehicleCount == 0)
         {
             return(false);
         }
         service    = building.Info.m_class.m_service;
         subService = building.Info.m_class.m_subService;
         level      = building.Info.m_class.m_level;
         if (service == ItemClass.Service.PublicTransport)
         {
             if (level == ItemClass.Level.Level1)
             {
                 switch (subService)
                 {
                 case ItemClass.SubService.PublicTransportBus:
                 case ItemClass.SubService.PublicTransportMetro:
                 case ItemClass.SubService.PublicTransportTrain:
                 case ItemClass.SubService.PublicTransportShip:
                 case ItemClass.SubService.PublicTransportPlane:
                 case ItemClass.SubService.PublicTransportTram:
                 case ItemClass.SubService.PublicTransportMonorail:
                 case ItemClass.SubService.PublicTransportTaxi:
                 case ItemClass.SubService.PublicTransportCableCar:
                     return(true);
                 }
             }
             else if (level == ItemClass.Level.Level2)
             {
                 switch (subService)
                 {
                 case ItemClass.SubService.PublicTransportShip:
                 case ItemClass.SubService.PublicTransportPlane:
                     return(true);
                 }
             }
         }
     }
     else if (building.Info.m_buildingAI is ShelterAI)
     {
         service    = building.Info.m_class.m_service;
         subService = building.Info.m_class.m_subService;
         level      = building.Info.m_class.m_level;
         if (service == ItemClass.Service.Disaster && subService == ItemClass.SubService.None &&
             level == ItemClass.Level.Level4)
         {
             return(true);
         }
     }
     return(false);
 }
        }        //public

        public static int TotalWorkCount(ushort buildingID, Building data, bool checkOnly, bool update)
        {
            int totalWorkCount = 0;

            //For performance
#if FASTRUN
            update = false;
#endif
            if (BuildingData.isBuildingWorkerUpdated[buildingID] && !update)
            {
                totalWorkCount = BuildingData.buildingWorkCount[buildingID];
            }
            else
            {
                if (data.Info.m_buildingAI is LandfillSiteAI)
                {
                    LandfillSiteAI buildingAI = data.Info.m_buildingAI as LandfillSiteAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is ExtractingFacilityAI)
                {
                    ExtractingFacilityAI buildingAI = data.Info.m_buildingAI as ExtractingFacilityAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is ProcessingFacilityAI)
                {
                    ProcessingFacilityAI buildingAI = data.Info.m_buildingAI as ProcessingFacilityAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is PoliceStationAI)
                {
                    PoliceStationAI buildingAI = data.Info.m_buildingAI as PoliceStationAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is FireStationAI)
                {
                    FireStationAI buildingAI = data.Info.m_buildingAI as FireStationAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is HospitalAI)
                {
                    HospitalAI buildingAI = data.Info.m_buildingAI as HospitalAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is CargoStationAI)
                {
                    CargoStationAI buildingAI = data.Info.m_buildingAI as CargoStationAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is TransportStationAI)
                {
                    TransportStationAI buildingAI = data.Info.m_buildingAI as TransportStationAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is CemeteryAI)
                {
                    CemeteryAI buildingAI = data.Info.m_buildingAI as CemeteryAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is MedicalCenterAI)
                {
                    MedicalCenterAI buildingAI = data.Info.m_buildingAI as MedicalCenterAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is MonumentAI)
                {
                    MonumentAI buildingAI = data.Info.m_buildingAI as MonumentAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is DepotAI)
                {
                    DepotAI buildingAI = data.Info.m_buildingAI as DepotAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is HelicopterDepotAI)
                {
                    HelicopterDepotAI buildingAI = data.Info.m_buildingAI as HelicopterDepotAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is MaintenanceDepotAI)
                {
                    MaintenanceDepotAI buildingAI = data.Info.m_buildingAI as MaintenanceDepotAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is FirewatchTowerAI)
                {
                    FirewatchTowerAI buildingAI = data.Info.m_buildingAI as FirewatchTowerAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is DoomsdayVaultAI)
                {
                    DoomsdayVaultAI buildingAI = data.Info.m_buildingAI as DoomsdayVaultAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is DisasterResponseBuildingAI)
                {
                    DisasterResponseBuildingAI buildingAI = data.Info.m_buildingAI as DisasterResponseBuildingAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is HadronColliderAI)
                {
                    HadronColliderAI buildingAI = data.Info.m_buildingAI as HadronColliderAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is SchoolAI)
                {
                    SchoolAI buildingAI = data.Info.m_buildingAI as SchoolAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is PowerPlantAI)
                {
                    PowerPlantAI buildingAI = data.Info.m_buildingAI as PowerPlantAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is SnowDumpAI)
                {
                    SnowDumpAI buildingAI = data.Info.m_buildingAI as SnowDumpAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is WarehouseAI)
                {
                    WarehouseAI buildingAI = data.Info.m_buildingAI as WarehouseAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is WaterFacilityAI)
                {
                    WaterFacilityAI buildingAI = data.Info.m_buildingAI as WaterFacilityAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is SaunaAI)
                {
                    SaunaAI buildingAI = data.Info.m_buildingAI as SaunaAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is PostOfficeAI)
                {
                    PostOfficeAI buildingAI = data.Info.m_buildingAI as PostOfficeAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is RadioMastAI)
                {
                    RadioMastAI buildingAI = data.Info.m_buildingAI as RadioMastAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is SpaceElevatorAI)
                {
                    SpaceElevatorAI buildingAI = data.Info.m_buildingAI as SpaceElevatorAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is SpaceRadarAI)
                {
                    SpaceRadarAI buildingAI = data.Info.m_buildingAI as SpaceRadarAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is MainIndustryBuildingAI)
                {
                    MainIndustryBuildingAI buildingAI = data.Info.m_buildingAI as MainIndustryBuildingAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is AuxiliaryBuildingAI)
                {
                    AuxiliaryBuildingAI buildingAI = data.Info.m_buildingAI as AuxiliaryBuildingAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is ShelterAI)
                {
                    ShelterAI buildingAI = data.Info.m_buildingAI as ShelterAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is HeatingPlantAI)
                {
                    HeatingPlantAI buildingAI = data.Info.m_buildingAI as HeatingPlantAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is MainCampusBuildingAI)
                {
                    MainCampusBuildingAI buildingAI = data.Info.m_buildingAI as MainCampusBuildingAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is MuseumAI)
                {
                    MuseumAI buildingAI = data.Info.m_buildingAI as MuseumAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is UniqueFactoryAI)
                {
                    UniqueFactoryAI buildingAI = data.Info.m_buildingAI as UniqueFactoryAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is UniqueFacultyAI)
                {
                    UniqueFacultyAI buildingAI = data.Info.m_buildingAI as UniqueFacultyAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is VarsitySportsArenaAI)
                {
                    VarsitySportsArenaAI buildingAI = data.Info.m_buildingAI as VarsitySportsArenaAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is LibraryAI)
                {
                    LibraryAI buildingAI = data.Info.m_buildingAI as LibraryAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is FishFarmAI)
                {
                    FishFarmAI buildingAI = data.Info.m_buildingAI as FishFarmAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is FishingHarborAI)
                {
                    FishingHarborAI buildingAI = data.Info.m_buildingAI as FishingHarborAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is EldercareAI)
                {
                    EldercareAI buildingAI = data.Info.m_buildingAI as EldercareAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is ChildcareAI)
                {
                    ChildcareAI buildingAI = data.Info.m_buildingAI as ChildcareAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else if (data.Info.m_buildingAI is MarketAI)
                {
                    MarketAI buildingAI = data.Info.m_buildingAI as MarketAI;
                    totalWorkCount = buildingAI.m_workPlaceCount0 + buildingAI.m_workPlaceCount1 + buildingAI.m_workPlaceCount2 + buildingAI.m_workPlaceCount3;
                }
                else
                {
                    if (!checkOnly)
                    {
                        DebugLog.LogToFileOnly("Error: find unknow building = " + data.Info.m_buildingAI.ToString());
                    }
                }

                BuildingData.isBuildingWorkerUpdated[buildingID] = true;
                BuildingData.buildingWorkCount[buildingID]       = totalWorkCount;
            }
            return(totalWorkCount);
        }
Exemple #28
0
 public void setDepotRef(DepotAI _depot)
 {
     r_Depot = _depot;
 }
Exemple #29
0
 public bool isFromSystem(DepotAI p)
 {
     return((p.m_info.m_class.m_subService == subService && p.m_transportInfo.m_vehicleType == vehicleType && p.m_maxVehicleCount > 0) ||
            (p.m_secondaryTransportInfo != null && p.m_secondaryTransportInfo.m_vehicleType == vehicleType && p.m_maxVehicleCount2 > 0));
 }