fix: update move for HP.
This commit is contained in:
@@ -108,6 +108,7 @@ namespace BrewMonster
|
||||
|
||||
static LayerMask UsedMask_Ground() => TerrainMask;
|
||||
|
||||
static RaycastHitDistanceComparer raycastHitDistanceComparer = new RaycastHitDistanceComparer();
|
||||
public static bool CollideWithEnv(ref env_trace_t pEnvTrc, bool isNeedCheckGr = true)
|
||||
{
|
||||
pEnvTrc.fFraction = 100.0f;
|
||||
@@ -123,25 +124,15 @@ namespace BrewMonster
|
||||
|
||||
if ((pEnvTrc.dwCheckFlag & CDR_EVN.CDR_BRUSH) == CDR_EVN.CDR_BRUSH)
|
||||
{
|
||||
float num = 10f;
|
||||
Vector3[] arrVExt = new Vector3[5] {
|
||||
vExt
|
||||
,new Vector3(vExt.x / num, vExt.y, vExt.z),
|
||||
new Vector3(vExt.x, vExt.y / num, vExt.z),
|
||||
new Vector3(vExt.x, vExt.y, vExt.z / num),
|
||||
vExt / num
|
||||
};
|
||||
dir = vDelta;
|
||||
for (int i = 0; i < arrVExt.Length; i++)
|
||||
{
|
||||
countHits = Physics.BoxCastNonAlloc(vStart, arrVExt[i], dir.normalized, hits, Quaternion.identity, vDelta.magnitude, BrushMask);
|
||||
if (countHits > 0 && hits[0].distance > 0.0009f)
|
||||
//hits = new RaycastHit[5];
|
||||
countHits = Physics.BoxCastNonAlloc(vStart, vExt, dir.normalized, hits, Quaternion.identity, vDelta.magnitude, BrushMask);
|
||||
if (countHits > 0)
|
||||
{
|
||||
System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
pEnvTrc.fFraction = (hits[0].distance) / vDelta.magnitude;
|
||||
pEnvTrc.vHitNormal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
pEnvTrc.dwClsFlag = CDR_EVN.CDR_BRUSH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((pEnvTrc.dwCheckFlag & CDR_EVN.CDR_TERRAIN) == CDR_EVN.CDR_TERRAIN)
|
||||
@@ -772,11 +763,19 @@ namespace BrewMonster
|
||||
{
|
||||
vPosOnSurface = vPos;
|
||||
int countHits = 0;
|
||||
countHits = Physics.RaycastNonAlloc(EC_Utility.ToVector3(vPosOnSurface), Vector3.down, fHitsTerrain, 1000f, TerrainMask);
|
||||
countHits = Physics.RaycastNonAlloc(EC_Utility.ToVector3(vPosOnSurface), Vector3.down, fHitsTerrain,maxDistance: 1000f, TerrainMask);
|
||||
if (countHits > 0)
|
||||
{
|
||||
vPosOnSurface.y = fHitsTerrain[0].point.y;
|
||||
vNormal = EC_Utility.ToA3DVECTOR3(fHitsTerrain[0].normal);
|
||||
System.Array.Sort(fHitsTerrain, 0, fHitsTerrain.Length, raycastHitDistanceComparer);
|
||||
for(int i = 0; i < fHitsTerrain.Length; i++)
|
||||
{
|
||||
if (fHitsTerrain[i].distance > 0.0009f)
|
||||
{
|
||||
vPosOnSurface.y = fHitsTerrain[i].point.y;
|
||||
vNormal = EC_Utility.ToA3DVECTOR3(fHitsTerrain[i].normal);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1026,7 +1025,12 @@ namespace BrewMonster
|
||||
countHits = Physics.BoxCastNonAlloc(vStart, arrVExt[i], dir.normalized, hits, Quaternion.identity, vDelta.magnitude, BrushMask);
|
||||
if (countHits > 0)
|
||||
{
|
||||
if (hits[0].distance > 0.0009f)
|
||||
System.Array.Sort(hits, 0, hits.Length, raycastHitDistanceComparer);
|
||||
if (Math.Abs(hits[0].distance - 0f) < float.Epsilon)
|
||||
{
|
||||
brushTraceInfo.bStartSolid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
brushTraceInfo.fFraction = (hits[0].distance) / vDelta.magnitude;
|
||||
brushTraceInfo.normal = EC_Utility.ToA3DVECTOR3(hits[0].normal);
|
||||
|
||||
@@ -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