예제 #1
0
        public static void RemoveAllUnwantedVehicles()
        {
            var r = new Randomizer();

            for (ushort vehicleId = 1; vehicleId < Singleton <VehicleManager> .instance.m_vehicles.m_size; vehicleId++)
            {
                if ((Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId].m_flags & Vehicle.Flags.Created) != 0)
                {
                    ref Vehicle vehicle     = ref Singleton <VehicleManager> .instance.m_vehicles.m_buffer[vehicleId];
                    VehicleInfo vehicleInfo = vehicle.Info;
                    if (vehicleInfo != null && !VehicleUtils.IsTrailer(vehicleInfo) && vehicle.m_transportLine == 0 && vehicle.m_sourceBuilding > 0)
                    {
                        var buildingSsd = ServiceSystemDefinition.from(vehicleInfo);
                        if (buildingSsd != null)
                        {
                            if (!ExtensionStaticExtensionMethods.IsModelCompatible(vehicle.m_sourceBuilding, vehicleInfo, ref buildingSsd))
                            {
                                if (vehicleInfo.m_vehicleAI is CarAI)
                                {
                                    var model = buildingSsd.GetAModel(ref r, vehicle.m_sourceBuilding);
                                    VehicleUtils.ReplaceVehicleModel(vehicleId, model);
                                }
                                else
                                {
                                    Singleton <VehicleManager> .instance.ReleaseVehicle(vehicleId);
                                }
                            }
                        }
                    }
                }
            }
        public void openInfo(ushort buildingID)
        {
            WorldInfoPanel.HideAllWorldInfoPanels();

            var ssds = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID].Info);
            var ext  = ssds.First().GetTransportExtension();

            m_buildingIdSelecionado          = default(InstanceID);
            m_ignoreDistrict.isChecked       = ext.GetIgnoreDistrict(buildingID);
            m_buildingIdSelecionado.Building = buildingID;
            buildingNameField.text           = Singleton <BuildingManager> .instance.GetBuildingName(buildingID, default(InstanceID));


            var configIdx = ssds.First().toConfigIndex();


            String bgIcon = SVMConfigWarehouse.getIconServiceSystem(configIdx);
            String fgIcon = SVMConfigWarehouse.getFgIconServiceSystem(configIdx);

            buildingTypeIcon.normalFgSprite = bgIcon;
            buildingTypeIconFg.spriteName   = fgIcon;

            SVMController.instance.CloseSVMPanel();
            Show();
            EventOnBuildingSelChanged?.Invoke(buildingID);
        }
예제 #3
0
        //    public static void RemoveAllUnwantedVehicles() { using var x = new EnumerableActionThread(new Func<ThreadBase, IEnumerator>(RemoveAllUnwantedVehicles)); }
        public static IEnumerator RemoveAllUnwantedVehicles(ThreadBase t)
        {
            ushort num = 0;

            while (num < Singleton <VehicleManager> .instance.m_vehicles.m_size)
            {
                VehicleInfo vehicleInfo = Singleton <VehicleManager> .instance.m_vehicles.m_buffer[num].Info;
                if (vehicleInfo != null && !VehicleUtils.IsTrailer(vehicleInfo) && Singleton <VehicleManager> .instance.m_vehicles.m_buffer[num].m_transportLine == 0 && Singleton <VehicleManager> .instance.m_vehicles.m_buffer[num].m_sourceBuilding > 0)
                {
                    BuildingInfo buildingInfo = Singleton <BuildingManager> .instance.m_buildings.m_buffer[Singleton <VehicleManager> .instance.m_vehicles.m_buffer[num].m_sourceBuilding].Info;
                    var          buildingSsd  = ServiceSystemDefinition.from(buildingInfo, vehicleInfo.m_vehicleType);
                    if (buildingSsd != null)
                    {
                        if (!ExtensionStaticExtensionMethods.IsModelCompatible(Singleton <VehicleManager> .instance.m_vehicles.m_buffer[num].m_sourceBuilding, vehicleInfo, ref buildingSsd))
                        {
                            Singleton <VehicleManager> .instance.ReleaseVehicle(num);
                        }
                    }
                }
                if (num % 256 == 255)
                {
                    yield return(num);
                }
                num++;
            }
            yield break;
        }
예제 #4
0
        public static bool PreGetColor(ref Color __result, ushort vehicleID, ref Vehicle data, InfoManager.InfoMode infoMode)
        {
            if (data.m_transportLine == 0)
            {
                if (infoMode != InfoManager.InfoMode.None)
                {
                    return(true);
                }

                ServiceSystemDefinition def = ServiceSystemDefinition.from(data.Info);
                if (def == default(ServiceSystemDefinition))
                {
                    return(true);
                }
                ushort buildingId = data.m_sourceBuilding;
                if (buildingId == 0)
                {
                    return(true);
                }

                Color c = def.GetTransportExtension().GetEffectiveColorBuilding(buildingId);
                if (c == Color.clear)
                {
                    return(true);
                }
                __result = c;
                return(false);
            }
            return(true);
        }
예제 #5
0
        public static List <ushort> getAllBuildingsFromCity(ServiceSystemDefinition ssd)
        {
            List <ushort>     saida = new List <ushort>();
            var               bm    = Singleton <BuildingManager> .instance;
            FastList <ushort> buildings;

            if (ssd.outsideConnection)
            {
                buildings = bm.GetOutsideConnections();
            }
            else
            {
                buildings = bm.GetServiceBuildings(ssd.service);
            }

            SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2})", ssd, buildings.ToArray(), buildings.m_size);

            foreach (ushort i in buildings)
            {
                if (ssd.isFromSystem(bm.m_buildings.m_buffer[i].Info))
                {
                    saida.Add(i);
                }
            }
            SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2}); saida.sz = {3}", ssd, buildings.ToArray(), buildings.m_size, saida.Count);
            return(saida);
        }
 protected virtual bool ProcessOffer(ushort buildingID, Building data, TransferManager.TransferReason material, TransferManager.TransferOffer offer, TransferManager.TransferReason trTarget, Tuple <VehicleInfo.VehicleType, bool, bool> tup, U instance)
 {
     if (material == trTarget)
     {
         ServiceSystemDefinition def = ServiceSystemDefinition.from(instance.m_info, tup.First);
         if (def == null)
         {
             SVMUtils.doLog("SSD Não definido para: {0} {1} {2} {3}", instance.m_info.m_class.m_service, instance.m_info.m_class.m_subService, instance.m_info.m_class.m_level, tup.First);
             return(false);
         }
         SVMUtils.doLog("[{1}] SSD = {0}", def, material);
         VehicleInfo randomVehicleInfo = ServiceSystemDefinition.availableDefinitions[def].GetAModel(buildingID);
         SVMUtils.doLog("[{1}] Veh = {0}", randomVehicleInfo?.ToString() ?? "<NULL>", material);
         if (randomVehicleInfo != null)
         {
             Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles;
             instance.CalculateSpawnPosition(buildingID, ref data, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out Vector3 position, out Vector3 vector2);
             if (Singleton <VehicleManager> .instance.CreateVehicle(out ushort num, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, material, tup.Second, tup.Third))
             {
                 randomVehicleInfo.m_vehicleAI.SetSource(num, ref vehicles.m_buffer[(int)num], buildingID);
                 randomVehicleInfo.m_vehicleAI.StartTransfer(num, ref vehicles.m_buffer[(int)num], material, offer);
                 return(true);
             }
         }
     }
     return(false);
 }
예제 #7
0
        public void Hide()
        {
            m_buildingInfoPanel.Hide();
            ServiceSystemDefinition ssd = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingIdSel.Building].Info).FirstOrDefault();

            VMCTabPanel.Instance.OpenAt(ref ssd);
        }
        private void updateBuildingEditShortcutButton(UIPanel parent)
        {
            if (parent != null)
            {
                UIButton buildingEditShortcut = parent.Find <UIButton>("SVMBuildingShortcut");
                if (!buildingEditShortcut)
                {
                    buildingEditShortcut = initBuildingEditOnWorldInfoPanel(parent);
                }
                var prop = typeof(WorldInfoPanel).GetField("m_InstanceID", System.Reflection.BindingFlags.NonPublic
                                                           | System.Reflection.BindingFlags.Instance);
                ushort buildingId = ((InstanceID)(prop.GetValue(parent.gameObject.GetComponent <WorldInfoPanel>()))).Building;
                var    ssds       = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info);

                byte count = 0;
                foreach (var ssd in ssds)
                {
                    var maxCount = SVMBuildingUtils.GetMaxVehiclesBuilding(buildingId, ssd.vehicleType, ssd.level);
                    if (maxCount > 0)
                    {
                        count++;
                        break;
                    }
                }
                buildingEditShortcut.isVisible = count > 0;
            }
        }
예제 #9
0
 internal void OpenAt(ServiceSystemDefinition ssd)
 {
     m_StripMain.selectedIndex = 0;
     if (ssd != null)
     {
         m_StripBuilings.selectedIndex = m_StripBuilings.Find <UIComponent>(ssd.GetDefType().Name)?.zOrder ?? 0;
     }
     SVMController.instance.OpenSVMPanel();
 }
예제 #10
0
 internal void OpenAt(ref ServiceSystemDefinition ssd)
 {
     //   m_StripMain.selectedIndex = 0;
     if (ssd != null)
     {
         var catIdx = ssd.Category;
         m_StripDistricts.selectedIndex = (int)catIdx;
         m_StripDistrictsStrips[catIdx].selectedIndex = m_StripDistrictsStrips[catIdx].Find <UIComponent>(ssd.GetDefType().Name)?.zOrder ?? 0;
     }
     VehiclesMasterControlMod.Controller.OpenVMCPanel();
 }
        private void PopulateCheckboxes()
        {
            foreach (string i in m_checkboxes.Keys)
            {
                UnityEngine.Object.Destroy(m_checkboxes[i].gameObject);
            }
            ServiceSystemDefinition ssd = SingletonLite <T> .instance.GetSSD();

            m_defaultAssets = ssd.GetBuildingExtension().GetAllBasicAssets();
            m_checkboxes    = new Dictionary <string, UICheckBox>();

            LogUtils.DoLog("m_defaultAssets Size = {0} ({1})", m_defaultAssets?.Count, string.Join(",", m_defaultAssets.Keys?.ToArray() ?? new string[0]));
            foreach (string i in m_defaultAssets.Keys)
            {
                var checkbox = (UICheckBox)m_uiHelper.AddCheckbox(m_defaultAssets[i], false, (x) =>
                {
                    IVMCBuildingExtension ext = SingletonLite <T> .instance.GetSSD().GetBuildingExtension();

                    ushort buildingId = m_buildingInfo.buildingIdSel.Building;
                    if (m_isLoading)
                    {
                        return;
                    }

                    if (x)
                    {
                        if (ext.GetIgnoreDistrict(buildingId))
                        {
                            ext.AddAsset(buildingId, i);
                        }
                        else
                        {
                            SingletonLite <T> .instance.GetSSD().GetDistrictExtension().AddAsset(BuildingUtils.GetBuildingDistrict(buildingId), i);
                        }
                    }
                    else
                    {
                        if (ext.GetIgnoreDistrict(buildingId))
                        {
                            ext.RemoveAsset(buildingId, i);
                        }
                        else
                        {
                            SingletonLite <T> .instance.GetSSD().GetDistrictExtension().RemoveAsset(BuildingUtils.GetBuildingDistrict(buildingId), i);
                        }
                    }
                });
                CreateModelCheckBox(i, checkbox);
                checkbox.label.tooltip              = checkbox.label.text;
                checkbox.label.textScale            = 0.9f;
                checkbox.label.transform.localScale = new Vector3(Math.Min((m_mainPanel.width - 50) / checkbox.label.width, 1), 1);
                m_checkboxes[i] = checkbox;
            }
        }
예제 #12
0
 internal void OpenAt(ServiceSystemDefinition ssd)
 {
     m_StripMain.selectedIndex = 0;
     if (ssd != null)
     {
         var catIdx = SVMConfigWarehouse.getCategory(ssd.toConfigIndex());
         m_StripBuilings.selectedIndex = (int)catIdx;
         m_StripBuilingsStrips[catIdx].selectedIndex = m_StripBuilingsStrips[catIdx].Find <UIComponent>(ssd.GetDefType().Name)?.zOrder ?? 0;
     }
     ServiceVehiclesManagerMod.instance.controller.OpenSVMPanel();
 }
        private static bool CreateIncomingVehicle(bool __result, TransportStationAI __instance, ushort buildingID, ref Building buildingData, ushort startStop, int gateIndex)
        {
            if (__instance.m_transportLineInfo != null && (ushort)FindConnectionVehicle.Invoke(__instance, new object[] { buildingID, buildingData, startStop, 3000f }) == 0)
            {
                SVMUtils.doLog("START CreateIncomingVehicle: {0} , {1}", typeof(TransportStationAI), __instance.name);
                ServiceSystemDefinition def = ServiceSystemDefinition.from(buildingData.Info).FirstOrDefault();
                if (def == null)
                {
                    SVMUtils.doLog("SSD Não definido para: {0} {1} {2}", buildingData.Info.m_class.m_service, buildingData.Info.m_class.m_subService, buildingData.Info.m_class.m_level);
                    return(false);
                }
                SVMUtils.doLog("[{1}] SSD = {0}", def, "CreateIncomingVehicle");
                VehicleInfo randomVehicleInfo = ServiceSystemDefinition.availableDefinitions[def].GetAModel(buildingID);
                SVMUtils.doLog("[{1}] Veh = {0}", randomVehicleInfo?.ToString() ?? "<NULL>", "CreateIncomingVehicle");

                if (randomVehicleInfo != null)
                {
                    ushort num = (ushort)FindConnectionBuilding.Invoke(__instance, new object[] { startStop });
                    if (num != 0)
                    {
                        Array16 <Vehicle> vehicles   = Singleton <VehicleManager> .instance.m_vehicles;
                        BuildingInfo      info       = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)num].Info;
                        Randomizer        randomizer = default(Randomizer);
                        randomizer.seed = (ulong)((long)gateIndex);
                        Vector3 vector;
                        Vector3 vector2;
                        info.m_buildingAI.CalculateSpawnPosition(num, ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)num], ref randomizer, randomVehicleInfo, out vector, out vector2);
                        TransportInfo transportInfo = __instance.m_transportInfo;
                        if (__instance.m_secondaryTransportInfo != null && __instance.m_secondaryTransportInfo.m_class.m_subService == __instance.m_transportLineInfo.m_class.m_subService)
                        {
                            transportInfo = __instance.m_secondaryTransportInfo;
                        }
                        if (randomVehicleInfo.m_vehicleAI.CanSpawnAt(vector) && Singleton <VehicleManager> .instance.CreateVehicle(out ushort num2, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, vector, transportInfo.m_vehicleReason, true, false))
                        {
                            vehicles.m_buffer[(int)num2].m_gateIndex = (byte)gateIndex;
                            Vehicle[] expr_172_cp_0 = vehicles.m_buffer;
                            ushort    expr_172_cp_1 = num2;
                            expr_172_cp_0[(int)expr_172_cp_1].m_flags = (expr_172_cp_0[(int)expr_172_cp_1].m_flags | (Vehicle.Flags.Importing | Vehicle.Flags.Exporting));
                            randomVehicleInfo.m_vehicleAI.SetSource(num2, ref vehicles.m_buffer[(int)num2], num);
                            randomVehicleInfo.m_vehicleAI.SetSource(num2, ref vehicles.m_buffer[(int)num2], buildingID);
                            randomVehicleInfo.m_vehicleAI.SetTarget(num2, ref vehicles.m_buffer[(int)num2], startStop);
                            SVMUtils.doLog("END CreateIncomingVehicle: {0} , {1}", typeof(TransportStationAI), __instance.name);
                            __result = true;
                            return(false);
                        }
                    }
                }
            }
            SVMUtils.doLog("END2 CreateIncomingVehicle: {0} , {1}", typeof(TransportStationAI), __instance.name);
            __result = false;
            return(false);
        }
예제 #14
0
        public static List <ushort> getAllBuildingsFromCity(ServiceSystemDefinition ssd, int?districtId = null, bool strict = false, bool mustAllowSpawn = false)
        {
            List <ushort>     saida = new List <ushort>();
            var               bm    = Singleton <BuildingManager> .instance;
            FastList <ushort> buildings;
            var               ext = ssd.GetTransportExtension();

            if (ssd.outsideConnection)
            {
                buildings = bm.GetOutsideConnections();
            }
            else
            {
                buildings = bm.GetServiceBuildings(ssd.service);
            }

            SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2})", ssd, buildings.ToArray(), buildings.m_size);

            foreach (ushort i in buildings)
            {
                if (ssd.isFromSystem(bm.m_buildings.m_buffer[i].Info))
                {
                    if (districtId != null && ext.GetAllowDistrictServiceRestrictions())
                    {
                        var buildingDistrict = DistrictManager.instance.GetDistrict(bm.m_buildings.m_buffer[i].m_position);
                        if (districtId != buildingDistrict && (strict || !ext.GetAllowGoOutsideEffective(buildingDistrict)))
                        {
                            continue;
                        }
                    }
                    if (mustAllowSpawn)
                    {
                        int max      = GetMaxVehiclesBuilding(i, ssd.vehicleType, ssd.level);
                        int count    = 0;
                        int cargo    = 0;
                        int capacity = 0;
                        int inbound  = 0;
                        int outbound = 0;
                        SVMBuildingUtils.CalculateOwnVehicles(i, ref bm.m_buildings.m_buffer[i], SVMBuildingAIOverrideUtils.getBuildingOverrideExtensionStrict(bm.m_buildings.m_buffer[i].Info).GetManagedReasons(bm.m_buildings.m_buffer[i].Info).Where(x => x.Value.vehicleLevel == null).Select(x => x.Key), ref count, ref cargo, ref capacity, ref inbound, ref outbound);
                        if (count >= max)
                        {
                            continue;
                        }
                    }
                    saida.Add(i);
                }
            }
            SVMUtils.doLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2}); saida.sz = {3}", ssd, buildings.ToArray(), buildings.m_size, saida.Count);
            return(saida);
        }
        public static VehicleInfo GetRandomVehicleInfoWithVehicle(VehicleManager vm, ref Randomizer randomizer, ItemClass.Service service, ItemClass.SubService subService, ItemClass.Level level, VehicleInfo.VehicleType vehicleType, ushort buildingId, ref Building building)
        {
            // A
            var ssds = ServiceSystemDefinition.from(service, subService, level, vehicleType, building.Info.m_buildingAI is OutsideConnectionAI);

            if (ssds != default)
            {
                var vehicleInfo = ssds.GetAModel(ref randomizer, buildingId);
                if (vehicleInfo != default)
                {
                    return(vehicleInfo);
                }
            }
            return(VehicleManager.instance.GetRandomVehicleInfo(ref randomizer, service, subService, level, vehicleType));
        }
        public override void AwakeBody()
        {
            instance = this;
            ServiceSystemDefinition def = Singleton <V> .instance.GetSSD();

            var from  = typeof(BuildingManager).GetMethod("CreateBuilding", allFlags);
            var to    = typeof(SVMTabControllerBuildingHooks <T, V>).GetMethod("AfterCreateBuilding", allFlags);
            var from2 = typeof(BuildingManager).GetMethod("ReleaseBuilding", allFlags);
            var to2   = typeof(SVMTabControllerBuildingHooks <T, V>).GetMethod("AfterRemoveBuilding", allFlags);

            SVMUtils.doLog("Loading After Hooks: {0} ({1}=>{2})", typeof(BuildingManager), from, to);
            SVMUtils.doLog("Loading After Hooks: {0} ({1}=>{2})", typeof(BuildingManager), from2, to2);
            AddRedirect(from, null, to);
            AddRedirect(from2, null, to2);
        }
예제 #17
0
        internal static List <string> LoadBasicAssets(ServiceSystemDefinition definition)
        {
            List <string> basicAssetsList = new List <string>();

            for (uint num = 0u; (ulong)num < (ulong)((long)PrefabCollection <VehicleInfo> .PrefabCount()); num += 1u)
            {
                VehicleInfo prefab = PrefabCollection <VehicleInfo> .GetPrefab(num);

                if (!(prefab == null) && definition.isFromSystem(prefab) && !IsTrailer(prefab))
                {
                    basicAssetsList.Add(prefab.name);
                }
            }
            return(basicAssetsList);
        }
예제 #18
0
        public static List <ushort> getAllBuildingsFromCity(ref ServiceSystemDefinition ssd, int?districtId = null, bool strict = false, bool mustAllowSpawn = false)
        {
            var                   saida = new List <ushort>();
            BuildingManager       bm    = Singleton <BuildingManager> .instance;
            FastList <ushort>     buildings;
            IVMCDistrictExtension ext = ssd.GetDistrictExtension();

            if (ssd.outsideConnection)
            {
                buildings = bm.GetOutsideConnections();
            }
            else
            {
                buildings = bm.GetServiceBuildings(ssd.service);
            }

            LogUtils.DoLog("getAllBuildingsFromCity ({0}) buildings = {1} (s={2})", ssd, buildings.ToArray(), buildings.m_size);

            foreach (ushort i in buildings)
            {
                ref Building building = ref bm.m_buildings.m_buffer[i];
                if (ssd.isFromSystem(building.Info))
                {
                    if (districtId != null && ssd.AllowRestrictions)
                    {
                        byte buildingDistrict = DistrictManager.instance.GetDistrict(bm.m_buildings.m_buffer[i].m_position);
                        if (districtId != buildingDistrict && (strict || (!ext.GetAllowServeOtherDistricts(buildingDistrict) ?? VehiclesMasterControlMod.allowServeOtherDistrictsAsDefault)))
                        {
                            continue;
                        }
                    }
                    if (mustAllowSpawn)
                    {
                        int max      = GetMaxVehiclesBuilding(ref building, ssd.vehicleType, ssd.level);
                        int count    = 0;
                        int cargo    = 0;
                        int capacity = 0;
                        int inbound  = 0;
                        int outbound = 0;
                        VMCBuildingUtils.CalculateOwnVehicles(ref bm.m_buildings.m_buffer[i], ref count, ref cargo, ref capacity, ref inbound, ref outbound);
                        if (count >= max)
                        {
                            continue;
                        }
                    }
                    saida.Add(i);
                }
            }
        public void setTabContent <T>(SVMTabControllerDistrictList <T> tabContent) where T : SVMSysDef <T>
        {
            if (m_system == null)
            {
                m_system = Singleton <T> .instance.GetSSD();

                m_parent = tabContent.mainPanel;
                CreateWindow();
                tabContent.eventOnDistrictSelectionChanged += onDistrictChanged;
                tabContent.eventOnColorDistrictChanged     += (color) =>
                {
                    SVMUtils.doLog("eventOnColorDistrictChanged");
                    m_lastColor = color;
                };
            }
        }
예제 #20
0
 private void CreateIgnoreDistrictOption()
 {
     m_ignoreDistrict = m_uiHelper.AddCheckboxLocale("K45_VMC_IGNORE_DISTRICT_CONFIG", false);
     m_ignoreDistrict.relativePosition   = new Vector3(5f, 150f);
     m_ignoreDistrict.eventCheckChanged += delegate(UIComponent comp, bool value)
     {
         if (Singleton <BuildingManager> .exists && m_buildingIdSelecionado.Building != 0)
         {
             IEnumerable <ServiceSystemDefinition> ssds = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building].Info);
             foreach (ServiceSystemDefinition ssd in ssds)
             {
                 ssd.GetBuildingExtension().SetIgnoreDistrict(m_buildingIdSelecionado.Building, value);
             }
             EventOnBuildingSelChanged?.Invoke(m_buildingIdSelecionado.Building);
         }
     };
     m_ignoreDistrict.label.textScale = 0.9f;
 }
        private void Awake()
        {
            CreateMainPanel();

            CreateScrollPanel();

            SetPreviewWindow();

            BindParentChanges();

            CreateRemoveUndesiredModelsButton();

            PopulateCheckboxes();

            ServiceSystemDefinition ssd = SingletonLite <T> .instance.GetSSD();

            bool allowColorChange = ssd.AllowColorChanging();

            if (allowColorChange)
            {
                KlyteMonoUtils.CreateUIElement(out UILabel lbl, m_mainPanel.transform, "DistrictColorLabel", new Vector4(5, m_mainPanel.height - 30, 120, 40));
                KlyteMonoUtils.LimitWidth(lbl, 120);
                lbl.autoSize = true;
                lbl.localeID = "K45_VMC_COLOR_LABEL";

                m_color = KlyteMonoUtils.CreateColorField(m_mainPanel);
                m_color.eventSelectedColorChanged += onChangeColor;

                KlyteMonoUtils.CreateUIElement(out UIButton resetColor, m_mainPanel.transform, "DistrictColorReset", new Vector4(m_mainPanel.width - 110, m_mainPanel.height - 35, 0, 0));
                KlyteMonoUtils.InitButton(resetColor, false, "ButtonMenu");
                KlyteMonoUtils.LimitWidth(resetColor, 100);
                resetColor.textPadding = new RectOffset(5, 5, 5, 2);
                resetColor.autoSize    = true;
                resetColor.localeID    = "K45_VMC_RESET_COLOR";
                resetColor.eventClick += onResetColor;
            }
            else
            {
                m_mainPanel.height -= 40;
            }
        }
        private void onChangeColor(UIComponent component, Color value)
        {
            if (m_isLoading)
            {
                return;
            }

            LogUtils.DoLog("onChangeColor");
            ServiceSystemDefinition ssd = SingletonLite <T> .instance.GetSSD();

            IVMCBuildingExtension ext = ssd.GetBuildingExtension();
            ushort buildingId         = m_buildingInfo.buildingIdSel.Building;

            if (ext.GetIgnoreDistrict(buildingId))
            {
                ext.SetColor(buildingId, value);
            }
            else
            {
                ssd.GetDistrictExtension().SetColor(BuildingUtils.GetBuildingDistrict(buildingId), value);
            }
        }
예제 #23
0
        private void Awake()
        {
            VMCTabPanel.eventOnDistrictSelectionChanged += onDistrictChanged;


            mainPanel            = GetComponentInChildren <UIScrollablePanel>();
            mainPanel.autoLayout = false;
            m_uiHelper           = new UIHelperExtension(mainPanel);

            KlyteMonoUtils.CreateUIElement(out UILabel lbl, mainPanel.transform, "DistrictColorLabel", new Vector4(5, 5, 250, 40));

            allowColorChange = SingletonLite <T> .instance.GetSSD().AllowColorChanging();

            if (allowColorChange)
            {
                KlyteMonoUtils.LimitWidth(lbl, 250);
                lbl.autoSize = true;
                lbl.localeID = "K45_VMC_DISTRICT_COLOR_LABEL";

                m_districtColor = KlyteMonoUtils.CreateColorField(mainPanel);
                m_districtColor.eventSelectedColorChanged += onChangeDistrictColor;

                KlyteMonoUtils.CreateUIElement(out UIButton resetColor, mainPanel.transform, "DistrictColorReset", new Vector4(290, 0, 0, 0));
                KlyteMonoUtils.InitButton(resetColor, false, "ButtonMenu");
                KlyteMonoUtils.LimitWidth(resetColor, 200);
                resetColor.textPadding = new RectOffset(5, 5, 5, 2);
                resetColor.autoSize    = true;
                resetColor.localeID    = "K45_VMC_RESET_COLOR";
                resetColor.eventClick += onResetColor;
            }
            ServiceSystemDefinition ssd = SingletonLite <T> .instance.GetSSD();

            IVMCDistrictExtension extension = SingletonLite <T> .instance.GetExtensionDistrict();

            KlyteMonoUtils.CreateElement(out m_assetSelectorWindow, mainPanel.transform);
            m_assetSelectorWindow.setTabContent(this);
        }
예제 #24
0
        public void RefreshLines()
        {
            if (Singleton <BuildingManager> .exists)
            {
                int count = 0;
                ServiceSystemDefinition ssd = SingletonLite <T> .instance.GetSSD();

                System.Collections.Generic.List <ushort> buildingList = VMCBuildingUtils.getAllBuildingsFromCity(ref ssd);

                LogUtils.DoLog("{0} buildingList = [{1}] (s={2})", GetType(), string.Join(",", buildingList.Select(x => x.ToString()).ToArray()), buildingList.Count);
                foreach (ushort buildingID in buildingList)
                {
                    ref Building b          = ref Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingID];
                    int          maxVehicle = Mathf.CeilToInt(VMCBuildingUtils.GetMaxVehiclesBuilding(ref b, ssd.vehicleType, ssd.level) * VMCBuildingUtils.GetProductionRate(ref b) / 100f);
                    if (maxVehicle > 0)
                    {
                        AddToList(buildingID, ref count);
                    }
                }
                RemoveExtraLines(count);
                LogUtils.DoLog("{0} final count = {1}", GetType(), count);

                m_LinesUpdated = true;
            }
        private void OnBuildingChange(ushort buildingId)
        {
            SVMUtils.doLog("EventOnBuildingSelChanged");
            m_isLoading = true;
            IEnumerable <ServiceSystemDefinition> ssds = ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info);

            if (!ssds.Contains(Singleton <T> .instance.GetSSD()))
            {
                m_mainPanel.isVisible = false;
                return;
            }
            m_mainPanel.isVisible = true;
            var ssd = Singleton <T> .instance.GetSSD();

            var  ext            = ssd.GetTransportExtension();
            bool isCustomConfig = ext.GetIgnoreDistrict(buildingId);

            SVMUtils.doLog("ssd = {0}", ssd);

            List <string> selectedAssets;
            Color         selectedColor;

            if (isCustomConfig)
            {
                selectedAssets = ext.GetAssetListBuilding(buildingId);
                selectedColor  = ext.GetColorBuilding(buildingId);
            }
            else
            {
                var districtId = SVMUtils.GetBuildingDistrict(buildingId);
                selectedAssets = ext.GetAssetListDistrict(districtId);
                selectedColor  = ext.GetColorDistrict(districtId);
            }
            foreach (var i in m_checkboxes.Keys)
            {
                m_checkboxes[i].isChecked = selectedAssets.Contains(i);
            }
            if (m_color != null)
            {
                m_color.selectedColor = selectedColor;
            }

            if (isCustomConfig)
            {
                m_title.text = string.Format(Locale.Get("SVM_ASSET_SELECT_WINDOW_TITLE"), Singleton <BuildingManager> .instance.GetBuildingName(buildingId, default(InstanceID)), SVMConfigWarehouse.getNameForServiceSystem(ssd.toConfigIndex()));
            }
            else
            {
                var districtId = SVMUtils.GetBuildingDistrict(buildingId);
                if (districtId > 0)
                {
                    m_title.text = string.Format(Locale.Get("SVM_ASSET_SELECT_WINDOW_TITLE_DISTRICT"), Singleton <DistrictManager> .instance.GetDistrictName(SVMUtils.GetBuildingDistrict(buildingId)), SVMConfigWarehouse.getNameForServiceSystem(ssd.toConfigIndex()));
                }
                else
                {
                    m_title.text = string.Format(Locale.Get("SVM_ASSET_SELECT_WINDOW_TITLE_CITY"), SVMConfigWarehouse.getNameForServiceSystem(ssd.toConfigIndex()));
                }
            }

            m_isLoading = false;
            m_previewPanel.isVisible = false;
        }
 internal static ConfigIndex getConfigServiceSystemForDefinition(ServiceSystemDefinition serviceSystemDefinition)
 {
     if (serviceSystemDefinition == ServiceSystemDefinition.OUT_TRAIN)
     {
         return(ConfigIndex.OUT_TRAIN);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.OUT_PLANE)
     {
         return(ConfigIndex.OUT_PLANE);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.OUT_SHIP)
     {
         return(ConfigIndex.OUT_SHIP);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.OUT_ROAD)
     {
         return(ConfigIndex.OUT_ROAD);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.DISASTER_CAR)
     {
         return(ConfigIndex.DISASTER_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.DISASTER_HELICOPTER)
     {
         return(ConfigIndex.DISASTER_HELICOPTER);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.FIRE_CAR)
     {
         return(ConfigIndex.FIRE_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.FIRE_HELICOPTER)
     {
         return(ConfigIndex.FIRE_HELICOPTER);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.GARBAGE_CAR)
     {
         return(ConfigIndex.GARBAGE_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.GARBBIO_CAR)
     {
         return(ConfigIndex.GARBBIO_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.HEALTHCARE_CAR)
     {
         return(ConfigIndex.HEALTHCARE_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.HEALTHCARE_HELICOPTER)
     {
         return(ConfigIndex.HEALTHCARE_HELICOPTER);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.DEATHCARE_CAR)
     {
         return(ConfigIndex.DEATHCARE_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.POLICE_CAR)
     {
         return(ConfigIndex.POLICE_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.POLICE_HELICOPTER)
     {
         return(ConfigIndex.POLICE_HELICOPTER);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.ROAD_CAR)
     {
         return(ConfigIndex.ROAD_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.WATER_CAR)
     {
         return(ConfigIndex.WATER_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.PRISION_CAR)
     {
         return(ConfigIndex.PRISION_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.TAXI_CAR)
     {
         return(ConfigIndex.TAXI_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.CABLECAR_CABLECAR)
     {
         return(ConfigIndex.CABLECAR_CABLECAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.SNOW_CAR)
     {
         return(ConfigIndex.SNOW_CAR);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.REG_TRAIN)
     {
         return(ConfigIndex.REG_TRAIN);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.REG_PLANE)
     {
         return(ConfigIndex.REG_PLANE);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.REG_SHIP)
     {
         return(ConfigIndex.REG_SHIP);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.CARG_TRAIN)
     {
         return(ConfigIndex.CARG_TRAIN);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.CARG_SHIP)
     {
         return(ConfigIndex.CARG_SHIP);
     }
     if (serviceSystemDefinition == ServiceSystemDefinition.BEAU_CAR)
     {
         return(ConfigIndex.BEAU_CAR);
     }
     return(ConfigIndex.NIL);
 }
        protected virtual bool ProcessOffer(ushort buildingID, ref Building data, TransferManager.TransferReason material, TransferManager.TransferOffer offer, TransferManager.TransferReason trTarget, StartTransferCallStructure tup, U instance)
        {
            if (material == trTarget)
            {
                ServiceSystemDefinition def = ServiceSystemDefinition.from(instance.m_info, tup.vehicleType);
                if (def == null)
                {
                    SVMUtils.doLog("SSD Não definido para: {0} {1} {2} {3}", instance.m_info.m_class.m_service, instance.m_info.m_class.m_subService, tup.vehicleLevel ?? instance.m_info.m_class.m_level, tup.vehicleType);
                    return(false);
                }

                #region District Check
                var ext = def.GetTransportExtension();

                if (ext.GetAllowDistrictServiceRestrictions())
                {
                    var buildingDistrict = DistrictManager.instance.GetDistrict(data.m_position);
                    var offerDistrict    = DistrictManager.instance.GetDistrict(offer.Position);
                    if (buildingDistrict != offerDistrict)
                    {
                        if (ServiceVehiclesManagerMod.debugMode)
                        {
                            SVMUtils.doLog($"Building serving different district: building {data.Info} ({buildingID} - districtId {buildingDistrict} {DistrictManager.instance.GetDistrictName(buildingDistrict)}) => offerDistrict: {offerDistrict} {DistrictManager.instance.GetDistrictName(offerDistrict)}");
                        }
                        if (!ext.GetAllowOutsidersEffective(offerDistrict))
                        {
                            var districtBuildings = SVMBuildingUtils.getAllBuildingsFromCity(def, offerDistrict, true, true);

                            if (ServiceVehiclesManagerMod.debugMode)
                            {
                                SVMUtils.doLog($"Offer doesn't allow outsiders. Available buildings found: {districtBuildings}");
                            }
                            if (districtBuildings.Count > 0)
                            {
                                var newBuildingId = districtBuildings[Singleton <SimulationManager> .instance.m_randomizer.Int32((uint)districtBuildings.Count)];
                                return(ProcessOffer(newBuildingId, ref BuildingManager.instance.m_buildings.m_buffer[newBuildingId], material, offer, trTarget, tup, instance));
                            }
                            if (ServiceVehiclesManagerMod.debugMode)
                            {
                                SVMUtils.doLog($"Ignoring because no buildings can handle it");
                            }
                        }
                        if (!ext.GetAllowGoOutsideEffective(buildingDistrict))
                        {
                            var districtBuildings = SVMBuildingUtils.getAllBuildingsFromCity(def, offerDistrict, false, true);
                            if (ServiceVehiclesManagerMod.debugMode)
                            {
                                SVMUtils.doLog($"Building district doesn't allow go out. Available buildings found: {districtBuildings}");
                            }
                            if (districtBuildings.Count > 0)
                            {
                                var newBuildingId = districtBuildings[Singleton <SimulationManager> .instance.m_randomizer.Int32((uint)districtBuildings.Count)];
                                return(ProcessOffer(newBuildingId, ref BuildingManager.instance.m_buildings.m_buffer[newBuildingId], material, offer, trTarget, tup, instance));
                            }
                            if (ServiceVehiclesManagerMod.debugMode)
                            {
                                SVMUtils.doLog($"Ignoring because no buildings can handle it (2)");
                            }
                        }
                    }
                }
                #endregion

                SVMUtils.doLog("[{1}] SSD = {0}", def, material);
                VehicleInfo randomVehicleInfo = ServiceSystemDefinition.availableDefinitions[def].GetAModel(buildingID);
                SVMUtils.doLog("[{1}] Veh = {0}", randomVehicleInfo?.ToString() ?? "<NULL>", material);
                if (randomVehicleInfo != null)
                {
                    Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles;
                    instance.CalculateSpawnPosition(buildingID, ref data, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, out Vector3 position, out Vector3 vector2);
                    if (Singleton <VehicleManager> .instance.CreateVehicle(out ushort num, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, position, material, tup.tramsferToSource, tup.transferToTarget))
                    {
                        randomVehicleInfo.m_vehicleAI.SetSource(num, ref vehicles.m_buffer[(int)num], buildingID);
                        randomVehicleInfo.m_vehicleAI.StartTransfer(num, ref vehicles.m_buffer[(int)num], material, offer);
                        return(true);
                    }
                }
            }
            return(false);
        }
        private static bool StartTransferOverride(ushort buildingID, ref Building data, TransferManager.TransferReason material, TransferManager.TransferOffer offer)
        {
            SVMUtils.doLog("START TRANSFER: {0} , {1}", typeof(OutsideConnectionAI), material);
            ServiceSystemDefinition def = null;

            switch (material)
            {
            case TransferManager.TransferReason.DummyTrain:
                if (offer.Building != buildingID)
                {
                    if (Singleton <SimulationManager> .instance.m_randomizer.Int32(2u) == 0)
                    {
                        def = ServiceSystemDefinition.CARG_TRAIN;
                    }
                    else
                    {
                        def = ServiceSystemDefinition.REG_TRAIN;
                    }
                    goto OfferProcessing;
                }
                break;

            case TransferManager.TransferReason.DummyShip:
                if (offer.Building != buildingID)
                {
                    if (Singleton <SimulationManager> .instance.m_randomizer.Int32(2u) == 0)
                    {
                        def = ServiceSystemDefinition.CARG_SHIP;
                    }
                    else
                    {
                        def = ServiceSystemDefinition.REG_SHIP;
                    }
                    goto OfferProcessing;
                }
                break;

            case TransferManager.TransferReason.DummyPlane:
                if (offer.Building != buildingID)
                {
                    def = ServiceSystemDefinition.REG_PLANE;
                    goto OfferProcessing;
                }
                break;
            }
            SVMUtils.doLog("END TRANSFER: {0} , {1} (not set)", typeof(OutsideConnectionAI), material);
            return(true);

OfferProcessing:
            SVMUtils.doLog("[{1}] SSD = {0}", def, material);
            VehicleInfo randomVehicleInfo = ServiceSystemDefinition.availableDefinitions[def].GetAModel(offer.Building);

            SVMUtils.doLog("[{1}] Veh = {0}", randomVehicleInfo?.ToString() ?? "<NULL>", material);

            Array16 <Vehicle> vehicles = Singleton <VehicleManager> .instance.m_vehicles;

            if (Singleton <VehicleManager> .instance.CreateVehicle(out ushort vehId, ref Singleton <SimulationManager> .instance.m_randomizer, randomVehicleInfo, data.m_position, material, false, true))
            {
                Vehicle[] expr_BB7_cp_0 = vehicles.m_buffer;
                ushort    expr_BB7_cp_1 = vehId;
                expr_BB7_cp_0[(int)expr_BB7_cp_1].m_flags = (expr_BB7_cp_0[(int)expr_BB7_cp_1].m_flags | Vehicle.Flags.DummyTraffic);
                Vehicle[] expr_BD6_cp_0 = vehicles.m_buffer;
                ushort    expr_BD6_cp_1 = vehId;
                expr_BD6_cp_0[(int)expr_BD6_cp_1].m_flags = (expr_BD6_cp_0[(int)expr_BD6_cp_1].m_flags & ~Vehicle.Flags.WaitingCargo);

                randomVehicleInfo.m_vehicleAI.SetSource(vehId, ref vehicles.m_buffer[(int)vehId], buildingID);
                randomVehicleInfo.m_vehicleAI.StartTransfer(vehId, ref vehicles.m_buffer[(int)vehId], material, offer);
                SVMUtils.doLog("END TRANSFER: {0} , {1} (found)", typeof(OutsideConnectionAI), material);
                return(false);
            }
            SVMUtils.doLog("END TRANSFER: {0} , {1} (not found)", typeof(OutsideConnectionAI), material);
            return(true);
        }
        public void Update()
        {
            if (!this.m_buildingInfoPanel.isVisible)
            {
                return;
            }
            Building b = Singleton <BuildingManager> .instance.m_buildings.m_buffer[m_buildingIdSelecionado.Building];

            if (!(b.Info.GetAI() is BuildingAI basicAI))
            {
                closeBuildingInfo(null, null);
                return;
            }

            var           ssds         = ServiceSystemDefinition.from(b.Info);
            List <string> textVehicles = new List <string>();

            foreach (var ssd in ssds)
            {
                int count    = 0;
                int cargo    = 0;
                int capacity = 0;
                int inbound  = 0;
                int outbound = 0;
                var ext      = SVMBuildingAIOverrideUtils.getBuildingOverrideExtension(b.Info);
                SVMBuildingUtils.CalculateOwnVehicles(m_buildingIdSelecionado.Building, ref b, ext.GetManagedReasons(b.Info).Keys, ref count, ref cargo, ref capacity, ref inbound, ref outbound);
                var    maxField       = ext.GetVehicleMaxCountField(ssd.vehicleType);
                int    maxVehicles    = (SVMUtils.GetPrivateField <int>(b.Info.GetAI(), maxField) * SVMBuildingUtils.GetProductionRate(ref b) / 100);
                string maxVehiclesStr = maxField == null || maxVehicles > 0x3FFF ? "∞" : maxVehicles.ToString();
                textVehicles.Add($"{count}/{maxVehiclesStr} ({Locale.Get("SVM_VEHICLE_TYPE", ssd.vehicleType.ToString())})");
            }
            vehiclesInUseLabel.text = string.Join(" | ", textVehicles.ToArray());
            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[] { SVMUtils.GetPrivateField <int>(basicAI, "m_workPlaceCount0"), SVMUtils.GetPrivateField <int>(basicAI, "m_workPlaceCount1"), SVMUtils.GetPrivateField <int>(basicAI, "m_workPlaceCount2"), SVMUtils.GetPrivateField <int>(basicAI, "m_workPlaceCount3") });
        }
 public void Hide()
 {
     m_buildingInfoPanel.Hide();
     SVMServiceBuildingDetailPanel.Get().OpenAt(ServiceSystemDefinition.from(Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingIdSel.Building].Info).FirstOrDefault());
 }