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