melee ai targeting fix
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
d2a8acf027
commit
d39254968f
@ -14,6 +14,16 @@
|
|||||||
"name" : "Blocker"
|
"name" : "Blocker"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" : "humanSwordsman",
|
||||||
|
"creatureId" : "human",
|
||||||
|
"equipment" : [
|
||||||
|
{
|
||||||
|
"pointId" : "handsCombined",
|
||||||
|
"itemId" : "Katana2H"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
+ bug fixes
|
+ bug fixes
|
||||||
Fix falling tree not always deactivating on server
|
Fix falling tree not always deactivating on server
|
||||||
Fix AI tracking deleted entity
|
|
||||||
Fix server ground movement tree playing animation over falling animation
|
Fix server ground movement tree playing animation over falling animation
|
||||||
Fix empty item slot not showing underneath dragged item
|
Fix empty item slot not showing underneath dragged item
|
||||||
Fix grass rendering distance
|
Fix grass rendering distance
|
||||||
|
|||||||
@ -690,6 +690,9 @@ Unit tests for above
|
|||||||
Fix physics debug rendering pipeline
|
Fix physics debug rendering pipeline
|
||||||
Update human collidable data
|
Update human collidable data
|
||||||
|
|
||||||
|
(09/05/2024)
|
||||||
|
Fix AI tracking deleted entity
|
||||||
|
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
|
|||||||
@ -119,8 +119,10 @@ public class EntityUtils {
|
|||||||
*/
|
*/
|
||||||
public static void cleanUpEntity(Entity e){
|
public static void cleanUpEntity(Entity e){
|
||||||
//remove from client
|
//remove from client
|
||||||
Globals.clientSceneWrapper.getScene().deregisterEntity(e);
|
if(Globals.clientSceneWrapper != null){
|
||||||
Globals.clientSceneWrapper.deregisterTranslationMapping(e);
|
Globals.clientSceneWrapper.getScene().deregisterEntity(e);
|
||||||
|
Globals.clientSceneWrapper.deregisterTranslationMapping(e);
|
||||||
|
}
|
||||||
//remove from all server classes
|
//remove from all server classes
|
||||||
if(Globals.realmManager != null){
|
if(Globals.realmManager != null){
|
||||||
Realm realm = Globals.realmManager.getEntityRealm(e);
|
Realm realm = Globals.realmManager.getEntityRealm(e);
|
||||||
|
|||||||
@ -117,7 +117,9 @@ public class ServerEntityUtils {
|
|||||||
HitboxCollectionState.destroyHitboxState(entity);
|
HitboxCollectionState.destroyHitboxState(entity);
|
||||||
Globals.realmManager.removeEntity(entity);
|
Globals.realmManager.removeEntity(entity);
|
||||||
EntityLookupUtils.removeEntity(entity);
|
EntityLookupUtils.removeEntity(entity);
|
||||||
Globals.aiManager.removeAI(entity);
|
if(Globals.aiManager != null){
|
||||||
|
Globals.aiManager.removeAI(entity);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//deregister all behavior trees
|
//deregister all behavior trees
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public class MeleeTargetingNode implements AITreeNode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AITreeNodeResult evaluate(Entity entity, Blackboard blackboard){
|
public AITreeNodeResult evaluate(Entity entity, Blackboard blackboard){
|
||||||
if(MeleeTargetingNode.hasTarget(blackboard) && this.targetIsValid(entity)){
|
if(MeleeTargetingNode.hasTarget(blackboard) && this.targetIsValid(MeleeTargetingNode.getTarget(blackboard))){
|
||||||
return AITreeNodeResult.SUCCESS;
|
return AITreeNodeResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,9 @@ public class MeleeTargetingNode implements AITreeNode {
|
|||||||
* @return true if valid, false otherwise
|
* @return true if valid, false otherwise
|
||||||
*/
|
*/
|
||||||
private boolean targetIsValid(Entity entity){
|
private boolean targetIsValid(Entity entity){
|
||||||
return Globals.realmManager.getEntityRealm(entity) != null;
|
return
|
||||||
|
Globals.realmManager.getEntityRealm(entity) != null
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
package electrosphere.entity;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
|
import annotations.UnitTest;
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.server.datacell.Realm;
|
||||||
|
import electrosphere.server.datacell.RealmManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit tests for the server entity utils
|
||||||
|
*/
|
||||||
|
public class ServerEntityUtilsUnitTests {
|
||||||
|
|
||||||
|
@UnitTest
|
||||||
|
public void destroyEntity_ValidEntity_NoRealm(){
|
||||||
|
//setup
|
||||||
|
Globals.realmManager = new RealmManager();
|
||||||
|
Realm realm = Globals.realmManager.createViewportRealm(new Vector3d(0,0,0), new Vector3d(1,1,1));
|
||||||
|
Entity entity = EntityCreationUtils.createServerEntity(realm, new Vector3d());
|
||||||
|
|
||||||
|
//perform action
|
||||||
|
ServerEntityUtils.destroyEntity(entity);
|
||||||
|
|
||||||
|
//verify
|
||||||
|
assertEquals(null, Globals.realmManager.getEntityRealm(entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
package electrosphere.server.ai.nodes.actions.combat;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import org.joml.Vector3d;
|
||||||
|
|
||||||
|
import annotations.IntegrationTest;
|
||||||
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.ServerEntityUtils;
|
||||||
|
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||||
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
|
import electrosphere.server.ai.blackboard.Blackboard;
|
||||||
|
import electrosphere.server.ai.nodes.AITreeNode.AITreeNodeResult;
|
||||||
|
import electrosphere.server.content.unit.UnitUtils;
|
||||||
|
import template.EntityTestTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for the melee targeting ai node
|
||||||
|
*/
|
||||||
|
public class MeleeTargetingNodeTests extends EntityTestTemplate {
|
||||||
|
|
||||||
|
@IntegrationTest
|
||||||
|
public void testStopTargetingDeadEntity(){
|
||||||
|
float aggroRange = 10;
|
||||||
|
|
||||||
|
//spawn test entities
|
||||||
|
Entity swordsman = UnitUtils.spawnUnit(Globals.realmManager.first(), new Vector3d(0,0,0), "humanSwordsman");
|
||||||
|
Entity target = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(1,0,0), "human", CreatureTemplate.createDefault("human"));
|
||||||
|
|
||||||
|
//check if the swordsman can find a target
|
||||||
|
Blackboard blackboard = new Blackboard();
|
||||||
|
MeleeTargetingNode meleeTargetingNode = new MeleeTargetingNode(aggroRange);
|
||||||
|
AITreeNodeResult eval1 = meleeTargetingNode.evaluate(swordsman, blackboard);
|
||||||
|
assertEquals(AITreeNodeResult.SUCCESS, eval1);
|
||||||
|
|
||||||
|
//delete the target
|
||||||
|
ServerEntityUtils.destroyEntity(target);
|
||||||
|
|
||||||
|
//check that the swordsman no longer finds a target
|
||||||
|
AITreeNodeResult eval2 = meleeTargetingNode.evaluate(swordsman, blackboard);
|
||||||
|
assertEquals(AITreeNodeResult.FAILURE, eval2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user