delay sound

This commit is contained in:
vuong dinh hoang
2026-04-24 10:47:49 +07:00
parent 6d19cbbcf4
commit a83c12a2ef
6 changed files with 31 additions and 27 deletions
@@ -290,7 +290,6 @@ namespace BrewMonster.Scripts
currentReleaseTime = Mathf.Min(currentReleaseTime, timeStamp);
}
_releaseAssetTimestamps[assetPath] = currentReleaseTime;
BMLogger.Log($"AddressableManager: Released asset: {assetPath}");
}
public void ForceReleaseAsset(string assetPath)
@@ -302,7 +301,6 @@ namespace BrewMonster.Scripts
Addressables.Release(loadedPrefabHandle);
}
_loadedPrefabAssets.Remove(assetPath);
BMLogger.Log($"AddressableManager: Force released prefab asset: {assetPath}");
}
else if (_loadedTextAssets.TryGetValue(assetPath, out var loadedTextHandle))
{
@@ -311,7 +309,6 @@ namespace BrewMonster.Scripts
Addressables.Release(loadedTextHandle);
}
_loadedTextAssets.Remove(assetPath);
BMLogger.Log($"AddressableManager: Force released text asset: {assetPath}");
}
else if (_loadedAudioAssets.TryGetValue(assetPath, out var loadedAudioHandle))
{
@@ -567,11 +567,9 @@ namespace BrewMonster
public string hitGrdGfxName;
public async UniTask<bool> Load(SkillStub skillStub, string flyGFXPath, string hitGrdGFXPath, string hitGFXPath)
{
flyGfxName = flyGFXPath;
hitGfxName = hitGFXPath;
hitGrdGfxName = hitGrdGFXPath;
// Load GFX prefabs / 加载GFX预制体
m_szFlyGfx = string.IsNullOrEmpty(flyGfxName) ? null : await AddressableManager.Instance.LoadPrefabAsync("gfx/" + flyGfxName);
m_szHitGfx = string.IsNullOrEmpty(hitGfxName) ? null : await AddressableManager.Instance.LoadPrefabAsync("gfx/" + hitGfxName);
@@ -873,7 +871,7 @@ public class CECAttackEvent
public int m_nSkillSection;
#if UNITY_EDITOR
int debugCounter = 0; // Debug counter to track Tick calls
int debugCounter = 0; // Debug counter to track Tick calls
#endif
public CECAttackEvent() { }
@@ -1075,7 +1073,7 @@ public class CECAttackEvent
if (bHideHitGfx) pszHitGFX = null;
// TODO: Implement AddSkillGfxEvent
// CECGameRun.Instance.GetWorld().GetSkillGfxMan().AddSkillGfxEvent(m_idHost, data.idTarget,
// CECGameRun.Instance.GetWorld().GetSkillGfxMan().AddSkillGfxEvent(m_idHost, data.idTarget,
// pszflyGFX, pszHitGFX, m_timeToDoDamage, false, GfxMoveMode.enumLinearMove, 1, 0, null, vFlyScale, vHitScale, data.dwModifier);
var target = EC_ManMessageMono.Instance?.GetObject(data.idTarget, 0)?.gameObject.transform;
if (target == null)
@@ -1113,7 +1111,7 @@ public class CECAttackEvent
// if (bHideHitGfx) szGFX = null;
// TODO: Implement AddSkillGfxEvent
// CECGameRun.Instance.GetWorld().GetSkillGfxMan().AddSkillGfxEvent(m_idHost, data.idTarget, null,
// CECGameRun.Instance.GetWorld().GetSkillGfxMan().AddSkillGfxEvent(m_idHost, data.idTarget, null,
// szGFX, m_timeToDoDamage, false, GfxMoveMode.enumLinearMove, 1, 0, null, vFlyScale, vHitScale, data.dwModifier);
// Temporary implementation for testing / 临时实现用于测试
@@ -1227,7 +1225,7 @@ public class CECAttackEvent
if (bHideHitGfx) pszHitGFX = null;
// TODO: Implement AddSkillGfxEvent
// CECGameRun.Instance.GetWorld().GetSkillGfxMan().AddSkillGfxEvent(m_idHost, data.idTarget,
// CECGameRun.Instance.GetWorld().GetSkillGfxMan().AddSkillGfxEvent(m_idHost, data.idTarget,
// pszflyGFX, pszHitGFX, m_timeToDoDamage, false, GfxMoveMode.enumLinearMove, 1,
// 0, null, vFlyScale, vHitScale, data.dwModifier);
}
@@ -3911,7 +3911,7 @@ namespace BrewMonster
public CECAttackEvent AttackEvent;
public bool IsHitAnim;
public bool IsForceStopPrevious;
public bool IsLoop;
public bool IsLoop;
public QueueActionEvent(string animationName, Action<bool, CECAttackEvent> setFlag, bool isHitAnim,
CECAttackEvent attackEvent, int iTransTime, bool isForceStopPrevious = false, bool isLoop = false)
{
+12 -13
View File
@@ -369,7 +369,7 @@ public class CLuaMemTbl
public class CECModel
{
private bool m_bInheritParentId = true;
private int m_nId = 0;
public GameObject m_pPlayerModel;
@@ -397,7 +397,7 @@ public class CECModel
pNode->m_pActFlag = NULL;
}*/
}
public bool HasCHAABB() { return m_pMapModel.HasCHAABB(); }
/// <summary>
@@ -438,14 +438,14 @@ public class CECModel
{
m_skeletonBuilder = m_transform.GetComponentInChildren<SkeletonBuilder>(true);
}
if (m_skeletonBuilder == null && m_transform != null)
{
// Fallback: search in parent hierarchy (for NPCs/Players)
// 回退:在父层次结构中搜索(用于NPC/玩家)
m_skeletonBuilder = m_transform.GetComponentInParent<SkeletonBuilder>();
}
if (m_skeletonBuilder == null)
{
BMLogger.LogWarning($"[CECModel] SkeletonBuilder not found for {(m_transform != null ? m_transform.name : "null")}. Hooks will not be available.");
@@ -497,12 +497,12 @@ public class CECModel
return null; // Still no skeleton found
}
}
if (string.IsNullOrEmpty(hookName))
{
return null;
}
// Check cache first
// 首先检查缓存
if (m_hookCache.TryGetValue(hookName, out Transform cachedHook))
@@ -513,11 +513,11 @@ public class CECModel
}
m_hookCache.Remove(hookName); // Remove invalid entry
}
// Lookup from skeleton
// 从骨架查找
Transform hook = m_skeletonBuilder.GetHook(hookName, recursive);
if (hook != null)
{
m_hookCache[hookName] = hook; // Cache for performance
@@ -575,7 +575,7 @@ public class CECModel
{
if (string.IsNullOrEmpty(hangerName))
return null;
return m_childModels.TryGetValue(hangerName, out CECModel child) ? child : null;
}
@@ -688,8 +688,7 @@ public class CECModel
{
string soundpath = AFile.NormalizePath(sfx.m_strFilePaths[0]);
soundpath = soundpath.ToLower();
SFXManager.Instance.PlaySkillSfxAtPointAsync(soundpath, Vector3.zero).Forget();
SFXManager.Instance.PlaySkillSfxAtPointAsync(soundpath, Vector3.zero).Forget();
}
}
}
@@ -774,7 +773,7 @@ public class CECModel
// TODO Phase 4: Add hook scale factor support
// TODO 第4阶段:添加挂点缩放因子支持
// fScale *= pHook->GetScaleFactor();
#if UNITY_EDITOR
BMLogger.Log($"[CECModel.PlayGfx] Using hook '{szHook}' for GFX '{szPath}', scale={fScale}");
#endif
@@ -845,4 +844,4 @@ public class CECModel
public enum ActionChannel
{
ACTCHA_WOUND = 1,
};
};
@@ -92,11 +92,23 @@ namespace BrewMonster.Scripts
/// Uses the cache fast-path when the clip is already loaded; otherwise waits
/// for AddressableManager initialization (no per-frame lambda polling) before
/// loading and playing the clip.
/// <para>
/// Pass <paramref name="delay"/> (in seconds) to postpone playback. The wait
/// can be cancelled early via <paramref name="cancellationToken"/>; if cancelled
/// the method exits silently without playing anything.
/// </para>
/// </summary>
public async UniTaskVoid PlaySkillSfxAtPointAsync(string address, Vector3 worldPos)
public async UniTaskVoid PlaySkillSfxAtPointAsync(
string address,
Vector3 worldPos,
float delay = 0f,
System.Threading.CancellationToken cancellationToken = default)
{
// BMLogger.LogError ($"HoangDev PlaySkillSfxAtPointAsync: address={address}, worldPos={worldPos}");
if (string.IsNullOrEmpty(address)) return;
if (delay > 0f)
await UniTask.Delay(System.TimeSpan.FromSeconds(delay), cancellationToken: cancellationToken);
var mgr = AddressableManager.Instance;
if (mgr == null) return;
@@ -53,8 +53,6 @@ namespace BrewMonster.Scripts
Debug.LogWarning($"[WorldMusicController] No music entry found for worldTag {worldTag}");
return;
}
BMLogger.LogError($"HoangDev: SetupAudioSources entry.bgmPath.ToLower():{entry.bgmPath.ToLower()}");
BMLogger.LogError($"HoangDev: SetupAudioSources entry.ambiencePath.ToLower()):{entry.ambiencePath.ToLower()}");
var bgmClip = await AddressableManager.Instance.LoadAudioClipAsync(entry.bgmPath.ToLower());
var ambienceClip = await AddressableManager.Instance.LoadAudioClipAsync(entry.ambiencePath.ToLower());