Skip to content

Commit

Permalink
bye bye asynccontentmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyDuchess committed Jun 30, 2024
1 parent e19875e commit 4ebbff1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 98 deletions.
24 changes: 10 additions & 14 deletions Assets/Scripts/OpenTS2/Audio/TSAudioSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using UnityEngine;

/// <summary>
Expand Down Expand Up @@ -34,7 +35,7 @@ public AudioAsset Audio
private float _timeAudioSourcePlaying = 0f;
private bool _audioClipPlaying = false;
private bool _paused = false;
private AsyncContentManager _asyncContentLoader;
private ContentManager _contentManager;

public void Pause()
{
Expand All @@ -61,18 +62,13 @@ public void Play()
public void PlayAsync(ResourceKey audioResourceKey)
{
CleanUp();
StartCoroutine(PlayAsyncInternal(audioResourceKey));
}

private IEnumerator PlayAsyncInternal(ResourceKey key)
{
var audioRequest = _asyncContentLoader.RequestAsset(key);
while (!audioRequest.Finished)
yield return null;
if (audioRequest.Result == AsyncContentManager.Results.Success)
PlayInternal(audioRequest.Asset as AudioAsset);
else
Stop();
Task.Run(() =>
{
_audio = _contentManager.GetAsset<AudioAsset>(audioResourceKey);
}).ContinueWith(task =>
{
PlayInternal(_audio);
}, TaskScheduler.FromCurrentSynchronizationContext());
}

private void PlayInternal(AudioAsset asset)
Expand All @@ -93,7 +89,7 @@ public void Stop()

private void Awake()
{
_asyncContentLoader = AsyncContentManager.Instance;
_contentManager = ContentManager.Instance;
_audioSource = GetComponent<AudioSource>();
if (_audioSource == null)
{
Expand Down
72 changes: 0 additions & 72 deletions Assets/Scripts/OpenTS2/Content/AsyncContentManager.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Scripts/OpenTS2/Content/AsyncContentManager.cs.meta

This file was deleted.

1 change: 0 additions & 1 deletion Assets/Scripts/OpenTS2/Engine/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public static void InitializeCore()
var nhoodManager = new NeighborhoodManager();
var casController = new CASManager();
var lotManger = new LotManager();
var asyncContentLoader = new AsyncContentManager();

TerrainManager.Initialize();
MaterialManager.Initialize();
Expand Down

0 comments on commit 4ebbff1

Please sign in to comment.