public void PreparePath(float x, float y, float z, float stepSize = 1.25f, int maxPath = 40, float polyRadius = 0.0f) { var pos = new Vector3(owner.positionX, owner.positionY, owner.positionZ); var dest = new Vector3(x, y, z); Zone zone; if (owner.GetZone() is PrivateArea || owner.GetZone() is PrivateAreaContent) { zone = (Zone)((PrivateArea)owner.GetZone()).GetParentZone(); } else { zone = (Zone)owner.GetZone(); } var sw = new System.Diagnostics.Stopwatch(); sw.Start(); if ((pathFlags & PathFindFlags.IgnoreNav) != 0) { path = new List <Vector3>(1) { new Vector3(x, y, z) } } ; else { path = NavmeshUtils.GetPath(zone, pos, dest, stepSize, maxPath, polyRadius); } if (path != null) { if (owner.oldPositionX == 0.0f && owner.oldPositionY == 0.0f && owner.oldPositionZ == 0.0f) { owner.oldPositionX = owner.positionX; owner.oldPositionY = owner.positionY; owner.oldPositionZ = owner.positionZ; } // todo: something went wrong if (path.Count == 0) { owner.positionX = owner.oldPositionX; owner.positionY = owner.oldPositionY; owner.positionZ = owner.oldPositionZ; } sw.Stop(); zone.pathCalls++; zone.pathCallTime += sw.ElapsedMilliseconds; //if (path.Count == 1) // Program.Log.Info($"mypos: {owner.positionX} {owner.positionY} {owner.positionZ} | targetPos: {x} {y} {z} | step {stepSize} | maxPath {maxPath} | polyRadius {polyRadius}"); //Program.Log.Error("[{0}][{1}] Created {2} points in {3} milliseconds", owner.actorId, owner.actorName, path.Count, sw.ElapsedMilliseconds); } }
public virtual bool CanSeePoint(float x, float y, float z) { return(NavmeshUtils.CanSee((Zone)owner.zone, owner.positionX, owner.positionY, owner.positionZ, x, y, z)); }