Merge remote-tracking branch 'origin/develop' into feature/HostAttack_Hoang
# Conflicts: # Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs # Assets/Scenes/a61.unity # Assets/Scripts/CECHostPlayer.cs
This commit is contained in:
@@ -413,7 +413,7 @@ namespace BrewMonster.Scripts
|
||||
{
|
||||
if (pWorkMove.GetAutoMove())
|
||||
{
|
||||
//pWorkMove.Finish();
|
||||
pWorkMove.Finish();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -606,6 +606,67 @@ namespace BrewMonster.Scripts
|
||||
StartAwaitingWorks();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFollowing()
|
||||
{
|
||||
return IsWorkRunning(CECHPWork.Host_work_ID.WORK_FOLLOW);
|
||||
}
|
||||
|
||||
public bool IsMovingToPosition()
|
||||
{
|
||||
return IsWorkRunning(CECHPWork.Host_work_ID.WORK_MOVETOPOS);
|
||||
}
|
||||
|
||||
public bool IsTracing()
|
||||
{
|
||||
return IsWorkRunning(CECHPWork.Host_work_ID.WORK_TRACEOBJECT);
|
||||
}
|
||||
|
||||
bool IsWorkRunning(int iWorkID)
|
||||
{
|
||||
bool result = false;
|
||||
if (ValidatePriority(m_iCurPriority))
|
||||
{
|
||||
WorkList workList = m_WorkStack[m_iCurPriority];
|
||||
if(workList != null)
|
||||
{
|
||||
for (int i = 0; i < workList.Count; ++i)
|
||||
{
|
||||
if (iWorkID == workList[i].GetWorkID())
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void FinishRunningWork(int idWork)
|
||||
{
|
||||
if (!IsWorkRunning(idWork))
|
||||
{
|
||||
return;
|
||||
}
|
||||
WorkList workList = m_WorkStack[m_iCurPriority];
|
||||
if(workList != null)
|
||||
{
|
||||
for (int i = 0; i < workList.Count;)
|
||||
{
|
||||
if (workList[i].GetWorkID() != idWork)
|
||||
{
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
KillWork(m_iCurPriority, i);
|
||||
}
|
||||
if (workList == null)
|
||||
{
|
||||
StartAwaitingWorks();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class CECHPWorkPostTickCommand
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace BrewMonster.Scripts
|
||||
m_vMoveDest = vMoveDest;
|
||||
m_bHaveDest = true;
|
||||
m_bGliding = false;
|
||||
//m_pHost->SetAdjustOrient(false); // 2014-9-10 徐文彬:在 CECHPWorkMove 创建的时候都会调用此函数,会导致其它时机通过 SetDestDirAndUp 调用对人物的朝向调整失效。
|
||||
//m_pHost.SetAdjustOrient(false); // 2014-9-10 徐文彬:在 CECHPWorkMove 创建的时候都会调用此函数,会导致其它时机通过 SetDestDirAndUp 调用对人物的朝向调整失效。
|
||||
// 重现方法为:月仙“望月咏”技能释放后、马上按住'A'或'D'等移动键并摁住不放,将导致人物施法方向偏离目标而朝向移动方向(需多次尝试)
|
||||
|
||||
//清空任务信息
|
||||
@@ -92,7 +92,7 @@ namespace BrewMonster.Scripts
|
||||
else if (IsAutoPF())
|
||||
{
|
||||
// TO DO: fix later
|
||||
//m_vCurDir = CECIntelligentRoute::Instance().GetCurDest() - m_pHost->GetPos();
|
||||
//m_vCurDir = CECIntelligentRoute::Instance().GetCurDest() - m_pHost.GetPos();
|
||||
//m_vCurDir.y = 0.0f;
|
||||
//m_vCurDir.Normalize();
|
||||
//if (m_bUseAutoMoveDialog)
|
||||
@@ -181,7 +181,7 @@ namespace BrewMonster.Scripts
|
||||
// if (m_iNPCTempleId)
|
||||
// {
|
||||
// CECNPC pNPC = g_pGame.GetGameRun().GetWorld().GetNPCMan().FindNPCByTempleID(m_iNPCTempleId);
|
||||
// if (pNPC && m_pHost.SelectTarget(pNPC->GetNPCID()))
|
||||
// if (pNPC && m_pHost.SelectTarget(pNPC.GetNPCID()))
|
||||
// {
|
||||
// CECHPWorkTrace pWork = m_pWorkMan.CreateNPCTraceWork(pNPC, m_iTaskId);
|
||||
// if (pWork)
|
||||
@@ -203,15 +203,15 @@ namespace BrewMonster.Scripts
|
||||
// if (!m_pHost.IsJumping() && !m_pHost.IsPlayingAction(CECPlayer::ACT_TRICK_RUN) &&
|
||||
// m_pHost.m_iMoveMode != CECPlayer::MOVE_SLIDE && !m_bMeetSlide)
|
||||
// {
|
||||
// int iAction = m_pHost->GetMoveStandAction(true);
|
||||
// int iAction = m_pHost.GetMoveStandAction(true);
|
||||
// m_pHost.PlayAction(iAction, false);
|
||||
// }
|
||||
|
||||
// Tick_Walk(fDeltaTime);
|
||||
//}
|
||||
//else // (m_pHost->m_iMoveEnv == CECPlayer::MOVEENV_AIR || m_pHost->m_iMoveEnv == CECPlayer::MOVEENV_WATER)
|
||||
//else // (m_pHost.m_iMoveEnv == CECPlayer::MOVEENV_AIR || m_pHost.m_iMoveEnv == CECPlayer::MOVEENV_WATER)
|
||||
//{
|
||||
// m_pHost->ResetJump();
|
||||
// m_pHost.ResetJump();
|
||||
|
||||
// // Play appropriate actions
|
||||
// if (!m_bGliding)
|
||||
@@ -273,9 +273,33 @@ namespace BrewMonster.Scripts
|
||||
bool IsAutoPF() { return m_iDestType == Types.DEST_AUTOPF; }
|
||||
|
||||
// Finish work
|
||||
void Finish()
|
||||
public void Finish()
|
||||
{
|
||||
m_bFinished = true;
|
||||
Cancel();
|
||||
|
||||
// Close 'Win_AutoPlay' dialog if it exists
|
||||
//CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan();
|
||||
//pGameUI.AutoMoveShowDialog(false);
|
||||
|
||||
if (m_bUseAutoMoveDialog)
|
||||
{
|
||||
if (m_bAutoLand)
|
||||
{
|
||||
m_bAutoLand = false;
|
||||
//if (g_pGame.GetGameRun().GetHostPlayer().IsFlying())
|
||||
// g_pGame.GetGameRun().GetHostPlayer().CmdFly(false);
|
||||
}
|
||||
|
||||
m_bUseAutoMoveDialog = false;
|
||||
m_fAutoHeight = -1.0f;
|
||||
m_bAutoFly = false;
|
||||
m_bReachedHeight = true;
|
||||
}
|
||||
|
||||
//清空任务追踪数据
|
||||
m_iNPCTempleId = 0;
|
||||
m_iTaskId = 0;
|
||||
}
|
||||
|
||||
void SetTaskNPCInfo(int tid, int taskid)
|
||||
@@ -288,8 +312,8 @@ namespace BrewMonster.Scripts
|
||||
//int tid, taskid;
|
||||
//tid = m_iNPCTempleId;
|
||||
//taskid = m_iTaskId;
|
||||
//CECGameUIMan* pGameUI = g_pGame->GetGameRun()->GetUIManager()->GetInGameUIMan();
|
||||
//pGameUI->SetAutoMoveShowDialogTarget((int)m_vMoveDest.x, (int)m_vMoveDest.z);
|
||||
//CECGameUIMan* pGameUI = g_pGame.GetGameRun().GetUIManager().GetInGameUIMan();
|
||||
//pGameUI.SetAutoMoveShowDialogTarget((int)m_vMoveDest.x, (int)m_vMoveDest.z);
|
||||
//SetDestination(CECHPWorkMove::DEST_2D, m_vMoveDest);
|
||||
//SetTaskNPCInfo(tid, taskid);
|
||||
//SetUseAutoMoveDialog(true);
|
||||
@@ -346,12 +370,12 @@ namespace BrewMonster.Scripts
|
||||
// bool bSwitchTo2D(true);
|
||||
// while (true)
|
||||
// {
|
||||
// if (m_pHost->IsFlying())
|
||||
// if (m_pHost.IsFlying())
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// CECHostBrushTest brushTester(m_pHost->GetPos(), m_pHost->m_CDRInfo.vExtent, m_pHost->m_CDRInfo.fStepHeight);
|
||||
// if (CECIntelligentRoute::Instance().Search(m_pHost->GetPos(), m_vMoveDest, &brushTester) != CECIntelligentRoute::enumSearchSuccess)
|
||||
// CECHostBrushTest brushTester(m_pHost.GetPos(), m_pHost.m_CDRInfo.vExtent, m_pHost.m_CDRInfo.fStepHeight);
|
||||
// if (CECIntelligentRoute::Instance().Search(m_pHost.GetPos(), m_vMoveDest, &brushTester) != CECIntelligentRoute::enumSearchSuccess)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
@@ -152,11 +152,11 @@ public abstract class CECTracedObject
|
||||
fTouchRadius = pNPC.GetTouchRadius();
|
||||
return m_pHost.CanTouchTarget(vHostPos, vTargetPos, fTouchRadius, iTouchReason, fMaxCut);
|
||||
}
|
||||
//else if (GPDataTypeHelper.ISMATTERID(m_iObjectId))
|
||||
//{
|
||||
// CECMatter pMatter = (pObject) as CECMatter;
|
||||
// return pMatter.CalcDist(vHostPos, true) < pMatter.GetGatherDist();
|
||||
//}
|
||||
else if (GPDataTypeHelper.ISMATTERID(m_iObjectId))
|
||||
{
|
||||
//CECMatter pMatter = (pObject) as CECMatter;
|
||||
//return pMatter.CalcDist(vHostPos, true) < pMatter.GetGatherDist();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
@@ -601,18 +601,18 @@ public class CECHPWorkTrace : CECHPWork
|
||||
{
|
||||
if (IsGoodTimeToTouch())
|
||||
{
|
||||
OnTouchTarget();
|
||||
return true;
|
||||
//if (m_pTraceObject.CanTouchFrom(m_pHost.GetPos()))
|
||||
//{
|
||||
// OnTouchTarget();
|
||||
// return true;
|
||||
//}
|
||||
//OnTouchTarget();
|
||||
//return true;
|
||||
if (m_pTraceObject.CanTouchFrom(m_pHost.GetPos() + new A3DVECTOR3(0f, m_pHost.m_CDRInfo.vExtent.y, 0f)))
|
||||
{
|
||||
OnTouchTarget();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_bCheckTouch = true;
|
||||
|
||||
return true; // TO DO: remove later
|
||||
//return true; // TO DO: remove later
|
||||
if (!m_pHost.IsRooting())
|
||||
{
|
||||
// Continue tracing object
|
||||
@@ -829,6 +829,7 @@ public class CECHPWorkTrace : CECHPWork
|
||||
vCurPos = m_pHost.m_MoveCtrl.GroundMove(m_vCurDirH, m_pHost.GetGroundSpeed(), fDeltaTime);
|
||||
if (m_pHost.m_MoveCtrl.MoveBlocked() >= 3)
|
||||
{
|
||||
Debug.LogError("SendStopMoveCmd");
|
||||
m_pHost.m_MoveCtrl.SetSlideLock(true);
|
||||
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), m_pHost.GetGroundSpeed(), (int)GPMoveMode.GP_MOVE_SLIDE);
|
||||
m_bFinished = true;
|
||||
@@ -840,6 +841,7 @@ public class CECHPWorkTrace : CECHPWork
|
||||
//{
|
||||
// CECIntelligentRoute::Instance().OnPlayerPosChange(vCurPos);
|
||||
//}
|
||||
Debug.LogError("SendMoveCmd");
|
||||
m_pHost.m_MoveCtrl.SendMoveCmd(vCurPos, 2, GPDataTypeHelper.g_vOrigin, EC_Utility.ToA3DVECTOR3(cdr.vAbsVelocity), (int)GPMoveMode.GP_MOVE_SLIDE);
|
||||
}
|
||||
}
|
||||
@@ -875,7 +877,7 @@ public class CECHPWorkTrace : CECHPWork
|
||||
}
|
||||
|
||||
vCurPos = m_pHost.m_MoveCtrl.GroundMove(m_vCurDirH, m_pHost.GetGroundSpeed(), fDeltaTime, m_pHost.m_fVertSpeed);
|
||||
Debug.LogError(vCurPos);
|
||||
|
||||
m_pHost.SetPos(EC_Utility.ToVector3(vCurPos));
|
||||
//if (GetUseAutoPF() && CECIntelligentRoute::Instance().IsMoveOn())
|
||||
//{
|
||||
@@ -892,11 +894,15 @@ public class CECHPWorkTrace : CECHPWork
|
||||
|
||||
if (m_pHost.m_MoveCtrl.MoveBlocked() >= 3)
|
||||
{
|
||||
// m_pHost.m_MoveCtrl.SendStopMoveCmd(vCurPos, m_pHost.GetGroundSpeed(), iMoveMode);
|
||||
Debug.LogError("SendStopMoveCmd");
|
||||
m_pHost.m_MoveCtrl.SendStopMoveCmd(EC_Utility.ToVector3(vCurPos), m_pHost.GetGroundSpeed(), iMoveMode);
|
||||
PressCancel();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("SendMoveCmd");
|
||||
m_pHost.m_MoveCtrl.SendMoveCmd(vCurPos, 0, vTargetPos, EC_Utility.ToA3DVECTOR3(cdr.vAbsVelocity), iMoveMode);
|
||||
}
|
||||
}
|
||||
else // m_bMeetSlide == true
|
||||
{
|
||||
|
||||
@@ -1081,6 +1081,7 @@ public abstract class CECPlayer : CECObject
|
||||
public float GetGroundSpeed()
|
||||
{
|
||||
// return m_bWalkRun ? g_pGame.GetConfigs().GetHostRunSpeed() : m_ExtProps.mv.walk_speed;
|
||||
return 5f;
|
||||
return m_bWalkRun ? m_ExtProps.mv.run_speed : m_ExtProps.mv.walk_speed;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,11 @@ namespace BrewMonster.Scripts
|
||||
public static class EC_CDR
|
||||
{
|
||||
// Cho phép CECHostMove gán mask theo scene (giữ linh hoạt nhưng không phá cấu trúc)
|
||||
public static LayerMask BrushMask { get; set; } = ~0;
|
||||
public static LayerMask TerrainMask { get; set; } = ~0;
|
||||
public static LayerMask BrushMask { get; set; } = 1<<7;
|
||||
public static LayerMask TerrainMask { get; set; } = 1<<6;
|
||||
|
||||
const float LOCAL_EPSILON = 1e-5f;
|
||||
|
||||
//[Flags]
|
||||
public class CDR_EVN
|
||||
{
|
||||
@@ -86,37 +87,44 @@ namespace BrewMonster.Scripts
|
||||
}
|
||||
|
||||
// == Thay CollideWithEnv (C++) bằng BoxCast ==
|
||||
static bool CollideWithEnv_BoxCast(Vector3 vStart, Vector3 vDelta, Vector3 vExt,
|
||||
LayerMask mask,
|
||||
out RaycastHit hit, out float fFraction, out Vector3 vHitNormal, out bool bStartSolid,
|
||||
float skin = 0.01f)
|
||||
{
|
||||
hit = default;
|
||||
vHitNormal = Vector3.up;
|
||||
bStartSolid = false;
|
||||
fFraction = 1.0f;
|
||||
//static bool CollideWithEnv_BoxCast(Vector3 vStart, Vector3 vDelta, Vector3 vExt,
|
||||
// LayerMask mask,
|
||||
// out RaycastHit hit, out float fFraction, out Vector3 vHitNormal, out bool bStartSolid,
|
||||
// float skin = 0.01f)
|
||||
//{
|
||||
// hit = default;
|
||||
// vHitNormal = Vector3.up;
|
||||
// bStartSolid = false;
|
||||
// fFraction = 0.0f;
|
||||
|
||||
float dist = vDelta.magnitude;
|
||||
if (dist <= 1e-6f) return false;
|
||||
// float dist = vDelta.magnitude;
|
||||
// if (dist <= 1e-6f) return false;
|
||||
|
||||
// start-in-solid
|
||||
var overlapped = Physics.OverlapBox(vStart, vExt - Vector3.one * skin, Quaternion.identity, mask, QueryTriggerInteraction.Ignore);
|
||||
if (overlapped != null && overlapped.Length > 0)
|
||||
{
|
||||
bStartSolid = true;
|
||||
return true;
|
||||
}
|
||||
// var hasHit = Physics.Raycast(vStart, vDelta,out hit, dist, mask);
|
||||
// if (hasHit)
|
||||
// {
|
||||
// bStartSolid = true;
|
||||
// fFraction = (t - 5E-4f) / vDelta.Normalize();
|
||||
// return true;
|
||||
// }
|
||||
// // start-in-solid
|
||||
// var overlapped = Physics.OverlapBox(vStart, vExt - Vector3.one * skin, Quaternion.identity, mask, QueryTriggerInteraction.Ignore);
|
||||
// if (overlapped != null && overlapped.Length > 0)
|
||||
// {
|
||||
// bStartSolid = true;
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// sweep AABB
|
||||
Vector3 dir = vDelta / Mathf.Max(dist, 1e-6f);
|
||||
if (Physics.BoxCast(vStart, vExt - Vector3.one * skin, dir, out hit, Quaternion.identity, dist, mask, QueryTriggerInteraction.Ignore))
|
||||
{
|
||||
fFraction = Mathf.Clamp01(hit.distance / Mathf.Max(dist, 1e-6f));
|
||||
vHitNormal = hit.normal;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// // sweep AABB
|
||||
// Vector3 dir = vDelta / Mathf.Max(dist, 1e-6f);
|
||||
// if (Physics.BoxCast(vStart, vExt - Vector3.one * skin, dir, out hit, Quaternion.identity, dist, mask, QueryTriggerInteraction.Ignore))
|
||||
// {
|
||||
// fFraction = Mathf.Clamp01(hit.distance / Mathf.Max(dist, 1e-6f));
|
||||
// vHitNormal = hit.normal;
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
// == Thay RetrieveSupportPlane (C++) bằng Raycast xuống ==
|
||||
static bool DoGroundProbe(Vector3 vStart, Vector3 vExt, float fDeltaY, LayerMask mask,
|
||||
@@ -159,16 +167,28 @@ namespace BrewMonster.Scripts
|
||||
bool bJump = (fYVel > 0.5f);
|
||||
|
||||
Vector3 vVelocity = CDRInfo.fSpeed * new Vector3(CDRInfo.vXOZVelDir.x, 0f, CDRInfo.vXOZVelDir.z) + fYVel * Vector3.up;
|
||||
|
||||
|
||||
if (bFreeFall)
|
||||
{
|
||||
vVelocity += -CDRInfo.fGravityAccel * CDRInfo.t * Vector3.up;
|
||||
fYVel += -CDRInfo.fGravityAccel * CDRInfo.t;
|
||||
}
|
||||
|
||||
Vector3 vVelDir = vVelocity;
|
||||
float fVelSpeed = vVelDir.magnitude;
|
||||
if (fVelSpeed > 1e-6f) vVelDir /= fVelSpeed; else vVelDir = Vector3.zero;
|
||||
if (!bFreeFall) fVelSpeed = Mathf.Min(fVelSpeed, VEL_MAX_SPEED);
|
||||
//vVelDir = vVelDir.normalized;
|
||||
if (fVelSpeed > 1e-6f)
|
||||
{
|
||||
vVelDir /= fVelSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
vVelDir = Vector3.zero;
|
||||
}
|
||||
if (!bFreeFall)
|
||||
{
|
||||
fVelSpeed = Mathf.Min(fVelSpeed, VEL_MAX_SPEED);
|
||||
}
|
||||
vVelocity = vVelDir * fVelSpeed;
|
||||
|
||||
float dtp = Vector3.Dot(vVelDir, CDRInfo.vTPNormal);
|
||||
@@ -190,96 +210,98 @@ namespace BrewMonster.Scripts
|
||||
int nTry = 0;
|
||||
LayerMask mask = UsedMask_Ground();
|
||||
|
||||
while (nTry < 4)
|
||||
while (nTry < 1)
|
||||
{
|
||||
vDelta = vVelocity * fTime;
|
||||
float fDeltaDist = vDelta.magnitude;
|
||||
if (fDeltaDist < DIST_EPSILON) break;
|
||||
//if (fDeltaDist < DIST_EPSILON) break;
|
||||
|
||||
// TO DO: fix later beacuse logic in CollideWithEnv_BoxCast is wrong
|
||||
//bool hasHit = CollideWithEnv_BoxCast(vStart, vDelta, vExt, mask,
|
||||
// out RaycastHit hit, out float fFraction, out Vector3 hitNormal, out bool bStartSolid);
|
||||
bool hasHit = false, bStartSolid = false;
|
||||
float fFraction = 0f;
|
||||
Vector3 hitNormal = Vector3.zero;
|
||||
Vector3 posFoot = vStart - Vector3.up * vExt.y;
|
||||
Debug.DrawLine(vStart, posFoot + vVelocity, Color.yellow, 10f);
|
||||
bool bClear = !Physics.Raycast(posFoot, (posFoot + vVelocity).normalized, out RaycastHit hit, fDeltaDist, mask);
|
||||
nTry++;
|
||||
|
||||
if (bStartSolid)
|
||||
{
|
||||
CDRInfo.fMoveDist = 0f;
|
||||
if (CDRInfo.vTPNormal.y < CDRInfo.fSlopeThresh) CDRInfo.vTPNormal = Vector3.up;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!hasHit)
|
||||
if (bClear)
|
||||
{
|
||||
vFinalPos = vStart + vDelta;
|
||||
Debug.DrawLine(vStart, vFinalPos, Color.red, 10f);
|
||||
CDRInfo.fMoveDist += fDeltaDist;
|
||||
break;
|
||||
}
|
||||
Debug.LogError("Hit");
|
||||
//if (bStartSolid)
|
||||
//{
|
||||
// CDRInfo.fMoveDist = 0f;
|
||||
// if (CDRInfo.vTPNormal.y < CDRInfo.fSlopeThresh) CDRInfo.vTPNormal = Vector3.up;
|
||||
// return;
|
||||
//}
|
||||
|
||||
vStart += vDelta * fFraction;
|
||||
CDRInfo.fMoveDist += (fDeltaDist * fFraction);
|
||||
fTime -= fTime * fFraction;
|
||||
vNormal = hitNormal;
|
||||
|
||||
vStart = hit.point + Vector3.up * vExt.y;
|
||||
vFinalPos = vStart;
|
||||
//CDRInfo.fMoveDist += (fDeltaDist * fFraction);
|
||||
//fTime -= fTime * fFraction;
|
||||
//vNormal = hitNormal;
|
||||
|
||||
// Step-up (giữ tinh thần bản gốc)
|
||||
if (!bFreeFall && !bTryPull && !bJump)
|
||||
{
|
||||
float skin = 0.01f;
|
||||
Vector3 vStartUp = vStart + new Vector3(0f, CDRInfo.fStepHeight, 0f);
|
||||
bool upBlocked = Physics.CheckBox(vStartUp, vExt - Vector3.one * skin, Quaternion.identity, mask, QueryTriggerInteraction.Ignore);
|
||||
if (!upBlocked)
|
||||
//float skin = 0.01f;
|
||||
posFoot = vStart - Vector3.up * vExt.y;
|
||||
Vector3 vStartUp = new Vector3(0f, CDRInfo.fStepHeight, 0f);
|
||||
bPull = !Physics.Raycast(posFoot, (posFoot + vStartUp).normalized, out hit, mask);
|
||||
if (bPull)
|
||||
{
|
||||
vStart += Vector3.up * CDRInfo.fStepHeight;
|
||||
posFoot = vStart - Vector3.up * vExt.y;
|
||||
Vector3 vDelta2 = vVelocity;
|
||||
bool hasHit2 = CollideWithEnv_BoxCast(vStartUp, vDelta2, vExt, mask,
|
||||
out RaycastHit hit2, out float frac2, out Vector3 hitNormal2, out bool bStartSolid2);
|
||||
if (hasHit2) vDelta2 *= frac2;
|
||||
|
||||
if (vDelta2.sqrMagnitude >= (vExt.x * vExt.x * 4f))
|
||||
bool bMove = !Physics.Raycast(posFoot, (posFoot + vVelocity).normalized, out hit, mask);
|
||||
if (!bMove)
|
||||
{
|
||||
vStart = vStartUp;
|
||||
vDelta = vDelta2;
|
||||
|
||||
float distAll = vVelocity.magnitude;
|
||||
float distMoved = vDelta.magnitude;
|
||||
if (distAll > 1e-6f) fTime *= Mathf.Clamp01(distMoved / Mathf.Max(distAll, 1e-6f));
|
||||
|
||||
bPull = true;
|
||||
//vDelta2 *= frac2;
|
||||
vFinalPos = hit.point + Vector3.up * vExt.y;
|
||||
}
|
||||
|
||||
//if (vDelta2.sqrMagnitude < (vExt.x * vExt.x * 4f))
|
||||
//{
|
||||
// vStart -= Vector3.up * CDRInfo.fStepHeight;
|
||||
// bPull = false;
|
||||
//}
|
||||
}
|
||||
bTryPull = true;
|
||||
}
|
||||
|
||||
if (!bPull)
|
||||
{
|
||||
if (vVelocity.sqrMagnitude > 1e-12f)
|
||||
{
|
||||
vVelDir = vVelocity.normalized;
|
||||
fVelSpeed = vVelocity.magnitude * (1f - nTry * 0.1f);
|
||||
//if (!bPull)
|
||||
//{
|
||||
// if (vVelocity.sqrMagnitude > 1e-12f)
|
||||
// {
|
||||
// vVelDir = vVelocity.normalized;
|
||||
// fVelSpeed = vVelocity.magnitude * (1f - nTry * 0.1f);
|
||||
|
||||
dtp = Vector3.Dot(vNormal, vVelDir);
|
||||
float fRelSpeed = Mathf.Min(fVelSpeed, 5.0f);
|
||||
// dtp = Vector3.Dot(vNormal, vVelDir);
|
||||
// float fRelSpeed = Mathf.Min(fVelSpeed, 5.0f);
|
||||
|
||||
if (dtp >= 0f && dtp < 1e-4f)
|
||||
{
|
||||
vVelocity += vNormal * VEL_REFLECT * fRelSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
vVelocity = (vVelDir - vNormal * dtp) * fVelSpeed - vNormal * dtp * VEL_REFLECT * fRelSpeed;
|
||||
}
|
||||
}
|
||||
// if (dtp >= 0f && dtp < 1e-4f)
|
||||
// {
|
||||
// vVelocity += vNormal * VEL_REFLECT * fRelSpeed;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// vVelocity = (vVelDir - vNormal * dtp) * fVelSpeed - vNormal * dtp * VEL_REFLECT * fRelSpeed;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (fYVel > VEL_EPSILON)
|
||||
{
|
||||
if (vNormal.y >= CDRInfo.fSlopeThresh || vNormal.y < -NORMAL_EPSILON) fYVel = 0f;
|
||||
}
|
||||
else if (fYVel < -VEL_EPSILON)
|
||||
{
|
||||
if (vNormal.y >= CDRInfo.fSlopeThresh) fYVel = 0f;
|
||||
}
|
||||
}
|
||||
// if (fYVel > VEL_EPSILON)
|
||||
// {
|
||||
// if (vNormal.y >= CDRInfo.fSlopeThresh || vNormal.y < -NORMAL_EPSILON) fYVel = 0f;
|
||||
// }
|
||||
// else if (fYVel < -VEL_EPSILON)
|
||||
// {
|
||||
// if (vNormal.y >= CDRInfo.fSlopeThresh) fYVel = 0f;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
// “vertical ground trace” – thay RetrieveSupportPlane
|
||||
|
||||
@@ -1353,5 +1353,18 @@ namespace CSNetwork.GPDataType
|
||||
{
|
||||
public int idTarget;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct cmd_host_notify_root
|
||||
{
|
||||
public A3DVECTOR3 pos;
|
||||
public byte type;
|
||||
};
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct cmd_host_dispel_root
|
||||
{
|
||||
public byte type;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@ namespace CSNetwork
|
||||
{
|
||||
public class GameSession : IDisposable
|
||||
{
|
||||
private static IPrefixedLogger
|
||||
_logger = LoggerFactory.GetLogger(nameof(GameSession)); // Get class-specific logger
|
||||
private static IPrefixedLogger _logger = LoggerFactory.GetLogger(nameof(GameSession)); // Get class-specific logger
|
||||
|
||||
private NetworkManager _networkManager;
|
||||
private string _host;
|
||||
@@ -32,10 +31,8 @@ namespace CSNetwork
|
||||
private string _password;
|
||||
private int _currentUserId = -1; // To store the UserID after successful login
|
||||
private int m_iCharID;
|
||||
private int m_idLastSelTarget = 0; // ID of selected item last time
|
||||
|
||||
private int m_idLastSelTarget = 0; // ID of selected item last time
|
||||
CECStringTab m_ErrorMsgs;
|
||||
|
||||
// State management for async operations and callbacks
|
||||
private Action<bool> _loginCallback;
|
||||
private Action<List<RoleInfo>> _roleListCallback;
|
||||
@@ -68,7 +65,6 @@ namespace CSNetwork
|
||||
_logger = LoggerFactory.GetCustomLogger(path, nameof(GameSession) + GetHashCode(), LoggerType.File);
|
||||
_networkManager.SetLogPath(path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Connects to the game server asynchronously.
|
||||
/// </summary>
|
||||
@@ -82,7 +78,6 @@ namespace CSNetwork
|
||||
_logger.Log(LogType.Warning, "ConnectAsync called but already connected.");
|
||||
return;
|
||||
}
|
||||
|
||||
_host = host;
|
||||
_port = port;
|
||||
_logger.Log(LogType.Info, $"Attempting to connect to {_host}:{_port}...");
|
||||
@@ -95,8 +90,7 @@ namespace CSNetwork
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Log(LogType.Warning,
|
||||
"Connection failed after ConnectAsync completed (check NetworkManager logs/events).");
|
||||
_logger.Log(LogType.Warning, "Connection failed after ConnectAsync completed (check NetworkManager logs/events).");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -127,7 +121,6 @@ namespace CSNetwork
|
||||
callback?.Invoke(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_loginCallback != null)
|
||||
{
|
||||
_logger.Log(LogType.Warning, "LoginAsync called while another login is already in progress.");
|
||||
@@ -155,18 +148,15 @@ namespace CSNetwork
|
||||
callback?.Invoke(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_currentUserId == -1)
|
||||
{
|
||||
_logger.Log(LogType.Warning, "GetRoleListAsync called but not logged in.");
|
||||
callback?.Invoke(null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_roleListCallback != null)
|
||||
{
|
||||
_logger.Log(LogType.Warning,
|
||||
"GetRoleListAsync called while another role list retrieval is already in progress.");
|
||||
_logger.Log(LogType.Warning, "GetRoleListAsync called while another role list retrieval is already in progress.");
|
||||
callback?.Invoke(null);
|
||||
return;
|
||||
}
|
||||
@@ -176,12 +166,10 @@ namespace CSNetwork
|
||||
_logger.Log(LogType.Info, "Requesting role list...");
|
||||
RequestRoleListInternal();
|
||||
}
|
||||
|
||||
public RoleInfo GetRoleInfo()
|
||||
{
|
||||
return _selectedRole;
|
||||
}
|
||||
|
||||
public void SelectRoleAsync(RoleInfo role, Action<RoleInfo> callback)
|
||||
{
|
||||
_selectedRole = role;
|
||||
@@ -192,8 +180,8 @@ namespace CSNetwork
|
||||
Roleid = role.roleid,
|
||||
Flag = 0
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
public void EnterWorldAsync(RoleInfo role, Action callback)
|
||||
{
|
||||
SendProtocol(new enterworld()
|
||||
@@ -202,14 +190,12 @@ namespace CSNetwork
|
||||
Provider_link_id = 0,
|
||||
}, callback);
|
||||
}
|
||||
|
||||
public void RequestDropIvtrItem(byte index, int amount)
|
||||
{
|
||||
gamedatasend gamedatasendRequest = new gamedatasend();
|
||||
gamedatasendRequest.Data = C2SCommandFactory.CreateDropIvtrItem(index, amount);
|
||||
SendProtocol(gamedatasendRequest);
|
||||
}
|
||||
|
||||
public void RequestDropEquipItem(byte index)
|
||||
{
|
||||
gamedatasend gamedatasendRequest = new gamedatasend();
|
||||
@@ -223,7 +209,6 @@ namespace CSNetwork
|
||||
gamedatasendRequest.Data = C2SCommandFactory.CreatePickupItem(idItem, tid);
|
||||
SendProtocol(gamedatasendRequest);
|
||||
}
|
||||
|
||||
public void RequestInventoryAsync(byte byPackage, Action callback)
|
||||
{
|
||||
gamedatasend gamedatasendRequest = new gamedatasend();
|
||||
@@ -237,7 +222,6 @@ namespace CSNetwork
|
||||
gamedatasendRequest.Data = C2SCommandFactory.CreateQueryPlayerCash();
|
||||
SendProtocol(gamedatasendRequest);
|
||||
}
|
||||
|
||||
public void RequestCheckSecurityPassWd(string password)
|
||||
{
|
||||
gamedatasend gamedatasendRequest = new gamedatasend();
|
||||
@@ -258,7 +242,6 @@ namespace CSNetwork
|
||||
gamedatasendRequest.Data = CSNetwork.C2SCommand.C2SCommandFactory.CreateGetMallShopping(count, goodsArray);
|
||||
SendProtocol(gamedatasendRequest);
|
||||
}
|
||||
|
||||
public void RequestOwnItemInfoAsync(
|
||||
byte byPackage,
|
||||
byte bySlot,
|
||||
@@ -272,8 +255,7 @@ namespace CSNetwork
|
||||
Action callback)
|
||||
{
|
||||
gamedatasend gamedatasendRequest = new gamedatasend();
|
||||
gamedatasendRequest.Data = C2SCommandFactory.CreateOwnItemInfo(byPackage, bySlot, type, expire_date, state,
|
||||
count, crc, content_length, content);
|
||||
gamedatasendRequest.Data = C2SCommandFactory.CreateOwnItemInfo(byPackage, bySlot, type, expire_date, state, count, crc, content_length, content);
|
||||
SendProtocol(gamedatasendRequest, callback);
|
||||
}
|
||||
|
||||
@@ -282,8 +264,7 @@ namespace CSNetwork
|
||||
{
|
||||
if (IsConnected)
|
||||
{
|
||||
_logger.Log(LogType.Debug,
|
||||
$"Sending protocol: {protocol.GetType().Name} (Detail: {protocol.ToString})");
|
||||
_logger.Log(LogType.Debug, $"Sending protocol: {protocol.GetType().Name} (Detail: {protocol.ToString})");
|
||||
_networkManager.Send(protocol);
|
||||
complete?.Invoke();
|
||||
}
|
||||
@@ -297,11 +278,13 @@ namespace CSNetwork
|
||||
|
||||
private void OnProtocolReceived(Protocol protocol)
|
||||
{
|
||||
|
||||
_logger.Log(LogType.Debug, $"Received protocol: {protocol.GetType().Name} (Type: {protocol.Type})");
|
||||
if (protocol is null)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
// Route protocol to appropriate handler
|
||||
switch (protocol.GetPType())
|
||||
{
|
||||
@@ -390,8 +373,7 @@ namespace CSNetwork
|
||||
case CommandID.PLAYER_INFO_00:
|
||||
case CommandID.SELF_INFO_1:
|
||||
// OnMsgPlayerInfo(-1, pDataBuf, pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERINFO, (int)MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf,
|
||||
pCmdHeader, iHostID, _selectedRole);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERINFO, (int)MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader, iHostID, _selectedRole);
|
||||
break;
|
||||
case CommandID.OBJECT_MOVE:
|
||||
int lenghtDataType = Marshal.SizeOf<int>();
|
||||
@@ -399,38 +381,31 @@ namespace CSNetwork
|
||||
int idObjMove = BitConverter.ToInt32(arrByteData);
|
||||
if (ISPLAYERID(idObjMove))
|
||||
{
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERMOVE, (int)MANAGER_INDEX.MAN_PLAYER, -1,
|
||||
pDataBuf, pCmdHeader, iHostID);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERMOVE, (int)MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader, iHostID);
|
||||
}
|
||||
else if (ISNPCID(idObjMove))
|
||||
{
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCMOVE, (int)MANAGER_INDEX.MAN_NPC, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCMOVE, (int)MANAGER_INDEX.MAN_NPC, 0, pDataBuf, pCmdHeader);
|
||||
}
|
||||
|
||||
break;
|
||||
case CommandID.OBJECT_STOP_MOVE:
|
||||
{
|
||||
int id1 = GPDataTypeHelper.FromBytes<int>(pDataBuf);
|
||||
if (ISPLAYERID(id1))
|
||||
{
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERSTOPMOVE, (int)MANAGER_INDEX.MAN_PLAYER, -1,
|
||||
pDataBuf, pCmdHeader);
|
||||
int id1 = GPDataTypeHelper.FromBytes<int>(pDataBuf);
|
||||
if (ISPLAYERID(id1))
|
||||
{
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERSTOPMOVE, (int)MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
|
||||
}
|
||||
else if (ISNPCID(id1))
|
||||
{
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCSTOPMOVE, (int)MANAGER_INDEX.MAN_NPC, 0, pDataBuf, pCmdHeader);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (ISNPCID(id1))
|
||||
{
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCSTOPMOVE, (int)MANAGER_INDEX.MAN_NPC, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case CommandID.OWN_IVTR_DATA:
|
||||
case CommandID.OWN_IVTR_DETAIL_DATA:
|
||||
case CommandID.OWN_IVTR_DETAIL_DATA:
|
||||
case CommandID.GET_OWN_MONEY:
|
||||
case CommandID.CHANGE_IVTR_SIZE:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_IVTRINFO, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader, iHostID);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_IVTRINFO, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader, iHostID);
|
||||
break;
|
||||
case CommandID.EXG_IVTR_ITEM:
|
||||
case CommandID.MOVE_IVTR_ITEM:
|
||||
@@ -440,61 +415,49 @@ namespace CSNetwork
|
||||
case CommandID.MOVE_EQUIP_ITEM:
|
||||
case CommandID.UNFREEZE_IVTR_SLOT:
|
||||
case CommandID.PLAYER_EQUIP_TRASHBOX_ITEM:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ITEMOPERATION, (int)MANAGER_INDEX.MAN_PLAYER, 0,
|
||||
pDataBuf, pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ITEMOPERATION, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.PLAYER_CASH:
|
||||
{
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_IVTRINFO, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader, iHostID);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_IVTRINFO, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader, iHostID);
|
||||
break;
|
||||
}
|
||||
case CommandID.MATTER_INFO_LIST:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_MM_MATTERINFO, (int)MANAGER_INDEX.MAN_MATTER, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_MM_MATTERINFO, (int)MANAGER_INDEX.MAN_MATTER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.MATTER_ENTER_WORLD:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_MM_MATTERENTWORLD, (int)MANAGER_INDEX.MAN_MATTER, 0,
|
||||
pDataBuf, pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_MM_MATTERENTWORLD, (int)MANAGER_INDEX.MAN_MATTER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.PICKUP_ITEM:
|
||||
case CommandID.PICKUP_ITEM:
|
||||
case CommandID.HOST_OBTAIN_ITEM:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_PICKUPITEM, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_PICKUPITEM, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.MATTER_PICKUP:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PICKUPMATTER, (int)MANAGER_INDEX.MAN_PLAYER, -1,
|
||||
pDataBuf, pCmdHeader);
|
||||
break;
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PICKUPMATTER, (int)MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.PICKUP_MONEY:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_PICKUPMONEY, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_PICKUPMONEY, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.HOST_CORRECT_POS:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_CORRECTPOS, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader, iHostID);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_CORRECTPOS, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader, iHostID);
|
||||
break;
|
||||
case CommandID.OWN_ITEM_INFO:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_OWNITEMINFO, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader, iHostID);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_OWNITEMINFO, (int)MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader, iHostID);
|
||||
break;
|
||||
case CommandID.NPC_ENTER_SLICE:
|
||||
case CommandID.NPC_INFO_LIST:
|
||||
case CommandID.NPC_INFO_00:
|
||||
case CommandID.NPC_ENTER_WORLD:
|
||||
case CommandID.NPC_VISIBLE_TID_NOTIFY:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCINFO, (int)MANAGER_INDEX.MAN_NPC, 0, pDataBuf,
|
||||
pCmdHeader, dwDataSize);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCINFO, (int)MANAGER_INDEX.MAN_NPC, 0, pDataBuf, pCmdHeader, dwDataSize);
|
||||
break;
|
||||
case CommandID.TASK_DATA:
|
||||
case CommandID.TASK_VAR_DATA:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_TASKDATA, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader, dwDataSize);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_TASKDATA, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader, dwDataSize);
|
||||
break;
|
||||
case CommandID.BE_HURT:
|
||||
case CommandID.HURT_RESULT:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_HURTRESULT, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_HURTRESULT, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.OBJECT_ATTACK_RESULT:
|
||||
//int id = GPDataTypeHelper.FromBytes<int>(pDataBuf);
|
||||
@@ -502,39 +465,38 @@ namespace CSNetwork
|
||||
//BMLogger.LogError($"OBJECT_ATTACK_RESULT: npc ? " + ISNPCID(id));
|
||||
|
||||
if (ISPLAYERID(pCmdAtk.attacker_id))
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERATKRESULT, MANAGER_INDEX.MAN_PLAYER, -1,
|
||||
pDataBuf, pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERATKRESULT, MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
|
||||
else if (ISNPCID(pCmdAtk.attacker_id))
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCATKRESULT, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCATKRESULT, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.HOST_ATTACKRESULT:
|
||||
_logger.Info($"HOST_ATTACKRESULT: " + pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ATKRESULT, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ATKRESULT, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.HOST_ATTACKED:
|
||||
_logger.Info($"HOST_ATTACKED: " + pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ATTACKED, 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:
|
||||
_logger.Info($"### GameDataSend: ERROR_MESSAGE: {BitConverter.ToInt32(pDataBuf, 0)}");
|
||||
cmd_error_msg pCmd = GPDataTypeHelper.FromBytes<cmd_error_msg>(pDataBuf);
|
||||
cmd_error_msg pCmd = GPDataTypeHelper.FromBytes<cmd_error_msg>(pDataBuf);
|
||||
BMLogger.LogError("hOANGdEV : ERROR_MESSAGE pCmd.iMessage!=0 " + pCmd.iMessage);
|
||||
|
||||
if (pCmd.iMessage != 0)
|
||||
if (pCmd.iMessage!=0)
|
||||
{
|
||||
|
||||
string szMsg = m_ErrorMsgs.GetWideString(pCmd.iMessage);
|
||||
if (string.IsNullOrEmpty(szMsg))
|
||||
BMLogger.LogError("SERVER - unknown error !");
|
||||
if (string.IsNullOrEmpty( szMsg))
|
||||
BMLogger.LogError("SERVER - unknown error !");
|
||||
//else if (pCmd.iMessage != 2)
|
||||
//g_pGame->GetGameRun()->AddChatMessage(szMsg, GP_CHAT_MISC);
|
||||
//g_pGame->GetGameRun()->AddChatMessage(szMsg, GP_CHAT_MISC);
|
||||
|
||||
}
|
||||
|
||||
if (pCmd.iMessage == 2)
|
||||
{
|
||||
|
||||
// Attack target is too far
|
||||
//pGameRun->PostMessage(MSG_HST_TARGETISFAR, MAN_PLAYER, 0, (DWORD)pDataBuf, pCmdHeader->cmd);
|
||||
}
|
||||
@@ -555,18 +517,15 @@ namespace CSNetwork
|
||||
}
|
||||
else if (pCmd.iMessage == 108 /*&& pGameRun->GetHostPlayer()->IsInKingService()*/)
|
||||
{
|
||||
/* CECGameUIMan* pGameUI = pGameRun->GetUIManager()->GetInGameUIMan();
|
||||
if (pGameUI)
|
||||
pGameUI->EndNPCService();*/
|
||||
/* CECGameUIMan* pGameUI = pGameRun->GetUIManager()->GetInGameUIMan();
|
||||
if (pGameUI)
|
||||
pGameUI->EndNPCService();*/
|
||||
}
|
||||
else if
|
||||
(pCmd.iMessage ==
|
||||
108 /*&& pGameRun->GetHostPlayer()->GetOfflineShopCtrl()->GetNPCSevFlag() != COfflineShopCtrl::NPCSEV_NULL*/
|
||||
)
|
||||
else if (pCmd.iMessage == 108 /*&& pGameRun->GetHostPlayer()->GetOfflineShopCtrl()->GetNPCSevFlag() != COfflineShopCtrl::NPCSEV_NULL*/)
|
||||
{
|
||||
/* CECGameUIMan* pGameUI = pGameRun->GetUIManager()->GetInGameUIMan();
|
||||
if (pGameUI)
|
||||
pGameUI->EndNPCService();*/
|
||||
/* CECGameUIMan* pGameUI = pGameRun->GetUIManager()->GetInGameUIMan();
|
||||
if (pGameUI)
|
||||
pGameUI->EndNPCService();*/
|
||||
}
|
||||
else if (pCmd.iMessage == 175)
|
||||
{
|
||||
@@ -582,8 +541,7 @@ namespace CSNetwork
|
||||
case CommandID.SELECT_TARGET:
|
||||
case CommandID.UNSELECT:
|
||||
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_SELTARGET, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_SELTARGET, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.NPC_DIED:
|
||||
case CommandID.NPC_DIED2:
|
||||
@@ -591,19 +549,18 @@ namespace CSNetwork
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCDIED, MANAGER_INDEX.MAN_NPC, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
case CommandID.OBJECT_DISAPPEAR:
|
||||
{
|
||||
int lenghtDataType1 = Marshal.SizeOf<int>();
|
||||
byte[] arrByteData1 = GetBytes(pDataBuf, lenghtDataType1, 0);
|
||||
int idObjMove1 = BitConverter.ToInt32(arrByteData1);
|
||||
if (ISPLAYERID(idObjMove1))
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERDISAPPEAR, MANAGER_INDEX.MAN_PLAYER, -1,
|
||||
pDataBuf, pCmdHeader);
|
||||
else if (ISNPCID(idObjMove1))
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCDISAPPEAR, MANAGER_INDEX.MAN_NPC, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
{
|
||||
int lenghtDataType1 = Marshal.SizeOf<int>();
|
||||
byte[] arrByteData1 = GetBytes(pDataBuf, lenghtDataType1, 0);
|
||||
int idObjMove1 = BitConverter.ToInt32(arrByteData1);
|
||||
if (ISPLAYERID(idObjMove1))
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_PM_PLAYERDISAPPEAR, MANAGER_INDEX.MAN_PLAYER, -1, pDataBuf, pCmdHeader);
|
||||
else if (ISNPCID(idObjMove1))
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_NM_NPCDISAPPEAR, MANAGER_INDEX.MAN_NPC, 0, pDataBuf, pCmdHeader);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case CommandID.SELF_INFO_00:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_INFO00, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf,
|
||||
pCmdHeader);
|
||||
@@ -615,6 +572,7 @@ namespace CSNetwork
|
||||
{
|
||||
if (iSubID == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else if (iSubID < 0)
|
||||
{
|
||||
@@ -625,25 +583,24 @@ namespace CSNetwork
|
||||
{
|
||||
byteArray[i] = data[i];
|
||||
}
|
||||
|
||||
int cid = BitConverter.ToInt32(byteArray);
|
||||
switch (pCmdHeader)
|
||||
{
|
||||
case CommandID.PLAYER_INFO_1:
|
||||
case CommandID.PLAYER_ENTER_WORLD:
|
||||
case CommandID.PLAYER_ENTER_SLICE:
|
||||
{
|
||||
if (cid != iHostID)
|
||||
{
|
||||
_logger.Info("### OnMsgPlayerInfo: ElsePlayer join");
|
||||
if (cid != iHostID)
|
||||
{
|
||||
_logger.Info("### OnMsgPlayerInfo: ElsePlayer join");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,8 +708,7 @@ namespace CSNetwork
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.Log(LogType.Debug,
|
||||
$"Received RoleListResponse. Handle: {response.handle}, Result: {response.result}, Count: {response.rolelist.Count}");
|
||||
_logger.Log(LogType.Debug, $"Received RoleListResponse. Handle: {response.handle}, Result: {response.result}, Count: {response.rolelist.Count}");
|
||||
|
||||
if (response.result == 0)
|
||||
{
|
||||
@@ -837,12 +793,10 @@ namespace CSNetwork
|
||||
_networkManager.Dispose();
|
||||
_networkManager = null;
|
||||
}
|
||||
|
||||
_loginCallback = null;
|
||||
_roleListCallback = null;
|
||||
_accumulatedRoles = null;
|
||||
}
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
@@ -857,10 +811,8 @@ namespace CSNetwork
|
||||
{
|
||||
return id != 0 && (id & 0x80000000) == 0;
|
||||
}
|
||||
|
||||
public bool ISNPCID(int id) => ((id & unchecked((int)0x80000000)) != 0)
|
||||
&& ((id & 0x40000000) == 0);
|
||||
|
||||
&& ((id & 0x40000000) == 0);
|
||||
private byte[] GetBytes(byte[] bytes, int length, int index)
|
||||
{
|
||||
byte[] arrByteData = new byte[length];
|
||||
@@ -868,30 +820,25 @@ namespace CSNetwork
|
||||
{
|
||||
arrByteData[i] = bytes[i + index];
|
||||
}
|
||||
|
||||
return arrByteData;
|
||||
}
|
||||
|
||||
public void c2s_CmdPlayerMove(in Vector3 vCurPos, in Vector3 vDest,
|
||||
int iTime, float fSpeed, int iMoveMode, ushort wStamp)
|
||||
int iTime, float fSpeed, int iMoveMode, ushort wStamp)
|
||||
{
|
||||
gamedatasend gamedatasend = new gamedatasend();
|
||||
|
||||
gamedatasend.Data =
|
||||
C2SCommandFactory.CreatePlayerMove(vCurPos, vDest, (ushort)iTime, fSpeed, (byte)iMoveMode, wStamp);
|
||||
gamedatasend.Data = C2SCommandFactory.CreatePlayerMove(vCurPos, vDest, (ushort)iTime, fSpeed, (byte)iMoveMode, wStamp);
|
||||
SendProtocol(gamedatasend);
|
||||
}
|
||||
|
||||
public void c2s_SendCmdStopMove(in Vector3 vDest, float fSpeed, int iMoveMode,
|
||||
byte byDir, ushort wStamp, int iTime)
|
||||
byte byDir, ushort wStamp, int iTime)
|
||||
{
|
||||
|
||||
gamedatasend gamedatasend = new gamedatasend();
|
||||
|
||||
gamedatasend.Data =
|
||||
C2SCommandFactory.CreatePlayerStop(vDest, fSpeed, (byte)iMoveMode, byDir, wStamp, (ushort)iTime);
|
||||
gamedatasend.Data = C2SCommandFactory.CreatePlayerStop(vDest, fSpeed, (byte)iMoveMode, byDir, wStamp, (ushort)iTime);
|
||||
SendProtocol(gamedatasend);
|
||||
}
|
||||
|
||||
public void SendChatData(byte cChannel, in string szMsg, int iPack, int iSlot)
|
||||
{
|
||||
publicchat publicChat = new publicchat();
|
||||
@@ -903,12 +850,7 @@ namespace CSNetwork
|
||||
_logger.Log(LogType.Warning, $"HoangDev : publicChat {publicChat}");
|
||||
SendProtocol(publicChat);
|
||||
}
|
||||
|
||||
private void SetCharacterID(int iCharID)
|
||||
{
|
||||
m_iCharID = iCharID;
|
||||
}
|
||||
|
||||
private void SetCharacterID(int iCharID) { m_iCharID = iCharID; }
|
||||
private void OnPrtcChatMessage(Protocol pProtocol, bool bCalledagain)
|
||||
{
|
||||
chatmessage p = (chatmessage)pProtocol;
|
||||
@@ -922,11 +864,7 @@ namespace CSNetwork
|
||||
public struct ChatMessageEvent
|
||||
{
|
||||
public string context;
|
||||
|
||||
public ChatMessageEvent(string context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
public ChatMessageEvent(string context) { this.context = context; }
|
||||
}
|
||||
|
||||
public void c2s_SendCmdGetAllData(bool byPack, bool byEquip, bool byTask)
|
||||
@@ -981,4 +919,4 @@ namespace CSNetwork
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,7 +926,7 @@ public class CECHostPlayer : CECPlayer
|
||||
m_aabb.Extents.Set(0.3f, 0.9f, 0.3f);
|
||||
m_aabbServer = m_aabb;
|
||||
CalcPlayerAABB();
|
||||
|
||||
SetPos(pos);
|
||||
// Create work manager
|
||||
m_pWorkMan = new CECHPWorkMan(this);
|
||||
if (m_pWorkMan == null)
|
||||
|
||||
@@ -11,8 +11,8 @@ TagManager:
|
||||
- Player
|
||||
- Water
|
||||
- UI
|
||||
-
|
||||
-
|
||||
- Terrain
|
||||
- Bush
|
||||
-
|
||||
-
|
||||
-
|
||||
|
||||
Reference in New Issue
Block a user