Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemRakeBlockBehavior.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
7
9
11
12 public override int[] HandledBlocks => [169, 219, 171, 172];
13
14 public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) {
15 TerrainRaycastResult? terrainRaycastResult = componentMiner.Raycast<TerrainRaycastResult>(ray, RaycastMode.Interaction);
16 if (terrainRaycastResult.HasValue) {
17 bool raked = false;
18 if (terrainRaycastResult.Value.CellFace.Face == 4) {
19 int cellValue = m_subsystemTerrain.Terrain.GetCellValue(
20 terrainRaycastResult.Value.CellFace.X,
21 terrainRaycastResult.Value.CellFace.Y,
22 terrainRaycastResult.Value.CellFace.Z
23 );
24 int num = Terrain.ExtractContents(cellValue);
25 Block block = BlocksManager.Blocks[num];
26 switch (num) {
27 case 2: {
28 int value2 = Terrain.ReplaceContents(cellValue, 168);
29 m_subsystemTerrain.ChangeCell(
30 terrainRaycastResult.Value.CellFace.X,
31 terrainRaycastResult.Value.CellFace.Y,
32 terrainRaycastResult.Value.CellFace.Z,
33 value2
34 );
35 m_subsystemAudio.PlayRandomSound(
36 "Audio/Impacts/Dirt",
37 0.5f,
38 0f,
39 new Vector3(
40 terrainRaycastResult.Value.CellFace.X,
41 terrainRaycastResult.Value.CellFace.Y,
42 terrainRaycastResult.Value.CellFace.Z
43 ),
44 3f,
45 true
46 );
47 Vector3 position2 = new(
48 terrainRaycastResult.Value.CellFace.X + 0.5f,
49 terrainRaycastResult.Value.CellFace.Y + 1.25f,
50 terrainRaycastResult.Value.CellFace.Z + 0.5f
51 );
52 m_subsystemParticles.AddParticleSystem(block.CreateDebrisParticleSystem(m_subsystemTerrain, position2, cellValue, 0.5f));
53 raked = true;
54 break;
55 }
56 case 8: {
57 int value = Terrain.ReplaceContents(cellValue, 2);
58 m_subsystemTerrain.ChangeCell(
59 terrainRaycastResult.Value.CellFace.X,
60 terrainRaycastResult.Value.CellFace.Y,
61 terrainRaycastResult.Value.CellFace.Z,
62 value
63 );
64 m_subsystemAudio.PlayRandomSound(
65 "Audio/Impacts/Plant",
66 0.5f,
67 0f,
68 new Vector3(
69 terrainRaycastResult.Value.CellFace.X,
70 terrainRaycastResult.Value.CellFace.Y,
71 terrainRaycastResult.Value.CellFace.Z
72 ),
73 3f,
74 true
75 );
76 Vector3 position = new(
77 terrainRaycastResult.Value.CellFace.X + 0.5f,
78 terrainRaycastResult.Value.CellFace.Y + 1.2f,
79 terrainRaycastResult.Value.CellFace.Z + 0.5f
80 );
81 m_subsystemParticles.AddParticleSystem(block.CreateDebrisParticleSystem(m_subsystemTerrain, position, cellValue, 0.75f));
82 raked = true;
83 break;
84 }
85 }
86 }
87 if (raked) {
88 componentMiner.DamageActiveTool(1);
89 }
90 return raked;
91 }
92 return false;
93 }
94
95 public override void Load(ValuesDictionary valuesDictionary) {
96 base.Load(valuesDictionary);
97 m_subsystemTerrain = Project.FindSubsystem<SubsystemTerrain>(true);
98 m_subsystemParticles = Project.FindSubsystem<SubsystemParticles>(true);
99 m_subsystemAudio = Project.FindSubsystem<SubsystemAudio>(true);
100 }
101 }
102}
Engine.Vector3 Vector3
virtual BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
virtual object Raycast(Ray3 ray, RaycastMode mode, bool raycastTerrain=true, bool raycastBodies=true, bool raycastMovingBlocks=true, float? Reach=null)
发出射线检测,检测玩家点击到的目标
virtual void DamageActiveTool(int damageCount)
override void Load(ValuesDictionary valuesDictionary)
override bool OnUse(Ray3 ray, ComponentMiner componentMiner)
static int ExtractContents(int value)
static int ReplaceContents(int value, int contents)
方块值的最低10位,替换为目标Content
ValuesDictionary ValuesDictionary