Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
FallenLeavesBlock.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class FallenLeavesBlock : CubeBlock {
6 public const int Index = 261;
7
8 public const float m_height = 0.0625f;
9
10 public BoundingBox[] m_collisionBoxes = [new(new Vector3(0f, 0f, 0f), new Vector3(1f, m_height, 1f))];
11
12 public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) {
13 Color sideColor = new(180, 170, 160);
14 Color color = GetColor(x, y, z);
15 Color color2 = GetColor(x, y, z + 1);
16 Color color3 = GetColor(x + 1, y, z);
17 Color color4 = GetColor(x + 1, y, z + 1);
18 generator.GenerateCubeVertices(
19 this,
20 value,
21 x,
22 y,
23 z,
28 sideColor,
29 color,
30 color3,
31 color4,
32 color2,
33 -1,
35 );
36 }
37
38 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer,
39 int value,
40 Color color,
41 float size,
42 ref Matrix matrix,
43 DrawBlockEnvironmentData environmentData) {
45 primitivesRenderer,
46 value,
47 new Vector3(size),
49 ref matrix,
50 color,
51 color,
52 environmentData
53 );
54 }
55
57 Vector3 position,
58 int value,
59 float strength) {
60 Color color = GetColor(Terrain.ToCell(position.X), Terrain.ToCell(position.Y), Terrain.ToCell(position.Z));
61 return new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, color, GetFaceTextureSlot(4, value));
62 }
63
64 public override void GetDropValues(SubsystemTerrain subsystemTerrain,
65 int oldValue,
66 int newValue,
67 int toolLevel,
68 List<BlockDropValue> dropValues,
69 out bool showDebris) {
70 showDebris = true;
71 }
72
73 public override BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value) => m_collisionBoxes;
74
75 public static Color GetColor(int x, int y, int z) {
76 uint num = (uint)MathUtils.Hash(x + y * 59 + z * 2411);
77 return Color.Lerp(new Color(128, 110, 110), new Color(255, 255, 220), num / 4.2949673E+09f);
78 }
79 }
80}
Engine.Color Color
Engine.Vector3 Vector3
static int Hash(int key)
virtual void GenerateCubeVertices(Block block, int value, int x, int y, int z, Color color, TerrainGeometrySubset[] subsetsByFace)
float DestructionDebrisScale
virtual int GetFaceTextureSlot(int face, int value)
static void DrawCubeBlock(PrimitivesRenderer3D primitivesRenderer, int value, Vector3 size, ref Matrix matrix, Color color, Color topColor, DrawBlockEnvironmentData environmentData)
override BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value)
override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List< BlockDropValue > dropValues, out bool showDebris)
override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
override BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
static Color GetColor(int x, int y, int z)
TerrainGeometrySubset[] AlphaTestSubsetsByFace
static int ToCell(float x)
static Color Lerp(Color c1, Color c2, float f)