Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
BlockIconWidget.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class BlockIconWidget : Widget {
7
8 public int m_value;
9
11
12 public Vector2 Size { get; set; }
13
14 public float Depth { get; set; }
15
16 public Color Color { get; set; }
17
18 public Matrix? CustomViewMatrix { get; set; }
19
20 public int Value {
21 get => m_value;
22 set {
23 if (m_value == 0
24 || value != m_value) {
25 m_value = value;
29 new Vector3(0f, 0f, 0f),
31 );
32 }
33 }
34 }
35
36 public int Contents {
38 set => Value = Terrain.ReplaceContents(Value, value);
39 }
40
41 public int Light {
43 set => Value = Terrain.ReplaceLight(Value, value);
44 }
45
46 public int Data {
48 set => Value = Terrain.ReplaceData(Value, value);
49 }
50
51 public float Scale { get; set; }
52
53 public BlockIconWidget() {
55 Size = new Vector2(float.PositiveInfinity);
56 IsHitTestVisible = false;
57 Light = 15;
58 Depth = 1f;
59 Color = Color.White;
60 Scale = 1f;
61 }
62
63 public override void Draw(DrawContext dc) {
66 ? DrawBlockEnvironmentData.SubsystemTerrain.SubsystemAnimatedTextures.AnimatedBlocksTexture
68 Viewport viewport = Display.Viewport;
69 float num = MathUtils.Min(ActualSize.X, ActualSize.Y) * Scale;
70 Matrix m = Matrix.CreateOrthographic(3.6f, 3.6f, -10f - 1f * Depth, 10f - 1f * Depth);
71 Matrix m2 = MatrixUtils.CreateScaleTranslation(num, 0f - num, ActualSize.X / 2f, ActualSize.Y / 2f)
73 * MatrixUtils.CreateScaleTranslation(2f / viewport.Width, -2f / viewport.Height, -1f, 1f);
77 Matrix matrix = CustomViewMatrix.HasValue
81 }
82
83 public override void MeasureOverride(Vector2 parentAvailableSize) {
84 IsDrawRequired = true;
86 }
87 }
88}
static Viewport Viewport
static int Min(int x1, int x2)
virtual Vector3 GetIconBlockOffset(int value, DrawBlockEnvironmentData environmentData)
virtual float GetIconViewScale(int value, DrawBlockEnvironmentData environmentData)
void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
绘制方块_用于绘制方块物品形态
virtual Vector3 GetIconViewOffset(int value, DrawBlockEnvironmentData environmentData)
DrawBlockEnvironmentData DrawBlockEnvironmentData
override void Draw(DrawContext dc)
override void MeasureOverride(Vector2 parentAvailableSize)
static Matrix CreateScaleTranslation(float sx, float sy, float tx, float ty)
static int ExtractContents(int value)
static int ReplaceData(int value, int data)
static int ExtractLight(int value)
static int ReplaceLight(int value, int light)
static int ReplaceContents(int value, int contents)
方块值的最低10位,替换为目标Content
static int ExtractData(int value)
readonly PrimitivesRenderer3D PrimitivesRenderer3D
Color GlobalColorTransform
Vector2 DesiredSize
bool IsDrawRequired
virtual bool IsHitTestVisible
Vector2 ActualSize
Matrix GlobalTransform
static Matrix CreateTranslation(float x, float y, float z)
static readonly Matrix Identity
static Matrix CreateLookAt(Vector3 position, Vector3 target, Vector3 up)
static Matrix CreateOrthographic(float width, float height, float nearPlane, float farPlane)
static readonly Vector3 UnitY