Initial Commit

This commit is contained in:
Simeon Radivoev 2022-02-12 12:53:50 +02:00
commit ee5c2f922d
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
2255 changed files with 547750 additions and 0 deletions

View file

@ -0,0 +1,36 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using Zenject;
using Hash128 = Unity.Entities.Hash128;
namespace DefaultNamespace
{
public class ParticleSystemFactory : IFactory<Hash128, AsyncOperationWrapper<GameObject>>
{
private readonly Dictionary<Hash128, AsyncOperationWrapper<GameObject>> loadingSystems =
new Dictionary<Hash128, AsyncOperationWrapper<GameObject>>();
private readonly Dictionary<Hash128, ParticleSystem> particleSystems = new Dictionary<Hash128, ParticleSystem>();
public AsyncOperationWrapper<GameObject> Create(Hash128 param)
{
if (particleSystems.TryGetValue(param, out var system))
{
return new AsyncOperationWrapper<GameObject>(system.gameObject);
}
if (loadingSystems.TryGetValue(param, out var systemLoading))
{
return systemLoading;
}
systemLoading = new AsyncOperationWrapper<GameObject>(Addressables.InstantiateAsync(param.ToString()));
systemLoading.Completed += operation =>
{
loadingSystems.Remove(param);
particleSystems.Add(param, operation.Result.GetComponent<ParticleSystem>());
};
loadingSystems.Add(param, systemLoading);
return systemLoading;
}
}
}