public void DrawSquares(DrawContext dc) { FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(1, DepthStencilState.None, null, BlendState.AlphaBlend); int count = flatBatch2D.LineVertices.Count; int count2 = flatBatch2D.TriangleVertices.Count; float num = (float)MathUtils.Remainder(Time.FrameStartTime + (double)m_timeOffset, 10000.0); float num2 = base.ActualSize.X / 12f; float num3 = (float)(int)base.GlobalColorTransform.A / 255f; for (float num4 = 0f; num4 < base.ActualSize.X; num4 += num2) { for (float num5 = 0f; num5 < base.ActualSize.Y; num5 += num2) { float num6 = 0.35f * MathUtils.Pow(MathUtils.Saturate(SimplexNoise.OctavedNoise(num4 + 1000f, num5, 0.7f * num, 0.5f, 1, 2f, 1f) - 0.1f), 1f) * num3; float num7 = 0.7f * MathUtils.Pow(SimplexNoise.OctavedNoise(num4, num5, 0.5f * num, 0.5f, 1, 2f, 1f), 3f) * num3; Vector2 corner = new Vector2(num4, num5); Vector2 corner2 = new Vector2(num4 + num2, num5 + num2); if (num6 > 0.01f) { flatBatch2D.QueueRectangle(corner, corner2, 0f, new Color(0f, 0f, 0f, num6)); } if (num7 > 0.01f) { flatBatch2D.QueueQuad(corner, corner2, 0f, new Color(0f, 0f, 0f, num7)); } } } flatBatch2D.TransformLines(base.GlobalTransform, count); flatBatch2D.TransformTriangles(base.GlobalTransform, count2); }
public override void Draw(DrawContext dc) { Color color = new Color((byte)128, (byte)128, (byte)128) * base.GlobalColorTransform * MathUtils.Saturate(m_scrollBarAlpha); if (color.A > 0 && m_scrollAreaLength > 0f) { FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None); int count = flatBatch2D.TriangleVertices.Count; if (Direction == LayoutDirection.Horizontal) { float scrollPosition = ScrollPosition; float x = base.ActualSize.X; Vector2 corner = new Vector2(scrollPosition / m_scrollAreaLength * x, base.ActualSize.Y - 5f); Vector2 corner2 = new Vector2((scrollPosition + x) / m_scrollAreaLength * x, base.ActualSize.Y - 1f); flatBatch2D.QueueQuad(corner, corner2, 0f, color); } else { float scrollPosition2 = ScrollPosition; float y = base.ActualSize.Y; Vector2 corner3 = new Vector2(base.ActualSize.X - 5f, scrollPosition2 / m_scrollAreaLength * y); Vector2 corner4 = new Vector2(base.ActualSize.X - 1f, (scrollPosition2 + y) / m_scrollAreaLength * y); flatBatch2D.QueueQuad(corner3, corner4, 0f, color); } flatBatch2D.TransformTriangles(base.GlobalTransform, count); } }
public override void Draw(DrawContext dc) { if (m_highlighted) { FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(100, DepthStencilState.None); int count = flatBatch2D.TriangleVertices.Count; flatBatch2D.QueueQuad(Vector2.Zero, base.ActualSize, 0f, new Color(128, 128, 128, 128)); flatBatch2D.TransformTriangles(base.GlobalTransform, count); m_highlighted = false; } }
public override void Draw(DrawContext dc) { if (SelectedIndex.HasValue && SelectedIndex.Value >= m_firstVisibleIndex && SelectedIndex.Value <= m_lastVisibleIndex) { Vector2 vector = (Direction == LayoutDirection.Horizontal) ? new Vector2((float)SelectedIndex.Value * ItemSize - ScrollPosition, 0f) : new Vector2(0f, (float)SelectedIndex.Value * ItemSize - ScrollPosition); FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None); int count = flatBatch2D.TriangleVertices.Count; Vector2 v = (Direction == LayoutDirection.Horizontal) ? new Vector2(ItemSize, base.ActualSize.Y) : new Vector2(base.ActualSize.X, ItemSize); flatBatch2D.QueueQuad(vector, vector + v, 0f, SelectionColor * base.GlobalColorTransform); flatBatch2D.TransformTriangles(base.GlobalTransform, count); } base.Draw(dc); }
public override void Draw(DrawContext dc) { if (Time.RealTime - m_lastBoxesStepTime > 0.25) { m_boxIndex++; m_lastBoxesStepTime = Time.RealTime; } FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(); int count = flatBatch2D.TriangleVertices.Count; for (int i = 0; i < 5; i++) { Vector2 v = new Vector2(((float)i + 0.5f) * 24f, 6f); Color c = (i == m_boxIndex % 5) ? LitBarColor : UnlitBarColor; float v2 = (i == m_boxIndex % 5) ? 12f : 8f; flatBatch2D.QueueQuad(v - new Vector2(v2) / 2f, v + new Vector2(v2) / 2f, 0f, c * base.GlobalColorTransform); } flatBatch2D.TransformTriangles(base.GlobalTransform, count); }
public override void Draw(DrawContext dc) { if (m_parsingPending) { ParsePoints(); } Color color = Color * base.GlobalColorTransform; FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(1, DepthStencilState.None); int count = flatBatch2D.TriangleVertices.Count; for (int i = 0; i < m_vertices.Count; i += 3) { Vector2 p = m_startOffset + m_vertices[i]; Vector2 p2 = m_startOffset + m_vertices[i + 1]; Vector2 p3 = m_startOffset + m_vertices[i + 2]; flatBatch2D.QueueTriangle(p, p2, p3, 0f, color); } flatBatch2D.TransformTriangles(base.GlobalTransform, count); }
public void DrawOverlay(Camera camera, Color color, float innerFactor, float outerFactor) { Vector2 viewportSize = camera.ViewportSize; Vector2 vector = new Vector2(0f, 0f); Vector2 vector2 = new Vector2(viewportSize.X, 0f); Vector2 vector3 = new Vector2(viewportSize.X, viewportSize.Y); Vector2 vector4 = new Vector2(0f, viewportSize.Y); Vector2 p = new Vector2(viewportSize.X / 2f, viewportSize.Y / 2f); Color color2 = color * outerFactor; Color color3 = color * innerFactor; FlatBatch2D flatBatch2D = m_primitivesRenderer2D.FlatBatch(0, DepthStencilState.None, null, BlendState.AlphaBlend); int count = flatBatch2D.TriangleVertices.Count; flatBatch2D.QueueTriangle(vector, vector2, p, 0f, color2, color2, color3); flatBatch2D.QueueTriangle(vector2, vector3, p, 0f, color2, color2, color3); flatBatch2D.QueueTriangle(vector3, vector4, p, 0f, color2, color2, color3); flatBatch2D.QueueTriangle(vector4, vector, p, 0f, color2, color2, color3); flatBatch2D.TransformTriangles(camera.ViewportMatrix, count); flatBatch2D.Flush(); }
public override void Draw(DrawContext dc) { if (Texture != null) { SamplerState samplerState = TextureLinearFilter ? SamplerState.LinearWrap : SamplerState.PointWrap; FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None); TexturedBatch2D texturedBatch2D = dc.PrimitivesRenderer2D.TexturedBatch(Texture, useAlphaTest: false, 0, DepthStencilState.None, null, null, samplerState); int count = flatBatch2D.TriangleVertices.Count; int count2 = texturedBatch2D.TriangleVertices.Count; QueueBevelledRectangle(texturedBatch2D, flatBatch2D, Vector2.Zero, base.ActualSize, 0f, BevelSize, CenterColor * base.GlobalColorTransform, BevelColor * base.GlobalColorTransform, ShadowColor * base.GlobalColorTransform, AmbientLight, DirectionalLight, TextureScale); flatBatch2D.TransformTriangles(base.GlobalTransform, count); texturedBatch2D.TransformTriangles(base.GlobalTransform, count2); } else { FlatBatch2D flatBatch2D2 = dc.PrimitivesRenderer2D.FlatBatch(0, DepthStencilState.None); int count3 = flatBatch2D2.TriangleVertices.Count; QueueBevelledRectangle(null, flatBatch2D2, Vector2.Zero, base.ActualSize, 0f, BevelSize, CenterColor * base.GlobalColorTransform, BevelColor * base.GlobalColorTransform, ShadowColor * base.GlobalColorTransform, AmbientLight, DirectionalLight, 0f); flatBatch2D2.TransformTriangles(base.GlobalTransform, count3); } }
public override void Draw(DrawContext dc) { Color color = Color * base.GlobalColorTransform; if (!string.IsNullOrEmpty(m_text)) { Vector2 position = new Vector2(0f - m_scroll, base.ActualSize.Y / 2f); SamplerState samplerState = TextureLinearFilter ? SamplerState.LinearClamp : SamplerState.PointClamp; FontBatch2D fontBatch2D = dc.PrimitivesRenderer2D.FontBatch(Font, 1, DepthStencilState.None, null, null, samplerState); int count = fontBatch2D.TriangleVertices.Count; fontBatch2D.QueueText(Text, position, 0f, color, TextAnchor.VerticalCenter, new Vector2(FontScale), FontSpacing); fontBatch2D.TransformTriangles(base.GlobalTransform, count); } if (!m_hasFocus || !(MathUtils.Remainder(Time.RealTime - m_focusStartTime, 0.5) < 0.25)) { return; } float num = Font.CalculateCharacterPosition(Text, CaretPosition, new Vector2(FontScale), FontSpacing); Vector2 v = new Vector2(0f, base.ActualSize.Y / 2f) + new Vector2(num - m_scroll, 0f); if (m_hasFocus) { if (v.X < 0f) { m_scroll = MathUtils.Max(m_scroll + v.X, 0f); } if (v.X > base.ActualSize.X) { m_scroll += v.X - base.ActualSize.X + 1f; } } FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(1, DepthStencilState.None); int count2 = flatBatch2D.TriangleVertices.Count; flatBatch2D.QueueQuad(v - new Vector2(0f, Font.GlyphHeight / 2f * FontScale * Font.Scale), v + new Vector2(1f, Font.GlyphHeight / 2f * FontScale * Font.Scale), 0f, color); flatBatch2D.TransformTriangles(base.GlobalTransform, count2); }
public override void Overdraw(DrawContext dc) { Color color = new Color(181, 172, 154) * base.GlobalColorTransform; float num = 0.6f; float directionalLight = 0.4f; FlatBatch2D flatBatch2D = dc.PrimitivesRenderer2D.FlatBatch(); int count = flatBatch2D.TriangleVertices.Count; if (Children.Count == 2) { if (SettingsManager.ScreenLayout2 == ScreenLayout.DoubleVertical || SettingsManager.ScreenLayout2 == ScreenLayout.DoubleOpposite) { Vector2 c = new Vector2(base.ActualSize.X / 2f - m_spacing / 2f, -100f); Vector2 c2 = new Vector2(base.ActualSize.X / 2f + m_spacing / 2f, base.ActualSize.Y + 100f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, c, c2, 0f, m_bevel, color, color, Color.Transparent, num, directionalLight, 0f); } if (SettingsManager.ScreenLayout2 == ScreenLayout.DoubleHorizontal) { Vector2 c3 = new Vector2(-100f, base.ActualSize.Y / 2f - m_spacing / 2f); Vector2 c4 = new Vector2(base.ActualSize.X + 100f, base.ActualSize.Y / 2f + m_spacing / 2f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, c3, c4, 0f, m_bevel, color, color, Color.Transparent, num, directionalLight, 0f); } } else if (Children.Count == 3) { if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleVertical || SettingsManager.ScreenLayout3 == ScreenLayout.TripleOpposite) { float x = -100f; float x2 = base.ActualSize.X / 2f - m_spacing / 2f + m_bevel; float x3 = base.ActualSize.X / 2f + m_spacing / 2f - m_bevel; float x4 = base.ActualSize.X + 100f; float y = -100f; float y2 = base.ActualSize.Y / 2f - m_spacing / 2f + m_bevel; float y3 = base.ActualSize.Y / 2f + m_spacing / 2f - m_bevel; float y4 = base.ActualSize.Y + 100f; BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x, y), new Vector2(x2, y4), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x3, y), new Vector2(x4, y2), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x3, y3), new Vector2(x4, y4), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); Color color2 = color * new Color(num, num, num, 1f); flatBatch2D.QueueQuad(new Vector2(x2, y), new Vector2(x3, y4), 0f, color2); flatBatch2D.QueueQuad(new Vector2(x3, y2), new Vector2(x4, y3), 0f, color2); } if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleHorizontal) { float x5 = -100f; float x6 = base.ActualSize.X / 2f - m_spacing / 2f + m_bevel; float x7 = base.ActualSize.X / 2f + m_spacing / 2f - m_bevel; float x8 = base.ActualSize.X + 100f; float y5 = -100f; float y6 = base.ActualSize.Y / 2f - m_spacing / 2f + m_bevel; float y7 = base.ActualSize.Y / 2f + m_spacing / 2f - m_bevel; float y8 = base.ActualSize.Y + 100f; BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x5, y5), new Vector2(x8, y6), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x5, y7), new Vector2(x6, y8), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x7, y7), new Vector2(x8, y8), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); Color color3 = color * new Color(num, num, num, 1f); flatBatch2D.QueueQuad(new Vector2(x5, y6), new Vector2(x8, y7), 0f, color3); flatBatch2D.QueueQuad(new Vector2(x6, y7), new Vector2(x7, y8), 0f, color3); } if (SettingsManager.ScreenLayout3 == ScreenLayout.TripleEven) { float x9 = -100f; float x10 = base.ActualSize.X / 2f - m_spacing / 2f + m_bevel; float x11 = base.ActualSize.X / 2f + m_spacing / 2f - m_bevel; float x12 = base.ActualSize.X + 100f; float x13 = base.ActualSize.X / 4f; float x14 = base.ActualSize.X * 3f / 4f; float y9 = -100f; float y10 = base.ActualSize.Y / 2f - m_spacing / 2f + m_bevel; float y11 = base.ActualSize.Y / 2f + m_spacing / 2f - m_bevel; float y12 = base.ActualSize.Y + 100f; BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x9, y9), new Vector2(x10, y10), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x11, y9), new Vector2(x12, y10), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x13, y11), new Vector2(x14, y12), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); Color color4 = color * new Color(num, num, num, 1f); flatBatch2D.QueueQuad(new Vector2(x10, y9), new Vector2(x11, y10), 0f, color4); flatBatch2D.QueueQuad(new Vector2(x9, y10), new Vector2(x12, y11), 0f, color4); flatBatch2D.QueueQuad(new Vector2(x9, y11), new Vector2(x13, y12), 0f, color4); flatBatch2D.QueueQuad(new Vector2(x14, y11), new Vector2(x12, y12), 0f, color4); } } else if (Children.Count == 4) { float x15 = -100f; float x16 = base.ActualSize.X / 2f - m_spacing / 2f + m_bevel; float x17 = base.ActualSize.X / 2f + m_spacing / 2f - m_bevel; float x18 = base.ActualSize.X + 100f; float y13 = -100f; float y14 = base.ActualSize.Y / 2f - m_spacing / 2f + m_bevel; float y15 = base.ActualSize.Y / 2f + m_spacing / 2f - m_bevel; float y16 = base.ActualSize.Y + 100f; BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x15, y13), new Vector2(x16, y14), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x17, y13), new Vector2(x18, y14), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x15, y15), new Vector2(x16, y16), 0f, 0f - m_bevel, Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); BevelledRectangleWidget.QueueBevelledRectangle(null, flatBatch2D, new Vector2(x17, y15), new Vector2(x18, y16), 0f, 0f - m_bevel, (Children.Count == 3) ? color : Color.Transparent, color, Color.Transparent, num, directionalLight, 0f); Color color5 = color * new Color(num, num, num, 1f); flatBatch2D.QueueQuad(new Vector2(x16, y13), new Vector2(x17, y16), 0f, color5); flatBatch2D.QueueQuad(new Vector2(x15, y14), new Vector2(x18, y15), 0f, color5); } else if (Children.Count > 4) { throw new InvalidOperationException("Too many GameWidgets."); } flatBatch2D.TransformTriangles(base.GlobalTransform, count); }
public void Draw(Camera camera, int drawOrder) { if (drawOrder == m_drawOrders[0]) { ViewUnderWaterDepth = 0f; ViewUnderMagmaDepth = 0f; Vector3 viewPosition = camera.ViewPosition; int x = Terrain.ToCell(viewPosition.X); int y = Terrain.ToCell(viewPosition.Y); int z = Terrain.ToCell(viewPosition.Z); FluidBlock surfaceFluidBlock; float? surfaceHeight = m_subsystemFluidBlockBehavior.GetSurfaceHeight(x, y, z, out surfaceFluidBlock); if (surfaceHeight.HasValue) { if (surfaceFluidBlock is WaterBlock) { ViewUnderWaterDepth = surfaceHeight.Value + 0.1f - viewPosition.Y; } else if (surfaceFluidBlock is MagmaBlock) { ViewUnderMagmaDepth = surfaceHeight.Value + 1f - viewPosition.Y; } } if (ViewUnderWaterDepth > 0f) { int seasonalHumidity = m_subsystemTerrain.Terrain.GetSeasonalHumidity(x, z); int temperature = m_subsystemTerrain.Terrain.GetSeasonalTemperature(x, z) + SubsystemWeather.GetTemperatureAdjustmentAtHeight(y); Color c = BlockColorsMap.WaterColorsMap.Lookup(temperature, seasonalHumidity); float num = MathUtils.Lerp(1f, 0.5f, (float)seasonalHumidity / 15f); float num2 = MathUtils.Lerp(1f, 0.2f, MathUtils.Saturate(0.075f * (ViewUnderWaterDepth - 2f))); float num3 = MathUtils.Lerp(0.33f, 1f, SkyLightIntensity); m_viewFogRange.X = 0f; m_viewFogRange.Y = MathUtils.Lerp(4f, 10f, num * num2 * num3); m_viewFogColor = Color.MultiplyColorOnly(c, 0.66f * num2 * num3); VisibilityRangeYMultiplier = 1f; m_viewIsSkyVisible = false; } else if (ViewUnderMagmaDepth > 0f) { m_viewFogRange.X = 0f; m_viewFogRange.Y = 0.1f; m_viewFogColor = new Color(255, 80, 0); VisibilityRangeYMultiplier = 1f; m_viewIsSkyVisible = false; } else { float num4 = 1024f; float num5 = 128f; int seasonalTemperature = m_subsystemTerrain.Terrain.GetSeasonalTemperature(Terrain.ToCell(viewPosition.X), Terrain.ToCell(viewPosition.Z)); float num6 = MathUtils.Lerp(0.5f, 0f, m_subsystemWeather.GlobalPrecipitationIntensity); float num7 = MathUtils.Lerp(1f, 0.8f, m_subsystemWeather.GlobalPrecipitationIntensity); m_viewFogRange.X = VisibilityRange * num6; m_viewFogRange.Y = VisibilityRange * num7; m_viewFogColor = CalculateSkyColor(new Vector3(camera.ViewDirection.X, 0f, camera.ViewDirection.Z), m_subsystemTimeOfDay.TimeOfDay, m_subsystemWeather.GlobalPrecipitationIntensity, seasonalTemperature); VisibilityRangeYMultiplier = MathUtils.Lerp(VisibilityRange / num4, VisibilityRange / num5, MathUtils.Pow(m_subsystemWeather.GlobalPrecipitationIntensity, 4f)); m_viewIsSkyVisible = true; } if (!FogEnabled) { m_viewFogRange = new Vector2(100000f, 100000f); } if (!DrawSkyEnabled || !m_viewIsSkyVisible || SettingsManager.SkyRenderingMode == SkyRenderingMode.Disabled) { FlatBatch2D flatBatch2D = m_primitivesRenderer2d.FlatBatch(-1, DepthStencilState.None, RasterizerState.CullNoneScissor, BlendState.Opaque); int count = flatBatch2D.TriangleVertices.Count; flatBatch2D.QueueQuad(Vector2.Zero, camera.ViewportSize, 0f, m_viewFogColor); flatBatch2D.TransformTriangles(camera.ViewportMatrix, count); m_primitivesRenderer2d.Flush(); } } else if (drawOrder == m_drawOrders[1]) { if (DrawSkyEnabled && m_viewIsSkyVisible && SettingsManager.SkyRenderingMode != SkyRenderingMode.Disabled) { DrawSkydome(camera); DrawStars(camera); DrawSunAndMoon(camera); DrawClouds(camera); m_primitivesRenderer3d.Flush(camera.ViewProjectionMatrix); } } else { DrawLightning(camera); m_primitivesRenderer3d.Flush(camera.ViewProjectionMatrix); } }