Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Replace Pathfinding with FlexiblePathfinding (part 2) #89

Merged
merged 16 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/behaviors/common/attackFollowedEntity.behavior
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
}
},
move_to
move_to
]
}
]
Expand Down
2 changes: 1 addition & 1 deletion assets/behaviors/common/doRandomMove.behavior
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
set_target_nearby_block : { moveProbability: 65 }
},
move_to
move_to
]
}

2 changes: 1 addition & 1 deletion assets/behaviors/common/follow.behavior
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}
}
},
move_to
move_to
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion assets/behaviors/common/restrictedStray.behavior
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
set_target_nearby_block_restricted : { moveProbability: 65 }
},
{
move_to: { distance: 2}
move_to: { distance: 2}
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion assets/behaviors/creatures/worker.behavior
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
sequence: [
{
move_to: {
move_to: {
distance: 0.7
}
},
Expand Down
15 changes: 15 additions & 0 deletions assets/behaviors/naiveMoveTo.behavior
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
sequence : [
{
selector : [
find_path
]
},
{ move_along_path: {
child : {
move_to: {}
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
child: {
move_along_path_continuous: {
child: {
move_to: {}
move_to: {}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{
move_along_path: {
child: {
move_to: {}
move_to: {}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{
move_along_path: {
child: {
move_to: {}
move_to: {}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions assets/behaviors/reliableMoveTo.behavior
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
loop : {
child : {
success : {
child: {
timeout : {
"time": 0.7,
"child": {
lookup: {
tree: "FlexibleMovement:naiveMoveTo"
}
}
}
}
}
}
}
}
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions assets/prefabs/behaviorNodes/finddummypathtonode.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"BehaviorNode": {
"type": "FindDummyPathToNode",
"name": "Find Dummy Path",
"category": "movement",
"shape": "rect",
"description": "Finds a dummy path to target consisting of the current and target location",
"color": [180, 180, 180, 255],
"textColor": [0, 0, 0, 255]
}
}
11 changes: 11 additions & 0 deletions assets/prefabs/behaviorNodes/findpathtonode.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"BehaviorNode": {
"type": "FindPathToNode",
"name": "Find Path",
"category": "movement",
"shape": "rect",
"description": "Finds a path to target using FlexiblePathfinding",
"color": [180, 180, 180, 255],
"textColor": [0, 0, 0, 255]
}
}
Comment on lines +1 to +11
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just remove all of these prefabs and link them in a central issue to bring them back with support for the behavior tree editor? Having half of them might be more confusing than helpful...

Or are they actually complete (or only a few missing)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There still is the ensureTargetPresent.prefab which can be removed as we remove the node.
Apart from that we still only have the "old ones" for:

  • condition
  • jump
  • log
  • setTargetLocalPlayer
  • setTargetToNearbyBlock

Would be nice if @DarkWeird could comment on my questions on the differences/changes between old originals and new replacements. Migrating the above-listed remaining ones in a similar fashion should be easy, but I'd like to understand the changes first before applying them to the rest.

11 changes: 11 additions & 0 deletions assets/prefabs/behaviorNodes/movealongpathnode.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"BehaviorNode": {
"type": "MoveAlongPathNode",
"name": "Move Along Path",
"category": "movement",
"shape": "rect",
"description": "Move sequentially along this entity's path",
"color": [180, 180, 180, 255],
"textColor": [0, 0, 0, 255]
}
}
11 changes: 11 additions & 0 deletions assets/prefabs/behaviorNodes/movetonode.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"BehaviorNode": {
"type": "MoveToNode",
"name": "Move To",
"category": "movement",
"shape": "rect",
"description": "Move to this entity's immediate move target using the FlexibleMovement mode",
"color": [180, 180, 180, 255],
"textColor": [0, 0, 0, 255]
}
}
11 changes: 11 additions & 0 deletions assets/prefabs/behaviorNodes/validatepathnode.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"BehaviorNode": {
"type": "ValidatePathNode",
"name": "Validate Path",
"category": "movement",
"shape": "rect",
"description": "Validate that this entity can traverse its current path",
"color": [180, 180, 180, 255],
"textColor": [0, 0, 0, 255]
}
}
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions assets/prefabs/characters/amphibious.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "FlexibleMovement:testcharacter",
"FlexibleMovement": {
"movementTypes": ["walking", "leaping", "swimming"]
}
}
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 additions & 0 deletions assets/prefabs/characters/flying.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "FlexibleMovement:testcharacter",
"FlexibleMovement": {
"movementTypes": ["flying"]
}
}
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions assets/prefabs/characters/swimming.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "FlexibleMovement:testcharacter",
"FlexibleMovement": {
"movementTypes": [
"swimming"
]
}
}
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved
38 changes: 38 additions & 0 deletions assets/prefabs/characters/testcharacter.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved
"FlexibleMovement": {
"movementTypes": ["walking", "leaping"]
},
"NameTag": { "text": "testcharacter" },
"Behavior" : {
"tree" : "naiveMoveTo"
},
"persisted" : true,
"location" : {},
"Character": {},
"CharacterHeldItem" : { },
"Network" :{},
"Health" : {
"maxHealth": 1,
"currentHealth": 1,
"excessSpeedDamageMultiplier": 0,
"destroyEntityOnNoHealth" : true
},
"Trigger" : {
"detectGroups" : ["engine:debris", "engine:sensor"]
},
"CreatureNameGenerator" : {
"genderRatio" : 0.5,
"nobility" : 0.5,
"theme": "DWARF"
},
"AliveCharacter": {},
"CharacterMovement" : {
"groundFriction" : 16,
"speedMultiplier" : 0.3,
"distanceBetweenFootsteps" : 0.2,
"distanceBetweenSwimStrokes" : 2.5,
"height" : 0.9,
"radius" : 0.3,
"jumpSpeed" : 12
}
}
12 changes: 12 additions & 0 deletions assets/prefabs/items/moveto.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parent": "engine:iconItem",
"DebugMoveTo": {},
"DisplayName": {
"name": "Path to"
},
"Item" : {
"name" : "Walk to block",
"icon" : "engine:items#walkToJob",
"usage" : "ON_BLOCK"
}
}
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions assets/ui/debug.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "FlexibleMovementDebugLayout",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code of this class is commented out. Either one the first things to revive, or to throw out in a follow up and write down an issue for instead.

"skin": "engineDefault"
}
8 changes: 4 additions & 4 deletions module.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
"optional": true,
"because": "tests/ClusterDebugger"
},
{
"id": "FlexiblePathfinding",
"minVersion": "1.0.0"
},
{
"id": "Health",
"minVersion": "2.0.0-SNAPSHOT"
Expand All @@ -20,10 +24,6 @@
"id": "Inventory",
"minVersion": "1.1.0"
},
{
"id": "Pathfinding",
"minVersion": "1.0.0"
},
{
"id": "ModuleTestingEnvironment",
"minVersion": "0.3.0",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
// Copyright 2022 The Terasology Foundation
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.module.behaviors.actions;

import org.terasology.engine.logic.behavior.BehaviorAction;
import org.terasology.engine.logic.behavior.core.Actor;
import org.terasology.engine.logic.behavior.core.BaseAction;
import org.terasology.engine.logic.behavior.core.BehaviorState;
import org.terasology.module.behaviors.components.MinionMoveComponent;
//import org.terasology.engine.logic.behavior.BehaviorAction;
//import org.terasology.engine.logic.behavior.core.Actor;
//import org.terasology.engine.logic.behavior.core.BaseAction;
//import org.terasology.engine.logic.behavior.core.BehaviorState;
//import org.terasology.flexiblemovement.components.FlexibleMovementComponent;

@BehaviorAction(name = "ensure_target_present")
public class EnsureTargetPresentAction extends BaseAction {
@Override
public BehaviorState modify(Actor actor, BehaviorState behaviorState) {
MinionMoveComponent minionMoveComponent = actor.getComponent(MinionMoveComponent.class);
// Not applicable.

if (minionMoveComponent.target != null) {
return BehaviorState.SUCCESS;
}
return BehaviorState.FAILURE;
}
}
//@BehaviorAction(name = "ensure_target_present")
//public class EnsureTargetPresentAction extends BaseAction {
// @Override
// public BehaviorState modify(Actor actor, BehaviorState behaviorState) {
// FlexibleMovementComponent minionMoveComponent = actor.getComponent(FlexibleMovementComponent.class);
//
// if (!minionMoveComponent.getPath().isEmpty()) {
// return BehaviorState.SUCCESS;
// }
// return BehaviorState.FAILURE;
// }
//}
Loading