Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
CarpetBlock.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
5 public class CarpetBlock : CubeBlock {
6 public static int Index = 208;
7
8 public BoundingBox[] m_collisionBoxes = [new(new Vector3(0f, 0f, 0f), new Vector3(1f, 0.0625f, 1f))];
9
11
12 public override bool IsFaceTransparent(SubsystemTerrain subsystemTerrain, int face, int value) => face != 5;
13
14 public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) {
15 int data = Terrain.ExtractData(value);
16 Color fabricColor = SubsystemPalette.GetFabricColor(generator, GetColor(data));
17 generator.GenerateCubeVertices(
18 this,
19 value,
20 x,
21 y,
22 z,
23 0.0625f,
24 0.0625f,
25 0.0625f,
26 0.0625f,
27 fabricColor,
28 fabricColor,
29 fabricColor,
30 fabricColor,
31 fabricColor,
32 -1,
33 geometry.OpaqueSubsetsByFace
34 );
35 }
36
37 public override void DrawBlock(PrimitivesRenderer3D primitivesRenderer,
38 int value,
39 Color color,
40 float size,
41 ref Matrix matrix,
42 DrawBlockEnvironmentData environmentData) {
43 int data = Terrain.ExtractData(value);
44 color *= SubsystemPalette.GetFabricColor(environmentData, GetColor(data));
46 primitivesRenderer,
47 value,
48 new Vector3(size, 0.0625f * size, size),
49 ref matrix,
50 color,
51 color,
52 environmentData
53 );
54 }
55
56 public override IEnumerable<int> GetCreativeValues() {
57 int i = 0;
58 while (i < 16) {
59 yield return Terrain.MakeBlockValue(208, 0, i);
60 int num = i + 1;
61 i = num;
62 }
63 }
64
65 public override void GetDropValues(SubsystemTerrain subsystemTerrain,
66 int oldValue,
67 int newValue,
68 int toolLevel,
69 List<BlockDropValue> dropValues,
70 out bool showDebris) {
71 showDebris = true;
72 if (toolLevel >= RequiredToolLevel) {
73 int data = Terrain.ExtractData(oldValue);
74 dropValues.Add(new BlockDropValue { Value = Terrain.MakeBlockValue(208, 0, data), Count = 1 });
75 }
76 }
77
79 Vector3 position,
80 int value,
81 float strength) {
82 int data = Terrain.ExtractData(value);
83 Color fabricColor = SubsystemPalette.GetFabricColor(subsystemTerrain, GetColor(data));
84 return new BlockDebrisParticleSystem(subsystemTerrain, position, strength, DestructionDebrisScale, fabricColor, DefaultTextureSlot);
85 }
86
87 public override CraftingRecipe GetAdHocCraftingRecipe(SubsystemTerrain subsystemTerrain,
88 string[] ingredients,
89 float heatLevel,
90 float playerLevel) {
91 if (heatLevel < 1f) {
92 return null;
93 }
94 List<string> list = ingredients.Where(i => !string.IsNullOrEmpty(i)).ToList();
95 if (list.Count == 2) {
96 int num = 0;
97 int num2 = 0;
98 int num3 = 0;
99 foreach (string item in list) {
100 CraftingRecipesManager.DecodeIngredient(item, out string craftingId, out int? data);
101 if (craftingId == BlocksManager.Blocks[208].CraftingId) {
102 num3 = Terrain.MakeBlockValue(208, 0, data ?? 0);
103 }
104 else if (craftingId == BlocksManager.Blocks[129].CraftingId) {
105 num = Terrain.MakeBlockValue(129, 0, data ?? 0);
106 }
107 else if (craftingId == BlocksManager.Blocks[128].CraftingId) {
108 num2 = Terrain.MakeBlockValue(128, 0, data ?? 0);
109 }
110 }
111 if (num != 0
112 && num3 != 0) {
113 int num4 = Terrain.ExtractData(num3);
115 int damage = BlocksManager.Blocks[129].GetDamage(num);
116 Block block = BlocksManager.Blocks[129];
117 int num5 = PaintBucketBlock.CombineColors(num4, color);
118 if (num5 != num4) {
119 return new CraftingRecipe {
120 ResultCount = 1,
121 ResultValue = Terrain.MakeBlockValue(208, 0, num5),
122 RemainsCount = 1,
123 RemainsValue =
124 BlocksManager.DamageItem(Terrain.MakeBlockValue(129, 0, color), damage + MathUtils.Max(block.Durability / 4, 1)),
125 RequiredHeatLevel = 1f,
126 Description = $"Dye carpet {SubsystemPalette.GetName(subsystemTerrain, color, null)}",
127 Ingredients = (string[])ingredients.Clone()
128 };
129 }
130 }
131 if (num2 != 0
132 && num3 != 0) {
133 int num6 = Terrain.ExtractData(num3);
134 int damage2 = BlocksManager.Blocks[128].GetDamage(num2);
135 Block block2 = BlocksManager.Blocks[128];
136 if (num6 != 0) {
137 return new CraftingRecipe {
138 ResultCount = 1,
139 ResultValue = Terrain.MakeBlockValue(208, 0, 0),
140 RemainsCount = 1,
141 RemainsValue = BlocksManager.DamageItem(
142 Terrain.MakeBlockValue(128, 0, 0),
143 damage2 + MathUtils.Max(block2.Durability / 4, 1)
144 ),
145 RequiredHeatLevel = 1f,
146 Description = "Undye carpet",
147 Ingredients = (string[])ingredients.Clone()
148 };
149 }
150 }
151 }
152 return null;
153 }
154
156
157 public override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value) {
158 int value2 = Terrain.ExtractData(value);
159 return SubsystemPalette.GetName(subsystemTerrain, value2, LanguageControl.GetBlock("CarpetBlock", "DisplayName"));
160 }
161
162 public static int GetColor(int data) => data & 0xF;
163
164 public static int SetColor(int data, int color) => (data & -16) | (color & 0xF);
165 }
166}
Engine.Vector3 Vector3
static int Max(int x1, int x2)
virtual void GenerateCubeVertices(Block block, int value, int x, int y, int z, Color color, TerrainGeometrySubset[] subsetsByFace)
bool CanBeBuiltIntoFurniture
float DestructionDebrisScale
string CraftingId
virtual int GetDamage(int value)
int DefaultTextureSlot
int RequiredToolLevel
static int DamageItem(int value, int damageCount, Entity owner=null)
static void DrawCubeBlock(PrimitivesRenderer3D primitivesRenderer, int value, Vector3 size, ref Matrix matrix, Color color, Color topColor, DrawBlockEnvironmentData environmentData)
override string GetDisplayName(SubsystemTerrain subsystemTerrain, int value)
BoundingBox[] m_collisionBoxes
override BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value)
override void DrawBlock(PrimitivesRenderer3D primitivesRenderer, int value, Color color, float size, ref Matrix matrix, DrawBlockEnvironmentData environmentData)
override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List< BlockDropValue > dropValues, out bool showDebris)
static int GetColor(int data)
static int SetColor(int data, int color)
override bool IsFaceTransparent(SubsystemTerrain subsystemTerrain, int face, int value)
override CraftingRecipe GetAdHocCraftingRecipe(SubsystemTerrain subsystemTerrain, string[] ingredients, float heatLevel, float playerLevel)
override BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
override IEnumerable< int > GetCreativeValues()
static void DecodeIngredient(string ingredient, out string craftingId, out int? data)
static string GetBlock(string blockName, string prop)
static int GetColor(int data)
static int CombineColors(int color1, int color2)
TerrainGeometrySubset[] OpaqueSubsetsByFace
static int MakeBlockValue(int contents)
static int ExtractData(int value)