예제 #1
0
        public void MoveCall(Vector3 newPosition)
        {
            Bounds originalBounds = GetBounds(false);

            Move(newPosition, 0);
            Bounds fullbounds = GetBounds(false);

            MoveItTool.UpdateArea(originalBounds, true);
            MoveItTool.UpdateArea(fullbounds, true);
        }
예제 #2
0
        public void MoveCall(Vector3 newPosition)
        {
            Bounds  originalBounds = GetBounds(false);
            Vector3 oldPosition    = this.position;

            Move(newPosition, 0);
            if (Pillar != null)
            {
                Vector3 subPosition = Pillar.position + newPosition - oldPosition;
                Pillar.Move(subPosition, Pillar.angle);
            }
            Bounds fullbounds = GetBounds(false);

            MoveItTool.UpdateArea(originalBounds, true);
            MoveItTool.UpdateArea(fullbounds, true);
        }
예제 #3
0
        public void MoveCall(Vector3 newPosition, float angle)
        {
            Bounds  originalBounds = GetBounds(false);
            Vector3 oldPosition    = this.position;
            float   oldAngle       = this.angle;
            float   terrainHeight  = TerrainManager.instance.SampleOriginalRawHeightSmooth(newPosition);
            bool    isFixed        = GetFixedHeightFlag(id.Building);

            AddFixedHeightFlag(id.Building);
            BuildingState state = SaveToState() as BuildingState;

            Move(newPosition, angle);

            Vector3   center     = oldPosition;
            float     deltaAngle = angle - oldAngle;
            Matrix4x4 matrixSub  = default;

            matrixSub.SetTRS(Vector3.zero, Quaternion.AngleAxis(deltaAngle * Mathf.Rad2Deg, Vector3.down), Vector3.one);
            if (state.subStates != null)
            {
                foreach (InstanceState subState in state.subStates)
                {
                    Vector3 subOffset   = (subState.position - center) - (state.position - center);
                    Vector3 subPosition = TransformPosition + matrixSub.MultiplyPoint(subOffset);

                    subPosition.y = subState.position.y - state.position.y + newPosition.y;

                    subState.instance.Move(subPosition, subState.angle + deltaAngle);
                    if (subState.instance is MoveableNode mn)
                    {
                        if (mn.Pillar != null)
                        {
                            mn.Pillar.Move(subPosition, subState.angle + deltaAngle);
                        }
                    }

                    if (subState is BuildingState bs)
                    {
                        if (bs.subStates != null)
                        {
                            foreach (InstanceState subSubState in bs.subStates)
                            {
                                Vector3 subSubOffset   = (subSubState.position - center) - (state.position - center);
                                Vector3 subSubPosition = TransformPosition + matrixSub.MultiplyPoint(subSubOffset);

                                subSubPosition.y = subSubState.position.y - state.position.y + newPosition.y;

                                subSubState.instance.Move(subSubPosition, subSubState.angle + deltaAngle);
                                if (subSubState.instance is MoveableNode mn2)
                                {
                                    if (mn2.Pillar != null)
                                    {
                                        mn2.Pillar.Move(subSubPosition, subSubState.angle + deltaAngle);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (!isFixed && Mathf.Abs(terrainHeight - newPosition.y) < 0.01f)
            {
                RemoveFixedHeightFlag(id.Building);
            }
            Bounds fullbounds = GetBounds(false);

            MoveItTool.UpdateArea(originalBounds, true);
            MoveItTool.UpdateArea(fullbounds, true);
        }