diff --git a/TurbulentArena/BSetWanderTarget.cpp b/TurbulentArena/BSetWanderTarget.cpp index 3c343fc..357262e 100644 --- a/TurbulentArena/BSetWanderTarget.cpp +++ b/TurbulentArena/BSetWanderTarget.cpp @@ -20,7 +20,7 @@ namespace bjoernligan return EBNodeStatus::Invalid; //Set new Max velocity depending on injury - float MoveSpeed = 50.f + 100.0f * m_xAgent->getOwner()->GetCombat()->GetHealthPercentage(); + float MoveSpeed = 100.f + 50.0f * m_xAgent->getOwner()->GetCombat()->GetHealthPercentage(); m_xAgent->getOwner()->GetMovementStats().SetMaxVelocity(MoveSpeed); m_xAgent->ChooseWanderPos(true, 20); diff --git a/TurbulentArena/Physics.cpp b/TurbulentArena/Physics.cpp index bdacdb1..a7cebf1 100644 --- a/TurbulentArena/Physics.cpp +++ b/TurbulentArena/Physics.cpp @@ -2,6 +2,7 @@ #include "Physics.hpp" #include "ContactListener.hpp" #include "Box2DWorldDraw.h" +#include "UserData.hpp" namespace bjoernligan { @@ -30,13 +31,31 @@ namespace bjoernligan float32 Physics::Raycast::ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction) { - if (m_result.bodies.empty()) - m_result.bodies.push_back(fixture->GetBody()); - else - m_result.bodies[0] = fixture->GetBody(); normal; point; fraction; + + B2UserData* userData = static_cast(fixture->GetBody()->GetUserData()); + + if (userData->type == B2UserData::NATURE) + { + NatureUD* nature = static_cast(userData); + if (!nature->m_see_through) + { + if (m_result.bodies.empty()) + m_result.bodies.push_back(fixture->GetBody()); + else + m_result.bodies[0] = fixture->GetBody(); + } + } + else if (userData->type == B2UserData::CLANMEMBER) + { + if (m_result.bodies.empty()) + m_result.bodies.push_back(fixture->GetBody()); + else + m_result.bodies[0] = fixture->GetBody(); + } + return fraction; } void Physics::Body::setPosition(const sf::Vector2f& p_position) diff --git a/TurbulentArena/Physics.hpp b/TurbulentArena/Physics.hpp index 0c6e0d9..fa6f9f7 100644 --- a/TurbulentArena/Physics.hpp +++ b/TurbulentArena/Physics.hpp @@ -1,4 +1,5 @@ #pragma once +#include "UserData.hpp" namespace bjoernligan { @@ -14,6 +15,7 @@ namespace bjoernligan void setPosition(float x, float y); b2Body* m_body; + std::unique_ptr m_b2UserData; }; enum EB2ShapeType diff --git a/TurbulentArena/PlayState.cpp b/TurbulentArena/PlayState.cpp index 5ee42ef..de52e27 100644 --- a/TurbulentArena/PlayState.cpp +++ b/TurbulentArena/PlayState.cpp @@ -99,6 +99,15 @@ namespace bjoernligan Physics::Body* body = m_physics->createBody(xParams); body->setPosition(x * tileSize.x + tileSize.x * 0.5f, y * tileSize.y + tileSize.y * 0.5f); + + bool seeThrough = false; + if (tile->getTileInfo()->m_properties.hasProperty("see_through")) + { + seeThrough = true; + } + + body->m_b2UserData = std::make_unique(seeThrough); + body->m_body->SetUserData(body->m_b2UserData.get()); } } } @@ -124,10 +133,10 @@ namespace bjoernligan ++teamSpawnsIt; } - m_xPlayerClan = m_clanManager->createClan("MacDonald", sf::Color(70, 70, 255), 20, 3); + m_xPlayerClan = m_clanManager->createClan("MacDonald", sf::Color(70, 70, 255), 1, 0); m_xGameOverChecker.AddClan(m_xPlayerClan); - m_xGameOverChecker.AddClan(m_clanManager->createClan("MacMuffin", sf::Color(255, 70, 70), 20, 3)); + m_xGameOverChecker.AddClan(m_clanManager->createClan("MacMuffin", sf::Color(255, 70, 70), 1, 0)); std::vector clans = m_clanManager->getClans(); std::vector members; diff --git a/TurbulentArena/UserData.hpp b/TurbulentArena/UserData.hpp index 5eb8984..e31ff0a 100644 --- a/TurbulentArena/UserData.hpp +++ b/TurbulentArena/UserData.hpp @@ -43,4 +43,21 @@ namespace bjoernligan ClanMember* clanMember; }; + + struct NatureUD : public B2UserData + { + NatureUD(bool see_through) : + B2UserData(NATURE), + m_see_through(see_through) + { + + } + + ~NatureUD() + { + + } + + bool m_see_through; + }; } \ No newline at end of file