Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
RyeBlock.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class RyeBlock : CrossBlock {
6 public static int Index = 174;
7
8 public override IEnumerable<int> GetCreativeValues() {
9 yield return Terrain.MakeBlockValue(174, 0, SetIsWild(SetSize(0, 7), true));
10 yield return Terrain.MakeBlockValue(174, 0, SetIsWild(SetSize(0, 1), false));
11 yield return Terrain.MakeBlockValue(174, 0, SetIsWild(SetSize(0, 3), false));
12 yield return Terrain.MakeBlockValue(174, 0, SetIsWild(SetSize(0, 5), false));
13 yield return Terrain.MakeBlockValue(174, 0, SetIsWild(SetSize(0, 7), false));
14 }
15
16 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer,
17 int value,
18 Color color,
19 float size,
20 ref Matrix matrix,
21 DrawBlockEnvironmentData environmentData) {
22 if (GetIsWild(Terrain.ExtractData(value))) {
23 color *= BlockColorsMap.Grass.Lookup(environmentData.Temperature, environmentData.Humidity);
25 primitivesRenderer,
26 value,
27 size,
28 ref matrix,
29 null,
30 color,
31 false,
32 environmentData
33 );
34 }
35 else {
37 primitivesRenderer,
38 value,
39 size,
40 ref matrix,
41 null,
42 color,
43 false,
44 environmentData
45 );
46 }
47 }
48
49 public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) {
50 if (GetIsWild(Terrain.ExtractData(value))) {
51 Color color = BlockColorsMap.Grass.Lookup(generator.Terrain, x, y, z);
53 this,
54 value,
55 x,
56 y,
57 z,
58 color,
59 GetFaceTextureSlot(0, value),
60 geometry.SubsetAlphaTest
61 );
62 }
63 else {
65 this,
66 value,
67 x,
68 y,
69 z,
71 GetFaceTextureSlot(0, value),
72 geometry.SubsetAlphaTest
73 );
74 }
75 }
76
77 public override int GetShadowStrength(int value) => GetSize(Terrain.ExtractData(value)) + 1;
78
80 Vector3 position,
81 int value,
82 float strength) {
83 if (GetIsWild(Terrain.ExtractData(value))) {
85 subsystemTerrain.Terrain,
86 Terrain.ToCell(position.X),
87 Terrain.ToCell(position.Y),
88 Terrain.ToCell(position.Z)
89 );
91 subsystemTerrain,
92 position,
93 strength,
95 color,
96 GetFaceTextureSlot(4, value)
97 );
98 }
100 subsystemTerrain,
101 position,
102 strength,
104 Color.White,
105 GetFaceTextureSlot(4, value)
106 );
107 }
108
109 public override int GetFaceTextureSlot(int face, int value) {
110 int data = Terrain.ExtractData(value);
111 int size = GetSize(data);
112 if (GetIsWild(data)) {
113 if (size > 2) {
114 return 87;
115 }
116 return 86;
117 }
118 return 88 + size;
119 }
120
121 public override void GetDropValues(SubsystemTerrain subsystemTerrain,
122 int oldValue,
123 int newValue,
124 int toolLevel,
125 List<BlockDropValue> dropValues,
126 out bool showDebris) {
127 int num = 0;
128 int data = 0;
129 int data2 = Terrain.ExtractData(oldValue);
130 int size = GetSize(data2);
131 bool isWild = GetIsWild(data2);
132 if (isWild) {
133 num = size > 2 && Random.Float(0f, 1f) < 0.33f ? 1 : 0;
134 data = 4;
135 }
136 else {
137 switch (size) {
138 case 5:
139 num = 1;
140 data = 4;
141 break;
142 case 6:
143 num = Random.Int(1, 2);
144 data = 4;
145 break;
146 case 7:
147 num = Random.Int(1, 3);
148 data = 5;
149 break;
150 }
151 }
152 showDebris = true;
153 BlockDropValue item;
154 for (int i = 0; i < num; i++) {
155 item = new BlockDropValue { Value = Terrain.MakeBlockValue(173, 0, data), Count = 1 };
156 dropValues.Add(item);
157 }
158 if (size == 7
159 && !isWild
160 && Random.Bool(0.5f)) {
161 item = new BlockDropValue { Value = 248, Count = 1 };
162 dropValues.Add(item);
163 }
164 }
165
166 public static int GetSize(int data) => data & 7;
167
168 public static int SetSize(int data, int size) {
169 size = Math.Clamp(size, 0, 7);
170 return (data & -8) | (size & 7);
171 }
172
173 public static bool GetIsWild(int data) => (data & 8) != 0;
174
175 public static int SetIsWild(int data, bool isWild) {
176 if (!isWild) {
177 return data & -9;
178 }
179 return data | 8;
180 }
181 }
182}
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
static void DrawFlatOrImageExtrusionBlock(PrimitivesRenderer3D primitivesRenderer, int value, float size, ref Matrix matrix, Texture2D texture, Color color, bool isEmissive, DrawBlockEnvironmentData environmentData)
float Float()
override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
static int SetIsWild(int data, bool isWild)
static int SetSize(int data, int size)
static bool GetIsWild(int data)
override int GetFaceTextureSlot(int face, int value)
static int Index
override int GetShadowStrength(int value)
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 IEnumerable< int > GetCreativeValues()
override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List< BlockDropValue > dropValues, out bool showDebris)
static int GetSize(int data)
TerrainGeometrySubset SubsetAlphaTest
static int ToCell(float x)
static int MakeBlockValue(int contents)
static int ExtractData(int value)
static Color White