Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
WoodBlock.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
4 public abstract class WoodBlock : CubeBlock {
5 public int m_cutTextureSlot;
6
7 public int m_sideTextureSlot;
8
9 public WoodBlock(int cutTextureSlot, int sideTextureSlot) {
10 m_cutTextureSlot = cutTextureSlot;
11 m_sideTextureSlot = sideTextureSlot;
12 }
13
14 public override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z) {
15 switch (GetCutFace(Terrain.ExtractData(value))) {
16 case 4:
17 generator.GenerateCubeVertices(
18 this,
19 value,
20 x,
21 y,
22 z,
24 geometry.OpaqueSubsetsByFace
25 ); break;
26 case 0:
27 generator.GenerateCubeVertices(
28 this,
29 value,
30 x,
31 y,
32 z,
33 1,
34 0,
35 0,
37 geometry.OpaqueSubsetsByFace
38 ); break;
39 default:
40 generator.GenerateCubeVertices(
41 this,
42 value,
43 x,
44 y,
45 z,
46 0,
47 1,
48 1,
50 geometry.OpaqueSubsetsByFace
51 ); break;
52 }
53 }
54
55 public override int GetFaceTextureSlot(int face, int value) {
56 int cutFace = GetCutFace(Terrain.ExtractData(value));
57 if (cutFace == face
58 || CellFace.OppositeFace(cutFace) == face) {
59 return m_cutTextureSlot;
60 }
61 return m_sideTextureSlot;
62 }
63
64 public override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain,
65 ComponentMiner componentMiner,
66 int value,
67 TerrainRaycastResult raycastResult) {
69 float num = float.NegativeInfinity;
70 int cutFace = 0;
71 for (int i = 0; i < 6; i++) {
72 float num2 = Vector3.Dot(CellFace.FaceToVector3(i), forward);
73 if (num2 > num) {
74 num = num2;
75 cutFace = i;
76 }
77 }
78 BlockPlacementData result = default;
79 result.Value = Terrain.MakeBlockValue(BlockIndex, 0, SetCutFace(0, cutFace));
80 result.CellFace = raycastResult.CellFace;
81 return result;
82 }
83
84 public override void GetDropValues(SubsystemTerrain subsystemTerrain,
85 int oldValue,
86 int newValue,
87 int toolLevel,
88 List<BlockDropValue> dropValues,
89 out bool showDebris) {
90 if (toolLevel >= GetRequiredToolLevel(oldValue)) {
91 int data = Terrain.ExtractData(oldValue);
92 data = SetCutFace(data, 4);
93 dropValues.Add(new BlockDropValue { Value = Terrain.MakeBlockValue(BlockIndex, 0, data), Count = 1 });
94 }
95 showDebris = true;
96 }
97
98 public static int GetCutFace(int data) {
99 data &= 3;
100 switch (data) {
101 case 0: return 4;
102 case 1: return 0;
103 default: return 1;
104 }
105 }
106
107 public static int SetCutFace(int data, int cutFace) {
108 data &= -4;
109 switch (cutFace) {
110 case 0:
111 case 2: return data | 1;
112 case 1:
113 case 3: return data | 2;
114 default: return data;
115 }
116 }
117 }
118}
virtual void GenerateCubeVertices(Block block, int value, int x, int y, int z, Color color, TerrainGeometrySubset[] subsetsByFace)
int BlockIndex
定义 Block.cs:6
virtual float GetRequiredToolLevel(int value)
ComponentCreatureModel ComponentCreatureModel
ComponentCreature ComponentCreature
TerrainGeometrySubset[] OpaqueSubsetsByFace
static int MakeBlockValue(int contents)
static int ExtractData(int value)
static int SetCutFace(int data, int cutFace)
WoodBlock(int cutTextureSlot, int sideTextureSlot)
override void GetDropValues(SubsystemTerrain subsystemTerrain, int oldValue, int newValue, int toolLevel, List< BlockDropValue > dropValues, out bool showDebris)
override BlockPlacementData GetPlacementValue(SubsystemTerrain subsystemTerrain, ComponentMiner componentMiner, int value, TerrainRaycastResult raycastResult)
方块放置方向
override int GetFaceTextureSlot(int face, int value)
static int GetCutFace(int data)
override void GenerateTerrainVertices(BlockGeometryGenerator generator, TerrainGeometry geometry, int value, int x, int y, int z)
static Color White
static Matrix CreateFromQuaternion(Quaternion quaternion)
Vector3 Forward
static float Dot(Vector3 v1, Vector3 v2)
static int OppositeFace(int face)
static Vector3 FaceToVector3(int face)