From 549833f3e97f5eac7cd97d7952fa27f83e4a8462 Mon Sep 17 00:00:00 2001 From: smok1e Date: Mon, 7 Jul 2025 22:03:50 +0300 Subject: [PATCH] Added countdown beep sound for Self-Destructing card --- .../ocelot/desktop/audio/SoundSource.scala | 3 +++ .../desktop/node/ComputerAwareNode.scala | 21 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/scala/ocelot/desktop/audio/SoundSource.scala b/src/main/scala/ocelot/desktop/audio/SoundSource.scala index 9568f44..5598fec 100644 --- a/src/main/scala/ocelot/desktop/audio/SoundSource.scala +++ b/src/main/scala/ocelot/desktop/audio/SoundSource.scala @@ -132,4 +132,7 @@ object SoundSource { lazy val MachineFloppyEject: SoundSource = SoundSource.fromBuffer(SoundBuffers.MachineFloppyEject, SoundCategory.Environment) + + lazy val SelfDestructingCardBeep: SoundSource = + BeepGenerator.newBeep(".", 1000, 100) } diff --git a/src/main/scala/ocelot/desktop/node/ComputerAwareNode.scala b/src/main/scala/ocelot/desktop/node/ComputerAwareNode.scala index 3b7477f..1e1264c 100644 --- a/src/main/scala/ocelot/desktop/node/ComputerAwareNode.scala +++ b/src/main/scala/ocelot/desktop/node/ComputerAwareNode.scala @@ -2,6 +2,7 @@ package ocelot.desktop.node import ocelot.desktop.{ColorScheme, OcelotDesktop, Settings => DesktopSettings} import ocelot.desktop.audio._ +import ocelot.desktop.geometry.{Vector2D, Vector3D} import ocelot.desktop.graphics.{Graphics, IconSource} import ocelot.desktop.inventory.SyncedInventory import ocelot.desktop.node.ComputerAwareNode._ @@ -13,6 +14,7 @@ import ocelot.desktop.ui.particle.Particle import ocelot.desktop.util.Messages import totoro.ocelot.brain.Settings import totoro.ocelot.brain.entity.traits.{Entity, Environment, WorkspaceAware} +import totoro.ocelot.brain.entity.SelfDestructingCard import totoro.ocelot.brain.event._ import java.util.Calendar @@ -22,12 +24,16 @@ abstract class ComputerAwareNode(entity: Entity with Environment with WorkspaceA with SyncedInventory with DiskActivityHandler with OcelotLogParticleNode - with ShiftClickNode { + with ShiftClickNode + with PositionalSoundSourcesNode { private lazy val soundCardSounds: (SoundStream, SoundSource) = Audio.newStream(SoundCategory.Records) private def soundCardStream: SoundStream = soundCardSounds._1 private def soundCardSource: SoundSource = soundCardSounds._2 + // PositionalSoundSourcesNode + override def soundSources: Seq[SoundSource] = Seq(SoundSource.MinecraftExplosion) + eventHandlers += { case BrainEvent(event: MachineCrashEvent) => val message = Messages.lift(event.message) match { @@ -58,6 +64,19 @@ abstract class ComputerAwareNode(entity: Entity with Environment with WorkspaceA }) } + override def update(): Unit = { + for (slot <- brainInventory.inventory) { + slot.get match { + case Some(card: SelfDestructingCard) => + if (card.time > 0 && card.time % 20 == 0) { + SoundSource.SelfDestructingCardBeep.play() + } + case _ => + } + } + super.update() + } + protected def drawOverlay(g: Graphics): Unit = HolidayIcon match { case Some(icon) if DesktopSettings.get.enableFestiveDecorations => val holidayOverlaySize = Size * 1.6f