コード例 #1
0
        public static void SetToolState(ToolStates state = ToolStates.Default, MT_Tools tool = MT_Tools.Off, ushort toolPhase = 0)
        {
            ToolStates previousState = ToolState;

            if (ToolState != state)
            {
                if (state != ToolStates.ToolActive && state != ToolStates.Aligning)
                {
                    UIMoreTools.m_activeToolMenu = null;
                }

                if (ToolState == ToolStates.ToolActive)
                {
                    if (MT_Tool == MT_Tools.MoveTo)
                    {
                        m_moveToPanel.Visible(false);
                    }
                }
            }

            ToolState        = state;
            m_toolsMode      = tool;
            m_alignToolPhase = toolPhase;

            if (state == ToolStates.ToolActive || state == ToolStates.Aligning || previousState == ToolStates.ToolActive || previousState == ToolStates.Aligning)
            {
                UIMoreTools.UpdateMoreTools();
            }
            m_debugPanel?.UpdatePanel();
        }
コード例 #2
0
 internal void CreateSubPanel(string subName, float entries)
 {
     m_panel.atlas                  = UIUtils.GetAtlas("Ingame");
     m_panel.backgroundSprite       = "SubcategoriesPanel";
     m_panel.clipChildren           = true;
     m_panel.size                   = new Vector2(160, 12 + (entries * 32f)); // Width is changed at runtime
     m_panel.isVisible              = false;
     m_subpanel.name                = subName;
     m_subpanel.padding             = new RectOffset(1, 1, 6, 6);
     m_subpanel.size                = m_panel.size;
     m_subpanel.autoLayoutDirection = LayoutDirection.Vertical;
     m_subpanel.autoLayout          = true;
     m_subpanel.relativePosition    = new Vector3(0, 0, 0);
     m_subpanel.autoLayoutPadding   = new RectOffset(0, 0, 0, 2);
     m_panel.autoLayout             = false;
     m_panel.absolutePosition       = UIMoreTools.MoreToolsBtn.absolutePosition + new Vector3(-m_panel.width, -m_panel.height - 10);
     m_panel.eventMouseEnter       += (UIComponent c, UIMouseEventParameter p) =>
     {
         UIMoreTools.m_activeDisplayMenu = this;
         if (MoveItTool.marqueeSelection)
         {
             UIToolOptionPanel.instance.m_filtersPanel.isVisible = false;
         }
         c.isVisible = true;
         UIMoreTools.UpdateMoreTools();
     };
     m_panel.eventMouseLeave += (UIComponent c, UIMouseEventParameter p) =>
     {
         UIMoreTools.m_activeDisplayMenu = null;
         if (MoveItTool.marqueeSelection)
         {
             UIToolOptionPanel.instance.m_filtersPanel.isVisible = true;
         }
         c.isVisible = false;
         UIMoreTools.UpdateMoreTools();
     };
 }
コード例 #3
0
        public override void Do()
        {
            Vector3   PoR;
            Matrix4x4 matrix = default;
            Bounds    bounds = GetTotalBounds(true, true);
            float     angleDelta, firstValidAngle = 0;

            System.Random   random          = new System.Random();
            BuildingManager buildingManager = Singleton <BuildingManager> .instance;

            foreach (InstanceState state in m_states)
            {
                if (state.instance.isValid)
                {
                    if (state.instance is MoveableBuilding || state.instance is MoveableProp || state.instance is MoveableProc)
                    {
                        firstValidAngle = state.angle;
                        break;
                    }
                }
            }
            angleDelta = 0 - firstValidAngle + newAngle;
            PoR        = bounds.center;

            foreach (InstanceState state in m_states)
            {
                if (state.instance.isValid)
                {
                    if (state.instance is MoveableBuilding mb)
                    {
                        //BuildingState bs = (BuildingState)state;

                        if (Mathf.Abs(Singleton <TerrainManager> .instance.SampleOriginalRawHeightSmooth(mb.position) - mb.position.y) > 0.01f)
                        {
                            mb.AddFixedHeightFlag(mb.id.Building);
                        }
                        else
                        {
                            mb.RemoveFixedHeightFlag(mb.id.Building);
                        }

                        if (this is AlignIndividualAction)
                        {
                            angleDelta = 0 - mb.angle + newAngle;
                            PoR        = state.position;
                        }
                        else if (this is AlignRandomAction)
                        {
                            angleDelta = 0 - mb.angle + (float)(random.NextDouble() * Math.PI * 2);
                            PoR        = state.position;
                        }

                        matrix.SetTRS(PoR, Quaternion.AngleAxis(angleDelta * Mathf.Rad2Deg, Vector3.down), Vector3.one);
                        mb.Transform(state, ref matrix, 0f, angleDelta, PoR, followTerrain);

                        BuildingInfo prefab   = (BuildingInfo)state.Info.Prefab;
                        ushort       id       = mb.id.Building;
                        Building     building = buildingManager.m_buildings.m_buffer[id];

                        if (prefab.m_hasParkingSpaces != VehicleInfo.VehicleType.None)
                        {
                            buildingManager.UpdateParkingSpaces(id, ref building);
                        }

                        buildingManager.UpdateBuildingRenderer(id, true);
                    }
                    else if (state.instance is MoveableProp mp)
                    {
                        if (this is AlignIndividualAction)
                        {
                            angleDelta = 0 - mp.angle + newAngle;
                            PoR        = state.position;
                        }
                        else if (this is AlignRandomAction)
                        {
                            angleDelta = 0 - mp.angle + (float)(random.NextDouble() * Math.PI * 2);
                            PoR        = state.position;
                        }
                        matrix.SetTRS(PoR, Quaternion.AngleAxis(angleDelta * Mathf.Rad2Deg, Vector3.down), Vector3.one);
                        mp.Transform(state, ref matrix, 0f, angleDelta, PoR, followTerrain);
                    }
                    else if (state.instance is MoveableProc mpo)
                    {
                        if (this is AlignIndividualAction)
                        {
                            angleDelta = 0 - mpo.angle + newAngle;
                            PoR        = state.position;
                        }
                        else if (this is AlignRandomAction)
                        {
                            angleDelta = 0 - mpo.angle + (float)(random.NextDouble() * Math.PI * 2);
                            PoR        = state.position;
                        }
                        matrix.SetTRS(PoR, Quaternion.AngleAxis(angleDelta * Mathf.Rad2Deg, Vector3.down), Vector3.one);
                        mpo.Transform(state, ref matrix, 0f, angleDelta, PoR, followTerrain);
                    }
                    else if (state.instance is MoveableTree mt)
                    {
                        if (this is AlignIndividualAction || this is AlignRandomAction)
                        {
                            continue;
                        }
                        matrix.SetTRS(PoR, Quaternion.AngleAxis(angleDelta * Mathf.Rad2Deg, Vector3.down), Vector3.one);
                        mt.Transform(state, ref matrix, 0f, angleDelta, PoR, followTerrain);
                    }
                }
            }

            MoveItTool.instance.ToolState      = MoveItTool.ToolStates.Default;
            MoveItTool.instance.AlignMode      = MoveItTool.AlignModes.Off;
            MoveItTool.instance.AlignToolPhase = 0;
            UIMoreTools.UpdateMoreTools();
            UpdateArea(bounds);
            UpdateArea(GetTotalBounds(false));
        }