Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemCactusBlockBehavior.cs
浏览该文件的文档.
2
3namespace Game {
6
8
10
11 public Random m_random = new();
12
13 public int m_sandBlockIndex;
14
17
18 public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ) {
19 int cellContents = SubsystemTerrain.Terrain.GetCellContents(x, y - 1, z);
20 if (cellContents != m_sandBlockIndex
21 && cellContents != m_cactusBlockIndex) {
23 0,
24 x,
25 y,
26 z,
27 0,
28 false,
29 false
30 );
31 }
32 }
33
34 public override void OnPoll(int value, int x, int y, int z, int pollPass) {
35 if (m_subsystemGameInfo.WorldSettings.EnvironmentBehaviorMode != 0) {
36 return;
37 }
38 int cellValue = SubsystemTerrain.Terrain.GetCellValue(x, y + 1, z);
39 if (Terrain.ExtractContents(cellValue) == 0
40 && Terrain.ExtractLight(cellValue) >= 12) {
41 int cellContents = SubsystemTerrain.Terrain.GetCellContents(x, y - 1, z);
42 int cellContents2 = SubsystemTerrain.Terrain.GetCellContents(x, y - 2, z);
43 if ((cellContents != m_cactusBlockIndex || cellContents2 != m_cactusBlockIndex)
44 && m_random.Float(0f, 1f) < 0.25f) {
45 m_subsystemCellChangeQueue.QueueCellChange(x, y + 1, z, Terrain.MakeBlockValue(m_cactusBlockIndex, 0, 0));
46 }
47 }
48 }
49
50 public override void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody) {
51 ComponentHealth componentHealth = componentBody.Entity.FindComponent<ComponentHealth>();
52 if (componentHealth != null) {
53 componentHealth.OnSpiked(
54 this,
55 0.1f / componentHealth.SpikeResilience * MathF.Abs(velocity),
56 cellFace,
57 velocity,
58 componentBody,
59 "Spiked by cactus"
60 );
61 }
62 }
63
64 public override void Load(ValuesDictionary valuesDictionary) {
65 m_subsystemTime = Project.FindSubsystem<SubsystemTime>(true);
67 m_subsystemGameInfo = Project.FindSubsystem<SubsystemGameInfo>(true);
70 base.Load(valuesDictionary);
71 }
72 }
73}
static int GetBlockIndex(string BlockName, bool throwIfNotFound=false)
通过方块名称来获取方块的Index
virtual void OnSpiked(SubsystemBlockBehavior spikeBlockBehavior, float damage, CellFace cellFace, float velocity, ComponentBody componentBody, string causeOfDeath)
override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ)
override void OnPoll(int value, int x, int y, int z, int pollPass)
override void Load(ValuesDictionary valuesDictionary)
override void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody)
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)
virtual int GetCellContents(int x, int y, int z)
static int ExtractLight(int value)
static int MakeBlockValue(int contents)
Component FindComponent(Type type, string name, bool throwOnError)
ValuesDictionary ValuesDictionary