fix: fix auto move to target when swim.
This commit is contained in:
@@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using BrewMonster.Managers;
|
||||
using Types = BrewMonster.Scripts.CECHPWorkMove.DestTypes;
|
||||
using BrewMonster.Network;
|
||||
|
||||
namespace BrewMonster.Scripts
|
||||
{
|
||||
@@ -116,20 +117,19 @@ namespace BrewMonster.Scripts
|
||||
}
|
||||
else if (IsAutoPF())
|
||||
{
|
||||
// TO DO: fix later
|
||||
//m_vCurDir = CECIntelligentRoute::Instance().GetCurDest() - m_pHost.GetPos();
|
||||
//m_vCurDir.y = 0.0f;
|
||||
//m_vCurDir.Normalize();
|
||||
//if (m_bUseAutoMoveDialog)
|
||||
//{
|
||||
// // �˴����� m_bUseAutoMoveDialog���� SetUseAutoMoveDialog ��˵��
|
||||
// m_bUseAutoMoveDialog = false;
|
||||
// m_bAutoLand = false;
|
||||
// m_fAutoHeight = -1.0f;
|
||||
// m_bAutoFly = false;
|
||||
// m_bReachedHeight = true;
|
||||
// m_bAutoFlyPending = false;
|
||||
//}
|
||||
m_vCurDir = CECIntelligentRoute.Instance().GetCurDest() - m_pHost.GetPos();
|
||||
m_vCurDir.y = 0.0f;
|
||||
m_vCurDir.Normalize();
|
||||
if (m_bUseAutoMoveDialog)
|
||||
{
|
||||
// �˴����� m_bUseAutoMoveDialog���� SetUseAutoMoveDialog ��˵��
|
||||
m_bUseAutoMoveDialog = false;
|
||||
m_bAutoLand = false;
|
||||
m_fAutoHeight = -1.0f;
|
||||
m_bAutoFly = false;
|
||||
m_bReachedHeight = true;
|
||||
m_bAutoFlyPending = false;
|
||||
}
|
||||
}
|
||||
|
||||
// TO DO: fix later
|
||||
@@ -231,11 +231,11 @@ namespace BrewMonster.Scripts
|
||||
|
||||
if (m_bAutoFly && !m_bAutoFlyPending && !m_pHost.IsFlying())
|
||||
{
|
||||
/* if (m_pHost.CmdFly())
|
||||
{
|
||||
m_bAutoFly = false;
|
||||
m_bAutoFlyPending = true;
|
||||
}*/
|
||||
if (m_pHost.CmdFly(true))
|
||||
{
|
||||
m_bAutoFly = false;
|
||||
m_bAutoFlyPending = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -443,8 +443,8 @@ namespace BrewMonster.Scripts
|
||||
if (m_bAutoLand)
|
||||
{
|
||||
m_bAutoLand = false;
|
||||
//if (g_pGame.GetGameRun().GetHostPlayer().IsFlying())
|
||||
// g_pGame.GetGameRun().GetHostPlayer().CmdFly(false);
|
||||
if (EC_Game.GetGameRun().GetHostPlayer().IsFlying())
|
||||
EC_Game.GetGameRun().GetHostPlayer().CmdFly(false);
|
||||
}
|
||||
|
||||
m_bUseAutoMoveDialog = false;
|
||||
@@ -466,14 +466,14 @@ namespace BrewMonster.Scripts
|
||||
|
||||
void SwitchToDest2D()
|
||||
{
|
||||
//int tid, taskid;
|
||||
//tid = m_iNPCTempleId;
|
||||
//taskid = m_iTaskId;
|
||||
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);
|
||||
//SetDestination(CECHPWorkMove::DEST_2D, m_vMoveDest);
|
||||
//SetTaskNPCInfo(tid, taskid);
|
||||
//SetUseAutoMoveDialog(true);
|
||||
SetDestination(CECHPWorkMove.DestTypes.DEST_2D, m_vMoveDest);
|
||||
SetTaskNPCInfo(tid, taskid);
|
||||
SetUseAutoMoveDialog(true);
|
||||
}
|
||||
// On first tick
|
||||
protected override void OnFirstTick()
|
||||
@@ -1227,7 +1227,7 @@ namespace BrewMonster.Scripts
|
||||
}
|
||||
else if (IsAutoPF())
|
||||
{
|
||||
//CECIntelligentRoute::Instance().ResetSearch();
|
||||
CECIntelligentRoute.Instance().ResetSearch();
|
||||
m_bSwitchTo2D = true;
|
||||
}
|
||||
return true;
|
||||
@@ -1242,7 +1242,49 @@ namespace BrewMonster.Scripts
|
||||
// Calculate vertical speed when fly or swim
|
||||
protected float CalcFlySwimVertSpeed(float fSpeed1, float fPushDir, float fPushAccel, float fDeltaTime)
|
||||
{
|
||||
return 0;
|
||||
float pa = Math.Abs(fPushDir - 0.0f) > float.Epsilon ? fPushAccel : 0.0f;
|
||||
|
||||
float na = 0.0f, fMaxSpeed;
|
||||
if (m_pHost.m_iMoveEnv == CECPlayer.Move_environment.MOVEENV_AIR)
|
||||
{
|
||||
na = CECHostMove.EC_NACCE_AIR;
|
||||
fMaxSpeed = m_pHost.GetFlySpeed();
|
||||
}
|
||||
else
|
||||
{
|
||||
na = CECHostMove.EC_NACCE_WATER;
|
||||
fMaxSpeed = m_pHost.GetSwimSpeedSev();
|
||||
}
|
||||
|
||||
// When player free fall into water, fSpeed1 may be >= fMaxSpeed
|
||||
if (Math.Abs(fSpeed1) > fMaxSpeed)
|
||||
{
|
||||
na *= 2.0f;
|
||||
if (fPushDir * fSpeed1 > 0.0f)
|
||||
pa = 0.0f;
|
||||
}
|
||||
|
||||
// Vertical accelerate
|
||||
float fAccel = 0.0f;
|
||||
if (fPushDir > 0.0f)
|
||||
fAccel = pa + na;
|
||||
else if (fPushDir < 0.0f)
|
||||
fAccel = -(pa + na);
|
||||
else if (fSpeed1 > 0.0f)
|
||||
fAccel = na;
|
||||
else if (fSpeed1 < 0.0f)
|
||||
fAccel = -na;
|
||||
|
||||
// Vertical speed
|
||||
float fSpeed2 = fSpeed1 + fAccel * fDeltaTime;
|
||||
if (Math.Abs(pa - 0.0f) < float.Epsilon && fSpeed2 * fSpeed1 < 0.0f)
|
||||
fSpeed2 = 0.0f;
|
||||
|
||||
// If accelerate and speed on same direction, limit speed
|
||||
if (fAccel * fSpeed2 > 0.0f)
|
||||
AAssist.a_Clamp(ref fSpeed2, -fMaxSpeed, fMaxSpeed);
|
||||
|
||||
return fSpeed2;
|
||||
}
|
||||
|
||||
protected void ClearResetUseAutoPF()
|
||||
@@ -1271,7 +1313,7 @@ namespace BrewMonster.Scripts
|
||||
if (CECUIManager.Instance != null)
|
||||
{
|
||||
string message = $"Please deactive the fly mode to start the path finding.";
|
||||
|
||||
|
||||
CECUIManager.Instance.ShowMessageBox(
|
||||
"Fly Mode", // 飞行模式
|
||||
message, // 消息
|
||||
@@ -1280,6 +1322,7 @@ namespace BrewMonster.Scripts
|
||||
Finish();
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Brush test is not fully ported yet; pass null for now (static movemap only).
|
||||
@@ -1298,14 +1341,14 @@ namespace BrewMonster.Scripts
|
||||
int mapX = Mathf.RoundToInt(m_vMoveDest.x / 10.0f) + 400;
|
||||
int mapY = Mathf.RoundToInt(m_vMoveDest.y / 10.0f);
|
||||
int mapZ = Mathf.RoundToInt(m_vMoveDest.z / 10.0f) + 550;
|
||||
|
||||
|
||||
// Show popup notification to player that path cannot be found
|
||||
// 显示弹窗通知玩家无法找到路径
|
||||
if (CECUIManager.Instance != null)
|
||||
{
|
||||
string message = $"Cannot find path to target position.\nPlease move manually to target location.\n\nMap Coordinates: ({mapX}, {mapZ}, ↑{mapY})";
|
||||
string messageCN = $"无法找到到目标位置的路径。\n请手动移动到目标位置。\n\n地图坐标: ({mapX}, {mapZ}, ↑{mapY})";
|
||||
|
||||
|
||||
CECUIManager.Instance.ShowMessageBox(
|
||||
"Path Not Found", // 路径未找到
|
||||
message, // English message with map coordinates
|
||||
@@ -1316,16 +1359,14 @@ namespace BrewMonster.Scripts
|
||||
{
|
||||
Debug.LogWarning($"[CECIntelligentRoute] Cannot find path to target position. Map Coordinates: ({mapX}, {mapZ}, ↑{mapY}). Please move manually.");
|
||||
}
|
||||
|
||||
|
||||
Finish();
|
||||
return;
|
||||
break;
|
||||
}
|
||||
else if (ret != CECIntelligentRoute.SearchResult.enumSearchSuccess)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
bSwitchTo2D = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -329,6 +329,30 @@ namespace AutoMove
|
||||
yield return new Vector2Int(p.x - 1, p.y - 1);
|
||||
}
|
||||
|
||||
public void ResetSearch()
|
||||
{
|
||||
// Çå³ýµ±Ç°ËÑË÷״̬
|
||||
//if (m_iStat == PF_STATE_UNKNOWN)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//if (m_pPfAlg)
|
||||
//{
|
||||
// m_pPfAlg->Reset();
|
||||
//}
|
||||
//if (m_pPathOptimizer)
|
||||
//{
|
||||
// m_pPathOptimizer.Reset();
|
||||
//}
|
||||
m_ptStart.x = m_ptStart.y = 0;
|
||||
m_iLayerStart = -1;
|
||||
m_ptGoal.x = m_ptGoal.y = 0;
|
||||
m_iLayerGoal = -1;
|
||||
//m_pBrushTest = null;
|
||||
|
||||
//m_iStat = PF_STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Very small min-heap for A*.
|
||||
/// A* 用的小型最小堆。
|
||||
|
||||
@@ -70,6 +70,9 @@ namespace BrewMonster.Scripts
|
||||
private int m_iCurMoveAgent = -1;
|
||||
private int m_iCurDest = -1;
|
||||
private Usage m_usage = Usage.enumUsageNone;
|
||||
private A3DVECTOR3 m_lastPos; // ÉÏ´ÎÒÆ¶¯µ½µÄλÖ㬵±ÓÐÐÂλÖÃʱ£¬ÓÃÓÚ¼ì²âÊÇ·ñÓ¦ÒÆÍùÏÂÒ»²½
|
||||
private float m_lastMove; // ÉÏ´ÎÒÆ¶¯¾àÀ룬ÓÃÓÚ¹À¼ÆÏÂÒ»²½½«Òƶ¯µÄ¾àÀ룬´Ó¶øÅжÏÊÇ·ñÓ¦ÒÆÍùÏÂÒ»²½
|
||||
private float m_dist2CurDest; // µ½´ï m_iCurDest »¹ÐèÒÆ¶¯µÄ¾àÀ룬ÓÃÓÚÅжÏÊÇ·ñÓ¦ÒÆÍùÏÂÒ»²½
|
||||
|
||||
private CECIntelligentRoute() { }
|
||||
|
||||
@@ -94,11 +97,30 @@ namespace BrewMonster.Scripts
|
||||
|
||||
public void ResetSearch()
|
||||
{
|
||||
//m_state = RouteState.enumRouteIdle;
|
||||
//m_start = new A3DVECTOR3(0);
|
||||
//m_end = new A3DVECTOR3(0);
|
||||
//m_iCurMoveAgent = -1;
|
||||
//m_iCurDest = -1;
|
||||
|
||||
if (IsIdle())
|
||||
{
|
||||
// µ±Ç°²»ÔÚËÑË÷״̬
|
||||
return;
|
||||
}
|
||||
RangedMoveAgent? pCurAgent = GetCurAgent();
|
||||
if (pCurAgent != null)
|
||||
{
|
||||
pCurAgent.Value.agent.ResetSearch();
|
||||
}
|
||||
m_state = RouteState.enumRouteIdle;
|
||||
m_start = new A3DVECTOR3(0);
|
||||
m_end = new A3DVECTOR3(0);
|
||||
m_start.Clear();
|
||||
m_end.Clear();
|
||||
m_iCurMoveAgent = -1;
|
||||
m_iCurDest = -1;
|
||||
m_lastPos.Clear();
|
||||
m_lastMove = 0.0f;
|
||||
m_dist2CurDest = 0.0f;
|
||||
}
|
||||
|
||||
public void ChangeWorldInstance(int idInstance)
|
||||
|
||||
Reference in New Issue
Block a user