mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 02:12:45 +01:00
Modernize ScanType enum
This commit is contained in:
parent
f894718183
commit
bdacc1137a
@ -568,7 +568,7 @@ void GameWorld::destroyEffect(VisualFX& effect) {
|
||||
}
|
||||
|
||||
void GameWorld::doWeaponScan(const WeaponScan& scan) {
|
||||
if (scan.type == WeaponScan::RADIUS) {
|
||||
if (scan.type == ScanType::Radius) {
|
||||
HitTest test {*dynamicsWorld};
|
||||
const auto result = test.sphereTest(scan.center, scan.radius);
|
||||
|
||||
@ -584,7 +584,7 @@ void GameWorld::doWeaponScan(const WeaponScan& scan) {
|
||||
target.object->takeDamage(di);
|
||||
}
|
||||
|
||||
} else if (scan.type == WeaponScan::HITSCAN) {
|
||||
} else if (scan.type == ScanType::HitScan) {
|
||||
btVector3 from(scan.center.x, scan.center.y, scan.center.z),
|
||||
to(scan.end.x, scan.end.y, scan.end.z);
|
||||
glm::vec3 hitEnd = scan.end;
|
||||
|
@ -1,22 +1,22 @@
|
||||
#ifndef _RWENGINE_WEAPON_HPP_
|
||||
#define _RWENGINE_WEAPON_HPP_
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
class CharacterObject;
|
||||
class GameObject;
|
||||
struct WeaponData;
|
||||
|
||||
enum class ScanType {
|
||||
/** Instant-hit ray weapons */
|
||||
HitScan,
|
||||
/** Area of effect attack */
|
||||
Radius,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief simple object for performing weapon checks against the world
|
||||
*/
|
||||
struct WeaponScan {
|
||||
enum ScanType {
|
||||
/** Instant-hit ray weapons */
|
||||
HITSCAN,
|
||||
/** Area of effect attack */
|
||||
RADIUS,
|
||||
};
|
||||
|
||||
const ScanType type;
|
||||
|
||||
float damage;
|
||||
@ -29,10 +29,10 @@ struct WeaponScan {
|
||||
WeaponData* weapon;
|
||||
GameObject* source;
|
||||
|
||||
// Constructor for a RADIUS hitscan
|
||||
// Constructor for Radius
|
||||
WeaponScan(float damage, const glm::vec3& center, float radius,
|
||||
WeaponData* weapon = nullptr, GameObject* source = nullptr)
|
||||
: type(RADIUS)
|
||||
: type(ScanType::Radius)
|
||||
, damage(damage)
|
||||
, center(center)
|
||||
, radius(radius)
|
||||
@ -40,10 +40,10 @@ struct WeaponScan {
|
||||
, source(source) {
|
||||
}
|
||||
|
||||
// Constructor for a ray hitscan
|
||||
// Constructor for HitScan
|
||||
WeaponScan(float damage, const glm::vec3& start, const glm::vec3& end,
|
||||
WeaponData* weapon = nullptr, GameObject* source = nullptr)
|
||||
: type(HITSCAN)
|
||||
: type(ScanType::HitScan)
|
||||
, damage(damage)
|
||||
, center(start)
|
||||
, end(end)
|
||||
|
@ -5,16 +5,20 @@
|
||||
#include <objects/ProjectileObject.hpp>
|
||||
#include "test_Globals.hpp"
|
||||
|
||||
auto& operator<<(std::ostream& s, const ScanType& type) {
|
||||
return s << static_cast<int>(type);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(WeaponTests)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(radius_ctor_creates_radius_scan) {
|
||||
WeaponScan scan{10.f, {1.f, 1.f, 1.f}, 5.f};
|
||||
BOOST_CHECK_EQUAL(scan.type, WeaponScan::RADIUS);
|
||||
BOOST_CHECK_EQUAL(scan.type, ScanType::Radius);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(hitscan_ctor_creates_radius_scan) {
|
||||
WeaponScan scan{10.f, {1.f, 1.f, 1.f}, {0.f, 0.f, 0.f}};
|
||||
BOOST_CHECK_EQUAL(scan.type, WeaponScan::HITSCAN);
|
||||
BOOST_CHECK_EQUAL(scan.type, ScanType::HitScan);
|
||||
}
|
||||
|
||||
struct WeaponScanFixture {
|
||||
|
Loading…
Reference in New Issue
Block a user