Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemWaterBlockBehavior.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public Random m_random = new();
6
7 public float m_soundVolume;
8
9 public override int[] HandledBlocks => [18];
10
12
13 public SubsystemWaterBlockBehavior() : base(BlocksManager.FluidBlocks[18], true) { }
14
15 public virtual void Update(float dt) {
16 if (SubsystemTime.PeriodicGameTimeEvent(0.25, 0.0)) {
18 }
19 if (SubsystemTime.PeriodicGameTimeEvent(1.0, 0.25)) {
20 float num = float.MaxValue;
21 foreach (Vector3 listenerPosition in SubsystemAudio.ListenerPositions) {
22 float? num2 = CalculateDistanceToFluid(listenerPosition, 8, true);
23 if (num2.HasValue
24 && num2.Value < num) {
25 num = num2.Value;
26 }
27 }
28 m_soundVolume = 0.5f * SubsystemAudio.CalculateVolume(num, 2f, 3.5f);
29 }
31 }
32
33 public override bool OnFluidInteract(int interactValue, int x, int y, int z, int fluidValue) {
34 if (BlocksManager.Blocks[Terrain.ExtractContents(interactValue)] is MagmaBlock) {
35 SubsystemAudio.PlayRandomSound("Audio/Sizzles", 1f, m_random.Float(-0.1f, 0.1f), new Vector3(x, y, z), 5f, true);
37 0,
38 x,
39 y,
40 z,
41 0,
42 false,
43 false
44 );
45 Set(x, y, z, 3);
46 return true;
47 }
48 return base.OnFluidInteract(interactValue, x, y, z, fluidValue);
49 }
50
51 public override void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue) {
52 if (y > 80
54 dropValue.Value = Terrain.MakeBlockValue(62);
55 }
56 else {
57 base.OnItemHarvested(x, y, z, blockValue, ref dropValue, ref newBlockValue);
58 }
59 }
60 }
61}
static int Max(int x1, int x2)
void Set(int x, int y, int z, int value)
float? CalculateDistanceToFluid(Vector3 p, int radius, bool flowingFluidOnly)
SubsystemFluidBlockBehavior(FluidBlock fluidBlock, bool generateSources)
virtual void DestroyCell(int toolLevel, int x, int y, int z, int newValue, bool noDrop, bool noParticleSystem, MovingBlock movingBlock=null)
override bool OnFluidInteract(int interactValue, int x, int y, int z, int fluidValue)
override void OnItemHarvested(int x, int y, int z, int blockValue, ref BlockDropValue dropValue, ref int newBlockValue)
static Func< int, int, bool > IsPlaceFrozen
static int ExtractContents(int value)
virtual int GetSeasonalTemperature(int x, int z)
static int MakeBlockValue(int contents)