public void updateDropdowns() { PropPositioningInfo config = PropConfig.Instance().propPositioningDict[entityName]; for (int i = 0; i < NUM_DROPDOWNS; i++) { if (i < config.numSigns) { dropDownGroups[i].label.Show(); dropDownGroups[i].dropDown.Show(); } else { dropDownGroups[i].label.Hide(); dropDownGroups[i].dropDown.Hide(); } } }
private void renderGameObjects() { List <Material> materials = TextureUtils.m_screenTextureStore.Values.ToList(); foreach (KeyValuePair <ushort, ScreenObj> obj in ScreenManager.instance.propDict) { ScreenObj screenObj = obj.Value; if (screenObj.signObject != null) { continue; } else { screenObj.signObject = new GameObject(obj.Key + "animatedsign"); screenObj.signObject.transform.position = screenObj.position; screenObj.signObject.transform.Rotate(0, (screenObj.angle) + 60f, 0); PropPositioningInfo positioningInfo = PropConfig.Instance().propPositioningDict[screenObj.propName]; for (byte i = 0; i < positioningInfo.numSigns; i++) { if (screenObj.isActive[i]) { if (screenObj.isStatic[i] && !TextureUtils.m_screenTextureStore.ContainsKey(screenObj.staticImageString[i])) { continue; } GameObject screenPaneObj = new GameObject(i.ToString()); screenPaneObj.AddComponent <MeshRenderer>(); screenPaneObj.AddComponent <MeshFilter>(); screenPaneObj.transform.parent = screenObj.signObject.transform; screenPaneObj.transform.localPosition = new Vector3(positioningInfo.xPos[i], positioningInfo.yPos[i], positioningInfo.zPos[i]); screenPaneObj.transform.localScale = new Vector3(positioningInfo.xSize[i], positioningInfo.ySize[i], 1f); screenPaneObj.transform.Rotate(0, (screenObj.angle) + positioningInfo.rotations[i], 0); Material mat = screenObj.isStatic[i] ? TextureUtils.m_screenTextureStore[screenObj.staticImageString[i]] : materials[messageRandom.Next(materials.Count)]; screenPaneObj.GetComponent <Renderer>().material = mat; screenPaneObj.GetComponent <MeshFilter>().mesh = MeshUtils.CreateRectMesh(mat.mainTexture.width, mat.mainTexture.height); } } ScreenManager.instance.propDict[obj.Key].signObject = screenObj.signObject; } } foreach (KeyValuePair <ushort, ScreenObj> obj in ScreenManager.instance.buildingDict) { ScreenObj screenObj = obj.Value; if (screenObj.signObject != null) { continue; } else { screenObj.signObject = new GameObject(obj.Key + "animatedsign"); screenObj.signObject.transform.position = screenObj.position; screenObj.signObject.transform.Rotate(0, (screenObj.angle) + 60f, 0); PropPositioningInfo positioningInfo = PropConfig.Instance().propPositioningDict[screenObj.propName]; for (byte i = 0; i < positioningInfo.numSigns; i++) { if (screenObj.isActive[i]) { if (screenObj.isStatic[i] && !TextureUtils.m_screenTextureStore.ContainsKey(screenObj.staticImageString[i])) { continue; } GameObject screenPaneObj = new GameObject(i.ToString()); screenPaneObj.AddComponent <MeshRenderer>(); screenPaneObj.AddComponent <MeshFilter>(); screenPaneObj.transform.parent = screenObj.signObject.transform; screenPaneObj.transform.localPosition = new Vector3(positioningInfo.xPos[i], positioningInfo.yPos[i], positioningInfo.zPos[i]); screenPaneObj.transform.localScale = new Vector3(positioningInfo.xSize[i], positioningInfo.ySize[i], 1f); screenPaneObj.transform.Rotate(0, (screenObj.angle) + positioningInfo.rotations[i], 0); Material mat = screenObj.isStatic[i] ? TextureUtils.m_screenTextureStore[screenObj.staticImageString[i]] : materials[messageRandom.Next(materials.Count)]; screenPaneObj.GetComponent <Renderer>().material = mat; screenPaneObj.GetComponent <MeshFilter>().mesh = MeshUtils.CreateRectMesh(mat.mainTexture.width, mat.mainTexture.height); } } ScreenManager.instance.buildingDict[obj.Key].signObject = screenObj.signObject; } } }
protected override void BeginOverlayImpl(RenderManager.CameraInfo cameraInfo) { if (refreshFlag) { refreshFlag = false; try { renderGameObjects(); } catch (Exception ex) { LoggerUtils.LogException(ex); } } if (!objHidden && cameraInfo.m_height > renderHeight) { foreach (ScreenObj screen in ScreenManager.instance.propDict.Values) { if (screen.signObject != null) { screen.signObject.SetActive(false); } } foreach (ScreenObj screen in ScreenManager.instance.buildingDict.Values) { if (screen.signObject != null) { screen.signObject.SetActive(false); } } objHidden = true; } else if (objHidden && cameraInfo.m_height <= renderHeight) //This is a mess, and I'll sort it soon :) { foreach (ScreenObj screen in ScreenManager.instance.propDict.Values) { if (screen.signObject != null) { screen.signObject.SetActive(true); } } foreach (ScreenObj screen in ScreenManager.instance.buildingDict.Values) { if (screen.signObject != null) { screen.signObject.SetActive(true); } } objHidden = false; } if (screenRefreshFlag) { screenRefreshFlag = false; List <Material> materials = TextureUtils.m_screenTextureStore.Values.ToList(); foreach (ScreenObj obj in ScreenManager.instance.buildingDict.Values) { if (obj.signObject) { PropPositioningInfo positioningInfo = PropConfig.Instance().propPositioningDict[obj.propName]; for (byte i = 0; i < positioningInfo.numSigns; i++) { Transform child = obj.signObject.transform.Find(i.ToString()); if (child != null && !obj.isStatic[i]) { Material mat = materials[messageRandom.Next(materials.Count)]; child.gameObject.GetComponent <MeshRenderer>().material = mat; } } } } foreach (ScreenObj obj in ScreenManager.instance.propDict.Values) { if (obj.signObject) { PropPositioningInfo positioningInfo = PropConfig.Instance().propPositioningDict[obj.propName]; for (byte i = 0; i < positioningInfo.numSigns; i++) { Transform child = obj.signObject.transform.Find(i.ToString()); if (child != null && !obj.isStatic[i]) { Material mat = materials[messageRandom.Next(materials.Count)]; child.gameObject.GetComponent <MeshRenderer>().material = mat; } } } } } }
protected override void OnToolUpdate() { if (m_toolController != null && !m_toolController.IsInsideUI && Cursor.visible) { RaycastOutput raycastOutput; if (RaycastProp(out raycastOutput)) { ushort propId = raycastOutput.m_propInstance; ushort buildingId = raycastOutput.m_building; if (propId != 0) { PropManager propManager = PropManager.instance; PropInstance prop = propManager.m_props.m_buffer[(int)propId]; if ((prop.m_flags & (ushort)(PropInstance.Flags.Created)) != (ushort)PropInstance.Flags.None && PropConfig.Instance().propPositioningDict.ContainsKey(prop.Info.GetLocalizedTitle())) { if (Event.current.type == EventType.MouseDown) { //unset tool ShowToolInfo(false, null, new Vector3()); dialog.isProp = true; dialog.entityId = propId; dialog.entityPosition = prop.Position; dialog.entityAngle = -1 * Mathf.Rad2Deg * prop.Angle; dialog.entityName = prop.Info.GetLocalizedTitle(); dialog.updateDropdowns(); dialog.Show(); ToolsModifierControl.toolController.CurrentTool = ToolsModifierControl.GetTool <DefaultTool>(); ToolsModifierControl.SetTool <DefaultTool>(); } else { ShowToolInfo(true, "Make this sign dynamic!", prop.Position); } } } else if (buildingId != 0) { BuildingManager buildingManager = BuildingManager.instance; Building building = buildingManager.m_buildings.m_buffer[buildingId]; UIPanel panel = GameObject.Find("(Library) CityServiceWorldInfoPanel").GetComponent <UIPanel>(); if ((building.m_flags & Building.Flags.Created) != Building.Flags.None && PropConfig.Instance().propPositioningDict.ContainsKey(building.Info.GetLocalizedTitle())) { Vector3 position; Quaternion rotation; building.CalculateMeshPosition(out position, out rotation); if (Event.current.type == EventType.MouseDown) { //unset tool ShowToolInfo(false, null, new Vector3()); panel.Hide(); dialog.isProp = false; dialog.entityId = buildingId; dialog.entityPosition = position; dialog.entityAngle = rotation.eulerAngles.y; dialog.entityName = building.Info.GetLocalizedTitle(); dialog.updateDropdowns(); dialog.Show(); //ScreenManager.instance.SetPropScreen(false, buildingId, position, rotation.eulerAngles.y, building.Info.GetLocalizedTitle()); ToolsModifierControl.toolController.CurrentTool = ToolsModifierControl.GetTool <DefaultTool>(); ToolsModifierControl.SetTool <DefaultTool>(); } else { ShowToolInfo(true, "Make this sign dynamic!", position); } } } else { ShowToolInfo(false, null, new Vector3()); } } else { ShowToolInfo(false, null, new Vector3()); } } else { ShowToolInfo(false, null, new Vector3()); } }