Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
GrassTrapBlock.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class GrassTrapBlock : Block {
6 public static int Index = 87;
7
8 public BlockMesh m_blockMesh = new();
9
11
13
14 public override void Initialize() {
15 Model model = ContentManager.Get<Model>("Models/GrassTrap");
16 Matrix boneAbsoluteTransform = BlockMesh.GetBoneAbsoluteTransform(model.FindMesh("GrassTrap").ParentBone);
17 Color color = BlockColorsMap.Grass.Lookup(8, 15);
18 m_blockMesh.AppendModelMeshPart(
19 model.FindMesh("GrassTrap").MeshParts[0],
20 boneAbsoluteTransform * Matrix.CreateTranslation(0.5f, 0.75f, 0.5f),
21 false,
22 false,
23 false,
24 false,
26 );
27 m_standaloneBlockMesh.AppendModelMeshPart(
28 model.FindMesh("GrassTrap").MeshParts[0],
29 boneAbsoluteTransform,
30 false,
31 false,
32 false,
33 false,
34 color
35 );
36 m_collisionBoxes[0] = new BoundingBox(new Vector3(0f, 0.75f, 0f), new Vector3(1f, 0.95f, 1f));
37 base.Initialize();
38 }
39
40 public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) {
42 this,
43 x,
44 y,
45 z,
47 BlockColorsMap.Grass.Lookup(generator.Terrain, x, y, z),
48 null,
49 null,
50 geometry.SubsetAlphaTest
51 );
52 }
53
54 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer,
55 int value,
56 Color color,
57 float size,
58 ref Matrix matrix,
59 DrawBlockEnvironmentData environmentData) {
60 BlocksManager.DrawMeshBlock(primitivesRenderer, m_standaloneBlockMesh, color, size, ref matrix, environmentData);
61 }
62
64 Vector3 position,
65 int value,
66 float strength) {
68 subsystemTerrain.Terrain,
69 Terrain.ToCell(position.X),
70 Terrain.ToCell(position.Y),
71 Terrain.ToCell(position.Z)
72 );
73 return new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, color, GetFaceTextureSlot(4, value));
74 }
75
76 public override BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value) => m_collisionBoxes;
77 }
78}
Engine.Vector3 Vector3
ModelMesh FindMesh(string name, bool throwIfNotFound=true)
ReadOnlyList< ModelMeshPart > MeshParts
static BlockColorsMap Grass
Color Lookup(int temperature, int humidity)
virtual void GenerateShadedMeshVertices(Block block, int x, int y, int z, BlockMesh blockMesh, Color color, Matrix? matrix, int[] facesMap, TerrainGeometrySubset subset)
float DestructionDebrisScale
virtual int GetFaceTextureSlot(int face, int value)
static Matrix GetBoneAbsoluteTransform(ModelBone modelBone)
static void DrawMeshBlock(PrimitivesRenderer3D primitivesRenderer, BlockMesh blockMesh, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
static object Get(Type type, string name)
override BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
override BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value)
override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
TerrainGeometrySubset SubsetAlphaTest
static int ToCell(float x)
static Color White
static Matrix CreateTranslation(float x, float y, float z)