Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemBottomSuckerBlockBehavior.cs
浏览该文件的文档.
1using Engine;
3
4namespace Game {
6 public override int[] HandledBlocks => [];
7
9
10 public override void Load(ValuesDictionary valuesDictionary) {
11 base.Load(valuesDictionary);
13 }
14
15 public override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ) {
16 int bottomSuckerBlockValue = SubsystemTerrain.Terrain.GetCellValue(x, y, z);
17 base.OnNeighborBlockChanged(x, y, z, neighborX, neighborY, neighborZ);
18 int face = BottomSuckerBlock.GetFace(Terrain.ExtractData(bottomSuckerBlockValue));
20 int cellValue = SubsystemTerrain.Terrain.GetCellValue(x + point.X, y + point.Y, z + point.Z);
21 if (!IsSupport(cellValue, face, bottomSuckerBlockValue)) {
23 0,
24 x,
25 y,
26 z,
27 0,
28 false,
29 false
30 );
31 }
32 }
33
34 public override void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody) {
36 ComponentHealth componentHealth = componentBody.Entity.FindComponent<ComponentHealth>();
37 if (componentHealth != null) {
38 componentHealth.OnSpiked(
39 this,
40 0.1f / componentHealth.SpikeResilience * MathF.Abs(velocity),
41 cellFace,
42 velocity,
43 componentBody,
44 "Spiked by a sea creature"
45 );
46 }
47 }
48 }
49
50 public virtual bool IsSupport(int value, int face, int bottomSuckerBlockValue = 226) {
52 if (block.IsCollidable_(value)) {
53 return !block.IsFaceNonAttachable(SubsystemTerrain, CellFace.OppositeFace(face), value, bottomSuckerBlockValue);
54 }
55 return false;
56 }
57 }
58}
virtual bool IsFaceNonAttachable(SubsystemTerrain subsystemTerrain, int face, int value, int attachBlockValue)
virtual bool IsCollidable_(int value)
static int GetBlockIndex(string BlockName, bool throwIfNotFound=false)
通过方块名称来获取方块的Index
virtual void OnSpiked(SubsystemBlockBehavior spikeBlockBehavior, float damage, CellFace cellFace, float velocity, ComponentBody componentBody, string causeOfDeath)
virtual bool IsSupport(int value, int face, int bottomSuckerBlockValue=226)
override void OnCollide(CellFace cellFace, float velocity, ComponentBody componentBody)
override void OnNeighborBlockChanged(int x, int y, int z, int neighborX, int neighborY, int neighborZ)
override void Load(ValuesDictionary valuesDictionary)
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 ExtractData(int value)
Component FindComponent(Type type, string name, bool throwOnError)
static int OppositeFace(int face)
static Point3 FaceToPoint3(int face)