Exemplo n.º 1
0
        public override Instance Clone(InstanceState instanceState, ref Matrix4x4 matrix4x, float deltaHeight, float deltaAngle, Vector3 center, bool followTerrain, Dictionary <ushort, ushort> clonedNodes, Action action)
        {
            TreeState state = instanceState as TreeState;

            Vector3 newPosition = matrix4x.MultiplyPoint(state.position - center);

            newPosition.y = state.position.y + deltaHeight;

            if (followTerrain)
            {
                newPosition.y = newPosition.y + TerrainManager.instance.SampleOriginalRawHeightSmooth(newPosition) - state.terrainHeight;
            }

            Instance cloneInstance = null;

            TreeInstance[] buffer = TreeManager.instance.m_trees.m_buffer;

            if (TreeManager.instance.CreateTree(out uint clone, ref SimulationManager.instance.m_randomizer,
                                                state.Info.Prefab as TreeInfo, newPosition, state.single))
            {
                InstanceID cloneID = default;
                cloneID.Tree  = clone;
                cloneInstance = new MoveableTree(cloneID);
            }

            return(cloneInstance);
        }
Exemplo n.º 2
0
        public override Instance Clone(InstanceState instanceState, Dictionary <ushort, ushort> clonedNodes)
        {
            TreeState state = instanceState as TreeState;

            Instance cloneInstance = null;

            if (TreeManager.instance.CreateTree(out uint clone, ref SimulationManager.instance.m_randomizer,
                                                state.Info.Prefab as TreeInfo, state.position, state.single))
            {
                InstanceID cloneID = default;
                cloneID.Tree  = clone;
                cloneInstance = new MoveableTree(cloneID);
            }

            return(cloneInstance);
        }