Files
test/Assets/PerfectWorld/Scripts/Vfx/CECGFXCaster.cs
2025-11-21 11:48:39 +07:00

90 lines
2.8 KiB
C#

using System.Threading.Tasks;
using BrewMonster.PerfectWorld.Scripts.Vfx;
using BrewMonster.Scripts;
using UnityEngine;
namespace BrewMonster
{
public class CECGFXCaster
{
// Load normal gfx
public async Task<BaseVfxObject> LoadGFXEx(string szFile)
{
if (string.IsNullOrEmpty(szFile))
{
BMLogger.LogError("path null!:");
return null;
}
// // ASSERT(m_pGFXMan);
var loadObj = await AddressableManager.Instance.LoadPrefabAsync(szFile.ToLower());
if (loadObj == null)
{
BMLogger.LogError("Null vfx object in path: " + szFile);
return null;
}
//GameController.Instance.SelectingVfxPrefab
// todo: make pool
BaseVfxObject pGFX = ObjectSpawner.Instance.InstantiateObject(loadObj, setThisAsParent:true).GetComponent<BaseVfxObject>();
if (!pGFX)
{
return null;
}
// NORMALGFX* pNode = new NORMALGFX;
// pNode->pGFX = pGFX;
// pNode->dwVisTimeCnt = TIME_CHECKVIS;
// pNode->bVisible = true;
//
// // Add to table
// m_GFXTab.put((int)pGFX, pNode);
return pGFX;
}
// private async void PlayLevelUpGfx(string path)
// {
// // Usage: Load the prefab asynchronously using AddressableManager
// GameObject prefab = await AddressableManager.Instance.LoadPrefabAsync(path);
// if(prefab != null)
// {
// // Instantiate at player's current position and rotation
// GameObject instance = Instantiate(prefab, transform.position, transform.rotation);
// }
// else
// {
// BMLogger.LogError($"Failed to load level up effect prefab at: {path}");
// }
// }
// // Release normal gfx
// void CECGFXCaster::ReleaseGFXEx(A3DGFXEx* pGFX, bool bCacheRelease/* true */)
// {
// if (!pGFX)
// return;
//
// // GFX exists ?
// GFXTable::pair_type Pair = m_GFXTab.get((int)pGFX);
// if (!Pair.second)
// return; // Counldn't find this GFX
//
// NORMALGFX* pNode = *Pair.first;
// m_GFXTab.erase((int)pGFX);
//
// if (bCacheRelease)
// {
// ASSERT(m_pGFXMan);
// m_pGFXMan->CacheReleasedGfx(pGFX);
// }
// else
// {
// pNode->pGFX->Release();
// delete pNode->pGFX;
// }
//
// delete pNode;
// }
}
}