From b5568e2a682c4bac2e3a80d90628650fbb4c8ca2 Mon Sep 17 00:00:00 2001 From: spatialfree Date: Mon, 4 Nov 2024 04:28:05 -0500 Subject: [PATCH] refactor out to SFX class --- src/Mono.cs | 12 ++---------- src/Rig.cs | 1 - src/SFX.cs | 13 +++++++++++++ 3 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 src/SFX.cs diff --git a/src/Mono.cs b/src/Mono.cs index 80e2846..5d1c916 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -30,14 +30,6 @@ static class Mono public static DeltaBool food_fall = new(false); public static double eat_timestamp = 0.0; - // put in SFX static class - static void PlayBox(this Sound sound, XYZi pos) - { - sound.Play(box_pose.ToMatrix(box_scale) * pos.ToVec3); - } - public static Sound sfx_crisp_nom = Sound.FromFile("sfx/crisp_nom.mp3"); - public static Sound sfx_punch_through = Sound.FromFile("sfx/punch_through.mp3"); - public static void Init() { for (int i = 0; i < snake.Length; i++) @@ -145,7 +137,7 @@ static class Mono if (in_box.delta != 0) // 1 just in -1 just out { holes.Add(snake[0], snake_dir); - sfx_punch_through.PlayBox(snake[0]); + SFX.punch_through.PlayBox(snake[0]); } if (holes.ContainsKey(snake[snake_len - 1])) { @@ -165,7 +157,7 @@ static class Mono grow_buffer += 3; Feed(); - sfx_crisp_nom.PlayBox(snake[0]); + SFX.crisp_nom.PlayBox(snake[0]); } } diff --git a/src/Rig.cs b/src/Rig.cs index 0031a11..cac778d 100644 --- a/src/Rig.cs +++ b/src/Rig.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using StereoKit; namespace snake; diff --git a/src/SFX.cs b/src/SFX.cs new file mode 100644 index 0000000..968b239 --- /dev/null +++ b/src/SFX.cs @@ -0,0 +1,13 @@ +using StereoKit; + +namespace snake; + +static class SFX +{ + public static void PlayBox(this Sound sound, XYZi pos) + { + sound.Play(Mono.box_pose.ToMatrix(Mono.box_scale) * pos.ToVec3); + } + public static Sound crisp_nom = Sound.FromFile("sfx/crisp_nom.mp3"); + public static Sound punch_through = Sound.FromFile("sfx/punch_through.mp3"); +} \ No newline at end of file