Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
TallGrassBlock.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class TallGrassBlock : CrossBlock {
6 public static int Index = 19;
7
8 public override void GetDropValues(SubsystemTerrain subsystemTerrain,
9 int oldValue,
10 int newValue,
11 int toolLevel,
12 List<BlockDropValue> dropValues,
13 out bool showDebris) {
14 int data = Terrain.ExtractData(oldValue);
15 if (!GetIsSmall(data)) {
16 dropValues.Add(new BlockDropValue { Value = Terrain.MakeBlockValue(19, 0, data), Count = 1 });
17 }
18 showDebris = true;
19 }
20
21 public override int GetFaceTextureSlot(int face, int value) {
22 if (!GetIsSmall(Terrain.ExtractData(value))) {
23 return 85;
24 }
25 return 84;
26 }
27
28 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer,
29 int value,
30 Color color,
31 float size,
32 ref Matrix matrix,
33 DrawBlockEnvironmentData environmentData) {
35 primitivesRenderer,
36 value,
37 size,
38 ref matrix,
39 null,
40 color * BlockColorsMap.Grass.Lookup(environmentData.Temperature, environmentData.Humidity),
41 false,
42 environmentData
43 );
44 }
45
46 public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) {
48 this,
49 value,
50 x,
51 y,
52 z,
53 BlockColorsMap.Grass.Lookup(generator.Terrain, x, y, z),
54 GetFaceTextureSlot(0, value),
55 geometry.SubsetAlphaTest
56 );
57 }
58
59 public override int GetShadowStrength(int value) {
60 if (!GetIsSmall(Terrain.ExtractData(value))) {
62 }
63 return DefaultShadowStrength / 2;
64 }
65
67 Vector3 position,
68 int value,
69 float strength) {
71 subsystemTerrain.Terrain,
72 Terrain.ToCell(position.X),
73 Terrain.ToCell(position.Y),
74 Terrain.ToCell(position.Z)
75 );
76 return new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, color, GetFaceTextureSlot(4, value));
77 }
78
79 public static bool GetIsSmall(int data) => (data & 8) != 0;
80
81 public static int SetIsSmall(int data, bool isSmall) {
82 if (!isSmall) {
83 return data & -9;
84 }
85 return data | 8;
86 }
87 }
88}
static BlockColorsMap Grass
Color Lookup(int temperature, int humidity)
virtual void GenerateCrossfaceVertices(Block block, int value, int x, int y, int z, Color color, int textureSlot, TerrainGeometrySubset subset)
float DestructionDebrisScale
int DefaultShadowStrength
static void DrawFlatOrImageExtrusionBlock(PrimitivesRenderer3D primitivesRenderer, int value, float size, ref Matrix matrix, Texture2D texture, Color color, bool isEmissive, DrawBlockEnvironmentData environmentData)
override int GetFaceTextureSlot(int face, int value)
static int SetIsSmall(int data, bool isSmall)
override BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
override int GetShadowStrength(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)
static bool GetIsSmall(int data)
override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
TerrainGeometrySubset SubsetAlphaTest
static int ToCell(float x)
static int MakeBlockValue(int contents)
static int ExtractData(int value)