public void Draw(SpriteBatch spriteBatch, Rectangle container, float zoom) { if (!Enabled) { return; } UISprite uiSprite = GUI.Style.RadiationSprite; var(offsetX, offsetY) = Map.DrawOffset * zoom; var(centerX, centerY) = container.Center.ToVector2(); var(halfSizeX, halfSizeY) = new Vector2(container.Width / 2f, container.Height / 2f) * zoom; float viewBottom = centerY + Map.Height * zoom; Vector2 topLeft = new Vector2(centerX + offsetX - halfSizeX, centerY + offsetY - halfSizeY); Vector2 size = new Vector2((Amount - increasedAmount) * zoom + halfSizeX, viewBottom - topLeft.Y); if (size.X < 0) { return; } Vector2 spriteScale = new Vector2(zoom); uiSprite.Sprite.DrawTiled(spriteBatch, topLeft, size, Params.RadiationAreaColor, Vector2.Zero, textureScale: spriteScale); Vector2 topRight = topLeft + Vector2.UnitX * size.X; int index = 0; for (float i = 0; i <= size.Y; i += sheet.FrameSize.Y / 2f * zoom) { bool isEven = ++index % 2 == 0; Vector2 origin = new Vector2(0.5f, 0) * sheet.FrameSize.X; // every other sprite's animation is reversed to make it seem more chaotic int sprite = (int)MathF.Floor(isEven ? spriteIndex : maxFrames - spriteIndex); sheet.Draw(spriteBatch, sprite, topRight + new Vector2(0, i), Params.RadiationBorderTint, origin, 0f, spriteScale); } isHovingOver = container.Contains(PlayerInput.MousePosition) && PlayerInput.MousePosition.X < topLeft.X + size.X; }
public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphics, float deltaTime) { if (GameMain.Config.EnableSplashScreen) { try { DrawSplashScreen(spriteBatch, graphics); if (currSplashScreen != null || PendingSplashScreens.Count > 0) { return; } } catch (Exception e) { DebugConsole.ThrowError("Playing splash screen video failed", e); GameMain.Config.EnableSplashScreen = false; } } var titleStyle = GUI.Style?.GetComponentStyle("TitleText"); Sprite titleSprite = null; if (!WaitForLanguageSelection && titleStyle != null && titleStyle.Sprites.ContainsKey(GUIComponent.ComponentState.None)) { titleSprite = titleStyle.Sprites[GUIComponent.ComponentState.None].First()?.Sprite; } drawn = true; currentBackgroundTexture ??= defaultBackgroundTexture; spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, samplerState: GUI.SamplerState); float scale = (GameMain.GraphicsWidth / (float)currentBackgroundTexture.Width) * 1.2f; float paddingX = currentBackgroundTexture.Width * scale - GameMain.GraphicsWidth; float paddingY = currentBackgroundTexture.Height * scale - GameMain.GraphicsHeight; double noiseT = (Timing.TotalTime * 0.02f); Vector2 pos = new Vector2((float)PerlinNoise.CalculatePerlin(noiseT, noiseT, 0) - 0.5f, (float)PerlinNoise.CalculatePerlin(noiseT, noiseT, 0.5f) - 0.5f); pos = new Vector2(pos.X * paddingX, pos.Y * paddingY); spriteBatch.Draw(currentBackgroundTexture, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight) / 2 + pos, null, Color.White, 0.0f, new Vector2(currentBackgroundTexture.Width / 2, currentBackgroundTexture.Height / 2), scale, SpriteEffects.None, 0.0f); spriteBatch.Draw(overlay, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.0f); float noiseStrength = (float)PerlinNoise.CalculatePerlin(noiseT, noiseT, 0); float noiseScale = (float)PerlinNoise.CalculatePerlin(noiseT * 5.0f, noiseT * 2.0f, 0) * 4.0f; noiseSprite.DrawTiled(spriteBatch, Vector2.Zero, new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight), startOffset: new Point(Rand.Range(0, noiseSprite.SourceRect.Width), Rand.Range(0, noiseSprite.SourceRect.Height)), color: Color.White * noiseStrength * 0.1f, textureScale: Vector2.One * noiseScale); titleSprite?.Draw(spriteBatch, new Vector2(GameMain.GraphicsWidth * 0.05f, GameMain.GraphicsHeight * 0.125f), Color.White, origin: new Vector2(0.0f, titleSprite.SourceRect.Height / 2.0f), scale: GameMain.GraphicsHeight / 2000.0f); if (WaitForLanguageSelection) { DrawLanguageSelectionPrompt(spriteBatch, graphics); } else if (DrawLoadingText) { if (TextManager.Initialized) { string loadText; if (LoadState == 100.0f) { #if DEBUG if (GameMain.Config.AutomaticQuickStartEnabled && GameMain.FirstLoad) { loadText = "QUICKSTARTING ..."; } else { #endif loadText = TextManager.Get("PressAnyKey"); #if DEBUG } #endif } else { loadText = TextManager.Get("Loading"); if (LoadState != null) { loadText += " " + (int)LoadState + " %"; } } if (GUI.LargeFont != null) { GUI.LargeFont.DrawString(spriteBatch, loadText.ToUpper(), new Vector2(GameMain.GraphicsWidth / 2.0f - GUI.LargeFont.MeasureString(loadText.ToUpper()).X / 2.0f, GameMain.GraphicsHeight * 0.75f), Color.White); } } if (GUI.Font != null && selectedTip != null) { string wrappedTip = ToolBox.WrapText(selectedTip, GameMain.GraphicsWidth * 0.5f, GUI.Font); string[] lines = wrappedTip.Split('\n'); float lineHeight = GUI.Font.MeasureString(selectedTip).Y; for (int i = 0; i < lines.Length; i++) { GUI.Font.DrawString(spriteBatch, lines[i], new Vector2((int)(GameMain.GraphicsWidth / 2.0f - GUI.Font.MeasureString(lines[i]).X / 2.0f), (int)(GameMain.GraphicsHeight * 0.8f + i * lineHeight)), Color.White); } } } spriteBatch.End(); spriteBatch.Begin(blendState: BlendState.Additive); Vector2 decorativeScale = new Vector2(GameMain.GraphicsHeight / 1080.0f); float noiseVal = (float)PerlinNoise.CalculatePerlin(Timing.TotalTime * 0.25f, Timing.TotalTime * 0.5f, 0); decorativeGraph.Draw(spriteBatch, (int)(decorativeGraph.FrameCount * noiseVal), new Vector2(GameMain.GraphicsWidth * 0.001f, GameMain.GraphicsHeight * 0.24f), Color.White, Vector2.Zero, 0.0f, decorativeScale, SpriteEffects.FlipVertically); decorativeMap.Draw(spriteBatch, (int)(decorativeMap.FrameCount * noiseVal), new Vector2(GameMain.GraphicsWidth * 0.99f, GameMain.GraphicsHeight * 0.66f), Color.White, decorativeMap.FrameSize.ToVector2(), 0.0f, decorativeScale); if (noiseVal < 0.2f) { //SCP-CB reference randText = (new string[] { "NIL", "black white gray", "Sometimes we would have had time to scream", "e8m106]af", "NO" }).GetRandom(); } else if (noiseVal < 0.3f) { randText = ToolBox.RandomSeed(9); } else if (noiseVal < 0.5f) { randText = Rand.Int(100).ToString().PadLeft(2, '0') + " " + Rand.Int(100).ToString().PadLeft(2, '0') + " " + Rand.Int(100).ToString().PadLeft(2, '0') + " " + Rand.Int(100).ToString().PadLeft(2, '0'); } GUI.LargeFont?.DrawString(spriteBatch, randText, new Vector2(GameMain.GraphicsWidth - decorativeMap.FrameSize.X * decorativeScale.X * 0.8f, GameMain.GraphicsHeight * 0.57f), Color.White * (1.0f - noiseVal)); spriteBatch.End(); }