Merge pull request 'Add sfx to skill trigger' (#357) from feature/skill-sfx into develop

Reviewed-on: https://git.pthub.vn/Unity/perfect-world-unity/pulls/357
This commit is contained in:
namth
2026-04-17 09:57:49 +00:00
5 changed files with 69792 additions and 36888 deletions
@@ -4879,6 +4879,7 @@ GameObject:
- component: {fileID: 6264607540402582859}
- component: {fileID: 2789629435814780223}
- component: {fileID: 4504844427513838873}
- component: {fileID: 4095127923563314150}
m_Layer: 0
m_Name: "\u6CD5\u5E08\u5973"
m_TagString: Untagged
@@ -5946,6 +5947,19 @@ MonoBehaviour:
- {fileID: 7400000, guid: 3e474cefdc0b2e648aec98c966f26991, type: 2}
- {fileID: 7400000, guid: 37c12771675cd69499260a8cadf95621, type: 2}
- {fileID: 7400000, guid: f343209405aa0f7469aeb6429b1fc5a5, type: 2}
--- !u!114 &4095127923563314150
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5133661830825835001}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 472c24b873524423f95454131fd11da6, type: 3}
m_Name:
m_EditorClassIdentifier:
combinedActionSO: {fileID: 11400000, guid: ccf54ff0e6d1e8542a9183e8defc97e4, type: 2}
--- !u!1 &5156671091954275778
GameObject:
m_ObjectHideFlags: 0
@@ -1,26 +1,30 @@
using System.Collections.Generic;
using System.IO;
//using ModelViewer.Scene.SceneObject;
using CSNetwork.GPDataType;
// using ModelViewer.Scene.SceneObject;
using UnityEngine;
namespace ModelViewer.Common
{
public static class A3DCombinedActionConst
{
public static uint DEFAULT_GFX_FADE_OUT_TIME = 1000;
public static int EVENT_TYPE_NONE = -1;
public static int EVENT_TYPE_BASE = 100;
public static int EVENT_TYPE_GFX = EVENT_TYPE_BASE + 0;
public static int EVENT_TYPE_SFX = EVENT_TYPE_BASE + 1;
public static int EVENT_TYPE_CHLDACT = EVENT_TYPE_BASE + 2;
public static int EVENT_TYPE_MATCHG = EVENT_TYPE_BASE + 3;
public static int EVENT_TYPE_ATT_PT = EVENT_TYPE_BASE + 4;
public static int EVENT_TYPE_SCRIPT = EVENT_TYPE_BASE + 5;
public static int EVENT_TYPE_CAM_PT = EVENT_TYPE_BASE + 6;
public static int EVENT_TYPE_MODELSCLCHG = EVENT_TYPE_BASE + 7;
public static int EVENT_TYPE_MATTRANS = EVENT_TYPE_BASE + 8;
public static int EVENT_TYPE_AUDIOEVENT = EVENT_TYPE_BASE + 9;
public const int EVENT_TYPE_GFX = 100;
public const int EVENT_TYPE_SFX = 101;
public const int EVENT_TYPE_CHLDACT = 102;
public const int EVENT_TYPE_MATCHG = 103;
public const int EVENT_TYPE_ATT_PT = 104;
public const int EVENT_TYPE_SCRIPT = 105;
public const int EVENT_TYPE_CAM_PT = 106;
public const int EVENT_TYPE_MODELSCLCHG = 107;
public const int EVENT_TYPE_MATTRANS = 108;
public const int EVENT_TYPE_AUDIOEVENT = 109;
// when add new type, change this definition
public static int EVENT_TYPE_END = EVENT_TYPE_AUDIOEVENT;
public const int EVENT_TYPE_END = 109;
public static string _format_cact_name = "CombineActName: ";
public static string _format_act_count = "BaseActCount: ";
@@ -175,7 +179,7 @@ namespace ModelViewer.Common
{
public int m_nType;
public uint m_dwStartTime;
public uint m_dwTimeSpan;
public int m_dwTimeSpan;
public bool m_bOnce;
public A3DCombinedAction m_pAct;
@@ -194,31 +198,105 @@ namespace ModelViewer.Common
{
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
// sscanf(szLine, _format_event_type, &nType);
tagValue = pTextFile.ReadLine();
szLine = pTextFile.ReadLine();
while(!szLine.Contains(A3DCombinedActionConst._format_event_type))
{
szLine = pTextFile.ReadLine();
}
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_event_type,out tagValue);
nType = int.TryParse(tagValue, out nType) ? nType : A3DCombinedActionConst.EVENT_TYPE_NONE;
}
EVENT_INFO pEvent = new();
// if (!pEvent) return NULL;
//
// if (dwVersion >= 18 && !pEvent->LoadEventBase(pFile, dwVersion)
// || !pEvent->Load(pFile, dwVersion))
// {
// delete pEvent;
// return NULL;
// }
EVENT_INFO pEvent = CreateEventByType(pAct, nType);
if (pEvent == null) return null;
if (dwVersion >= 18 && !pEvent.LoadEventBase(pFile, pTextFile, dwVersion)
|| !pEvent.Load(pFile, pTextFile, dwVersion))
{
return null;
}
return pEvent;
}
public static EVENT_INFO CreateEventByType(A3DCombinedAction pAct, int nType)
{
switch (nType)
{
case A3DCombinedActionConst.EVENT_TYPE_GFX:
return new FX_BASE_INFO();
case A3DCombinedActionConst.EVENT_TYPE_SFX:
return new FX_BASE_INFO();
// case A3DCombinedActionConst.EVENT_TYPE_CHLDACT:
// return new ChildActInfo(pAct);
// case A3DCombinedActionConst.EVENT_TYPE_MATCHG:
// return new MaterialScaleChange(pAct);
// case A3DCombinedActionConst.EVENT_TYPE_ATT_PT:
// return new SGCAttackPointMark(pAct);
// case A3DCombinedActionConst.EVENT_TYPE_SCRIPT:
// return new GfxScriptEvent(pAct);
// case A3DCombinedActionConst.EVENT_TYPE_CAM_PT:
// return new CameraControlEvent(pAct);
// case A3DCombinedActionConst.EVENT_TYPE_MODELSCLCHG:
// return new BoneScaleChange(pAct);
// case A3DCombinedActionConst.EVENT_TYPE_MATTRANS:
// return new MaterialScaleTrans(pAct);
// case A3DCombinedActionConst.EVENT_TYPE_AUDIOEVENT:
// return new AUDIOEVENT_INFO(pAct);
}
return new EVENT_INFO();
}
public bool LoadEventBase(AFile pFile, StreamReader pTextFile, uint dwVersion)
{
string szLine = string.Empty;
string tagValue;
long dwReadLen;
if (pFile != null)
{
}
else
{
szLine = pTextFile.ReadLine();
while(!szLine.Contains(A3DCombinedActionConst._format_start_time))
{
szLine = pTextFile.ReadLine();
}
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_start_time, out tagValue);
if (dwVersion >= 20)
{
szLine = pTextFile.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_time_span, out tagValue);
int.TryParse(tagValue, out m_dwTimeSpan);
}
szLine = pTextFile.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_once, out tagValue);
int.TryParse(tagValue, out int nBool);
m_bOnce = (nBool != 0);
}
return true;
}
public virtual bool Load(AFile pFile, StreamReader pTextFile, uint dwVersion)
{
return true;
}
}
[System.Serializable]
public class FX_BASE_INFO : EVENT_INFO
{
//public RandStringContainer[] m_pFiles;
// public RandStringContainer m_pFiles;
// Then you have to random from this list to play the fx file (Can be VFX or SFX)
public List<string> m_strFilePaths = new();
public string m_strHookName;
//public A3DVECTOR3 m_vOffset;
public A3DVECTOR3 m_vOffset;
public float m_fYaw;
public float m_fPitch;
public float m_fRot;
@@ -248,6 +326,159 @@ namespace ModelViewer.Common
// TODO: There are 3 types: GFX_INFO, SFX_INFO, AUDIOEVENT_INFO
return new FX_BASE_INFO();
}
public bool LoadBase(FileStream fileStream, StreamReader file, uint dwVersion)
{
bool isBinary = fileStream != null;
if (isBinary)
{
}
else
{
string szLine = string.Empty;
string tagValue;
if (dwVersion < 18)
{
szLine = file.ReadLine();
while(!szLine.Contains(A3DCombinedActionConst._format_fx_start_time))
{
szLine = file.ReadLine();
}
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_fx_start_time, out tagValue);
uint.TryParse(tagValue, out m_dwStartTime);
}
if (dwVersion < 53)
{
szLine = file.ReadLine();
while(!szLine.Contains(A3DCombinedActionConst._format_fx_path))
{
szLine = file.ReadLine();
}
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_fx_path, out tagValue);
if (tagValue.EndsWith(".wav"))
tagValue = tagValue.Replace(".wav", "");
m_strFilePaths.Add(tagValue);
}
else // dwVersion >= 53
{
int iNum = 0;
szLine = file.ReadLine();
while(!szLine.Contains(A3DCombinedActionConst._format_fx_path_num))
{
szLine = file.ReadLine();
}
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_fx_path_num, out tagValue);
int.TryParse(tagValue, out iNum);
for (int iIdx = 0; iIdx < iNum; ++iIdx)
{
szLine = file.ReadLine();
while(!szLine.Contains(A3DCombinedActionConst._format_fx_path))
{
szLine = file.ReadLine();
}
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_fx_path, out tagValue);
if (tagValue.EndsWith(".wav"))
tagValue = tagValue.Replace(".wav", "");
m_strFilePaths.Add(tagValue);
}
}
while(!szLine.Contains(A3DCombinedActionConst._format_hook_name))
{
szLine = file.ReadLine();
}
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_hook_name, out tagValue);
m_strHookName = tagValue;
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_hook_offset, out tagValue);
string[] values = tagValue.Split(',');
if (values.Length >= 3)
{
float.TryParse(values[0].Trim(), out m_vOffset.x);
float.TryParse(values[1].Trim(), out m_vOffset.y);
float.TryParse(values[2].Trim(), out m_vOffset.z);
}
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_hook_yaw, out tagValue);
float.TryParse(tagValue, out m_fYaw);
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_hook_pitch, out tagValue);
float.TryParse(tagValue, out m_fPitch);
if (dwVersion >= 19)
{
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_hook_rot, out tagValue);
float.TryParse(tagValue, out m_fRot);
}
if (dwVersion > 1)
{
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_bind_parent, out tagValue);
int.TryParse(tagValue, out int nBool);
m_bBindParent = (nBool != 0);
}
if (dwVersion >= 15 && dwVersion < 50)
{
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_fadeout, out tagValue);
int.TryParse(tagValue, out int nBool);
bool bFadeOut = (nBool != 0);
if (bFadeOut)
m_dwFadeOutTime = A3DCombinedActionConst.DEFAULT_GFX_FADE_OUT_TIME;
else
m_dwFadeOutTime = 0;
}
else if (dwVersion >= 50)
{
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_fadeout, out tagValue);
uint.TryParse(tagValue, out m_dwFadeOutTime);
}
// Èç¹ûµ­³öʱ¼äΪ¸ºÊý£¬Ö±½ÓÖÃΪ0
if (m_dwFadeOutTime >= 0x80000000)
m_dwFadeOutTime = 0;
if (dwVersion >= 17)
{
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_model_alpha, out tagValue);
int.TryParse(tagValue, out int nBool);
m_bModelAlpha = (nBool != 0);
}
if (dwVersion >= 58)
{
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_custom_path, out tagValue);
int.TryParse(tagValue, out int nBool);
m_bCustomFilePath = (nBool != 0);
}
if( dwVersion >= 62 )
{
szLine = file.ReadLine();
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_custom_data, out tagValue);
int.TryParse(tagValue, out m_nCustomData);
}
}
return true;
}
public override bool Load(AFile pFile, StreamReader pTextFile, uint dwVersion)
{
LoadBase(null, pTextFile, dwVersion);
return true;
}
}
[System.Serializable]
@@ -264,6 +495,8 @@ namespace ModelViewer.Common
return m_ActLst[0].m_nMinLoops == -1 || m_ActLst[0].m_nMaxLoops == -1;
}
public List<ACTION_INFO> m_ActLst = new();
[SerializeReference]
public List<EVENT_INFO> m_EventInfoLst = new();
// Original, this property describes the comact's span time, now the span time may change randomly,
@@ -394,6 +627,7 @@ namespace ModelViewer.Common
if (pInfo == null) continue;
//TODO: Implement Load function
// pInfo.Load(fileStream, file, dwVersion);
pInfo.LoadBase(fileStream, file, dwVersion); // this should be called inside of each type of FX_BASE_INFO (GFX_INFO, SFX_INFO, AUDIOEVENT_INFO)
m_EventInfoLst.Add(pInfo);
}
}
@@ -402,6 +636,10 @@ namespace ModelViewer.Common
// pFile->ReadLine(szLine, AFILE_LINEMAXLEN, &dwReadLen);
// sscanf(szLine, _format_event_count, &nEventCount);
szLine = file.ReadLine();
while(!szLine.Contains(A3DCombinedActionConst._format_event_count))
{
szLine = file.ReadLine();
}
AAssit.GetStringAfter(szLine, A3DCombinedActionConst._format_event_count, out tagValue);
int.TryParse(tagValue, out nEventCount);
@@ -6,14 +6,9 @@ using UnityEngine;
namespace BrewMonster.Scripts.ECModel
{
[CreateAssetMenu(fileName = "CombinedActionSO", menuName = "BrewMonster/CombinedActionSO")]
public class CombinedActionSO : ScriptableObject
{
public List<A3DCombinedAction> CombinedActionData = new();
public A3DCombinedAction GetActionByName(string name)
{
A3DCombinedAction returnValue = null;
returnValue = CombinedActionData.Find(x => x.m_strName == name);
return returnValue;
}
}
}
+19 -1
View File
@@ -12,6 +12,7 @@ using ConvexHullDataArray = System.Collections.Generic.List<object>;
using ECModelHookMap = System.Collections.Generic.Dictionary<string, object>;
using BrewMonster;
using BrewMonster.Scripts.ECModel;
using Unity.VisualScripting.FullSerializer;
public enum ECMScript
{
enumECMScriptStartAction = 0,
@@ -675,7 +676,24 @@ public class CECModel
{
EventBus.PublishChannelClass(m_nId, new QueueActionEvent(actionInfos[i].m_strName, null, false, attackEvent, nTransTime, false));
}
var eventInfoList = combinedAction.m_EventInfoLst;
if(eventInfoList != null && eventInfoList.Count > 0)
{
foreach(var eventInfo in eventInfoList)
{
//0 is sound event
if (eventInfo is FX_BASE_INFO sfx)
{
if(sfx.m_strFilePaths != null && sfx.m_strFilePaths.Count > 0)
{
string soundpath = AFile.NormalizePath(sfx.m_strFilePaths[0]);
soundpath = soundpath.ToLower();
SFXManager.Instance.PlaySkillSfxAtPointAsync(soundpath, Vector3.zero).Forget();
}
}
}
}
return true;
}
public A3DCombinedAction GetComActByName(string szActName)