`
This commit is contained in:
parent
33a3657e2b
commit
a6b48f0e3c
@ -40,7 +40,9 @@ namespace XNet.Business.Entity
|
||||
/// </summary>
|
||||
public Vec3 WorldMax { get; set; } = new Vec3();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 地图 Template 值
|
||||
/// </summary>
|
||||
public string MapKey { get; set; } = string.Empty;
|
||||
public string RoomId { get; set; } = string.Empty;
|
||||
|
||||
|
||||
@ -43,6 +43,25 @@ namespace XNet.Business
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ControlAIPlayer()
|
||||
{
|
||||
foreach (var rooms in _wsManager.InstanceSubscribers.Values)
|
||||
{
|
||||
var room = rooms.FirstOrDefault().Value;
|
||||
if (room != null)
|
||||
{
|
||||
var template = _navMeshManager.GetNavTemplate(room.MapKey);
|
||||
if (template == null) return;
|
||||
var min = template.Bmin;
|
||||
var max = template.Bmax;
|
||||
foreach(var player in room.Players)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SyncAllMessageToClient()
|
||||
{
|
||||
await SendSyncLocationMessage();
|
||||
|
||||
@ -11,21 +11,26 @@ namespace XNet.Business.PathNavigation
|
||||
public class NavMeshManager
|
||||
{
|
||||
// --- 核心类:地图资源模板 (共享) ---
|
||||
private class NavMeshTemplate : IDisposable
|
||||
public class NavMeshTemplate : IDisposable
|
||||
{
|
||||
public string TemplateId { get; }
|
||||
public DtNavMesh NavMesh { get; }
|
||||
public DtNavMeshQuery Query { get; }
|
||||
public ReaderWriterLockSlim RwLock { get; }
|
||||
|
||||
public RcVec3f Bmin { get; }
|
||||
public RcVec3f Bmax { get; }
|
||||
|
||||
private bool _disposed = false;
|
||||
|
||||
public NavMeshTemplate(string id, DtNavMesh mesh, DtNavMeshQuery query)
|
||||
public NavMeshTemplate(string id, DtNavMesh mesh, DtNavMeshQuery query, RcVec3f bmin, RcVec3f bmax)
|
||||
{
|
||||
TemplateId = id;
|
||||
NavMesh = mesh;
|
||||
Query = query;
|
||||
RwLock = new ReaderWriterLockSlim();
|
||||
Bmin = bmin;
|
||||
Bmax = bmax;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@ -162,6 +167,15 @@ namespace XNet.Business.PathNavigation
|
||||
return true;
|
||||
}
|
||||
|
||||
public NavMeshTemplate? GetNavTemplate(string roomId)
|
||||
{
|
||||
if (!_instanceMap.TryGetValue(roomId, out var templateId)) return null;
|
||||
if (!_templates.TryGetValue(templateId, out var template)) return null;
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
|
||||
public RcVec3f? GetClosetPoint(string roomId, Vector3 originPt, out long startRef)
|
||||
{
|
||||
startRef = 0;
|
||||
@ -365,7 +379,7 @@ namespace XNet.Business.PathNavigation
|
||||
}
|
||||
var navMeshQuery = new DtNavMeshQuery(navMesh);
|
||||
|
||||
return new NavMeshTemplate(id, navMesh, navMeshQuery);
|
||||
return new NavMeshTemplate(id, navMesh, navMeshQuery, bmin, bmax);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user