Skip to content

Commit

Permalink
sounds: Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Jay-Gatsby committed Feb 13, 2023
1 parent 674cdb2 commit c13239f
Show file tree
Hide file tree
Showing 71 changed files with 1,131 additions and 2,803 deletions.
2 changes: 2 additions & 0 deletions VisualPinball.Engine/VPT/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@ public static class TroughType
public const int TwoCoilsOneSwitch = 3;
public const int ClassicSingleBall = 4;
}


}
53 changes: 53 additions & 0 deletions VisualPinball.Engine/VPT/ISoundEmitter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Visual Pinball Engine
// Copyright (C) 2023 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using Unity.VisualScripting.YamlDotNet.Core.Tokens;
using UnityEngine;

namespace VisualPinball.Engine.VPT
{
//Implemented in components relating to sounds, including the Mechanical Sounds component.
public interface ISoundEmitter
{
SoundTrigger[] AvailableTriggers { get;}
VolumeEmitter[] GetVolumeEmitters(SoundTrigger trigger);
event EventHandler<SoundEventArgs> OnSound;
}

public struct SoundTrigger
{
public string Id;
public string Name;

}

//The emitter for the sound trigger. Determines how the volume will be calculated.
//Example: The "Fixed" volume emitter would be an emitter for the "Coil On" trigger. Same volume as configured by the sound asset.
//Example: The "Ball Velocity" volume emitter would be an emitter for the "Ball Collision" trigger. Volume depends on the ball velocity upon collision.
public struct VolumeEmitter
{
public string Id;
public string Name;
}

public struct SoundEventArgs
{
public SoundTrigger Trigger;
public float Volume;
}
}
11 changes: 11 additions & 0 deletions VisualPinball.Engine/VPT/ISoundEmitter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions VisualPinball.Engine/VPT/MechSounds.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 100 additions & 0 deletions VisualPinball.Engine/VPT/MechSounds/MechSoundsData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Visual Pinball Engine
// Copyright (C) 2023 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using VisualPinball.Engine.IO;
using System.IO;
using VisualPinball.Engine.VPT.Table;
using UnityEngine;

namespace VisualPinball.Engine.VPT.MechSounds
{
[Serializable]
public class MechSoundsData : ItemData
{

public override string GetName() => Name;
public override void SetName(string name) { Name = name; }

[BiffString("NAME", IsWideString = true, Pos = 14)]
public string Name = string.Empty;
public SoundTrigger[] AvailableTriggers;
public SoundTrigger SelectedTrigger;
public VolumeEmitter[] AvailableEmitters;

[Serializable]
public class MechSound
{
public int Trigger;
public ScriptableObject Sound;
public int Volume;
public float VolumeValue = 1;
public actionType Action = actionType.PlayOnce;
public float Fade = 50;

}

void AddNew()
{
SoundList.Add(new MechSound());
}

void Remove(int index)
{
SoundList.RemoveAt(index);
}

public List<MechSound> SoundList;
public enum actionType { PlayOnce, Loop };

#region BIFF


public MechSoundsData() : base(StoragePrefix.VpeGameItem)
{
}

public MechSoundsData(string name) : base(StoragePrefix.VpeGameItem)
{
Name = name;
}

static MechSoundsData()
{
Init(typeof(MechSoundsData), Attributes);
}

public MechSoundsData(BinaryReader reader, string storageName) : this(storageName)
{
Load(this, reader, Attributes);
}

public override void Write(BinaryWriter writer, HashWriter hashWriter)
{
writer.Write((int)ItemType.Flipper);
WriteRecord(writer, Attributes, hashWriter);
WriteEnd(writer, hashWriter);
}

private static readonly Dictionary<string, List<BiffAttribute>> Attributes = new Dictionary<string, List<BiffAttribute>>();

#endregion


}
}

11 changes: 11 additions & 0 deletions VisualPinball.Engine/VPT/MechSounds/MechSoundsData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion VisualPinball.Unity/Assets/Presets.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Loading

0 comments on commit c13239f

Please sign in to comment.