organize folder

This commit is contained in:
VDH
2025-10-10 15:10:36 +07:00
parent febe6f8b00
commit a7666f9aa1
42 changed files with 307 additions and 103 deletions
@@ -0,0 +1,24 @@
using BrewMonster;
using CSNetwork.GPDataType;
using System;
using UnityEngine;
public class CECGameRun
{
private CECWorld m_pWorld;
public CECWorld GetWorld() { return m_pWorld; }
public bool StartGame(int idInst, Vector3 vHostPos)
{
if (!JumpToInstance(idInst, vHostPos))
{
BMLogger.LogError ( "CECGameRun::StartGame, Failed to create game world.");
return false;
}
return true;
}
private bool JumpToInstance(int idInst, Vector3 vHostPos, int iParallelWorldID = 0)
{
return true;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 923b4102fc6857a4e94d7a662b2e6e1a
@@ -8,6 +8,7 @@ namespace BrewMonster.Network
#region Fields
private static ATaskTemplMan m_pTaskMan; // Task template manager
private static elementdataman m_pElementDataMan; // global element templates manager
private static CECGameRun m_pGameRun; // Game running object
#endregion
#region Properties
@@ -29,8 +30,15 @@ namespace BrewMonster.Network
Debug.LogError("[Dat]- CECGame::Init, Storage task Init Failed!");
return false;
}
m_pGameRun = new CECGameRun();
if (m_pGameRun == null)
{
BMLogger.LogError("CECGame::Init");
return false;
}
return true;
}
public static CECGameRun GetGameRun() { return m_pGameRun; }
#endregion
}
}
@@ -40,6 +40,16 @@ namespace PerfectWorld.Scripts.Managers
EQUIPIVTR_DYNSKILLEQUIP2 = 28,
EQUIPIVTR_FASHION_WEAPON = 29,
SIZE_EQUIPIVTR = 30,
EQUIPIVTR_UNUSED1 = SIZE_EQUIPIVTR,
EQUIPIVTR_UNUSED2 = 31,
EQUIPIVTR_GENERALCARD1,
EQUIPIVTR_GENERALCARD2,
EQUIPIVTR_GENERALCARD3,
EQUIPIVTR_GENERALCARD4 = 35,
EQUIPIVTR_GENERALCARD5,
EQUIPIVTR_GENERALCARD6,
SIZE_ALL_EQUIPIVTR,
SIZE_GENERALCARD_EQUIPIVTR = SIZE_ALL_EQUIPIVTR - EQUIPIVTR_GENERALCARD1,
}
public static byte GetEquipLocationForItem(int templateId)
@@ -1,6 +1,7 @@
using BrewMonster;
using CSNetwork.GPDataType;
using ModelRenderer.Scripts.GameData;
using PerfectWorld.Scripts.Managers;
using PerfectWorld.Scripts.Player;
using System;
using System.Collections.Generic;
@@ -15,12 +16,15 @@ public abstract class CECPlayer : CECObject
protected GameObject m_pPlayerModel;
protected float rotationSpeed = 5;
internal int m_iMoveMode; // Player's move mode
internal int m_idSelTarget; // Ñ¡ÖÐÄ¿±êµÄID
uint m_dwStates; // Player's basic states
internal int m_idSelTarget;
protected int m_iShape; // Ñ¡ÖÐÄ¿±êµÄID
uint m_dwStates; // Player's basic states
protected int[] m_aEquips;
protected ROLEEXTPROP m_ExtProps; // Extend properties
protected float m_fTouchRad = 0.3f; // Touch radius
protected int m_iBattleCamp = Player_camp_in_battle.GP_BATTLE_CAMP_NONE; // Battle this player belongs to
byte m_factionPVPMask; // pvp mask
byte m_factionPVPMask; // pvp mask
protected uint m_dwResFlags; // pvp mask
protected ROLEBASICPROP m_BasicProps;
public int m_iMoveEnv = Move_environment.MOVEENV_GROUND; // Move environment
public bool m_bWalkRun;
@@ -28,6 +32,8 @@ public abstract class CECPlayer : CECObject
protected void Awake()
{
m_PlayerActions = _default_actions;
m_iShape = 0;
m_aEquips = new int[(int)EC_IvtrType.IndexOfIteminEquipmentInventory.SIZE_ALL_EQUIPIVTR];
}
public void SetPlayerInfor(INFO playinfo)
{
@@ -43,12 +49,12 @@ public abstract class CECPlayer : CECObject
BuildActionList();
}
public bool IsDead(){ return (m_dwStates & PlayerNPCState.GP_STATE_CORPSE) != 0; }
public bool IsDead() { return (m_dwStates & PlayerNPCState.GP_STATE_CORPSE) != 0; }
public bool IsValidAction(int iIndex) { return (iIndex >= 0 && iIndex < (int)PLAYER_ACTION_TYPE.ACT_MAX) ? true : false; }
public int GetCharacterID() { return m_PlayerInfo.cid; }
private static void BuildActionList()
{
if (_default_actions == null)
@@ -152,6 +158,7 @@ public abstract class CECPlayer : CECObject
public PLAYER_ACTION_TYPE type;
public PLAYER_ACTION_INFO_CONFIG data;
};
public INFO GetPlayerInfo() { return m_PlayerInfo; }
public enum PLAYER_ACTION_TYPE
{
// 0
@@ -288,7 +295,7 @@ public abstract class CECPlayer : CECObject
ACT_CASTSKILL // Chỉ là placeholder cho skill actions
}
public float GetTouchRadius(){ return m_fTouchRad; }
public float GetTouchRadius() { return m_fTouchRad; }
// Is player in battle
public bool IsInBattle() { return m_iBattleCamp != Player_camp_in_battle.GP_BATTLE_CAMP_NONE; }
@@ -381,8 +388,10 @@ public abstract class CECPlayer : CECObject
}
// Get move environment
public int GetMoveEnv(){ return m_iMoveEnv; }
// Get character ID
public int GetMoveEnv() { return m_iMoveEnv; }
public bool IsShapeChanged() { return m_iShape != 0; }
public int GetWeaponID() { return m_aEquips[(int)EC_IvtrType.IndexOfIteminEquipmentInventory.EQUIPIVTR_WEAPON] & 0xffff; }
public bool IsAllResReady() { return (m_dwResFlags & (uint)PlayerResourcesReadyFlag.RESFG_ALL) == (uint)PlayerResourcesReadyFlag.RESFG_ALL; }
}
public struct PlayActionEvent
{
@@ -405,7 +414,15 @@ public struct INFO
this.crc_e = crc_;
}
}
public enum PlayerResourcesReadyFlag
{
RESFG_SKELETON = 0x01,
RESFG_SKIN = 0x02,
RESFG_CUSTOM = 0x04,
RESFG_ASSEMBLED = 0x08,
RESFG_ALL = 0x0f,
};
public static class Duel_state // Duel state
{
public const int DUEL_ST_NONE = 0,
@@ -889,6 +889,15 @@ namespace CSNetwork.GPDataType
public byte[] content;
};
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct cmd_host_attack_result
{
public int idTarget;
public int iDamage; // Èç¹ûÊÇ0±íʾûÓл÷ÖÐ
public int attack_flag; // ±ê¼Ç¸Ã¹¥»÷ÊÇ·ñÓй¥»÷ÓÅ»¯·ûºÍ·ÀÓùÓÅ»¯·ûºÍÖØ»÷·¢Éú
public byte attack_speed;
};
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct cmd_own_ivtr_detail_info
{
@@ -433,7 +433,7 @@ namespace CSNetwork
break;
case CommandID.HOST_ATTACKED:
BMLogger.LogError("HoangDev : HOST_ATTACKED");
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ATKRESULT, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ATTACKED, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
break;
case CommandID.ERROR_MESSAGE:
+228 -94
View File
@@ -1,6 +1,7 @@
using BrewMonster;
using BrewMonster.Network;
using CSNetwork;
using CSNetwork.Common;
using CSNetwork.GPDataType;
using CSNetwork.Protocols;
using CSNetwork.Protocols.RPCData;
@@ -12,6 +13,7 @@ using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using TMPro;
using Unity.VisualScripting;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.InputSystem;
@@ -133,19 +135,19 @@ public class CECHostPlayer : CECPlayer
{
CECObject clickedObject = hit.collider.gameObject.GetComponent<CECObject>();
if(clickedObject != null)
if (clickedObject != null)
{
int idObject = CECObject.GetObjectID(clickedObject);
if (idObject != 0)
{
CECNPC pNPC = EC_ManMessageMono.Instance._CECNPCMan.GetNPC(idObject);
if(pNPC != null)
if (pNPC != null)
{
if (!pNPC.IsDead())
{
idTraceTarget = idObject;
}
if (idTraceTarget != 0)
if (idTraceTarget != 0)
{
if (AttackableJudge(idObject, bForceAttack) == 1)
iTraceReason = CECHPWorkTrace.Trace_reason.TRACE_ATTACK;
@@ -329,26 +331,156 @@ public class CECHostPlayer : CECPlayer
case int value when value == EC_MsgDef.MSG_HST_PICKUPITEM:
OnMsgHstPickupItem(Msg);
break;
case int value when value == EC_MsgDef.MSG_HST_ATKRESULT: OnMsgHstAttackResult(Msg); break;
//case int value when value == EC_MsgDef.MSG_HST_ATTACKED: OnMsgHstAttacked(Msg); break;
case int value when value == EC_MsgDef.MSG_HST_HURTRESULT: OnMsgHstHurtResult(Msg); break;
}
}
public void OnMsgHstAttackResult(ECMSG Msg)
{
cmd_host_attack_result pCmd = (cmd_host_attack_result)Msg.dwParam1;
int iAttackTime = 0;
PlayAttackEffect(pCmd.idTarget, 0, 0, pCmd.iDamage, (uint)pCmd.attack_flag, pCmd.attack_speed * 50, ref iAttackTime);
TurnFaceTo(pCmd.idTarget);
if (iAttackTime != 0)
{
if (m_pWorkMan.GetRunningWork(CECHPWork.Host_work_ID.WORK_HACKOBJECT) is CECHPWorkMelee pCurWork)
{
pCurWork.SetIdleTime(iAttackTime);
}
}
}
public void PlayAttackEffect(int idTarget, int idSkill, int skillLevel, int nDamage,
uint dwModifier, int nAttackSpeed, ref int piAttackTime/* NULL */, int nSection = 0)
{
/* if (!IsAllResReady())
return;
if (idSkill == 0)
{
int idWeapon = IsShapeChanged() ? 0 : GetWeaponID();
int nTimeFly = 10;
if (idWeapon != 0)
{
// ¿´¿´ÊDz»ÊÇÔ¶³ÌÎäÆ÷
DATA_TYPE dt = default;
WEAPON_ESSENCE? pWeapon = (WEAPON_ESSENCE)ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)idWeapon, ID_SPACE.ID_SPACE_ESSENCE, ref dt);
if (dt == DATA_TYPE.DT_WEAPON_ESSENCE && pWeapon != null && pWeapon.Value.require_projectile != 0)
{
nTimeFly = 700;
if (m_aEquips[(int)EC_IvtrType.IndexOfIteminEquipmentInventory.EQUIPIVTR_PROJECTILE] != 0)
idWeapon = m_aEquips[(int)EC_IvtrType.IndexOfIteminEquipmentInventory.EQUIPIVTR_PROJECTILE];
}
}
if (g_pGame->GetGameRun()->GetWorld()->GetAttacksMan()->FindAttackByAttacker(GetPlayerInfo().cid))
{
// signal early attack event
ClearComActFlagAllRankNodes(true);
}
// melee attack
CECAttackEvent* pAttack = g_pGame->GetGameRun()->GetWorld()->GetAttacksMan()->AddMeleeAttack(
GetPlayerInfo().cid, idTarget, idWeapon, dwModifier, nDamage, nTimeFly);
if (pAttack)
{
if (!IsDead() && (dwModifier & CECAttackEvent::MOD_RETORT) == 0
&& (dwModifier & CECAttackEvent::MOD_ATTACK_AURA) == 0
&& PlayAttackAction(nAttackSpeed, piAttackTime, &pAttack->m_bSignaled)
&& (dwModifier & CECAttackEvent::MOD_BEAT_BACK) == 0)
{
}
else
{
pAttack->m_bSignaled = true;
}
}
}
else
{
if (skillLevel == 0)
{
if (m_pCurSkill)
skillLevel = m_pCurSkill->GetSkillLevel();
else
skillLevel = 1;
}
CECAttackEvent* pAttack = NULL;
// first try to find if there is already a skill attack event in attackman
CECAttackerEvents attackerEvents = g_pGame->GetGameRun()->GetWorld()->GetAttacksMan()->FindAttackByAttacker(GetPlayerInfo().cid);
if (attackerEvents)
{
if (CECAttackEvent * pAttack = attackerEvents.Find(idSkill, nSection))
{
// Ãæ¹¥»÷µÄ·ÇµÚÒ»´ÎÉ˺¦ÏûÏ¢
pAttack->AddTarget(idTarget, dwModifier, nDamage);
goto EXIT;
}
else
{
attackerEvents.Signal();
}
}
if (GNET::ElementSkill::IsGoblinSkill(idSkill) &&
GNET::ElementSkill::GetType(idSkill) == 2)
{
pAttack = g_pGame->GetGameRun()->GetWorld()->GetAttacksMan()->AddSkillAttack(
GetPlayerInfo().cid, GetPlayerInfo().cid, idTarget, GetWeaponID(), idSkill, skillLevel, dwModifier, nDamage);
}
else
{
// begin a skill attack
pAttack = g_pGame->GetGameRun()->GetWorld()->GetAttacksMan()->AddSkillAttack(
GetPlayerInfo().cid, m_idCurSkillTarget, idTarget, GetWeaponID(), idSkill, skillLevel, dwModifier, nDamage);
}
if (pAttack)
{
pAttack->SetSkillSection(nSection);
if (!IsDead() && (dwModifier & CECAttackEvent::MOD_RETORT) == 0
&& (dwModifier & CECAttackEvent::MOD_ATTACK_AURA) == 0
&& PlaySkillAttackAction(idSkill, nAttackSpeed, NULL, nSection, &pAttack->m_bSignaled)
&& (dwModifier & CECAttackEvent::MOD_BEAT_BACK) == 0)
{
}
else
{
pAttack->m_bSignaled = true;
}
}
EXIT:
// For skill attacking, time is always set to 0
if (piAttackTime)
*piAttackTime = 0;
}*/
}
private void OnMsgHstHurtResult(ECMSG Msg)
{
BMLogger.LogError("HoangDev : OnMsgHstHurtResult");
int cmd = Convert.ToInt32(Msg.dwParam2);
if (cmd == CommandID. BE_HURT)
if (cmd == CommandID.BE_HURT)
{
cmd_be_hurt pCmd = (cmd_be_hurt)Msg.dwParam1;
/* if (pCmd.damage!=0)
Damaged(pCmd->damage);*/
/* if (pCmd.damage!=0)
Damaged(pCmd->damage);*/
}
else if (cmd == CommandID. HURT_RESULT)
else if (cmd == CommandID.HURT_RESULT)
{
cmd_hurt_result pCmd = (cmd_hurt_result)Msg.dwParam1;
if (pCmd.target_id == m_PlayerInfo.cid)
return; // Host himself will receive BE_HURT, so ignore this.
if (UnityGameSession.Instance.GameSession. ISPLAYERID(pCmd.target_id))
if (UnityGameSession.Instance.GameSession.ISPLAYERID(pCmd.target_id))
{
/*CECElsePlayer pTarget = m_pPlayerMan.GetElsePlayer(pCmd.target_id);
if (pTarget)
@@ -369,85 +501,44 @@ public class CECHostPlayer : CECPlayer
switch (cmd)
{
case CommandID.PICKUP_ITEM:
{
// Parse the pickup item data from the server response
if (data != null && data.Length >= 16)
{
int tid = BitConverter.ToInt32(data, 0);
int expire_date = BitConverter.ToInt32(data, 4);
uint iAmount = BitConverter.ToUInt32(data, 8);
uint iSlotAmount = BitConverter.ToUInt32(data, 12);
byte byPackage = data[16];
byte bySlot = data[17];
Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}");
// Notify pickupItem script about successful pickup
pickupItem pickupScript = UnityEngine.Object.FindFirstObjectByType<pickupItem>();
if (pickupScript != null)
// Parse the pickup item data from the server response
if (data != null && data.Length >= 16)
{
pickupScript.OnPickupSuccess(tid);
}
// Create new inventory item data
var newItem = new InventoryItemData
{
Package = byPackage,
Slot = bySlot,
TemplateId = tid,
ExpireDate = expire_date,
State = 0,
Count = (int)iAmount,
Crc = 0,
Content = null
};
// Add item to inventory
EC_Inventory.SetItem(byPackage, bySlot, newItem);
Debug.Log($"[Inventory] Successfully added item {tid} to package {byPackage}, slot {bySlot} with count {iAmount}");
// Trigger UI refresh if an EC_InventoryUI is present in scene
var ui = GameObject.FindFirstObjectByType<EC_InventoryUI>();
if (ui != null)
{
ui.RefreshAll();
}
}
else
{
Debug.LogWarning("[Inventory] PICKUP_ITEM: Invalid data length");
}
break;
}
}
}
public void OnMsgHstItemOperation(ECMSG Msg)
{
var data = Msg.dwParam1 as byte[];
int cmd = Convert.ToInt32(Msg.dwParam2);
switch (cmd)
{
case CommandID.PLAYER_DROP_ITEM:
{
// Parse the drop item data from the server response
if (data != null && data.Length >= 6)
{
byte byPackage = data[0];
byte bySlot = data[1];
int count = BitConverter.ToInt32(data, 2);
int tid = BitConverter.ToInt32(data, 6);
byte reason = data[10];
Debug.Log($"[Inventory] PLAYER_DROP_ITEM: package={byPackage}, slot={bySlot}, count={count}, tid={tid}, reason={reason}");
// Update the inventory by removing the item
bool success = EC_Inventory.RemoveItem(byPackage, bySlot, count);
if (success)
{
Debug.Log($"[Inventory] Successfully removed {count} items from package {byPackage}, slot {bySlot}");
int tid = BitConverter.ToInt32(data, 0);
int expire_date = BitConverter.ToInt32(data, 4);
uint iAmount = BitConverter.ToUInt32(data, 8);
uint iSlotAmount = BitConverter.ToUInt32(data, 12);
byte byPackage = data[16];
byte bySlot = data[17];
Debug.Log($"[Inventory] PICKUP_ITEM: tid={tid}, expire_date={expire_date}, iAmount={iAmount}, iSlotAmount={iSlotAmount}, byPackage={byPackage}, bySlot={bySlot}");
// Notify pickupItem script about successful pickup
pickupItem pickupScript = UnityEngine.Object.FindFirstObjectByType<pickupItem>();
if (pickupScript != null)
{
pickupScript.OnPickupSuccess(tid);
}
// Create new inventory item data
var newItem = new InventoryItemData
{
Package = byPackage,
Slot = bySlot,
TemplateId = tid,
ExpireDate = expire_date,
State = 0,
Count = (int)iAmount,
Crc = 0,
Content = null
};
// Add item to inventory
EC_Inventory.SetItem(byPackage, bySlot, newItem);
Debug.Log($"[Inventory] Successfully added item {tid} to package {byPackage}, slot {bySlot} with count {iAmount}");
// Trigger UI refresh if an EC_InventoryUI is present in scene
var ui = GameObject.FindFirstObjectByType<EC_InventoryUI>();
if (ui != null)
@@ -457,15 +548,56 @@ public class CECHostPlayer : CECPlayer
}
else
{
Debug.LogWarning($"[Inventory] Failed to remove items from package {byPackage}, slot {bySlot}");
Debug.LogWarning("[Inventory] PICKUP_ITEM: Invalid data length");
}
break;
}
else
}
}
public void OnMsgHstItemOperation(ECMSG Msg)
{
var data = Msg.dwParam1 as byte[];
int cmd = Convert.ToInt32(Msg.dwParam2);
switch (cmd)
{
case CommandID.PLAYER_DROP_ITEM:
{
Debug.LogWarning("[Inventory] PLAYER_DROP_ITEM: Invalid data length");
// Parse the drop item data from the server response
if (data != null && data.Length >= 6)
{
byte byPackage = data[0];
byte bySlot = data[1];
int count = BitConverter.ToInt32(data, 2);
int tid = BitConverter.ToInt32(data, 6);
byte reason = data[10];
Debug.Log($"[Inventory] PLAYER_DROP_ITEM: package={byPackage}, slot={bySlot}, count={count}, tid={tid}, reason={reason}");
// Update the inventory by removing the item
bool success = EC_Inventory.RemoveItem(byPackage, bySlot, count);
if (success)
{
Debug.Log($"[Inventory] Successfully removed {count} items from package {byPackage}, slot {bySlot}");
// Trigger UI refresh if an EC_InventoryUI is present in scene
var ui = GameObject.FindFirstObjectByType<EC_InventoryUI>();
if (ui != null)
{
ui.RefreshAll();
}
}
else
{
Debug.LogWarning($"[Inventory] Failed to remove items from package {byPackage}, slot {bySlot}");
}
}
else
{
Debug.LogWarning("[Inventory] PLAYER_DROP_ITEM: Invalid data length");
}
break;
}
break;
}
case CommandID.EQUIP_ITEM:
{
byte index_inv = data[0];
@@ -924,7 +1056,7 @@ public class CECHostPlayer : CECPlayer
return Mathf.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z);
}
public int GetCharacterID(){ return m_PlayerInfo.cid; }
public int GetCharacterID() { return m_PlayerInfo.cid; }
public bool CannotAttack() { return (m_dwLIES & (uint)Logic_Influence_Extned_states.LIES_DISABLEFIGHT) != 0; }
@@ -993,17 +1125,19 @@ public class CECHostPlayer : CECPlayer
A3DVECTOR3 vector = new A3DVECTOR3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
return CanTouchTarget(vector, vTargetPos, fTargetRad, iReason, fMaxCut);
}
public bool IsRooting() {
public bool IsRooting()
{
var mask = (uint)(Logic_Influence_Extned_states.LIES_ROOT
| Logic_Influence_Extned_states.LIES_SLEEP
| Logic_Influence_Extned_states.LIES_STUN);
return (m_dwLIES & mask) != 0; }
return (m_dwLIES & mask) != 0;
}
bool IsInFortress() { return m_fortressEnter.role_in_war != 0; }
bool IsPVPOpen() { return m_pvp.bEnable; }
// Get faction ID
int GetFactionID(){ return m_idFaction; }
int GetFactionID() { return m_idFaction; }
public bool IsJumping() { return m_iJumpCount > 0; }