Files
ft/CodexOutput/upserver/ReviewLifecycleTests/baseline/Generated.cs

200 lines
7.4 KiB
C#

using System;using System.Linq;using System.Collections.Generic;using System.Threading;using System.Threading.Tasks;
public partial class GetUiSubject {
public async Task GetUI()
{
HomePanel homePanel = null;
if (!fishingData.isMapBuff && !IsHideHomeMap)
{
var go = await UIManager.Instance.RestartShowUI(UITypes.HomePanel);
homePanel = go.GetComponent<HomePanel>();
}
//实例
GContext.container.Resolve<IDeferredRewardStashService>();
//这里确认补单
await GContext.container.Resolve<PlayerShopData>().ReleaseReplenishment();
await Awaiters.SecondsRealtime(0.5f);
GContext.container.Resolve<FishingEventData>().ShowRankTierChange();
if (fishingData.isMapBuff)
{
fishingData.isMapBuff = false;
}
else
{
fishingBehavior?.RodBehaviour.gameObject.SetActive(true);
fishingBehavior.cameraAnimator.speed = 1;
GContext.Publish(new ShowHandEvent() { isShow = true });
SetMapShow(!IsHideHomeMap);
if (IsHideHomeMap)
{
IsHideHomeMap = false;
}
else if (homePanel != null)
{
homePanel.OnStart();
}
}
}
}
public partial class ManagerSubject {
public async Task Init(System.Action<float> progress)
{
//playerData = GContext.container.Resolve<PlayerData>();
_tables = GContext.container.Resolve<cfg.Tables>();
//var service = (SoundService)soundService;
await soundService.InitAsync();
var opMap = new Dictionary<string, AsyncOperationHandle<AudioClip>>();
foreach (var addr in residentFish)
{
opMap[addr] = Addressables.LoadAssetAsync<AudioClip>(addr);
}
var tasks = opMap.Values.Select(_ => _.Task);
var total = (float)tasks.Count();
while (true)
{
var completed = tasks.Count(_ => _.IsCompleted);
if (completed == total)
{
progress.Invoke(1f);
break;
}
else
{
progress.Invoke(completed / total);
}
await Awaiters.NextFrame;
}
residentClip = opMap.ToDictionary(_ => _.Key, _ => _.Value.Result);
disposables = new CompositeDisposable();
GContext.OnEvent<EventUISound>().Subscribe(PlaySound).AddTo(disposables);
GContext.OnEvent<EventRewardSound>().Subscribe(PlayRewardSound).AddTo(disposables);
GContext.OnEvent<EventFishingSound>().Subscribe(PlayFishingSound).AddTo(disposables);
GContext.OnEvent<EventBGMSound>().Subscribe(PlayMusic).AddTo(disposables);
GContext.OnEvent<FadeOutEvent>().Subscribe(FadeOutEvent).AddTo(disposables);
GContext.OnEvent<AssetReferenceAudioClip>().Subscribe(PlaySoundByReference).AddTo(disposables);
GContext.OnEvent<AssetReferenceAudioVoiceClip>().Subscribe(PlayVoiceSoundByReference).AddTo(disposables);
GContext.OnEvent<ChangeRodDataEvent>().Subscribe(OnChangeRodData).AddTo(disposables);
GContext.OnEvent<SoundMuteEvent>().Subscribe(OnSoundMute).AddTo(disposables);
GContext.OnEvent<OnSoundStateEvent>().Subscribe(OnSoundStateEvent).AddTo(disposables);
soundService.BGMVol = GContext.container.Resolve<ISettingService>().Music ? 80 : 0;
soundService.SFXVol = GContext.container.Resolve<ISettingService>().Sound ? 80 : 0;
soundService.VoiceVol = GContext.container.Resolve<ISettingService>().Sound ? 80 : 0;
}
public void Release()
{
if (disposables != null)
{
disposables.Dispose();
disposables = null;
}
if (residentClip != null)
{
foreach (var item in residentClip)
{
if (item.Value != null)
{
Addressables.Release(item.Value);
}
}
residentClip.Clear();
}
if (rewardSoundDic != null)
{
rewardSoundDic.Clear();
}
if (soundService != null)
{
foreach (var s in _activeFishingLoopSounds.ToList())
{
if (s != null)
{
s.audioSource.Stop();
soundService.ReturnSound(s);
}
}
}
_activeFishingLoopSounds.Clear();
if (soundService != null)
{
soundService.Release();
}
if (BGM_Clip != null)
{
Addressables.Release(BGM_Clip);
BGM_Clip = null;
}
if (BGM_Sound != null && BGM_Sound.gameObject != null)
{
GameObject.Destroy(BGM_Sound.gameObject);
BGM_Sound = null;
}
BGMName = null;
}
}
public partial class ServiceSubject {
public async Task InitAsync(string mixerAddr = "AudioMixer", string soundPrefabAddr = "sound",
string bgmGroupId = "BGM", string fishingGroupId = "Fishing", string uiGroupId = "UI", string voiceGroupId = "Voice")
{
SoundFadeTaskDic = new Dictionary<Sound, CancellationTokenSource>();
mixerHandle = Addressables.LoadAssetAsync<AudioMixer>(mixerAddr);
mixer = await mixerHandle.Task;
Assert.IsNotNull(mixer);
mixer.GetFloat(Bgm_Vol_Param_Name, out bgmVol);
mixer.GetFloat(Fishing_Vol_Param_Name, out fishingVol);
bgmGroup = FindMixerGroup(bgmGroupId);
fishingGroup = FindMixerGroup(fishingGroupId);
uiGroup = FindMixerGroup(uiGroupId);
voiceGroup = FindMixerGroup(voiceGroupId);
normal = mixer.FindSnapshot("Snapshot");// ("normal");
//lowpass = mixer.FindSnapshot("lowpass");
Assert.IsNotNull(bgmGroup);
Assert.IsNotNull(fishingGroup);
Assert.IsNotNull(uiGroup);
soundPrefabHandle = Addressables.LoadAssetAsync<GameObject>(soundPrefabAddr);
var soundPrefab = await soundPrefabHandle.Task;
Assert.IsNotNull(soundPrefab);
var sound = soundPrefab.GetComponent<Sound>();
Assert.IsNotNull(sound);
lowpassEvtDisposable = GContext.OnEvent<LowpassEffectEvt>().Subscribe(OnLowpassEffectEvt);
poolService.CreatePool<Sound>(sound, 10, 50);
}
public void Release()
{
if (SoundFadeTaskDic != null)
{
foreach (var source in SoundFadeTaskDic.Values)
{
source.Cancel();
}
SoundFadeTaskDic.Clear();
SoundFadeTaskDic = null;
}
poolService?.DestroyPool<Sound>();
if (mixerHandle.IsValid()) Addressables.Release(mixerHandle);
mixerHandle = default;
if (soundPrefabHandle.IsValid()) Addressables.Release(soundPrefabHandle);
soundPrefabHandle = default;
lowpassEvtDisposable?.Dispose();
lowpassEvtDisposable = null;
}
}