Пример #1
0
        public override void OnReceivedServerPacket(int packetid, byte[] data)
        {
            if (packetid == 1025)
            {
                AssetLocation loc = SerializerUtil.Deserialize <AssetLocation>(data);

                if (alarmSound == null)
                {
                    alarmSound = capi.World.LoadSound(new SoundParams()
                    {
                        Location        = loc,
                        Position        = Pos.XYZ.ToVec3f(),
                        Range           = 48,
                        ShouldLoop      = true,
                        SoundType       = EnumSoundType.Sound,
                        Volume          = 0,
                        DisposeOnFinish = false
                    });
                }

                if (!alarmSound.IsPlaying)
                {
                    alarmSound.Start();
                    alarmSound.FadeIn(0.25f, null);
                }
            }

            if (packetid == 1026)
            {
                alarmSound?.FadeOutAndStop(0.25f);
            }

            base.OnReceivedServerPacket(packetid, data);
        }
 public void KillFire(bool consumeFuel)
 {
     IsBurning = false;
     Blockentity.UnregisterGameTickListener(l1);
     Blockentity.UnregisterGameTickListener(l2);
     ambientSound?.FadeOutAndStop(1);
     OnFireDeath(consumeFuel);
 }
Пример #3
0
        public override void OnGameTick(float dt)
        {
            base.OnGameTick(dt);

            if (alarmSound != null && alarmSound.IsPlaying)
            {
                alarmSound.SetPosition((float)Pos.X, (float)Pos.Y, (float)Pos.Z);

                if (!Alive)
                {
                    alarmSound.FadeOutAndStop(0.25f);
                }
            }
        }