Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
CairnBlock.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class CairnBlock : Block {
6 public static int Index = 258;
7
8 public BlockMesh m_mesh = new();
9
11
13
14 public override void Initialize() {
15 Model model = ContentManager.Get<Model>("Models/Cairn");
16 Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("Cairn").ParentBone);
17 Color white = Color.White;
18 BlockMesh blockMesh = new();
19 blockMesh.AppendModelMeshPart(
20 model.FindMesh("Cairn").MeshParts[0],
21 boneAbsoluteTransform * Matrix.CreateRotationX(-(float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f),
22 false,
23 false,
24 false,
25 false,
26 white
27 );
28 BlockMesh blockMesh2 = new();
29 blockMesh2.AppendModelMeshPart(
30 model.FindMesh("Wood").MeshParts[0],
31 boneAbsoluteTransform * Matrix.CreateRotationX(-(float)Math.PI / 2f) * Matrix.CreateTranslation(0.5f, 0f, 0.5f),
32 false,
33 false,
34 false,
35 false,
36 white
37 );
38 m_mesh.AppendBlockMesh(blockMesh);
39 m_mesh.AppendBlockMesh(blockMesh2);
40 m_standaloneMesh.AppendModelMeshPart(
41 model.FindMesh("Cairn").MeshParts[0],
42 boneAbsoluteTransform
43 * Matrix.CreateScale(1.3f)
44 * Matrix.CreateRotationX(-(float)Math.PI / 2f)
45 * Matrix.CreateTranslation(0f, 0f, 0f),
46 false,
47 false,
48 true,
49 false,
50 white
51 );
52 m_standaloneMesh.AppendModelMeshPart(
53 model.FindMesh("Wood").MeshParts[0],
54 boneAbsoluteTransform
55 * Matrix.CreateScale(1.3f)
56 * Matrix.CreateRotationX(-(float)Math.PI / 2f)
57 * Matrix.CreateTranslation(0f, 0f, 0f),
58 false,
59 false,
60 true,
61 false,
62 white
63 );
65 base.Initialize();
66 }
67
68 public override BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value) => m_collisionBoxes;
69
70 public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) {
71 generator.GenerateMeshVertices(
72 this,
73 x,
74 y,
75 z,
76 m_mesh,
78 null,
79 geometry.SubsetOpaque
80 );
81 }
82
83 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer,
84 int value,
85 Color color,
86 float size,
87 ref Matrix matrix,
88 DrawBlockEnvironmentData environmentData) {
89 BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneMesh, color, size, ref matrix, environmentData);
90 }
91
92 public override void GetDropValues(SubsystemTerrain subsystemTerrain,
93 int oldValue,
94 int newValue,
95 int toolLevel,
96 List<BlockDropValue> dropValues,
97 out bool showDebris) {
98 int num = Terrain.ExtractData(oldValue);
99 int num2 = 10 + 4 * num;
100 int num3 = num >= 3 ? 1 : 0;
101 BlockDropValue item;
102 for (int i = 0; i < 3; i++) {
103 item = new BlockDropValue { Value = 79, Count = 1 };
104 dropValues.Add(item);
105 }
106 for (int j = 0; j < num2; j++) {
107 item = new BlockDropValue { Value = 248, Count = 1 };
108 dropValues.Add(item);
109 }
110 for (int k = 0; k < num3; k++) {
111 item = new BlockDropValue { Value = 111, Count = 1 };
112 dropValues.Add(item);
113 }
114 for (int l = 0; l < 2; l++) {
115 item = new BlockDropValue { Value = 23, Count = 1 };
116 dropValues.Add(item);
117 }
118 showDebris = false;
119 }
120 }
121}
ModelMesh FindMesh(string name, bool throwIfNotFound=true)
ReadOnlyList< ModelMeshPart > MeshParts
virtual void GenerateMeshVertices(Block block, int x, int y, int z, BlockMesh blockMesh, Color color, Matrix? matrix, TerrainGeometrySubset subset)
virtual BoundingBox CalculateBoundingBox()
static Matrix GetBoneAbsoluteTransform(ModelBone modelBone)
virtual void AppendModelMeshPart(ModelMeshPart meshPart, Matrix matrix, bool makeEmissive, bool flipWindingOrder, bool doubleSided, bool flipNormals, Color color)
static void DrawMeshBlock(PrimitivesRenderer3D primitivesRenderer, BlockMesh blockMesh, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
BoundingBox[] m_collisionBoxes
override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List< BlockDropValue > dropValues, out bool showDebris)
override void Initialize()
override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
BlockMesh m_standaloneMesh
override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
override BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value)
static object Get(Type type, string name)
TerrainGeometrySubset SubsetOpaque
static int ExtractData(int value)
static Color White
static Matrix CreateRotationX(float radians)
static Matrix CreateTranslation(float x, float y, float z)
static Matrix CreateScale(float scale)