Merge pull request 'EP normal attack' (#39) from feature/EP_normal_attack into develop
Reviewed-on: https://git.brew.monster/Unity/perfect-world-unity/pulls/39
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
|
||||
{
|
||||
|
||||
@@ -947,6 +947,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
|
||||
|
||||
@@ -1338,5 +1338,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;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -481,9 +481,8 @@ namespace CSNetwork
|
||||
|
||||
if (pCmd.iMessage == 2)
|
||||
{
|
||||
|
||||
// Attack target is too far
|
||||
//pGameRun->PostMessage(MSG_HST_TARGETISFAR, MAN_PLAYER, 0, (DWORD)pDataBuf, pCmdHeader->cmd);
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_TARGETISFAR, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
}
|
||||
else if (pCmd.iMessage == 20)
|
||||
{
|
||||
@@ -545,6 +544,10 @@ namespace CSNetwork
|
||||
|
||||
break;
|
||||
}
|
||||
case CommandID.HOST_NOTIFY_ROOT:
|
||||
case CommandID.HOST_DISPEL_ROOT:
|
||||
EC_ManMessage.PostMessage(EC_MsgDef.MSG_HST_ROOTNOTIFY, MANAGER_INDEX.MAN_PLAYER, 0, pDataBuf, pCmdHeader);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:78669dc5fa14a381c579516583b1cbd4aae51ff6e2ae606ff286dd51f78fe266
|
||||
oid sha256:83be124266b0b08e95d67f6a647ee64594af1b9c784997da01817fe0fd1da242
|
||||
size 543980635
|
||||
|
||||
@@ -188,13 +188,13 @@ public class CECHostPlayer : CECPlayer
|
||||
// return;
|
||||
//}
|
||||
// Trace a object
|
||||
/* if (iTraceReason == CECHPWorkTrace.Trace_reason.TRACE_ATTACK)
|
||||
if (iTraceReason == CECHPWorkTrace.Trace_reason.TRACE_ATTACK)
|
||||
{
|
||||
if (!CanDo(ActionCanDo.CANDO_MELEE))
|
||||
return;
|
||||
Debug.LogError("Attack");
|
||||
//Debug.LogError("Attack");
|
||||
NormalAttackObject(idTraceTarget, bForceAttack);
|
||||
}*/
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// if (!CanDo(CANDO_MOVETO))
|
||||
@@ -823,7 +823,7 @@ public class CECHostPlayer : CECPlayer
|
||||
SetPlayerInfor(new INFO(role.cid, role.crc_e, role.crc_c));
|
||||
Vector3 pos = new Vector3(role.pos.x, role.pos.y, role.pos.z);
|
||||
if (txtName != null) txtName.text = roleName;
|
||||
transform.position = pos;
|
||||
//transform.position = pos;
|
||||
SetModelHostPlayer();
|
||||
m_dwResFlags = (uint)PlayerResourcesReadyFlag.RESFG_ALL;
|
||||
joystick = FindAnyObjectByType<Joystick>();
|
||||
@@ -837,7 +837,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