feat: add actor behavior example config
This commit is contained in:
@@ -44,6 +44,36 @@ namespace XWorld.Framework.Tests.ActorBehavior
|
||||
|
||||
Assert.Contains("missing_wave", ex.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ExampleConfigFiles_LoadFromRepository()
|
||||
{
|
||||
string root = FindRepoRoot();
|
||||
string dir = System.IO.Path.Combine(root, "Client", "Assets", "Resources", "Config", "ActorBehavior");
|
||||
|
||||
BehaviorConfigCatalog catalog = BehaviorConfigCatalog.LoadFromJson(
|
||||
"fighter",
|
||||
System.IO.File.ReadAllText(System.IO.Path.Combine(dir, "fighter_skill.json")),
|
||||
System.IO.File.ReadAllText(System.IO.Path.Combine(dir, "fighter_flyobj.json")),
|
||||
System.IO.File.ReadAllText(System.IO.Path.Combine(dir, "fighter_buff.json")));
|
||||
|
||||
Assert.True(catalog.Behaviors.ContainsKey("slash"));
|
||||
}
|
||||
|
||||
private static string FindRepoRoot()
|
||||
{
|
||||
string? dir = AppContext.BaseDirectory;
|
||||
while (dir != null)
|
||||
{
|
||||
string gitPath = System.IO.Path.Combine(dir, ".git");
|
||||
if (System.IO.Directory.Exists(gitPath) || System.IO.File.Exists(gitPath))
|
||||
{
|
||||
return dir;
|
||||
}
|
||||
dir = System.IO.Directory.GetParent(dir)?.FullName;
|
||||
}
|
||||
throw new InvalidOperationException("repo root not found");
|
||||
}
|
||||
}
|
||||
|
||||
internal static class TestBehaviorJson
|
||||
|
||||
Reference in New Issue
Block a user