Ejemplo 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)
        {
            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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }