add: creating a jump path via menu and console command
This commit is contained in:
parent
bea600bd4e
commit
b946cbdcbf
4 changed files with 38 additions and 4 deletions
|
|
@ -507,6 +507,7 @@
|
||||||
1. Outgoing Path
|
1. Outgoing Path
|
||||||
2. Incoming Path
|
2. Incoming Path
|
||||||
3. Bidirectional (Both Ways)
|
3. Bidirectional (Both Ways)
|
||||||
|
4. Jumping Path
|
||||||
|
|
||||||
0. Exit
|
0. Exit
|
||||||
|
|
||||||
|
|
@ -516,6 +517,7 @@
|
||||||
1. Исходящий путь
|
1. Исходящий путь
|
||||||
2. Входящий путь
|
2. Входящий путь
|
||||||
3. Двунаправленный (Оба пути)
|
3. Двунаправленный (Оба пути)
|
||||||
|
4. Прыговой путь
|
||||||
|
|
||||||
0. Выход
|
0. Выход
|
||||||
|
|
||||||
|
|
@ -1799,6 +1801,12 @@ Creates both-ways path connection between faced and nearest node.
|
||||||
[TRANSLATED]
|
[TRANSLATED]
|
||||||
Создаёт двойной путь между указанной и ближайшей точкой.
|
Создаёт двойной путь между указанной и ближайшей точкой.
|
||||||
|
|
||||||
|
[ORIGINAL]
|
||||||
|
Creates jumping path connection from nearest to faced node.
|
||||||
|
|
||||||
|
[TRANSLATED]
|
||||||
|
Создаёт прыговой путь от ближайшей к указанной точке.
|
||||||
|
|
||||||
[ORIGINAL]
|
[ORIGINAL]
|
||||||
Deletes path from nearest to faced node.
|
Deletes path from nearest to faced node.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@ CR_DECLARE_SCOPED_ENUM (FindPath,
|
||||||
CR_DECLARE_SCOPED_ENUM (PathConnection,
|
CR_DECLARE_SCOPED_ENUM (PathConnection,
|
||||||
Outgoing = 0,
|
Outgoing = 0,
|
||||||
Incoming,
|
Incoming,
|
||||||
Bidirectional
|
Bidirectional,
|
||||||
|
Jumping
|
||||||
)
|
)
|
||||||
|
|
||||||
// node edit states
|
// node edit states
|
||||||
|
|
|
||||||
|
|
@ -347,6 +347,7 @@ int BotControl::cmdNode () {
|
||||||
addGraphCmd ("path_create_in", "path_create_in [noarguments]", "Creates incoming path connection from faced to nearest node.", &BotControl::cmdNodePathCreate);
|
addGraphCmd ("path_create_in", "path_create_in [noarguments]", "Creates incoming path connection from faced to nearest node.", &BotControl::cmdNodePathCreate);
|
||||||
addGraphCmd ("path_create_out", "path_create_out [noarguments]", "Creates outgoing path connection from nearest to faced node.", &BotControl::cmdNodePathCreate);
|
addGraphCmd ("path_create_out", "path_create_out [noarguments]", "Creates outgoing path connection from nearest to faced node.", &BotControl::cmdNodePathCreate);
|
||||||
addGraphCmd ("path_create_both", "path_create_both [noarguments]", "Creates both-ways path connection between faced and nearest node.", &BotControl::cmdNodePathCreate);
|
addGraphCmd ("path_create_both", "path_create_both [noarguments]", "Creates both-ways path connection between faced and nearest node.", &BotControl::cmdNodePathCreate);
|
||||||
|
addGraphCmd ("path_create_jump", "path_create_jump [noarguments]", "Creates jumping path connection from nearest to faced node.", &BotControl::cmdNodePathCreate);
|
||||||
addGraphCmd ("path_delete", "path_delete [noarguments]", "Deletes path from nearest to faced node.", &BotControl::cmdNodePathDelete);
|
addGraphCmd ("path_delete", "path_delete [noarguments]", "Deletes path from nearest to faced node.", &BotControl::cmdNodePathDelete);
|
||||||
addGraphCmd ("path_set_autopath", "path_set_autopath [max_distance]", "Opens menu for setting autopath maximum distance.", &BotControl::cmdNodePathSetAutoDistance);
|
addGraphCmd ("path_set_autopath", "path_set_autopath [max_distance]", "Opens menu for setting autopath maximum distance.", &BotControl::cmdNodePathSetAutoDistance);
|
||||||
|
|
||||||
|
|
@ -697,7 +698,10 @@ int BotControl::cmdNodePathCreate () {
|
||||||
graph.setEditFlag (GraphEdit::On);
|
graph.setEditFlag (GraphEdit::On);
|
||||||
|
|
||||||
// choose the direction for path creation
|
// choose the direction for path creation
|
||||||
if (strValue (cmd).endsWith ("_both")) {
|
if (strValue (cmd).endsWith ("_jump")) {
|
||||||
|
graph.pathCreate (PathConnection::Jumping);
|
||||||
|
}
|
||||||
|
else if (strValue (cmd).endsWith ("_both")) {
|
||||||
graph.pathCreate (PathConnection::Bidirectional);
|
graph.pathCreate (PathConnection::Bidirectional);
|
||||||
}
|
}
|
||||||
else if (strValue (cmd).endsWith ("_in")) {
|
else if (strValue (cmd).endsWith ("_in")) {
|
||||||
|
|
@ -1719,6 +1723,11 @@ int BotControl::menuGraphPath (int item) {
|
||||||
showMenu (Menu::NodePath);
|
showMenu (Menu::NodePath);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
graph.pathCreate (PathConnection::Jumping);
|
||||||
|
showMenu (Menu::NodePath);
|
||||||
|
break;
|
||||||
|
|
||||||
case 10:
|
case 10:
|
||||||
closeMenu ();
|
closeMenu ();
|
||||||
break;
|
break;
|
||||||
|
|
@ -2409,11 +2418,12 @@ void BotControl::createMenus () {
|
||||||
|
|
||||||
// path connections
|
// path connections
|
||||||
m_menus.emplace (
|
m_menus.emplace (
|
||||||
Menu::NodePath, keys (3),
|
Menu::NodePath, keys (4),
|
||||||
"\\yCreate Path (Choose Direction)\\w\n\n"
|
"\\yCreate Path (Choose Direction)\\w\n\n"
|
||||||
"1. Outgoing Path\n"
|
"1. Outgoing Path\n"
|
||||||
"2. Incoming Path\n"
|
"2. Incoming Path\n"
|
||||||
"3. Bidirectional (Both Ways)\n\n"
|
"3. Bidirectional (Both Ways)\n"
|
||||||
|
"4. Jumping Path\n\n"
|
||||||
"0. Exit",
|
"0. Exit",
|
||||||
&BotControl::menuGraphPath);
|
&BotControl::menuGraphPath);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1059,6 +1059,21 @@ void BotGraph::pathCreate (char dir) {
|
||||||
else if (dir == PathConnection::Incoming) {
|
else if (dir == PathConnection::Incoming) {
|
||||||
addPath (nodeTo, nodeFrom, distance);
|
addPath (nodeTo, nodeFrom, distance);
|
||||||
}
|
}
|
||||||
|
else if (dir == PathConnection::Jumping) {
|
||||||
|
if (!isConnected (nodeFrom, nodeTo)) {
|
||||||
|
addPath (nodeFrom, nodeTo, distance);
|
||||||
|
}
|
||||||
|
for (auto &link : m_paths[nodeFrom].links) {
|
||||||
|
if (link.index == nodeTo && !(link.flags & PathFlag::Jump)) {
|
||||||
|
link.flags |= PathFlag::Jump;
|
||||||
|
m_paths[nodeFrom].radius = 0.0f;
|
||||||
|
msg ("Path added from %d to %d.", nodeFrom, nodeTo);
|
||||||
|
}
|
||||||
|
else if (link.index == nodeTo && (link.flags & PathFlag::Jump)) {
|
||||||
|
msg ("Denied path creation from %d to %d (path already exists).", nodeFrom, nodeTo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
addPath (nodeFrom, nodeTo, distance);
|
addPath (nodeFrom, nodeTo, distance);
|
||||||
addPath (nodeTo, nodeFrom, distance);
|
addPath (nodeTo, nodeFrom, distance);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue