fix: update move for HP.
This commit is contained in:
@@ -30,6 +30,7 @@ using Host_work_ID = BrewMonster.Scripts.CECHPWork.Host_work_ID;
|
||||
using ObjectCoords = System.Collections.Generic.List<CSNetwork.GPDataType.OBJECT_COORD>;
|
||||
using Trace_reason = BrewMonster.CECHPWorkTrace.Trace_reason;
|
||||
using System.Threading.Tasks;
|
||||
using static BrewMonster.EC_CDR;
|
||||
|
||||
namespace BrewMonster
|
||||
{
|
||||
@@ -126,6 +127,8 @@ namespace BrewMonster
|
||||
CECCounter m_PetOptCnt = new CECCounter(); // Pet operation time counter
|
||||
protected bool[] m_playerLimits = new bool[(int)PLAYER_LIMIT.PLAYER_LIMIT_MAX];
|
||||
|
||||
RaycastHitDistanceComparer raycastHitDistanceComparer = new RaycastHitDistanceComparer();
|
||||
|
||||
// תÉú´ÎÊý
|
||||
byte m_ReincarnationCount = 0;
|
||||
|
||||
@@ -1380,6 +1383,7 @@ namespace BrewMonster
|
||||
pos.y += m_CDRInfo.vExtent.y;
|
||||
if (Physics.RaycastNonAlloc(pos, Vector3.down, hits, m_CDRInfo.vExtent.y, 1 << 6) > 0)
|
||||
{
|
||||
System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
m_CDRInfo.vTPNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
}
|
||||
else
|
||||
@@ -1786,12 +1790,14 @@ namespace BrewMonster
|
||||
float fTerrainHeight = 0f;
|
||||
if (Physics.RaycastNonAlloc(startPoint, dir, hits, layerGround) > 0)
|
||||
{
|
||||
System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
fTerrainHeight = Vector3.Distance(hits[0].point, startPoint);
|
||||
}
|
||||
|
||||
float fWaterHeight = 0f;
|
||||
if (Physics.RaycastNonAlloc(startPoint, dir, hits, layerWater) > 0)
|
||||
{
|
||||
System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
fWaterHeight = Vector3.Distance(hits[0].point, startPoint);
|
||||
}
|
||||
|
||||
@@ -2446,6 +2452,7 @@ namespace BrewMonster
|
||||
int countHits0 = Physics.RaycastNonAlloc(EC_Utility.ToVector3(vPos) + Vector3.up * 500f, Vector3.down, hits, 1000f, 1 << 8);
|
||||
if (countHits0 > 0)
|
||||
{
|
||||
System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
h0 = hits[0].point.y;
|
||||
}
|
||||
if (vPos.y < h0 - m_MoveConst.fShoreDepth)
|
||||
@@ -3169,6 +3176,7 @@ namespace BrewMonster
|
||||
|
||||
if (Physics.RaycastNonAlloc(EC_Utility.ToVector3(vTestPos) + Vector3.up * 500f, Vector3.down, hits, 1000f, 1 << 8) > 0)
|
||||
{
|
||||
System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
m_GndInfo.fWaterHei = hits[0].point.y;
|
||||
}
|
||||
|
||||
@@ -3193,7 +3201,6 @@ namespace BrewMonster
|
||||
if (iNewEnv == Move_environment.MOVEENV_GROUND)
|
||||
{
|
||||
m_GndInfo.bOnGround = true;
|
||||
|
||||
// if (vPos.y > m_GndInfo.fGndHei + 0.2f)
|
||||
if (m_CDRInfo.vTPNormal == new A3DVECTOR3(0))
|
||||
{
|
||||
@@ -3271,6 +3278,7 @@ namespace BrewMonster
|
||||
LayerMask layerMaskBush = 1 << 7;
|
||||
if (Physics.RaycastNonAlloc(vPos, (Vector3.down), hits, 1000f, layerMaskTerrain) > 0 /*&& hits[0].distance > 0.0009f*/)
|
||||
{
|
||||
System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
vTerrainPos = hits[0].point;
|
||||
vTerrainNormal = hits[0].normal;
|
||||
}
|
||||
@@ -3296,47 +3304,76 @@ namespace BrewMonster
|
||||
return false;
|
||||
}
|
||||
|
||||
void VertAABBTrace(Vector3 vCenter, Vector3 vExt, ref Vector3 vHitPos, ref A3DVECTOR3 vHitNormal,
|
||||
//void VertAABBTrace(Vector3 vCenter, Vector3 vExt, ref Vector3 vHitPos, ref A3DVECTOR3 vHitNormal,
|
||||
// float DeltaY /* =100.0f */)
|
||||
//{
|
||||
// vHitPos = vCenter;
|
||||
// vHitPos.y -= DeltaY;
|
||||
|
||||
// LayerMask layerMask = 1 << 6 | 1 << 7;
|
||||
// hits = new RaycastHit[5];
|
||||
// int count = Physics.BoxCastNonAlloc(vCenter, new Vector3(vExt.x, vExt.y / 10f, vExt.z), (Vector3.down).normalized,
|
||||
// hits, transform.rotation, DeltaY, layerMask);
|
||||
// if (count == 0 || (count > 0 && hits[0].distance < 0.0009f))
|
||||
// {
|
||||
// vHitPos = vCenter;
|
||||
// vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
// if (Math.Abs(hits[0].distance - 0f) <= float.Epsilon)
|
||||
// {
|
||||
// // halfBox with y = 0.05f? I need Y box check too small.
|
||||
// count = Physics.BoxCastNonAlloc(vCenter, new Vector3(vExt.x, 0.05f, vExt.z), (Vector3.down).normalized,
|
||||
// hits, transform.rotation, DeltaY, layerMask);
|
||||
// if (count == 0 || ( count > 0 && hits[0].distance < 0.0009f))
|
||||
// {
|
||||
// vHitPos = vCenter;
|
||||
// vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
// vHitPos = hits[0].point;
|
||||
// vHitPos.y += vExt.y;
|
||||
// vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// vHitPos = hits[0].point;
|
||||
// vHitPos.y += vExt.y;
|
||||
// vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
bool VertAABBTrace(Vector3 vCenter, Vector3 vExt, ref Vector3 vHitPos, ref A3DVECTOR3 vHitNormal,
|
||||
float DeltaY /* =100.0f */)
|
||||
{
|
||||
ground_trace_t groundTrc = new ground_trace_t();
|
||||
groundTrc.vStart = EC_Utility.ToA3DVECTOR3(vCenter);
|
||||
groundTrc.vExt = EC_Utility.ToA3DVECTOR3(vExt);
|
||||
groundTrc.fDeltaY = DeltaY;
|
||||
vHitPos = vCenter;
|
||||
vHitPos.y -= DeltaY;
|
||||
//RetrieveSupportPlane(&groundTrc);
|
||||
|
||||
LayerMask layerMask = 1 << 6 | 1 << 7;
|
||||
hits = new RaycastHit[5];
|
||||
int count = Physics.BoxCastNonAlloc(vCenter, vExt, (Vector3.down).normalized,
|
||||
hits, transform.rotation, DeltaY, layerMask);
|
||||
if (count == 0 || (count > 0 && hits[0].distance < 0.0009f))
|
||||
if (!RetrieveSupportPlane(ref groundTrc))
|
||||
{
|
||||
vHitPos = vCenter;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up);
|
||||
vHitNormal = new A3DVECTOR3(0.0f, 1.0f, 0.0f);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (groundTrc.bSupport)
|
||||
{
|
||||
if (Math.Abs(hits[0].distance - 0f) <= float.Epsilon)
|
||||
{
|
||||
// halfBox with y = 0.05f? I need Y box check too small.
|
||||
count = Physics.BoxCastNonAlloc(vCenter, new Vector3(vExt.x, 0.05f, vExt.z), (Vector3.down).normalized,
|
||||
hits, transform.rotation, DeltaY, layerMask);
|
||||
if (count == 0 || ( count > 0 && hits[0].distance < 0.0009f))
|
||||
{
|
||||
vHitPos = vCenter;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(Vector3.up);
|
||||
}
|
||||
else
|
||||
{
|
||||
vHitPos = hits[0].point;
|
||||
vHitPos.y += vExt.y;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vHitPos = hits[0].point;
|
||||
vHitPos.y += vExt.y;
|
||||
vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
}
|
||||
vHitPos = EC_Utility.ToVector3(groundTrc.vEnd);
|
||||
vHitNormal = groundTrc.vHitNormal;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get cool time
|
||||
@@ -4298,7 +4335,13 @@ namespace BrewMonster
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public struct RaycastHitDistanceComparer : System.Collections.Generic.IComparer<RaycastHit>
|
||||
{
|
||||
public int Compare(RaycastHit x, RaycastHit y)
|
||||
{
|
||||
return x.distance.CompareTo(y.distance);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user