Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemFallenLeavesBlockBehavior.cs
浏览该文件的文档.
2
3namespace Game {
6
8
9 Random m_random = new();
10
11 public override int[] HandledBlocks => [];
12
13 public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ) {
16 0,
17 x,
18 y,
19 z,
20 0,
21 false,
22 false
23 );
24 }
25 }
26
27 public override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded) {
28 UpdateFallenLeaves(x, y, z);
29 }
30
31 public override void OnPoll(int value, int x, int y, int z, int pollPass) {
32 if (m_random.Bool(0.5f)) {
33 UpdateFallenLeaves(x, y, z);
34 }
35 }
36
37 public override void Load(ValuesDictionary valuesDictionary) {
38 base.Load(valuesDictionary);
39 m_subsystemTerrain = Project.FindSubsystem<SubsystemTerrain>(true);
40 m_subsystemSeasons = Project.FindSubsystem<SubsystemSeasons>(true);
41 }
42
43 public static bool CanSupportFallenLeaves(int value) {
44 int num = Terrain.ExtractContents(value);
45 return !BlocksManager.Blocks[num].IsTransparent_(value);
46 }
47
48 public static bool StopsFallenLeaves(int value) {
49 int num = Terrain.ExtractContents(value);
50 Block block = BlocksManager.Blocks[num];
51 if (!(block is AirBlock)) {
52 return !(block is LeavesBlock);
53 }
54 return false;
55 }
56
57 public static bool CanBeReplacedByFallenLeaves(int value) => Terrain.ExtractContents(value) == 0;
58
59 void UpdateFallenLeaves(int x, int y, int z) {
60 if (m_subsystemSeasons.Season == Season.Spring
61 || m_subsystemSeasons.Season == Season.Summer) {
62 m_subsystemTerrain.DestroyCell(
63 0,
64 x,
65 y,
66 z,
68 true,
69 true
70 );
71 }
72 }
73 }
74}
virtual bool IsTransparent_(int value)
override void OnPoll(int value, int x, int y, int z, int pollPass)
override void Load(ValuesDictionary valuesDictionary)
override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ)
override void OnBlockGenerated(int value, int x, int y, int z, bool isLoaded)
virtual void DestroyCell(int toolLevel, int x, int y, int z, int newValue, bool noDrop, bool noParticleSystem, MovingBlock movingBlock=null)
static int ExtractContents(int value)
virtual int GetCellValue(int x, int y, int z)
static int MakeBlockValue(int contents)
ValuesDictionary ValuesDictionary