You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1009 B
37 lines
1009 B
3 years ago
|
using System;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
[FriendClass(typeof(NavmeshComponent))]
|
||
|
public static class NavmeshComponentSystem
|
||
|
{
|
||
|
public class AwakeSystem: AwakeSystem<NavmeshComponent, Func<string, byte[]>>
|
||
|
{
|
||
|
public override void Awake(NavmeshComponent self, Func<string, byte[]> loader)
|
||
|
{
|
||
|
NavmeshComponent.Instance = self;
|
||
|
self.Loader = loader;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static long Get(this NavmeshComponent self, string name)
|
||
|
{
|
||
|
long ptr;
|
||
|
if (self.Navmeshs.TryGetValue(name, out ptr))
|
||
|
{
|
||
|
return ptr;
|
||
|
}
|
||
|
|
||
|
byte[] buffer = self.Loader(name);
|
||
|
if (buffer.Length == 0)
|
||
|
{
|
||
|
throw new Exception($"no nav data: {name}");
|
||
|
}
|
||
|
|
||
|
ptr = Recast.RecastLoadLong(name.GetHashCode(), buffer, buffer.Length);
|
||
|
self.Navmeshs[name] = ptr;
|
||
|
|
||
|
return ptr;
|
||
|
}
|
||
|
}
|
||
|
}
|