<commit_before>// Copyright (c) 2017 <NAME>
#include "Jewel3D/Precompiled.h"
#include "SoundListener.h"

namespace Jwl
{
	Entity::WeakPtr SoundListener::listener;

	SoundListener::SoundListener(Entity& _owner)
		: Component(_owner)
	{
		if (GetListener())
		{
			// If there already is an active SoundListener, we don't disturb it.
			_owner.Disable<SoundListener>();
		}
		else
		{
			listener = owner.GetWeakPtr();
		}
	}

	Entity::Ptr SoundListener::GetListener()
	{
		return listener.lock();
	}

	void SoundListener::OnDisable()
	{
		auto listenerEntity = GetListener();

		// If we are in fact the currently active listener, we can be disabled.
		if (listenerEntity.get() == &owner)
		{
			listener.reset();
		}
	}
	
	void SoundListener::OnEnable()
	{
		// If there is already an active listener, we must disable it
		// Because OpenAL only supports one active listener at a time.
		if (auto listenerEntity = GetListener())
		{
			listenerEntity->Disable<SoundListener>();
		}

		listener = owner.GetWeakPtr();
	}
}<commit_msg>Disabling the active SoundListener will now mute all audio<commit_after>// Copyright (c) 2017 <NAME>
#include "Jewel3D/Precompiled.h"
#include "SoundListener.h"
#include "SoundSystem.h"

namespace Jwl
{
	Entity::WeakPtr SoundListener::listener;

	SoundListener::SoundListener(Entity& _owner)
		: Component(_owner)
	{
		if (GetListener())
		{
			// If there already is an active SoundListener, we don't disturb it.
			_owner.Disable<SoundListener>();
		}
		else
		{
			listener = owner.GetWeakPtr();
			SoundSystem.Unmute();
		}
	}

	Entity::Ptr SoundListener::GetListener()
	{
		return listener.lock();
	}

	void SoundListener::OnDisable()
	{
		auto listenerEntity = GetListener();

		// If we are in fact the currently active listener, we can be disabled.
		if (listenerEntity.get() == &owner)
		{
			listener.reset();
			SoundSystem.Mute();
		}
	}

	void SoundListener::OnEnable()
	{
		// If there is already an active listener, we must disable it
		// because OpenAL only supports one active listener at a time.
		if (auto listenerEntity = GetListener())
		{
			listenerEntity->Disable<SoundListener>();
		}

		listener = owner.GetWeakPtr();
		SoundSystem.Unmute();
	}
}
{'fraction_non_alphanumeric': 0.1251700680272109, 'fraction_numerical': 0.0045351473922902496, 'mean_word_length': 3.891352549889135, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6524725', 'n_tokens_mistral': 781, 'n_tokens_neox': 682, 'n_words': 191}