Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemFertilizerBlockBehavior.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
7
9
11
12 public override int[] HandledBlocks => [102];
13
14 public override bool OnUse(Ray3 ray, ComponentMiner componentMiner) {
15 TerrainRaycastResult? terrainRaycastResult = componentMiner.Raycast<TerrainRaycastResult>(ray, RaycastMode.Interaction);
16 if (terrainRaycastResult.HasValue
17 && terrainRaycastResult.Value.CellFace.Face == 4) {
18 int y = terrainRaycastResult.Value.CellFace.Y;
19 for (int i = terrainRaycastResult.Value.CellFace.X - 1; i <= terrainRaycastResult.Value.CellFace.X + 1; i++) {
20 for (int j = terrainRaycastResult.Value.CellFace.Z - 1; j <= terrainRaycastResult.Value.CellFace.Z + 1; j++) {
21 int cellValue = m_subsystemTerrain.Terrain.GetCellValue(i, y, j);
22 if (Terrain.ExtractContents(cellValue) == 168) {
23 int data = SoilBlock.SetNitrogen(Terrain.ExtractData(cellValue), 3);
24 int value = Terrain.ReplaceData(cellValue, data);
25 m_subsystemTerrain.ChangeCell(i, y, j, value);
26 }
27 }
28 }
29 m_subsystemAudio.PlayRandomSound(
30 "Audio/Impacts/Dirt",
31 0.5f,
32 0f,
33 new Vector3(terrainRaycastResult.Value.CellFace.X, terrainRaycastResult.Value.CellFace.Y, terrainRaycastResult.Value.CellFace.Z),
34 3f,
35 true
36 );
37 Vector3 position = new(
38 terrainRaycastResult.Value.CellFace.X + 0.5f,
39 terrainRaycastResult.Value.CellFace.Y + 1.5f,
40 terrainRaycastResult.Value.CellFace.Z + 0.5f
41 );
43 m_subsystemParticles.AddParticleSystem(
44 block.CreateDebrisParticleSystem(m_subsystemTerrain, position, componentMiner.ActiveBlockValue, 1.25f)
45 );
46 componentMiner.RemoveActiveTool(1);
47 return true;
48 }
49 return false;
50 }
51
52 public override void Load(ValuesDictionary valuesDictionary) {
53 base.Load(valuesDictionary);
54 m_subsystemTerrain = Project.FindSubsystem<SubsystemTerrain>(true);
55 m_subsystemParticles = Project.FindSubsystem<SubsystemParticles>(true);
56 m_subsystemAudio = Project.FindSubsystem<SubsystemAudio>(true);
57 }
58 }
59}
Engine.Vector3 Vector3
virtual BlockDebrisParticleSystem CreateDebrisParticleSystem(SubsystemTerrain subsystemTerrain, Vector3 position, int value, float strength)
virtual void RemoveActiveTool(int removeCount)
virtual object Raycast(Ray3 ray, RaycastMode mode, bool raycastTerrain=true, bool raycastBodies=true, bool raycastMovingBlocks=true, float? Reach=null)
发出射线检测,检测玩家点击到的目标
static int SetNitrogen(int data, int nitrogen)
override bool OnUse(Ray3 ray, ComponentMiner componentMiner)
override void Load(ValuesDictionary valuesDictionary)
static int ExtractContents(int value)
static int ReplaceData(int value, int data)
static int ExtractData(int value)
ValuesDictionary ValuesDictionary