package com.example.tests;
import com.frotty27.hrtk.api.annotation.EcsTest;
import com.frotty27.hrtk.api.annotation.HytaleSuite;
import com.frotty27.hrtk.api.annotation.WorldTest;
import com.frotty27.hrtk.api.annotation.Tag;
import com.frotty27.hrtk.api.annotation.DisplayName;
import com.frotty27.hrtk.api.annotation.Order;
import com.frotty27.hrtk.api.assert_.AIAssert;
import com.frotty27.hrtk.api.assert_.HytaleAssert;
import com.frotty27.hrtk.api.assert_.PathfindingAssert;
import com.frotty27.hrtk.api.context.EcsTestContext;
import com.frotty27.hrtk.api.context.WorldTestContext;
import com.frotty27.hrtk.api.lifecycle.IsolationStrategy;
@HytaleSuite(value = "AI Surface Tests", isolation = IsolationStrategy.DEDICATED_WORLD)
@Tag("ai")
public class AISurfaceTests {
@WorldTest
@Order(1)
@DisplayName("Spawned NPC has active AI")
void spawnedNPCHasActiveAI(WorldTestContext ctx) {
// Spawn a fully initialized NPC - it should have AI components.
Object entity = ctx.spawnNPC("Trork_Warrior", 10, 64, 10);
ctx.waitTicks(2);
Object store = ctx.getStore();
// assertAIActive checks if the entity's StateEvaluator component is active.
// This confirms the NPC is making decisions and processing AI logic.
AIAssert.assertAIActive(store, entity);
}
@EcsTest
@Order(2)
@DisplayName("Pathfinding classes are available on the server")
void pathfindingAvailable(EcsTestContext ctx) {
// assertPathfindingAvailable checks that the AStar pathfinding classes
// exist on the classpath. If they are missing, NPCs cannot navigate.
PathfindingAssert.assertPathfindingAvailable();
}
@EcsTest
@Order(3)
@DisplayName("StateEvaluator class is available on the classpath")
void stateEvaluatorAvailable(EcsTestContext ctx) {
// This is a precondition check - if the StateEvaluator class is missing,
// no AI assertions will work.
HytaleAssert.assertTrue(
"StateEvaluator class should be available",
AITestAdapter.stateEvaluatorClassAvailable()
);
}
@WorldTest
@Order(4)
@DisplayName("Trork_Warrior has active AI after spawn")
void trorkWarriorAIActive(WorldTestContext ctx) {
Object entity = ctx.spawnNPC("Trork_Warrior", 20, 64, 20);
ctx.waitTicks(2);
AIAssert.assertAIActive(ctx.getStore(), entity);
}
}