This commit is contained in:
VDH
2025-11-14 19:03:42 +07:00
parent 690a8dd9de
commit f86cce30e9
9 changed files with 199 additions and 810 deletions
@@ -2,21 +2,74 @@ using Animancer;
using BrewMonster;
using BrewMonster.Assets.PerfectWorld.Scripts.Common;
using BrewMonster.Managers;
using BrewMonster.Scripts.Skills;
using CSNetwork.GPDataType;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using static UnityEditor.AddressableAssets.Build.Layout.BuildLayout;
using File = System.IO.File;
public class CECAttacksMan : Singleton<CECAttacksMan>
public class CECAttacksMan : MonoSingleton<CECAttacksMan>
{
private readonly LinkedList<CECAttackEvent> m_AttackLinkedList = new LinkedList<CECAttackEvent>();
public CECMultiSectionSkillMan m_pMultiSkillGfxComposerMan;
public CECMultiSectionSkillMan m_pMultiSkillGfxComposerMan;
protected A3DSkillGfxComposerMan m_pSkillGfxComposerMan;
#if UNITY_EDITOR
public List<CECAttackEvent> m_AttackList = new List<CECAttackEvent>();
#endif
private void Start()
{
SetupAttacksMan();
uint idSkill = 0;
while (true)
{
idSkill = ElementSkill.NextSkill(idSkill);
if (idSkill == 0)
break;
string pszSGCFile = ElementSkill.GetEffect(idSkill);
while (pszSGCFile.StartsWith("\\"))
pszSGCFile = pszSGCFile.Substring(1);
string szSGCFile;
if (string.IsNullOrEmpty(pszSGCFile))
szSGCFile = "gfx\\sgc\\nosuchthing.sgc";
else
szSGCFile = $"gfx/sgc/{pszSGCFile}";
if (FileExists(szSGCFile))
{
if (!m_pSkillGfxComposerMan.LoadOneComposer((int)idSkill, szSGCFile))
{
// a_LogOutput(1, "CECAttacksMan::CECAttacksMan(), failed to load skill [%d]'s gfx composer [%s]", idSkill, szSGCFile);
}
}
}
/*char szMultiSectionFile[MAX_PATH] = { 0 };
strcpy(szMultiSectionFile, "configs\\multi_section_skill.txt");
m_pMultiSkillGfxComposerMan = new CECMultiSectionSkillMan();
if (!m_pMultiSkillGfxComposerMan || !m_pMultiSkillGfxComposerMan->LoadConfig(szMultiSectionFile))
{
a_LogOutput(1, "CECAttacksMan::CECAttacksMan(), failed to load multi skill sgc config file [%s]", szMultiSectionFile);
}
strcpy(szMultiSectionFile, "configs\\skill_state_action.txt");
if (!LoadSkillStateActionConfig(szMultiSectionFile))
a_LogOutput(1, "CECAttacksMan::CECAttacksMan(), failed to load multi skill action config file [%s]", szMultiSectionFile);*/
}
public void SetupAttacksMan()
{
m_pSkillGfxComposerMan = new A3DSkillGfxComposerMan();
uint idSkill = 0;
}
private void Update()
{
@@ -34,7 +87,11 @@ public class CECAttacksMan : Singleton<CECAttacksMan>
node = next;
}
}
bool FileExists(string relativePath)
{
string fullPath = Path.Combine(Application.streamingAssetsPath, relativePath);
return System.IO.File.Exists(fullPath);
}
public CECAttackerEvents FindAttackByAttacker(int idHost)
{
CECAttackerEvents result = new CECAttackerEvents();
@@ -70,6 +127,10 @@ public class CECAttacksMan : Singleton<CECAttacksMan>
newEvent.UpdateTargetFlag();
return m_AttackLinkedList.Last.Value;
}
public A3DSkillGfxComposerMan GetSkillGfxComposerMan()
{
return m_pSkillGfxComposerMan;
}
public bool GetSkillSectionActionSuffix(int skill, int section, out string suffix)
{
// TODO: Implement multi-section skill logic
@@ -295,10 +356,36 @@ public class A3DSkillGfxComposer
/// Load composer from file
/// 从文件加载组合器
/// </summary>
public bool Load(string sgcFile)
public bool Load(string szFile)
{
// TODO: Implement SGC file loading
BMLogger.LogWarning($"A3DSkillGfxComposer.Load: Not yet implemented for {sgcFile}");
// C# equivalent of: AFileImage file;
// C# equivalent of: if (!file.Open(szFile, AFILE_OPENEXIST)) return false;
string fullPath = Path.Combine(Application.streamingAssetsPath, szFile);
if (!File.Exists(fullPath))
return false;
// C# equivalent of: if (!Load(&file))
using (var fileStream = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
{
if (!Load(fileStream))
{
// C# equivalent of: file.Close(); (handled by using statement)
return false;
}
}
// C# equivalent of: file.Close(); (handled by using statement)
return true;
}
/// <summary>
/// Load composer from stream (internal implementation)
/// 从流加载组合器(内部实现)
/// </summary>
private bool Load(Stream stream)
{
// TODO: Implement the actual parsing logic from A3DSkillGfxComposer::Load(AFileImage* pFile)
// 待实现:从 A3DSkillGfxComposer::Load(AFileImage* pFile) 移植实际的解析逻辑
BMLogger.LogWarning("A3DSkillGfxComposer.Load(Stream): Parsing logic not yet implemented");
return false;
}
@@ -315,11 +402,12 @@ public class A3DSkillGfxComposer
/// Play skill effect
/// 播放技能特效
/// </summary>
/* public void Play(int nHostID, int nCastTargetID, List<TARGET_DATA> targets, bool bIsGoblinSkill = false)
public void Play(int nHostID, int nCastTargetID, List<TARGET_DATA> targets, bool bIsGoblinSkill = false)
{
// TODO: Implement skill effect playback
BMLogger.Log($"A3DSkillGfxComposer.Play: Host {nHostID}, Target {nCastTargetID}");
}*/
// 待实现:技能特效播放逻辑
BMLogger.Log($"A3DSkillGfxComposer.Play: Host {nHostID}, CastTarget {nCastTargetID}, Targets:{targets?.Count ?? 0}, Goblin:{bIsGoblinSkill}");
}
}
[Serializable]
public class CECAttackEvent
@@ -431,19 +519,18 @@ public class CECAttackEvent
if (pMan != null)
{
// TODO: Implement ElementSkill.IsGoblinSkill check
// pMan.Play(m_idSkill, m_nSkillSection, m_idHost, m_idCastTarget, m_targets, ElementSkill.IsGoblinSkill(m_idSkill));
pMan.Play(m_idSkill, m_nSkillSection, m_idHost, m_idCastTarget, m_targets, false);
pMan.Play(m_idSkill, m_nSkillSection, m_idHost, m_idCastTarget, m_targets, ElementSkill.IsGoblinSkill((uint)m_idSkill));
pComposer = pMan.GetSkillGfxComposer(m_idSkill, m_nSkillSection);
}
}
else
{
// TODO: Implement SkillGfxComposerMan
// if (ElementSkill.IsGoblinSkill(m_idSkill))
// m_pManager.GetSkillGfxComposerMan().Play(m_idSkill, m_idHost, m_idCastTarget, m_targets, true);
// else
// m_pManager.GetSkillGfxComposerMan().Play(m_idSkill, m_idHost, m_idCastTarget, m_targets);
// pComposer = m_pManager.GetSkillGfxComposerMan().GetSkillGfxComposer(m_idSkill);
if (ElementSkill.IsGoblinSkill((uint)m_idSkill))
m_pManager.GetSkillGfxComposerMan().Play(m_idSkill, m_idHost, m_idCastTarget, m_targets, true);
else
m_pManager.GetSkillGfxComposerMan().Play(m_idSkill, m_idHost, m_idCastTarget, m_targets);
pComposer = m_pManager.GetSkillGfxComposerMan().GetSkillGfxComposer(m_idSkill);
BMLogger.LogWarning("SkillGfxComposerMan not yet implemented");
}
@@ -540,7 +627,7 @@ public class CECAttackEvent
// TODO: Implement AddSkillGfxEvent
// 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 / 临时实现用于测试
var target = EC_ManMessageMono.Instance?.GetObject(data.idTarget, 0)?.gameObject.transform;
if (target == null)
@@ -216,7 +216,6 @@ public abstract partial class CECPlayer : CECObject
public static void InitStaticRes()
{
BMLogger.LogError("HoangDev: InitStaticRes");
BuildActionList();
DATA_TYPE dt = default;
_player_levelup_exp = (PLAYER_LEVELEXP_CONFIG)ElementDataManProvider.GetElementDataMan()
@@ -227,6 +227,13 @@ namespace BrewMonster.Scripts.Skills
// Чļ
public virtual byte[] GetEffect() { return null; }
public static string GetEffect(uint id)
{
SkillStub stub = SkillStub.GetStub(id);
if (stub != null)
return stub.effect;
return "";
}
public virtual byte[] GetElseEffect() { return null; }
// ʹҪMP
@@ -0,0 +1,65 @@
using System.Collections.Generic;
using BrewMonster.Scripts;
namespace BrewMonster
{
public class A3DSkillGfxComposerMan
{
private readonly Dictionary<int, A3DSkillGfxComposer> m_ComposerMap = new Dictionary<int, A3DSkillGfxComposer>();
public bool LoadOneComposer(int nSkillID, string szPath)
{
if (m_ComposerMap.ContainsKey(nSkillID))
return false;
var composer = new A3DSkillGfxComposer();
if (!composer.Load(szPath))
{
// failed to load
return false;
}
// In original C++: composer->Init(g_pGame->GetGameRun()->GetWorld()->GetSkillGfxMan()->GetPtr());
// Not wired in Unity yet; keep placeholder init to allow future hookup.
composer.Init(null);
m_ComposerMap[nSkillID] = composer;
return true;
}
public void Release()
{
// If A3DSkillGfxComposer needs disposal later, do it here
m_ComposerMap.Clear();
}
public void Play(
int nSkillID,
int nHostID,
int nCastTargetID,
List<TARGET_DATA> Targets,
bool bIsGoblinSkill = false)
{
if (!m_ComposerMap.TryGetValue(nSkillID, out var composer) || composer == null)
return;
// Forward to composer (stubbed for now if Play not implemented)
try
{
// Provide a minimal default fly time estimation behavior when composer has no fly time configured
// Real effect triggering should be implemented inside composer.Play
composer.Play(nHostID, nCastTargetID, Targets, bIsGoblinSkill);
}
catch (System.MissingMethodException)
{
BMLogger.LogWarning("A3DSkillGfxComposer.Play is not implemented yet.");
}
}
public A3DSkillGfxComposer GetSkillGfxComposer(int skill)
{
return m_ComposerMap.TryGetValue(skill, out var composer) ? composer : null;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9c12636dc24f8b74db43aafc75343ce9
+2 -2
View File
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:9f45d4e79cbf04b71e1e1bf360f444d945bf41a61fe66c90737387c48b61cf6c
size 530349871
oid sha256:60e415b46566e4294f5dbb32e7b1cf13d15123d5625c92512787838511a09fb9
size 530350648
+2 -2
View File
@@ -276,7 +276,7 @@ public partial class CECHostPlayer : CECPlayer
SelectTarget(m_idUCSelTarget);
}
/*if (idTraceTarget != 0)
if (idTraceTarget != 0)
{
if (iTraceReason == CECHPWorkTrace.Trace_reason.TRACE_ATTACK)
{
@@ -284,7 +284,7 @@ public partial class CECHostPlayer : CECPlayer
return;
NormalAttackObject(idTraceTarget, bForceAttack);
}
}*/
}
}
m_pWorkMan?.Tick(Time.deltaTime);
File diff suppressed because one or more lines are too long
+6 -2
View File
@@ -165,6 +165,7 @@ PlayerSettings:
androidMinAspectRatio: 1
applicationIdentifier:
Android: com.DefaultCompany.perfectworldunity
iPhone: com.DefaultCompany.perfect-world-unity
buildNumber:
Standalone: 0
VisionOS: 0
@@ -507,6 +508,9 @@ PlayerSettings:
- serializedVersion: 3
m_BuildTarget: Android
m_Formats: 01000000
- serializedVersion: 3
m_BuildTarget: iOS
m_Formats: 03000000
playModeTestRunnerEnabled: 0
runPlayModeTestAsEditModeTest: 0
actionOnDotNetUnhandledException: 1
@@ -773,7 +777,7 @@ PlayerSettings:
webGLCloseOnQuit: 0
webWasm2023: 0
scriptingDefineSymbols:
Android: DOTWEEN;TESTFAST
Android: DOTWEEN;TESTFAST;_TASK_CLIENT
EmbeddedLinux: DOTWEEN
GameCoreScarlett: DOTWEEN
GameCoreXboxOne: DOTWEEN
@@ -789,7 +793,7 @@ PlayerSettings:
WebGL: DOTWEEN
Windows Store Apps: DOTWEEN
XboxOne: DOTWEEN
iPhone: DOTWEEN
iPhone: DOTWEEN;_TASK_CLIENT
tvOS: DOTWEEN
additionalCompilerArguments: {}
platformArchitecture: {}