Esempio n. 1
0
        public override void RenderCloneGeometry(InstanceState instanceState, ref Matrix4x4 matrix4x, Vector3 deltaPosition, float deltaAngle, Vector3 center, bool followTerrain, RenderManager.CameraInfo cameraInfo, Color toolColor)
        {
            PropState state = instanceState as PropState;

            PropInfo   info       = state.info as PropInfo;
            Randomizer randomizer = new Randomizer(state.instance.id.Prop);
            float      scale      = info.m_minScale + (float)randomizer.Int32(10000u) * (info.m_maxScale - info.m_minScale) * 0.0001f;

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

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

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

            float newAngle = state.angle + deltaAngle;

            if (info.m_requireHeightMap)
            {
                TerrainManager.instance.GetHeightMapping(newPosition, out Texture heightMap, out Vector4 heightMapping, out Vector4 surfaceMapping);
                PropInstance.RenderInstance(cameraInfo, info, id, newPosition, scale, newAngle, info.GetColor(ref randomizer), RenderManager.DefaultColorLocation, true, heightMap, heightMapping, surfaceMapping);
            }
            else
            {
                PropInstance.RenderInstance(cameraInfo, info, id, newPosition, scale, newAngle, info.GetColor(ref randomizer), RenderManager.DefaultColorLocation, true);
            }
        }
Esempio n. 2
0
        public override void RenderCloneOverlay(InstanceState instanceState, ref Matrix4x4 matrix4x, Vector3 deltaPosition, float deltaAngle, Vector3 center, bool followTerrain, RenderManager.CameraInfo cameraInfo, Color toolColor)
        {
            if (MoveItTool.m_isLowSensitivity)
            {
                return;
            }

            PropState state = instanceState as PropState;

            PropInfo   info       = state.Info.Prefab as PropInfo;
            Randomizer randomizer = new Randomizer(state.instance.id.Prop);
            float      scale      = info.m_minScale + (float)randomizer.Int32(10000u) * (info.m_maxScale - info.m_minScale) * 0.0001f;

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

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

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

            float newAngle = state.angle + deltaAngle;

            PropTool.RenderOverlay(cameraInfo, info, newPosition, scale, newAngle, toolColor);
        }
Esempio n. 3
0
        public override Instance Clone(InstanceState instanceState, ref Matrix4x4 matrix4x, float deltaHeight, float deltaAngle, Vector3 center, bool followTerrain, Dictionary <ushort, ushort> clonedNodes, Action action)
        {
            PropState state = instanceState as PropState;

            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;

            PropInstance[] buffer = PropManager.instance.m_props.m_buffer;

            if (PropManager.instance.CreateProp(out ushort clone, ref SimulationManager.instance.m_randomizer,
                                                state.Info.Prefab as PropInfo, newPosition, state.angle + deltaAngle, state.single))
            {
                InstanceID cloneID = default;
                cloneID.Prop = clone;
                buffer[clone].FixedHeight = state.fixedHeight;
                cloneInstance             = new MoveableProp(cloneID);
            }

            return(cloneInstance);
        }
Esempio n. 4
0
        // Constructor for FindIt object
        public CloneActionFindIt(PrefabInfo prefab)
        {
            m_oldSelection = selection;
            m_states.Clear();

            Vector3       position = MoveItTool.RaycastMouseLocation();
            InstanceState state    = new InstanceState();

            if (prefab is BuildingInfo)
            {
                state = new BuildingState
                {
                    isSubInstance = false,
                    isHidden      = false,
                    flags         = Building.Flags.Completed
                };
                state.Info.Prefab = prefab;
                InstanceID id = new InstanceID
                {
                    Building = 1,
                    Type     = InstanceType.Building
                };
                state.instance = new MoveableBuilding(id);
            }
            else if (prefab is PropInfo)
            {
                state = new PropState
                {
                    fixedHeight = false,
                    single      = false,
                };
                state.Info.Prefab = prefab;
                InstanceID id = new InstanceID
                {
                    Prop = 1,
                    Type = InstanceType.Prop
                };
                state.instance = new MoveableProp(id);
            }
            else if (prefab is TreeInfo)
            {
                state = new TreeState
                {
                    fixedHeight = false,
                    single      = false,
                };
                state.Info.Prefab = prefab;
                InstanceID id = new InstanceID
                {
                    Tree = 1,
                    Type = InstanceType.Tree
                };
                state.instance = new MoveableTree(id);
            }

            state.position      = position;
            state.terrainHeight = position.y;
            m_states.Add(state);
            center = position;
        }
Esempio n. 5
0
        public override Instance Clone(InstanceState instanceState, Dictionary <ushort, ushort> clonedNodes)
        {
            PropState state = instanceState as PropState;

            Instance cloneInstance = null;

            if (PropLayer.Manager.CreateProp(out uint clone, state.Info.Prefab as PropInfo, state.position, state.angle, state.single))
            {
                InstanceID cloneID = default;
                cloneID       = PropLayer.Manager.SetProp(cloneID, clone);
                cloneInstance = new MoveableProp(cloneID);
            }

            return(cloneInstance);
        }
Esempio n. 6
0
        public override Instance Clone(InstanceState instanceState, Dictionary <ushort, ushort> clonedNodes)
        {
            PropState state = instanceState as PropState;

            Instance cloneInstance = null;

            if (PropManager.instance.CreateProp(out ushort clone, ref SimulationManager.instance.m_randomizer,
                                                state.Info.Prefab as PropInfo, state.position, state.angle, state.single))
            {
                InstanceID cloneID = default;
                cloneID.Prop  = clone;
                cloneInstance = new MoveableProp(cloneID);
            }

            return(cloneInstance);
        }
Esempio n. 7
0
        public override InstanceState GetState()
        {
            PropState state = new PropState();

            state.instance = this;

            ushort prop = id.Prop;

            state.info = info;

            state.position      = PropManager.instance.m_props.m_buffer[prop].Position;
            state.angle         = PropManager.instance.m_props.m_buffer[prop].Angle;
            state.terrainHeight = TerrainManager.instance.SampleOriginalRawHeightSmooth(state.position);

            state.single = PropManager.instance.m_props.m_buffer[prop].Single;

            return(state);
        }
Esempio n. 8
0
        public override InstanceState SaveToState(bool integrate = true)
        {
            PropState state = new PropState
            {
                instance        = this,
                isCustomContent = Info.Prefab.m_isCustomContent
            };

            IProp prop = PropLayer.Manager.Buffer(id);

            state.Info = Info;

            state.position      = prop.Position;
            state.angle         = prop.Angle;
            state.terrainHeight = TerrainManager.instance.SampleOriginalRawHeightSmooth(state.position);
            state.single        = prop.Single;
            state.fixedHeight   = prop.FixedHeight;

            state.SaveIntegrations(integrate);

            return(state);
        }
Esempio n. 9
0
        public override InstanceState SaveToState(bool integrate = true)
        {
            PropState state = new PropState
            {
                instance        = this,
                isCustomContent = Info.Prefab.m_isCustomContent
            };

            ushort prop = id.Prop;

            state.Info = Info;

            state.position      = PropManager.instance.m_props.m_buffer[prop].Position;
            state.angle         = PropManager.instance.m_props.m_buffer[prop].Angle;
            state.terrainHeight = TerrainManager.instance.SampleOriginalRawHeightSmooth(state.position);

            state.single      = PropManager.instance.m_props.m_buffer[prop].Single;
            state.fixedHeight = PropManager.instance.m_props.m_buffer[prop].FixedHeight;

            state.SaveIntegrations(integrate);

            return(state);
        }