Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
PanoramaWidget.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class PanoramaWidget : Widget {
6 public static string TexturePath = "Textures/Gui/Panorama";
7
9
10 public float m_timeOffset;
11
12 public Texture2D Texture { get; set; }
13
14 public PanoramaWidget() {
16 m_timeOffset = new Random().Float(0f, 1000f);
17 }
18
19 public virtual void DrawImage(DrawContext dc) {
20 float num = (float)MathUtils.Remainder(Time.FrameStartTime + m_timeOffset, 10000.0);
21 float x = 2f * SimplexNoise.OctavedNoise(num, 0.02f, 4, 2f, 0.5f) - 1f;
22 float y = 2f * SimplexNoise.OctavedNoise(num + 100f, 0.02f, 4, 2f, 0.5f) - 1f;
23 m_position += 0.06f * new Vector2(x, y) * MathUtils.Min(Time.FrameDuration, 0.1f);
24 m_position.X = MathUtils.Remainder(m_position.X, 1f);
25 m_position.Y = MathUtils.Remainder(m_position.Y, 1f);
26 float f = 0.5f * MathUtils.PowSign(MathF.Sin(0.21f * num + 2f), 2f) + 0.5f;
27 float num2 = MathUtils.Lerp(0.3f, 0.5f, f);
28 float num3 = num2 / Texture.Height * Texture.Width / ActualSize.X * ActualSize.Y;
29 float x2 = m_position.X;
30 float y2 = m_position.Y;
31 Vector2 zero = Vector2.Zero;
32 Vector2 actualSize = ActualSize;
33 Vector2 texCoord = new(x2 - num2, y2 - num3);
34 Vector2 texCoord2 = new(x2 + num2, y2 + num3);
36 Texture,
37 false,
38 0,
40 null,
43 );
44 int count = texturedBatch2D.TriangleVertices.Count;
45 texturedBatch2D.QueueQuad(zero, actualSize, 1f, texCoord, texCoord2, GlobalColorTransform);
46 texturedBatch2D.TransformTriangles(GlobalTransform, count);
47 }
48
49 public virtual void DrawSquares(DrawContext dc) {
51 int count = flatBatch2D.LineVertices.Count;
52 int count2 = flatBatch2D.TriangleVertices.Count;
53 float num = (float)MathUtils.Remainder(Time.FrameStartTime + m_timeOffset, 10000.0);
54 float num2 = ActualSize.X / 12f;
55 float num3 = GlobalColorTransform.A / 255f;
56 for (float num4 = 0f; num4 < ActualSize.X; num4 += num2) {
57 for (float num5 = 0f; num5 < ActualSize.Y; num5 += num2) {
58 float num6 = 0.35f
59 * MathF.Pow(
62 num4 + 1000f,
63 num5,
64 0.7f * num,
65 0.5f,
66 1,
67 2f,
68 1f
69 )
70 - 0.1f
71 ),
72 1f
73 )
74 * num3;
75 float num7 = 0.7f
76 * MathF.Pow(
78 num4,
79 num5,
80 0.5f * num,
81 0.5f,
82 1,
83 2f,
84 1f
85 ),
86 3f
87 )
88 * num3;
89 Vector2 corner = new(num4, num5);
90 Vector2 corner2 = new(num4 + num2, num5 + num2);
91 if (num6 > 0.01f) {
92 flatBatch2D.QueueRectangle(corner, corner2, 0f, new Color(0f, 0f, 0f, num6));
93 }
94 if (num7 > 0.01f) {
95 flatBatch2D.QueueQuad(corner, corner2, 0f, new Color(0f, 0f, 0f, num7));
96 }
97 }
98 }
99 flatBatch2D.TransformLines(GlobalTransform, count);
100 flatBatch2D.TransformTriangles(GlobalTransform, count2);
101 }
102
103 public override void MeasureOverride(Vector2 parentAvailableSize) {
104 IsDrawRequired = true;
105 }
106
107 public override void Draw(DrawContext dc) {
108 DrawImage(dc);
109 DrawSquares(dc);
110 }
111 }
112}
Engine.Color Color
void TransformLines(Matrix matrix, int start=0, int end=-1)
readonly DynamicArray< VertexPositionColor > TriangleVertices
readonly DynamicArray< VertexPositionColor > LineVertices
void TransformTriangles(Matrix matrix, int start=0, int end=-1)
void TransformTriangles(Matrix matrix, int start=0, int end=-1)
readonly DynamicArray< VertexPositionColorTexture > TriangleVertices
static readonly BlendState AlphaBlend
static readonly DepthStencilState None
static readonly DepthStencilState DepthWrite
void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Color color)
void QueueRectangle(Vector2 corner1, Vector2 corner2, float depth, Color color)
TexturedBatch2D TexturedBatch(Texture2D texture, bool useAlphaTest=false, int layer=0, DepthStencilState depthStencilState=null, RasterizerState rasterizerState=null, BlendState blendState=null, SamplerState samplerState=null)
FlatBatch2D FlatBatch(int layer=0, DepthStencilState depthStencilState=null, RasterizerState rasterizerState=null, BlendState blendState=null)
void QueueQuad(Vector2 corner1, Vector2 corner2, float depth, Vector2 texCoord1, Vector2 texCoord2, Color color)
static float Remainder(float x, float y)
static int Min(int x1, int x2)
static float Saturate(float x)
static float PowSign(float x, float n)
static float Lerp(float x1, float x2, float f)
static float FrameDuration
定义 Time.cs:46
static double FrameStartTime
定义 Time.cs:42
static object Get(Type type, string name)
virtual void DrawImage(DrawContext dc)
override void Draw(DrawContext dc)
override void MeasureOverride(Vector2 parentAvailableSize)
virtual void DrawSquares(DrawContext dc)
float Float()
static float OctavedNoise(float x, float frequency, int octaves, float frequencyStep, float amplitudeStep, bool ridged=false)
readonly PrimitivesRenderer2D PrimitivesRenderer2D
Color GlobalColorTransform
bool IsDrawRequired
Vector2 ActualSize
Matrix GlobalTransform
static readonly Vector2 Zero