public override void Update()
 {
     if (m_virtualRealityButton.IsClicked)
     {
         if (SettingsManager.UseVr)
         {
             SettingsManager.UseVr = false;
             VrManager.StopVr();
         }
         else
         {
             SettingsManager.UseVr = true;
             VrManager.StartVr();
         }
     }
     if (m_brightnessSlider.IsSliding)
     {
         SettingsManager.Brightness = m_brightnessSlider.Value;
     }
     m_virtualRealityButton.IsEnabled = VrManager.IsVrAvailable;
     m_virtualRealityButton.Text      = (SettingsManager.UseVr ? "Enabled" : "Disabled");
     m_brightnessSlider.Value         = SettingsManager.Brightness;
     m_brightnessSlider.Text          = MathUtils.Round(SettingsManager.Brightness * 10f).ToString();
     if (base.Input.Back || base.Input.Cancel || Children.Find <ButtonWidget>("TopBar.Back").IsClicked)
     {
         ScreensManager.SwitchScreen(ScreensManager.PreviousScreen);
     }
 }
 public Matrix CalculateBaseProjectionMatrix()
 {
     if (!base.Eye.HasValue)
     {
         float num  = 90f;
         float num2 = 1f;
         if (SettingsManager.ViewAngleMode == ViewAngleMode.Narrow)
         {
             num2 = 0.8f;
         }
         else if (SettingsManager.ViewAngleMode == ViewAngleMode.Normal)
         {
             num2 = 0.9f;
         }
         ViewWidget viewWidget = base.GameWidget.ViewWidget;
         float      num3       = viewWidget.ActualSize.X / viewWidget.ActualSize.Y;
         float      num4       = MathUtils.Min(num * num3, num);
         float      num5       = num4 * num3;
         if (num5 < 90f)
         {
             num4 *= 90f / num5;
         }
         else if (num5 > 175f)
         {
             num4 *= 175f / num5;
         }
         return(Matrix.CreatePerspectiveFieldOfView(MathUtils.DegToRad(num4 * num2), num3, 0.1f, 2048f));
     }
     return(VrManager.GetProjectionMatrix(base.Eye.Value, 0.1f, 2048f));
 }
Beispiel #3
0
 public bool IsVrButtonDownOnce(VrController controller, VrControllerButton button)
 {
     if (!m_isCleared && (Devices & WidgetInputDevice.VrControllers) != 0)
     {
         return(VrManager.IsButtonDownOnce(controller, button));
     }
     return(false);
 }
Beispiel #4
0
 public float GetVrTriggerPosition(VrController controller, float deadZone = 0f)
 {
     if (!m_isCleared && (Devices & WidgetInputDevice.VrControllers) != 0)
     {
         return(VrManager.GetTriggerPosition(controller, deadZone));
     }
     return(0f);
 }
Beispiel #5
0
 public Vector2?GetVrTouchpadPosition(VrController controller, float deadZone = 0f)
 {
     if (!m_isCleared && (Devices & WidgetInputDevice.VrControllers) != 0)
     {
         return(VrManager.GetTouchpadPosition(controller, deadZone));
     }
     return(null);
 }
Beispiel #6
0
 public Vector2 GetVrStickPosition(VrController controller, float deadZone = 0f)
 {
     if (!m_isCleared && (Devices & WidgetInputDevice.VrControllers) != 0)
     {
         return(VrManager.GetStickPosition(controller, deadZone));
     }
     return(Vector2.Zero);
 }
Beispiel #7
0
        public static void Run()
        {
            VrManager.WaitGetPoses();
            double realTime = Time.RealTime;

            LastFrameTime               = (float)(realTime - m_frameBeginTime);
            LastCpuFrameTime            = (float)(m_cpuEndTime - m_frameBeginTime);
            m_frameBeginTime            = realTime;
            Window.PresentationInterval = ((!VrManager.IsVrStarted) ? SettingsManager.PresentationInterval : 0);
            try
            {
                if (ExceptionManager.Error == null)
                {
                    while (m_urisToHandle.Count > 0)
                    {
                        Uri obj = m_urisToHandle[0];
                        m_urisToHandle.RemoveAt(0);
                        Program.HandleUri?.Invoke(obj);
                    }
                    PerformanceManager.Update();
                    MotdManager.Update();
                    MusicManager.Update();
                    ScreensManager.Update();
                    DialogsManager.Update();
                }
                else
                {
                    ExceptionManager.UpdateExceptionScreen();
                }
            }
            catch (Exception e)
            {
                ExceptionManager.ReportExceptionToUser(null, e);
                ScreensManager.SwitchScreen("MainMenu");
            }
            try
            {
                Display.RenderTarget = null;
                if (ExceptionManager.Error == null)
                {
                    ScreensManager.Draw();
                    PerformanceManager.Draw();
                    ScreenCaptureManager.Run();
                }
                else
                {
                    ExceptionManager.DrawExceptionScreen();
                }
                m_cpuEndTime = Time.RealTime;
            }
            catch (Exception e2)
            {
                ExceptionManager.ReportExceptionToUser(null, e2);
                ScreensManager.SwitchScreen("MainMenu");
            }
        }
 public Ray3?CalculateVrHandRay()
 {
     if (VrManager.IsControllerPresent(VrController.Right))
     {
         Camera activeCamera = m_componentPlayer.GameWidget.ActiveCamera;
         Matrix m            = VrManager.HmdMatrixInverted * Matrix.CreateWorld(activeCamera.ViewPosition, activeCamera.ViewDirection, activeCamera.ViewUp);
         Matrix matrix       = VrManager.GetControllerMatrix(VrController.Right) * m;
         return(new Ray3(matrix.Translation + matrix.Forward * (5f / 64f), matrix.Forward));
     }
     return(null);
 }
 public static void Draw()
 {
     if (VrManager.IsVrStarted)
     {
         Point2 point = new Point2(Display.Viewport.Width, Display.Viewport.Height);
         if (MathUtils.Max(point.X, point.Y) == 0)
         {
             point = new Point2(1500, 1000);
         }
         while (MathUtils.Max(point.X, point.Y) < 1024)
         {
             point *= 2;
         }
         if (m_uiRenderTarget == null || m_uiRenderTarget.Width != point.X || m_uiRenderTarget.Height != point.Y)
         {
             Utilities.Dispose(ref m_uiRenderTarget);
             m_uiRenderTarget = new RenderTarget2D(point.X, point.Y, 1, ColorFormat.Rgba8888, DepthFormat.Depth24Stencil8);
         }
         RenderTarget2D renderTarget = Display.RenderTarget;
         try
         {
             Display.RenderTarget = m_uiRenderTarget;
             LayoutAndDrawWidgets();
             Display.RenderTarget = VrManager.VrRenderTarget;
             for (VrEye vrEye = VrEye.Left; vrEye <= VrEye.Right; vrEye++)
             {
                 Display.Clear(Color.Black, 1f, 0);
                 DrawVrBackground();
                 DrawVrQuad();
                 Matrix hmdMatrix        = VrManager.HmdMatrix;
                 Matrix m                = Matrix.Invert(VrManager.GetEyeToHeadTransform(vrEye));
                 Matrix m2               = Matrix.Invert(hmdMatrix);
                 Matrix projectionMatrix = VrManager.GetProjectionMatrix(vrEye, 0.1f, 1024f);
                 m_pr3.Flush(m2 * m * projectionMatrix);
                 VrManager.SubmitEyeTexture(vrEye, VrManager.VrRenderTarget);
             }
         }
         finally
         {
             Display.RenderTarget = renderTarget;
         }
         m_pr2.TexturedBatch(m_uiRenderTarget, useAlphaTest: false, 0, DepthStencilState.None, RasterizerState.CullNoneScissor, BlendState.Opaque, SamplerState.PointClamp).QueueQuad(new Vector2(0f, 0f), new Vector2(m_uiRenderTarget.Width, m_uiRenderTarget.Height), 0f, new Vector2(0f, 0f), new Vector2(1f, 1f), Color.White);
         m_pr2.Flush();
     }
     else
     {
         Utilities.Dispose(ref m_uiRenderTarget);
         LayoutAndDrawWidgets();
     }
 }
Beispiel #10
0
 public void UpdateInputFromVrControllers()
 {
     VrCursorPosition = null;
     if (VrQuadMatrix.HasValue)
     {
         Matrix value            = VrQuadMatrix.Value;
         Matrix controllerMatrix = VrManager.GetControllerMatrix(VrController.Right);
         Plane  plane            = new Plane(value.Translation, value.Translation + value.Right, value.Translation + value.Up);
         Ray3   ray = new Ray3(controllerMatrix.Translation, controllerMatrix.Forward);
         float? num = ray.Intersection(plane);
         if (num.HasValue)
         {
             Vector3 v = ray.Position + num.Value * ray.Direction - value.Translation;
             float   x = Vector3.Dot(v, Vector3.Normalize(value.Right)) / value.Right.Length() * Widget.ActualSize.X;
             float   y = (1f - Vector3.Dot(v, Vector3.Normalize(value.Up)) / value.Up.Length()) * Widget.ActualSize.Y;
             VrCursorPosition = Vector2.Transform(new Vector2(x, y), Widget.GlobalTransform);
         }
     }
     if (IsVrButtonDownOnce(VrController.Left, VrControllerButton.TouchpadLeft))
     {
         Left = true;
     }
     if (IsVrButtonDownOnce(VrController.Left, VrControllerButton.TouchpadRight))
     {
         Right = true;
     }
     if (IsVrButtonDownOnce(VrController.Left, VrControllerButton.TouchpadUp))
     {
         Up = true;
     }
     if (IsVrButtonDownOnce(VrController.Left, VrControllerButton.TouchpadDown))
     {
         Down = true;
     }
     if (IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadLeft))
     {
         Left = true;
     }
     if (IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadRight))
     {
         Right = true;
     }
     if (IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadUp))
     {
         Up = true;
     }
     if (IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadDown))
     {
         Down = true;
     }
     if (IsVrButtonDownOnce(VrController.Right, VrControllerButton.Grip))
     {
         Back   = true;
         Cancel = true;
     }
     if (IsVrButtonDownOnce(VrController.Left, VrControllerButton.Touchpad) || IsVrButtonDownOnce(VrController.Left, VrControllerButton.Trigger) || IsVrButtonDownOnce(VrController.Right, VrControllerButton.Touchpad) || IsVrButtonDownOnce(VrController.Right, VrControllerButton.Trigger))
     {
         Any = true;
     }
     if (IsVrCursorVisible && VrCursorPosition.HasValue)
     {
         if (IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadUp))
         {
             Scroll = new Vector3(VrCursorPosition.Value, 1f);
         }
         if (IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadDown))
         {
             Scroll = new Vector3(VrCursorPosition.Value, -1f);
         }
         if (IsVrButtonDown(VrController.Right, VrControllerButton.Trigger))
         {
             Press = VrCursorPosition.Value;
         }
         if (IsVrButtonDownOnce(VrController.Right, VrControllerButton.Trigger))
         {
             Ok            = true;
             Tap           = VrCursorPosition.Value;
             m_vrDownPoint = VrCursorPosition.Value;
             m_vrDragTime  = Time.FrameStartTime;
         }
         if (!IsVrButtonDown(VrController.Right, VrControllerButton.Trigger) && m_vrDownPoint.HasValue)
         {
             if (GetVrTriggerPosition(VrController.Left) > 0.5f)
             {
                 SpecialClick = new Segment2(m_vrDownPoint.Value, VrCursorPosition.Value);
             }
             else
             {
                 Click = new Segment2(m_vrDownPoint.Value, VrCursorPosition.Value);
             }
         }
     }
     if (!IsVrButtonDown(VrController.Right, VrControllerButton.Trigger))
     {
         m_vrDragInProgress = false;
         m_vrDownPoint      = null;
     }
     if (m_vrDragInProgress && VrCursorPosition.HasValue)
     {
         Drag = VrCursorPosition;
     }
     else if (IsVrButtonDown(VrController.Right, VrControllerButton.Trigger) && m_vrDownPoint.HasValue)
     {
         if (Vector2.Distance(m_vrDownPoint.Value, VrCursorPosition.Value) > SettingsManager.MinimumDragDistance * Widget.GlobalScale)
         {
             m_vrDragInProgress = true;
             Drag     = m_vrDownPoint.Value;
             DragMode = DragMode.AllItems;
         }
         else if (Time.FrameStartTime - m_vrDragTime > (double)SettingsManager.MinimumHoldDuration)
         {
             Hold     = m_vrDownPoint.Value;
             HoldTime = (float)(Time.FrameStartTime - m_vrDragTime);
         }
     }
 }
Beispiel #11
0
        public LoadingScreen()
        {
            XElement node = ContentManager.Get <XElement>("Screens/LoadingScreen");

            LoadContents(this, node);
            AddLoadAction(delegate
            {
                VrManager.Initialize();
            });
            AddLoadAction(delegate
            {
                CommunityContentManager.Initialize();
            });
            AddLoadAction(delegate
            {
                MotdManager.Initialize();
            });
            AddLoadAction(delegate
            {
                LightingManager.Initialize();
            });
            AddLoadAction(delegate
            {
                StringsManager.LoadStrings();
            });
            AddLoadAction(delegate
            {
                TextureAtlasManager.LoadAtlases();
            });
            foreach (ContentInfo item in ContentManager.List())
            {
                ContentInfo localContentInfo = item;
                AddLoadAction(delegate
                {
                    ContentManager.Get(localContentInfo.Name);
                });
            }
            AddLoadAction(delegate
            {
                DatabaseManager.Initialize();
            });
            AddLoadAction(delegate
            {
                WorldsManager.Initialize();
            });
            AddLoadAction(delegate
            {
                BlocksTexturesManager.Initialize();
            });
            AddLoadAction(delegate
            {
                CharacterSkinsManager.Initialize();
            });
            AddLoadAction(delegate
            {
                FurniturePacksManager.Initialize();
            });
            AddLoadAction(delegate
            {
                BlocksManager.Initialize();
            });
            AddLoadAction(delegate
            {
                CraftingRecipesManager.Initialize();
            });
            AddLoadAction(delegate
            {
                MusicManager.CurrentMix = MusicManager.Mix.Menu;
            });
        }
 public void UpdateInputFromVrControllers(WidgetInput input)
 {
     if (!IsControlledByVr)
     {
         return;
     }
     IsControlledByTouch = false;
     if (m_componentGui.ModalPanelWidget != null || DialogsManager.HasDialogs(m_componentPlayer.GuiWidget))
     {
         if (!input.IsVrCursorVisible)
         {
             input.IsVrCursorVisible = true;
         }
     }
     else
     {
         input.IsVrCursorVisible = false;
         float   num              = MathUtils.Pow(1.25f, 10f * (SettingsManager.MoveSensitivity - 0.5f));
         float   num2             = MathUtils.Pow(1.25f, 10f * (SettingsManager.LookSensitivity - 0.5f));
         float   num3             = MathUtils.Clamp(m_subsystemTime.GameTimeDelta, 0f, 0.1f);
         Vector2 v                = Vector2.Normalize(m_componentPlayer.ComponentBody.Matrix.Right.XZ);
         Vector2 v2               = Vector2.Normalize(m_componentPlayer.ComponentBody.Matrix.Forward.XZ);
         Vector2 vrStickPosition  = input.GetVrStickPosition(VrController.Left, 0.2f);
         Vector2 vrStickPosition2 = input.GetVrStickPosition(VrController.Right, 0.2f);
         Matrix  m                = VrManager.HmdMatrixInverted.OrientationMatrix * m_componentPlayer.ComponentCreatureModel.EyeRotation.ToMatrix();
         Vector2 xZ               = Vector3.TransformNormal(new Vector3(VrManager.WalkingVelocity.X, 0f, VrManager.WalkingVelocity.Y), m).XZ;
         Vector3 value            = Vector3.TransformNormal(new Vector3(VrManager.HeadMove.X, 0f, VrManager.HeadMove.Y), m);
         Vector3 zero             = Vector3.Zero;
         zero += 0.5f * new Vector3(Vector2.Dot(xZ, v), 0f, Vector2.Dot(xZ, v2));
         zero += new Vector3(2f * vrStickPosition.X, 2f * vrStickPosition2.Y, 2f * vrStickPosition.Y);
         m_playerInput.Move      += zero;
         m_playerInput.SneakMove += zero;
         m_playerInput.VrMove     = value;
         TouchInput?touchInput = VrManager.GetTouchInput(VrController.Left);
         if (touchInput.HasValue && num3 > 0f)
         {
             if (touchInput.Value.InputType == TouchInputType.Move)
             {
                 Vector2 move   = touchInput.Value.Move;
                 Vector2 vector = 10f * num / num3 * new Vector2(0.5f) * move * MathUtils.Pow(move.LengthSquared(), 0.175f);
                 m_playerInput.SneakMove.X += vector.X;
                 m_playerInput.SneakMove.Z += vector.Y;
                 m_playerInput.Move.X      += ProcessInputValue(touchInput.Value.TotalMoveLimited.X, 0.1f, 1f);
                 m_playerInput.Move.Z      += ProcessInputValue(touchInput.Value.TotalMoveLimited.Y, 0.1f, 1f);
             }
             else if (touchInput.Value.InputType == TouchInputType.Tap)
             {
                 m_playerInput.Jump = true;
             }
         }
         m_playerInput.Look += 0.5f * vrStickPosition2 * MathUtils.Pow(vrStickPosition2.LengthSquared(), 0.25f);
         Vector3 hmdMatrixYpr     = VrManager.HmdMatrixYpr;
         Vector3 hmdLastMatrixYpr = VrManager.HmdLastMatrixYpr;
         Vector3 vector2          = hmdMatrixYpr - hmdLastMatrixYpr;
         m_playerInput.VrLook = new Vector2(vector2.X, hmdMatrixYpr.Y);
         TouchInput?touchInput2 = VrManager.GetTouchInput(VrController.Right);
         Vector2    zero2       = Vector2.Zero;
         if (touchInput2.HasValue)
         {
             if (touchInput2.Value.InputType == TouchInputType.Move)
             {
                 zero2.X = touchInput2.Value.Move.X;
                 m_playerInput.Move.Y += ProcessInputValue(touchInput2.Value.TotalMoveLimited.Y, 0.1f, 1f);
             }
             else if (touchInput2.Value.InputType == TouchInputType.Tap)
             {
                 m_playerInput.Jump = true;
             }
         }
         if (num3 > 0f)
         {
             m_vrSmoothLook      = Vector2.Lerp(m_vrSmoothLook, zero2, 14f * num3);
             m_playerInput.Look += num2 / num3 * new Vector2(0.25f) * m_vrSmoothLook * MathUtils.Pow(m_vrSmoothLook.LengthSquared(), 0.3f);
         }
         if (VrManager.IsControllerPresent(VrController.Right))
         {
             m_playerInput.Dig      = (VrManager.IsButtonDown(VrController.Right, VrControllerButton.Trigger) ? CalculateVrHandRay() : m_playerInput.Dig);
             m_playerInput.Hit      = (VrManager.IsButtonDownOnce(VrController.Right, VrControllerButton.Trigger) ? CalculateVrHandRay() : m_playerInput.Hit);
             m_playerInput.Aim      = (VrManager.IsButtonDown(VrController.Left, VrControllerButton.Trigger) ? CalculateVrHandRay() : m_playerInput.Aim);
             m_playerInput.Interact = (VrManager.IsButtonDownOnce(VrController.Left, VrControllerButton.Trigger) ? CalculateVrHandRay() : m_playerInput.Interact);
         }
         m_playerInput.ToggleMount       |= input.IsVrButtonDownOnce(VrController.Left, VrControllerButton.TouchpadUp);
         m_playerInput.ToggleSneak       |= input.IsVrButtonDownOnce(VrController.Left, VrControllerButton.TouchpadDown);
         m_playerInput.EditItem          |= input.IsVrButtonDownOnce(VrController.Left, VrControllerButton.Grip);
         m_playerInput.ToggleCreativeFly |= input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadUp);
         if (input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadLeft))
         {
             m_playerInput.ScrollInventory--;
         }
         if (input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.TouchpadRight))
         {
             m_playerInput.ScrollInventory++;
         }
         m_playerInput.Drop |= input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.Grip);
     }
     if (!DialogsManager.HasDialogs(m_componentPlayer.GuiWidget))
     {
         m_playerInput.ToggleInventory |= input.IsVrButtonDownOnce(VrController.Right, VrControllerButton.Menu);
     }
 }
        public void Draw(Camera camera, int drawOrder)
        {
            if (!(m_componentPlayer.ComponentHealth.Health > 0f) || !camera.GameWidget.IsEntityFirstPersonTarget(base.Entity) || !m_componentPlayer.ComponentInput.IsControlledByVr)
            {
                return;
            }
            Vector3 eyePosition      = m_componentPlayer.ComponentCreatureModel.EyePosition;
            int     x                = Terrain.ToCell(eyePosition.X);
            int     num              = Terrain.ToCell(eyePosition.Y);
            int     z                = Terrain.ToCell(eyePosition.Z);
            int     activeBlockValue = m_componentMiner.ActiveBlockValue;

            if (Time.FrameStartTime >= m_nextHandLightTime)
            {
                float?num2 = LightingManager.CalculateSmoothLight(m_subsystemTerrain, eyePosition);
                if (num2.HasValue)
                {
                    m_nextHandLightTime = Time.FrameStartTime + 0.1;
                    m_handLight         = num2.Value;
                }
            }
            Matrix identity = Matrix.Identity;

            if (m_pokeAnimationTime > 0f)
            {
                float num3 = MathUtils.Sin(MathUtils.Sqrt(m_pokeAnimationTime) * (float)Math.PI);
                if (activeBlockValue != 0)
                {
                    identity *= Matrix.CreateRotationX((0f - MathUtils.DegToRad(90f)) * num3);
                }
                else
                {
                    identity *= Matrix.CreateRotationX((0f - MathUtils.DegToRad(45f)) * num3);
                }
            }
            if (!VrManager.IsControllerPresent(VrController.Right))
            {
                return;
            }
            Matrix m = VrManager.HmdMatrixInverted * Matrix.CreateWorld(camera.ViewPosition, camera.ViewDirection, camera.ViewUp) * camera.ViewMatrix;
            Matrix controllerMatrix = VrManager.GetControllerMatrix(VrController.Right);

            if (activeBlockValue == 0)
            {
                Display.DepthStencilState      = DepthStencilState.Default;
                Display.RasterizerState        = RasterizerState.CullCounterClockwiseScissor;
                m_shader.Texture               = m_componentPlayer.ComponentCreatureModel.TextureOverride;
                m_shader.SamplerState          = SamplerState.PointClamp;
                m_shader.MaterialColor         = Vector4.One;
                m_shader.AmbientLightColor     = new Vector3(m_handLight * LightingManager.LightAmbient);
                m_shader.DiffuseLightColor1    = new Vector3(m_handLight);
                m_shader.DiffuseLightColor2    = new Vector3(m_handLight);
                m_shader.LightDirection1       = -Vector3.TransformNormal(LightingManager.DirectionToLight1, camera.ViewMatrix);
                m_shader.LightDirection2       = -Vector3.TransformNormal(LightingManager.DirectionToLight2, camera.ViewMatrix);
                m_shader.Transforms.View       = Matrix.Identity;
                m_shader.Transforms.Projection = camera.ProjectionMatrix;
                m_shader.Transforms.World[0]   = Matrix.CreateScale(0.01f) * identity * controllerMatrix * m;
                foreach (ModelMesh mesh in m_vrHandModel.Meshes)
                {
                    foreach (ModelMeshPart meshPart in mesh.MeshParts)
                    {
                        Display.DrawIndexed(PrimitiveType.TriangleList, m_shader, meshPart.VertexBuffer, meshPart.IndexBuffer, meshPart.StartIndex, meshPart.IndicesCount);
                    }
                }
            }
            else
            {
                if (num >= 0 && num <= 255)
                {
                    TerrainChunk chunkAtCell = m_subsystemTerrain.Terrain.GetChunkAtCell(x, z);
                    if (chunkAtCell != null && chunkAtCell.State >= TerrainChunkState.InvalidVertices1)
                    {
                        m_itemLight = m_subsystemTerrain.Terrain.GetCellLightFast(x, num, z);
                    }
                }
                int     num4   = Terrain.ExtractContents(activeBlockValue);
                Block   block  = BlocksManager.Blocks[num4];
                Vector3 vector = block.InHandRotation * ((float)Math.PI / 180f) + m_itemRotation;
                Matrix  matrix = Matrix.CreateFromYawPitchRoll(vector.Y, vector.X, vector.Z) * Matrix.CreateTranslation(block.InHandOffset) * identity * Matrix.CreateTranslation(m_itemOffset) * controllerMatrix * m;
                m_drawBlockEnvironmentData.SubsystemTerrain = m_subsystemTerrain;
                m_drawBlockEnvironmentData.InWorldMatrix    = matrix;
                m_drawBlockEnvironmentData.Light            = m_itemLight;
                m_drawBlockEnvironmentData.Humidity         = m_subsystemTerrain.Terrain.GetHumidity(x, z);
                m_drawBlockEnvironmentData.Temperature      = m_subsystemTerrain.Terrain.GetTemperature(x, z) + SubsystemWeather.GetTemperatureAdjustmentAtHeight(num);
                block.DrawBlock(m_primitivesRenderer, activeBlockValue, Color.White, block.InHandScale, ref matrix, m_drawBlockEnvironmentData);
            }
            m_primitivesRenderer.Flush(camera.ProjectionMatrix);
        }