Beispiel #1
0
        private static bool GetNameRico(ref string __result, ushort buildingID)
        {
            if (BuildingManager.instance.m_buildings.m_buffer[buildingID].Info.m_buildingAI is ResidentialBuildingAI)
            {
                if (AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Residence == Xml.AdrRicoNamesGenerationConfig.GenerationMethod.NONE)
                {
                    return(true);
                }
            }
            else if (BuildingManager.instance.m_buildings.m_buffer[buildingID].Info.m_buildingAI is IndustrialBuildingAI)
            {
                if (AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Industry == Xml.AdrRicoNamesGenerationConfig.GenerationMethod.NONE)
                {
                    return(true);
                }
            }
            else if (BuildingManager.instance.m_buildings.m_buffer[buildingID].Info.m_buildingAI is CommercialBuildingAI)
            {
                if (AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Commerce == Xml.AdrRicoNamesGenerationConfig.GenerationMethod.NONE)
                {
                    return(true);
                }
            }
            else if (BuildingManager.instance.m_buildings.m_buffer[buildingID].Info.m_buildingAI is OfficeBuildingAI)
            {
                if (AdrController.CurrentConfig.GlobalConfig.BuildingConfig.RicoNamesGenerationConfig.Office == Xml.AdrRicoNamesGenerationConfig.GenerationMethod.NONE)
                {
                    return(true);
                }
            }
            else
            {
                return(true);
            }

            Vector3 sidewalk = BuildingManager.instance.m_buildings.m_buffer[buildingID].CalculateSidewalkPosition();

            AdrUtils.GetAddressLines(sidewalk, BuildingManager.instance.m_buildings.m_buffer[buildingID].m_position, out string[] addressLines);
            if (addressLines.Length == 0)
            {
                return(true);
            }

            __result = addressLines[0];
            return(false);
        }
Beispiel #2
0
        private void UpdateAddressField(UIComponent parent)
        {
            if (parent != null)
            {
                UIButton addressIcon = parent.Find <UIButton>("AddressesIcon");
                if (!addressIcon)
                {
                    addressIcon = InitBuildingEditOnWorldInfoPanel(parent);
                }
                UIButton zmButton = parent.Find <UIButton>("ZmButton");
                if (!zmButton)
                {
                    zmButton = InitZmButtonOnWorldInfoPanel(parent);
                }
                try
                {
                    ushort buildingId = GetWipBuildingInstanceId(parent.gameObject.GetComponent <WorldInfoPanel>()).Building;
                    addressIcon.isVisible = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].Info.m_placementMode == BuildingInfo.PlacementMode.Roadside;
                    if (addressIcon.isVisible)
                    {
                        UILabel addressLabel   = addressIcon.Find <UILabel>("Address");
                        Vector3 sidewalk       = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].CalculateSidewalkPosition();
                        Vector3 midPosBuilding = Singleton <BuildingManager> .instance.m_buildings.m_buffer[buildingId].m_position;

                        AdrUtils.GetAddressLines(sidewalk, midPosBuilding, out string[] addressLines);
                        if (addressLines == null)
                        {
                            addressIcon.isVisible = false;
                            return;
                        }
                        addressLabel.prefix = addressLines[0];
                        addressLabel.suffix = addressLines[1] + "\n" + addressLines[2];
                    }
                    zmButton.color        = buildingId == CurrentConfig.GlobalConfig.AddressingConfig.ZeroMarkBuilding ? Color.white : Color.black;
                    zmButton.focusedColor = zmButton.color;
                }
                catch (Exception e)
                {
                    LogUtils.DoErrorLog($"Exception trying to update address:\n{e.GetType()}\n{e.StackTrace}");
                }
            }
        }