Added Attack animation, Fix Edge case for path finding. Added footsteps. Level 2 merge #444

Merged
maverickdgg merged 7 commits from Navigation into main 2023-03-25 16:54:30 +08:00
5 changed files with 203 additions and 75 deletions
Showing only changes of commit ab4493822a - Show all commits

View File

@ -1,3 +1,3 @@
Name: Level2_AITest_NavData
ID: 255209218
ID: 258243609
Type: 15

View File

@ -1,4 +1,4 @@
- NavData: 255209218
- NavData: 258243609
- EID: 20
Name: ===== Light =====
IsActive: true
@ -112,6 +112,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -164,6 +165,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -216,6 +218,7 @@
Enabled: true
Score: 500
currCategory: 2
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -268,6 +271,7 @@
Enabled: true
Score: 500
currCategory: 2
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -320,6 +324,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -372,6 +377,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -424,6 +430,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -482,6 +489,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 2
dontReturn: false
soundDistance: 10
@ -702,6 +710,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -754,6 +763,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -806,6 +816,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -858,6 +869,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -910,6 +922,7 @@
Enabled: true
Score: 500
currCategory: 2
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -962,6 +975,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1014,6 +1028,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1066,6 +1081,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1118,6 +1134,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1170,6 +1187,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1222,6 +1240,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1274,6 +1293,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1326,6 +1346,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1378,6 +1399,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1430,6 +1452,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1482,6 +1505,7 @@
Enabled: true
Score: 500
currCategory: 2
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1534,6 +1558,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1586,6 +1611,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1638,6 +1664,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1696,6 +1723,7 @@
Enabled: true
Score: 500
currCategory: 2
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -1748,6 +1776,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -1800,6 +1829,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -1852,6 +1882,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -1904,6 +1935,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -1956,6 +1988,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -2014,6 +2047,7 @@
Enabled: true
Score: 500
currCategory: 2
currFood: 0
density: 1
dontReturn: false
soundDistance: 10
@ -2066,6 +2100,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -2118,6 +2153,7 @@
Enabled: true
Score: 50
currCategory: 1
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -2170,6 +2206,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -2222,6 +2259,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -2274,6 +2312,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 3
dontReturn: false
soundDistance: 10
@ -2332,6 +2371,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 2
dontReturn: false
soundDistance: 10
@ -2558,6 +2598,7 @@
Enabled: true
Score: 10
currCategory: 0
currFood: 0
density: 2
dontReturn: false
soundDistance: 10
@ -2778,6 +2819,7 @@
Scripts:
- Type: ScoringZone
Enabled: true
startingParticleCount: 10
- EID: 18
Name: CollisionWall
IsActive: true
@ -2841,6 +2883,7 @@
Scripts:
- Type: ScoringZone
Enabled: true
startingParticleCount: 10
- EID: 17
Name: CollisionWall
IsActive: true
@ -3041,8 +3084,6 @@
armLength: 2
turnSpeedPitch: 0.200000003
turnSpeedYaw: 0.400000006
inverseXControls: true
inverseYControls: false
pitchUpperClamp: 45
pitchLowerClamp: 5
- EID: 9

View File

@ -442,6 +442,11 @@ namespace SHADE
if (ImGui::DragScalar("Col", ImGuiDataType_U16, &navSystem->numCols_editor)) {}
if(ImGui::DragScalar("Row", ImGuiDataType_U16, &navSystem->numRows_editor)){}
if (ImGui::Checkbox("Draw Navigation Area", &navSystem->drawNavigationArea)) {}
if (ImGui::Checkbox("Draw Navigation Data", &navSystem->drawNavigationData)) {}
if (ImGui::Checkbox("Draw Path", &navSystem->drawPath)) {}
if (ImGui::Button("Generate"))
{

View File

@ -26,6 +26,11 @@ namespace SHADE
auto id = ComponentFamily::GetID<SHNavigationComponent>();
SHComponentManager::CreateComponentSparseSet<SHNavigationComponent>();
SystemID i = SystemFamily::GetID<SHNavigationSystem>();
drawNavigationArea = true;
drawNavigationData = true;
drawPath = true;
}
void SHNavigationSystem::Exit()
@ -227,21 +232,20 @@ namespace SHADE
if (editor->editorState != SHEditor::State::PLAY)
{
SHNavigationSystem* system = static_cast<SHNavigationSystem*>(GetSystem());
if (SHInputManager::GetKeyDown(SHInputManager::SH_KEYCODE::H))
{
system->GenerateNavigationGridData(SHVec3{ 0.0f }, navigationAreaSize, 80, 80);
}
auto debugDrawSystem = SHSystemManager::GetSystem<SHDebugDrawSystem>();
if (debugDrawSystem)
{
if (system->drawNavigationArea)
{
SHTransform trans;
trans.position = SHVec3{ 0.0f };
trans.scale = navigationAreaSize;
trans.ComputeTRS();
debugDrawSystem->DrawWireCube(trans.trs, SHColour::YELLOW, false);
#ifdef DRAW_NAVIGATION_DATA
}
if (system->drawNavigationData)
{
for (uint16_t r = 0; r < system->numRows; ++r)
{
for (uint16_t c = 0; c < system->numCols; ++c)
@ -277,11 +281,8 @@ namespace SHADE
}
}
#endif
}
}
}
#endif
}
@ -334,12 +335,11 @@ namespace SHADE
//return so we don't run the parts after this twice.
return;
}
comp.forward = SHVec3::Normalise(direction);
#ifdef DRAW_NAVIGATION_PATH
#ifdef SHEDITOR
if (drawPath)
{
auto debugDrawSystem = SHSystemManager::GetSystem<SHDebugDrawSystem>();
auto queue = comp.path;
@ -364,7 +364,7 @@ namespace SHADE
}
queue.pop();
}
}
#endif
}
@ -404,6 +404,83 @@ namespace SHADE
NavigationNode startingNode;
startingNode.index = GetNavigationGridIndex(transform->GetWorldPosition());
if (GetNavigationData(startingNode.index) == true)
{
uint16_t i = comp.tolerance;
while (openList.empty())
{
NavigationGridIndex tolCheckIndex = startingNode.index;
tolCheckIndex.row += i;
if (GetNavigationData(tolCheckIndex) == false)
{
startingNode.index = tolCheckIndex;
break;
}
tolCheckIndex = startingNode.index;
tolCheckIndex.row -= i;
if (GetNavigationData(tolCheckIndex) == false)
{
startingNode.index = tolCheckIndex;
break;
}
tolCheckIndex = startingNode.index;
tolCheckIndex.column += i;
if (GetNavigationData(tolCheckIndex) == false)
{
startingNode.index = tolCheckIndex;
break;
}
tolCheckIndex = startingNode.index;
tolCheckIndex.column -= i;
if (GetNavigationData(tolCheckIndex) == false)
{
startingNode.index = tolCheckIndex;
break;
}
tolCheckIndex = startingNode.index;
tolCheckIndex.row += i;
tolCheckIndex.column += i;
if (GetNavigationData(tolCheckIndex) == false)
{
startingNode.index = tolCheckIndex;
break;
}
tolCheckIndex = startingNode.index;
tolCheckIndex.row -= i;
tolCheckIndex.column -= i;
if (GetNavigationData(tolCheckIndex) == false)
{
startingNode.index = tolCheckIndex;
break;
}
tolCheckIndex = startingNode.index;
tolCheckIndex.row -= i;
tolCheckIndex.column += i;
if (GetNavigationData(tolCheckIndex) == false)
{
startingNode.index = tolCheckIndex;
break;
}
tolCheckIndex = startingNode.index;
tolCheckIndex.row += i;
tolCheckIndex.column -= i;
if (GetNavigationData(tolCheckIndex) == false)
{
startingNode.index = tolCheckIndex;
break;
}
++i;
}
}
startingNode.parent.row = NullGridIndex;
startingNode.parent.column = NullGridIndex;
startingNode.h = std::numeric_limits<uint32_t>::max();
@ -413,6 +490,8 @@ namespace SHADE
openList.push_back(startingNode);
NavigationNode endNode;
endNode.index.row = NullGridIndex;
endNode.index.column = NullGridIndex;

View File

@ -75,6 +75,9 @@ namespace SHADE
AssetID navDataAsset{};
bool drawNavigationArea;
bool drawNavigationData;
bool drawPath;
void GenerateNavigationGridData(SHVec3 origin, SHVec3 size, uint16_t numRow, uint16_t numCol) noexcept;