Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #10 from VT-DevGiT/devlopement
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
warquys authored Dec 14, 2022
2 parents 0fc06f8 + 7033633 commit abe140f
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 23 deletions.
10 changes: 6 additions & 4 deletions VT-Api/Core/Audio/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace VT_Api.Core.Audio
{
public class AudioManager
internal class AudioManager
{
#region Attributes & Properties
public static AudioManager Get => Singleton<AudioManager>.Instance;
Expand All @@ -16,7 +16,8 @@ public class AudioManager
#endregion

#region Constructors & Destructor
internal AudioManager() {
internal AudioManager()
{

Synapse.Api.Logger.Get.Debug("AudioRun");
}
Expand All @@ -27,13 +28,12 @@ internal AudioManager() {

internal void Init()
{
//_controller = new Controller();
_controller = new Controller();
}

public void Loop(bool enabled)
{
_controller.Loop = enabled;
//Synapse.Api.Logger.Get.Info($"Loop : {_controller.Loop}");
}

private void UnmutePlayer(Player player)
Expand All @@ -45,6 +45,8 @@ private void UnmutePlayer(Player player)
private void MutePlayer(Player player)
{
var id = player.Radio.mirrorIgnorancePlayer._playerId;
if (_controller.MutedPlayers.Contains(id))
return;
_controller.MutePlayer(id);
}

Expand Down
31 changes: 23 additions & 8 deletions VT-Api/Core/Audio/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,24 @@ internal class Controller
public FakeMicrophone Microphone;

public bool Loop { get; set; }
public float Volume { get; set; } = 1;

public readonly List<string> MutedPlayers = new List<string>();
public float _volume;
/// <summary>
/// It was in %
/// </summary>
public float Volume
{
get
{
return _volume * 100;
}
set
{
_volume = Mathf.Clamp(value, 0, 100) / 100;
}
}

public List<string> MutedPlayers { get; } = new List<string>();
#endregion

#region Constructors & Destructor
Expand All @@ -36,11 +51,12 @@ public Controller()
public void UnMutePlayer(string playerId)
{
MutedPlayers.Remove(playerId);
UnMutePlayer(playerId);
Comms.PlayerChannels.Open(playerId, false, ChannelPriority.Default, Volume);
Comms.PlayerChannels.Open(playerId, false, ChannelPriority.Default, _volume);
}

public void MutePlayer(string playerId)
{
MutedPlayers.Add(playerId);
var channel = Comms.PlayerChannels._openChannelsBySubId.FirstOrDefault(x => x.Value.TargetId == playerId);
Comms.PlayerChannels.Close(channel.Value);
}
Expand Down Expand Up @@ -68,7 +84,7 @@ public IEnumerator<float> PlayFromFile(string path, float volume = 100, bool loo
yield return Timing.WaitForOneFrame;
yield return Timing.WaitForOneFrame;

Volume = Mathf.Clamp(volume, 0, 100) / 100;
Volume = volume;
RefreshChannels();

Microphone.File = new FileStream(path, FileMode.Open);
Expand All @@ -90,7 +106,7 @@ public void RefreshChannels()
foreach (var channel in Comms.PlayerChannels._openChannelsBySubId.Values.ToList())
{
Comms.PlayerChannels.Close(channel);
Comms.PlayerChannels.Open(channel.TargetId, false, ChannelPriority.Default, Volume);
Comms.PlayerChannels.Open(channel.TargetId, false, ChannelPriority.Default, _volume);
}
}

Expand All @@ -112,10 +128,9 @@ private void OnWaitingForPlayers()

private void OnPlayerJoinedSession(VoicePlayerState player)
{
Comms.PlayerChannels.Open(player.Name, false, ChannelPriority.Default, Volume);
Comms.PlayerChannels.Open(player.Name, false, ChannelPriority.Default, _volume);
}

#endregion

}
}
5 changes: 3 additions & 2 deletions VT-Api/Core/Audio/FakeMicrophone.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Dissonance.Audio.Capture;
using Dissonance;
using Dissonance.Audio.Capture;
using Dissonance.Networking;
using NAudio.Wave;
using System;
Expand All @@ -24,7 +25,7 @@ internal class FakeMicrophone : MonoBehaviour, IMicrophoneCapture

private readonly WaveFormat _format = new WaveFormat(48000, 1);
private readonly float[] _frame = new float[960];
private readonly byte[] _frameBytes = new byte[960 * 4];
private readonly byte[] _frameBytes = new byte[960 * sizeof(float)];

private float _elapsedTime;

Expand Down
2 changes: 1 addition & 1 deletion VT-Api/Core/Translation/TranslationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace VT_Api.Core.Translation
{
public class TranslationManager
internal class TranslationManager
{

#region Properties & Variables
Expand Down
4 changes: 2 additions & 2 deletions VT-Api/Patches/VtEvent/ItemPatches/ChangeIntoGrenadePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace VT_Api.Patches.VtEvent.ItemPatches
class ChangeIntoFragPatch
{
[HarmonyPrefix]
private static bool ExplosionDetectedPatch(TimedGrenadePickup __instance, Footprint attacker, Vector3 source, float range)
private static bool ExplosionDetectedPatch(TimedGrenadePickup __instance, object attacker, Vector3 error, Vector3 source, float range)
{
try
{
Expand All @@ -28,7 +28,7 @@ private static bool ExplosionDetectedPatch(TimedGrenadePickup __instance, Footpr
return false;

__instance._replaceNextFrame = true;
__instance._attacker = attacker;
__instance._attacker = (Footprint)attacker;
}
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions VT-Api/VtController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ public class VtController
public static VtController Get { get; private set; }

internal AutoRegisterManager AutoRegister { get => Singleton<AutoRegisterManager>.Instance; } // nothing public (yet)
public AudioManager Audio { get => Singleton<AudioManager>.Instance; }
internal AudioManager Audio { get => Singleton<AudioManager>.Instance; } // need patch
internal MiniGameManager MinGames { get => Singleton<MiniGameManager>.Instance; } // not finish
public RoleManager Role { get => Singleton<RoleManager>.Instance; }
public TeamManager Team { get => Singleton<TeamManager>.Instance; }
public EventHandler Events { get => Singleton<EventHandler>.Instance; }
public MapAndRoundManger MapAction { get => Singleton<MapAndRoundManger>.Instance; }
public NetworkLiar NetworkLiar { get => Singleton<NetworkLiar>.Instance; }
public ItemManager Item { get => Singleton<ItemManager>.Instance; }
public TranslationManager Translation { get => Singleton<TranslationManager>.Instance; }
internal TranslationManager Translation { get => Singleton<TranslationManager>.Instance; } // not finish
internal NpcManger Npc { get => Singleton<NpcManger>.Instance; } // not finish
internal CommandHandler Commands { get => Singleton<CommandHandler>.Instance; } // nothing public (yet)

Expand Down Expand Up @@ -97,16 +97,16 @@ private void LogMessage()
private void InitAll()
{
TryInit(AutoRegister.Init, "Initialising AutoRegister failed");
TryInit(Audio.Init, "Initialising Audio failed");
TryInit(MinGames.Init, "Initialising MinGames failed");
//TryInit(Audio.Init, "Initialising Audio failed");
//TryInit(MinGames.Init, "Initialising MinGames failed");
TryInit(Events.Init, "Initialising Events failed");
TryInit(Commands.Init, "Initialising Commands failed");
TryInit(Configs.Init, "Initialising Configs failed");
TryInit(Team.Init, "Initialising Team failed");
TryInit(Role.Init, "Initialising Role failed");
TryInit(Item.Init, "Initialising Item failed");
TryInit(Translation.Init, "Initialising Translation failed");
TryInit(Npc.Init, "Initialising Npc failed");
//TryInit(Translation.Init, "Initialising Translation failed");
//TryInit(Npc.Init, "Initialising Npc failed");
}

private void TryInit(Action init, string msg)
Expand Down

0 comments on commit abe140f

Please sign in to comment.