mirror of
https://github.com/rwengine/openrw.git
synced 2024-09-02 08:39:49 +02:00
Start using structure bindings
This commit is contained in:
parent
45ea1df74c
commit
80666bc38d
@ -12,8 +12,8 @@ using OGameStringStream = std::basic_ostringstream<GameStringChar>;
|
|||||||
FontMap::FontMap(std::initializer_list<std::reference_wrapper<const gschar_unicode_map_t>> maps) {
|
FontMap::FontMap(std::initializer_list<std::reference_wrapper<const gschar_unicode_map_t>> maps) {
|
||||||
for (const auto &map : maps) {
|
for (const auto &map : maps) {
|
||||||
m_to_unicode.insert(map.get().cbegin(), map.get().cend());
|
m_to_unicode.insert(map.get().cbegin(), map.get().cend());
|
||||||
for (const auto &m : map.get()) {
|
for (const auto &[gameStringChar, unicode] : map.get()) {
|
||||||
m_from_unicode[m.second] = m.first;
|
m_from_unicode[unicode] = gameStringChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto &q = m_from_unicode.find(UnicodeValue::UNICODE_QUESTION_MARK);
|
const auto &q = m_from_unicode.find(UnicodeValue::UNICODE_QUESTION_MARK);
|
||||||
|
@ -110,10 +110,10 @@ bool SoundManager::loadSound(const std::string& name,
|
|||||||
if (sound_iter != sounds.end()) {
|
if (sound_iter != sounds.end()) {
|
||||||
sound = &sound_iter->second;
|
sound = &sound_iter->second;
|
||||||
} else {
|
} else {
|
||||||
auto emplaced = sounds.emplace(std::piecewise_construct,
|
auto [it, emplaced] = sounds.emplace(std::piecewise_construct,
|
||||||
std::forward_as_tuple(name),
|
std::forward_as_tuple(name),
|
||||||
std::forward_as_tuple());
|
std::forward_as_tuple());
|
||||||
sound = &emplaced.first->second;
|
sound = &it->second;
|
||||||
|
|
||||||
sound->source = std::make_shared<SoundSource>();
|
sound->source = std::make_shared<SoundSource>();
|
||||||
sound->buffer = std::make_unique<SoundBuffer>();
|
sound->buffer = std::make_unique<SoundBuffer>();
|
||||||
@ -128,10 +128,10 @@ bool SoundManager::loadSound(const std::string& name,
|
|||||||
void SoundManager::loadSound(size_t index) {
|
void SoundManager::loadSound(size_t index) {
|
||||||
Sound* sound = nullptr;
|
Sound* sound = nullptr;
|
||||||
|
|
||||||
auto emplaced =
|
auto [it, emplaced] =
|
||||||
sfx.emplace(std::piecewise_construct, std::forward_as_tuple(index),
|
sfx.emplace(std::piecewise_construct, std::forward_as_tuple(index),
|
||||||
std::forward_as_tuple());
|
std::forward_as_tuple());
|
||||||
sound = &emplaced.first->second;
|
sound = &it->second;
|
||||||
|
|
||||||
sound->source = std::make_shared<SoundSource>();
|
sound->source = std::make_shared<SoundSource>();
|
||||||
sound->source->loadSfx(sdt, index);
|
sound->source->loadSfx(sdt, index);
|
||||||
@ -149,22 +149,22 @@ size_t SoundManager::createSfxInstance(size_t index) {
|
|||||||
|
|
||||||
// Try to reuse first available buffer
|
// Try to reuse first available buffer
|
||||||
// (aka with stopped state)
|
// (aka with stopped state)
|
||||||
for (auto& sound : buffers) {
|
for (auto& [id, sound] : buffers) {
|
||||||
if (sound.second.buffer && sound.second.isStopped()) {
|
if (sound.buffer && sound.isStopped()) {
|
||||||
// Let's use this buffer
|
// Let's use this buffer
|
||||||
sound.second.buffer = std::make_unique<SoundBuffer>();
|
sound.buffer = std::make_unique<SoundBuffer>();
|
||||||
sound.second.source = soundRef->second.source;
|
sound.source = soundRef->second.source;
|
||||||
sound.second.isLoaded =
|
sound.isLoaded =
|
||||||
sound.second.buffer->bufferData(*sound.second.source);
|
sound.buffer->bufferData(*sound.source);
|
||||||
return sound.first;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// There's no available free buffer, so
|
// There's no available free buffer, so
|
||||||
// we should create a new one.
|
// we should create a new one.
|
||||||
auto emplaced = buffers.emplace(std::piecewise_construct,
|
auto [it, emplaced] = buffers.emplace(std::piecewise_construct,
|
||||||
std::forward_as_tuple(bufferNr),
|
std::forward_as_tuple(bufferNr),
|
||||||
std::forward_as_tuple());
|
std::forward_as_tuple());
|
||||||
sound = &emplaced.first->second;
|
sound = &it->second;
|
||||||
|
|
||||||
sound->id = bufferNr;
|
sound->id = bufferNr;
|
||||||
sound->buffer = std::make_unique<SoundBuffer>();
|
sound->buffer = std::make_unique<SoundBuffer>();
|
||||||
|
@ -24,21 +24,16 @@ void Animator::tick(float dt) {
|
|||||||
glm::quat rotation{1.0f,0.0f,0.0f,0.0f};
|
glm::quat rotation{1.0f,0.0f,0.0f,0.0f};
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Blend all active animations together
|
|
||||||
std::map<ModelFrame*, BoneTransform> blendFrames;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (AnimationState& state : animations) {
|
for (AnimationState& state : animations) {
|
||||||
if (state.animation == nullptr) continue;
|
if (state.animation == nullptr) continue;
|
||||||
|
|
||||||
if (state.boneInstances.empty()) {
|
if (state.boneInstances.empty()) {
|
||||||
for (const auto& bone : state.animation->bones) {
|
for (const auto& [name, bonePtr] : state.animation->bones) {
|
||||||
auto frame = model->findFrame(bone.first);
|
auto frame = model->findFrame(name);
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
state.boneInstances.emplace(bone.second.get(), frame);
|
state.boneInstances.emplace(bonePtr.get(), frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,42 +46,20 @@ void Animator::tick(float dt) {
|
|||||||
animTime = std::fmod(animTime, state.animation->duration);
|
animTime = std::fmod(animTime, state.animation->duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& b : state.boneInstances) {
|
for (auto& [bonePtr, frame] : state.boneInstances) {
|
||||||
if (b.first->frames.empty()) continue;
|
if (bonePtr->frames.empty()) continue;
|
||||||
auto kf = b.first->getInterpolatedKeyframe(animTime);
|
auto kf = bonePtr->getInterpolatedKeyframe(animTime);
|
||||||
|
|
||||||
BoneTransform xform;
|
BoneTransform xform;
|
||||||
xform.rotation = kf.rotation;
|
xform.rotation = kf.rotation;
|
||||||
if (b.first->type != AnimationBone::R00) {
|
if (bonePtr->type != AnimationBone::R00) {
|
||||||
xform.translation = kf.position;
|
xform.translation = kf.position;
|
||||||
}
|
}
|
||||||
|
frame->setTranslation(frame->getDefaultTranslation() +
|
||||||
#if 0
|
|
||||||
auto prevAnim = blendFrames.find(b.second.frameIndex);
|
|
||||||
if (prevAnim != blendFrames.end())
|
|
||||||
{
|
|
||||||
prevAnim->second.translation += xform.translation;
|
|
||||||
prevAnim->second.rotation *= xform.rotation;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
blendFrames[b.second.frameIndex] = xform;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
b.second->setTranslation(b.second->getDefaultTranslation() +
|
|
||||||
xform.translation);
|
xform.translation);
|
||||||
b.second->setRotation(glm::mat3_cast(xform.rotation));
|
frame->setRotation(glm::mat3_cast(xform.rotation));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
for (auto& p : blendFrames) {
|
|
||||||
p.first->setTranslation(p.first->getDefaultTranslation() +
|
|
||||||
p.second.translation);
|
|
||||||
p.first->setRotation(glm::mat3_cast(p.second.rotation));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Animator::isCompleted(unsigned int slot) const {
|
bool Animator::isCompleted(unsigned int slot) const {
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
int GameState::addRadarBlip(BlipData& blip) {
|
int GameState::addRadarBlip(BlipData& blip) {
|
||||||
int l = 0;
|
int l = 0;
|
||||||
for (const auto& radarBlip : radarBlips) {
|
for (const auto& [nr, blipData] : radarBlips) {
|
||||||
if ((radarBlip.first) != l) {
|
if ((nr) != l) {
|
||||||
l = radarBlip.first - 1;
|
l = nr - 1;
|
||||||
} else {
|
} else {
|
||||||
l++;
|
l++;
|
||||||
}
|
}
|
||||||
|
@ -439,8 +439,8 @@ void GameWorld::ObjectPool::insert(std::unique_ptr<GameObject> object) {
|
|||||||
if (object->getGameObjectID() == 0) {
|
if (object->getGameObjectID() == 0) {
|
||||||
// Find the lowest free GameObjectID.
|
// Find the lowest free GameObjectID.
|
||||||
GameObjectID availID = 1;
|
GameObjectID availID = 1;
|
||||||
for (auto& p : objects) {
|
for (auto& [id, objectPtr] : objects) {
|
||||||
if (p.first == availID) availID++;
|
if (id == availID) availID++;
|
||||||
}
|
}
|
||||||
|
|
||||||
object->setGameObjectID(availID);
|
object->setGameObjectID(availID);
|
||||||
|
@ -458,20 +458,20 @@ void VehicleObject::tickPhysics(float dt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update passenger positions
|
// Update passenger positions
|
||||||
for (auto& seat : seatOccupants) {
|
for (auto& [seatId, objectPtr] : seatOccupants) {
|
||||||
auto character = static_cast<CharacterObject*>(seat.second);
|
auto character = static_cast<CharacterObject*>(objectPtr);
|
||||||
|
|
||||||
glm::vec3 passPosition{};
|
glm::vec3 passPosition{};
|
||||||
if (character->isEnteringOrExitingVehicle()) {
|
if (character->isEnteringOrExitingVehicle()) {
|
||||||
passPosition = getSeatEntryPositionWorld(seat.first);
|
passPosition = getSeatEntryPositionWorld(seatId);
|
||||||
} else {
|
} else {
|
||||||
passPosition = getPosition();
|
passPosition = getPosition();
|
||||||
if (seat.first < info->seats.size()) {
|
if (seatId < info->seats.size()) {
|
||||||
passPosition +=
|
passPosition +=
|
||||||
getRotation() * (info->seats[seat.first].offset);
|
getRotation() * (info->seats[seatId].offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
seat.second->updateTransform(passPosition, getRotation());
|
objectPtr->updateTransform(passPosition, getRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getVehicle()->vehicletype_ == VehicleModelInfo::BOAT) {
|
if (getVehicle()->vehicletype_ == VehicleModelInfo::BOAT) {
|
||||||
|
@ -7719,8 +7719,8 @@ void opcode_02dd(const ScriptArguments& args, const ScriptString areaName, Scrip
|
|||||||
if (zone) {
|
if (zone) {
|
||||||
// Create a list of candidate characters by iterating and checking if the char is in this zone
|
// Create a list of candidate characters by iterating and checking if the char is in this zone
|
||||||
std::vector<std::pair<GameObjectID, GameObject*>> candidates;
|
std::vector<std::pair<GameObjectID, GameObject*>> candidates;
|
||||||
for (auto& p : args.getWorld()->pedestrianPool.objects) {
|
for (auto& [id, pedestrianPtr] : args.getWorld()->pedestrianPool.objects) {
|
||||||
auto character = static_cast<CharacterObject*>(p.second.get());
|
auto character = static_cast<CharacterObject*>(pedestrianPtr.get());
|
||||||
|
|
||||||
// We only consider characters walking around normally
|
// We only consider characters walking around normally
|
||||||
// @todo not sure if we are able to grab script objects or players too
|
// @todo not sure if we are able to grab script objects or players too
|
||||||
@ -7735,7 +7735,7 @@ void opcode_02dd(const ScriptArguments& args, const ScriptString areaName, Scrip
|
|||||||
auto& max = zone->max;
|
auto& max = zone->max;
|
||||||
if (cp.x > min.x && cp.y > min.y && cp.z > min.z &&
|
if (cp.x > min.x && cp.y > min.y && cp.z > min.z &&
|
||||||
cp.x < max.x && cp.y < max.y && cp.z < max.z) {
|
cp.x < max.x && cp.y < max.y && cp.z < max.z) {
|
||||||
candidates.emplace_back(p.first, p.second.get());
|
candidates.emplace_back(id, pedestrianPtr.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7746,13 +7746,13 @@ void opcode_02dd(const ScriptArguments& args, const ScriptString areaName, Scrip
|
|||||||
// @todo verify if the lifetime is actually changed in the original game
|
// @todo verify if the lifetime is actually changed in the original game
|
||||||
// husho: lifetime is changed to mission object lifetime
|
// husho: lifetime is changed to mission object lifetime
|
||||||
unsigned int randomIndex = std::rand() % candidateCount;
|
unsigned int randomIndex = std::rand() % candidateCount;
|
||||||
const auto p = candidates[randomIndex];
|
const auto [candidateId, candidatePtr] = candidates.at(randomIndex);
|
||||||
auto character = static_cast<CharacterObject*>(p.second);
|
auto character = static_cast<CharacterObject*>(candidatePtr);
|
||||||
character->setLifetime(GameObject::MissionLifetime);
|
character->setLifetime(GameObject::MissionLifetime);
|
||||||
if (args.getThread()->isMission) {
|
if (args.getThread()->isMission) {
|
||||||
script::addObjectToMissionCleanup(args, character);
|
script::addObjectToMissionCleanup(args, character);
|
||||||
}
|
}
|
||||||
*args[1].globalInteger = p.first;
|
*args[1].globalInteger = candidateId;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,8 +455,8 @@ std::string GameConfig::ParseResult::what() const {
|
|||||||
}
|
}
|
||||||
if (!this->m_unknownData.empty()) {
|
if (!this->m_unknownData.empty()) {
|
||||||
oss << "\nUnknown configuration keys:";
|
oss << "\nUnknown configuration keys:";
|
||||||
for (const auto &keyvalue : m_unknownData) {
|
for (const auto &[key, value] : m_unknownData) {
|
||||||
oss << "\n - " << keyvalue.first;
|
oss << "\n - " << key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return oss.str();
|
return oss.str();
|
||||||
|
@ -71,8 +71,8 @@ void GameInput::updateGameInputState(GameInputState *state,
|
|||||||
auto level = event.type == SDL_KEYDOWN ? 1.f : 0.f;
|
auto level = event.type == SDL_KEYDOWN ? 1.f : 0.f;
|
||||||
auto& levels = state->levels;
|
auto& levels = state->levels;
|
||||||
|
|
||||||
auto range = kDefaultControls.equal_range(sym);
|
auto [rangeBegin, rangeEnd] = kDefaultControls.equal_range(sym);
|
||||||
for (auto it = range.first; it != range.second; ++it) {
|
for (auto it = rangeBegin; it != rangeEnd; ++it) {
|
||||||
levels[it->second] = level;
|
levels[it->second] = level;
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -25,16 +25,13 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
const std::map<GameRenderer::SpecialModel, std::pair<std::string, std::string>>
|
|
||||||
kSpecialModels = {
|
|
||||||
{GameRenderer::ZoneCylinderA,
|
|
||||||
std::pair<std::string, std::string>("zonecyla.dff", "particle")},
|
|
||||||
{GameRenderer::ZoneCylinderB,
|
|
||||||
std::pair<std::string, std::string>("zonecylb.dff", "particle")},
|
|
||||||
{GameRenderer::Arrow,
|
|
||||||
std::pair<std::string, std::string>("arrow.dff", "")}};
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
static constexpr std::array<
|
||||||
|
std::tuple<GameRenderer::SpecialModel, char const*, char const*>, 3>
|
||||||
|
kSpecialModels{{{GameRenderer::ZoneCylinderA, "zonecyla.dff", "particle"},
|
||||||
|
{GameRenderer::ZoneCylinderB, "zonecylb.dff", "particle"},
|
||||||
|
{GameRenderer::Arrow, "arrow.dff", ""}}};
|
||||||
|
|
||||||
constexpr float kMaxPhysicsSubSteps = 2;
|
constexpr float kMaxPhysicsSubSteps = 2;
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -64,9 +61,9 @@ RWGame::RWGame(Logger& log, int argc, char* argv[])
|
|||||||
|
|
||||||
data.load();
|
data.load();
|
||||||
|
|
||||||
for (const auto& p : kSpecialModels) {
|
for (const auto& [specialModel, fileName, name] : kSpecialModels) {
|
||||||
auto model = data.loadClump(p.second.first, p.second.second);
|
auto model = data.loadClump(fileName, name);
|
||||||
renderer.setSpecialModel(p.first, model);
|
renderer.setSpecialModel(specialModel, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up text renderer
|
// Set up text renderer
|
||||||
@ -213,7 +210,7 @@ void RWGame::handleCheatInput(char symbol) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
checkForCheat("GUNSGUNSGUNS", [&] {
|
checkForCheat("GUNSGUNSGUNS", [&] {
|
||||||
constexpr std::array<int, 11> ammo = {{
|
static constexpr std::array<int, 11> ammo = {{
|
||||||
1, //baseball bat
|
1, //baseball bat
|
||||||
100,//pistol
|
100,//pistol
|
||||||
100,//uzi
|
100,//uzi
|
||||||
@ -226,7 +223,7 @@ void RWGame::handleCheatInput(char symbol) {
|
|||||||
200,//m16
|
200,//m16
|
||||||
5 //sniper rifle
|
5 //sniper rifle
|
||||||
}};
|
}};
|
||||||
for (std::array<int, 11>::size_type i = 0; i < ammo.size(); i++)
|
for (auto i = 0u; i < ammo.size(); i++)
|
||||||
player->addToInventory(static_cast<int>(i+1),ammo[i]);
|
player->addToInventory(static_cast<int>(i+1),ammo[i]);
|
||||||
state.showHelpMessage("CHEAT2"); // III / VC: Inputting weapon cheats.
|
state.showHelpMessage("CHEAT2"); // III / VC: Inputting weapon cheats.
|
||||||
});
|
});
|
||||||
|
@ -108,7 +108,7 @@ std::shared_ptr<Menu> DebugState::createMapMenu() {
|
|||||||
}},
|
}},
|
||||||
{"Unsolid garage doors",
|
{"Unsolid garage doors",
|
||||||
[=] {
|
[=] {
|
||||||
std::vector<std::string> garageDoorModels{
|
static constexpr std::array<char const*, 33> garageDoorModels{{
|
||||||
"8ballsuburbandoor", "amcogaragedoor",
|
"8ballsuburbandoor", "amcogaragedoor",
|
||||||
"bankjobdoor", "bombdoor",
|
"bankjobdoor", "bombdoor",
|
||||||
"crushercrush", "crushertop",
|
"crushercrush", "crushertop",
|
||||||
@ -125,11 +125,11 @@ std::shared_ptr<Menu> DebugState::createMapMenu() {
|
|||||||
"SalvGarage", "shedgaragedoor",
|
"SalvGarage", "shedgaragedoor",
|
||||||
"Sub_sprayshopdoor", "towergaragedoor1",
|
"Sub_sprayshopdoor", "towergaragedoor1",
|
||||||
"towergaragedoor2", "towergaragedoor3",
|
"towergaragedoor2", "towergaragedoor3",
|
||||||
"vheistlocdoor"};
|
"vheistlocdoor"}};
|
||||||
|
|
||||||
auto gw = game->getWorld();
|
auto gw = game->getWorld();
|
||||||
for (auto& i : gw->instancePool.objects) {
|
for (auto& [id, instancePtr] : gw->instancePool.objects) {
|
||||||
auto obj = static_cast<InstanceObject*>(i.second.get());
|
auto obj = static_cast<InstanceObject*>(instancePtr.get());
|
||||||
if (std::find(garageDoorModels.begin(),
|
if (std::find(garageDoorModels.begin(),
|
||||||
garageDoorModels.end(),
|
garageDoorModels.end(),
|
||||||
obj->getModelInfo<BaseModelInfo>()->name) !=
|
obj->getModelInfo<BaseModelInfo>()->name) !=
|
||||||
@ -148,18 +148,29 @@ std::shared_ptr<Menu> DebugState::createVehicleMenu() {
|
|||||||
auto menu = Menu::create({{"Back", [=] { enterMenu(createDebugMenu()); }}},
|
auto menu = Menu::create({{"Back", [=] { enterMenu(createDebugMenu()); }}},
|
||||||
kDebugFont, kDebugEntryHeight);
|
kDebugFont, kDebugEntryHeight);
|
||||||
|
|
||||||
const std::map<std::string, int> kVehicleTypes = {
|
static constexpr std::array<std::tuple<char const*, unsigned int>, 19>
|
||||||
{"Landstalker", 90}, {"Taxi", 110}, {"Firetruck", 97},
|
kVehicleTypes{{{"Landstalker", 90},
|
||||||
{"Police", 116}, {"Ambulance", 106}, {"Bobcat", 112},
|
{"Taxi", 110},
|
||||||
{"Banshee", 119}, {"Rhino", 122}, {"Barracks", 123},
|
{"Firetruck", 97},
|
||||||
{"Rumpo", 130}, {"Columbian", 138}, {"Dodo", 126},
|
{"Police", 116},
|
||||||
{"Speeder", 142}, {"Yakuza", 136}, {"Cheetah", 105},
|
{"Ambulance", 106},
|
||||||
{"Ambulance", 106}, {"FBI", 107}, {"Mafia", 134},
|
{"Bobcat", 112},
|
||||||
{"Infernus", 101},
|
{"Banshee", 119},
|
||||||
};
|
{"Rhino", 122},
|
||||||
|
{"Barracks", 123},
|
||||||
|
{"Rumpo", 130},
|
||||||
|
{"Columbian", 138},
|
||||||
|
{"Dodo", 126},
|
||||||
|
{"Speeder", 142},
|
||||||
|
{"Yakuza", 136},
|
||||||
|
{"Cheetah", 105},
|
||||||
|
{"Ambulance", 106},
|
||||||
|
{"FBI", 107},
|
||||||
|
{"Mafia", 134},
|
||||||
|
{"Infernus", 101}}};
|
||||||
|
|
||||||
for (auto& e : kVehicleTypes) {
|
for (const auto& [name, id] : kVehicleTypes) {
|
||||||
menu->lambda(e.first, [=] { spawnVehicle(e.second); });
|
menu->lambda(name, [this, id = id] { spawnVehicle(id); });
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->offset = kDebugMenuOffset;
|
menu->offset = kDebugMenuOffset;
|
||||||
@ -171,22 +182,28 @@ std::shared_ptr<Menu> DebugState::createAIMenu() {
|
|||||||
Menu::create({{"Back", [=] { this->enterMenu(createDebugMenu()); }}},
|
Menu::create({{"Back", [=] { this->enterMenu(createDebugMenu()); }}},
|
||||||
kDebugFont, kDebugEntryHeight);
|
kDebugFont, kDebugEntryHeight);
|
||||||
|
|
||||||
const std::map<std::string, int> kPedTypes = {
|
static constexpr std::array<std::tuple<char const*, unsigned int>, 6>
|
||||||
{"Triad", 12}, {"Cop", 1}, {"SWAT", 2},
|
kPedTypes{{
|
||||||
{"FBI", 3}, {"Fireman", 6}, {"Construction", 74},
|
{"Triad", 12},
|
||||||
};
|
{"Cop", 1},
|
||||||
|
{"SWAT", 2},
|
||||||
|
{"FBI", 3},
|
||||||
|
{"Fireman", 6},
|
||||||
|
{"Construction", 74},
|
||||||
|
}};
|
||||||
|
|
||||||
for (auto& e : kPedTypes) {
|
for (const auto& [name, id] : kPedTypes) {
|
||||||
menu->lambda(e.first + " Follower", [=] { spawnFollower(e.second); });
|
menu->lambda(name, [this, id = id] { spawnFollower(id); });
|
||||||
}
|
}
|
||||||
|
|
||||||
menu->lambda("Kill All Peds", [=] {
|
menu->lambda("Kill All Peds", [=] {
|
||||||
for (auto& p : game->getWorld()->pedestrianPool.objects) {
|
for (auto& [id, pedestrianPtr] :
|
||||||
if (p.second->getLifetime() == GameObject::PlayerLifetime) {
|
game->getWorld()->pedestrianPool.objects) {
|
||||||
|
if (pedestrianPtr->getLifetime() == GameObject::PlayerLifetime) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
p.second->takeDamage({p.second->getPosition(),
|
pedestrianPtr->takeDamage({pedestrianPtr->getPosition(),
|
||||||
p.second->getPosition(), 100.f,
|
pedestrianPtr->getPosition(), 100.f,
|
||||||
GameObject::DamageInfo::Explosion, 0.f});
|
GameObject::DamageInfo::Explosion, 0.f});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -214,7 +231,7 @@ std::shared_ptr<Menu> DebugState::createWeatherMenu() {
|
|||||||
Menu::create({{"Back", [=] { this->enterMenu(createDebugMenu()); }}},
|
Menu::create({{"Back", [=] { this->enterMenu(createDebugMenu()); }}},
|
||||||
kDebugFont, kDebugEntryHeight);
|
kDebugFont, kDebugEntryHeight);
|
||||||
|
|
||||||
const std::array<std::string, 4> w{{"Sunny", "Cloudy", "Rainy", "Foggy"}};
|
static constexpr std::array<char const*, 4> w{{"Sunny", "Cloudy", "Rainy", "Foggy"}};
|
||||||
|
|
||||||
for (std::size_t i = 0; i < w.size(); ++i) {
|
for (std::size_t i = 0; i < w.size(); ++i) {
|
||||||
menu->lambda(w[i],
|
menu->lambda(w[i],
|
||||||
@ -230,7 +247,7 @@ std::shared_ptr<Menu> DebugState::createMissionsMenu() {
|
|||||||
Menu::create({{"Back", [=] { this->enterMenu(createDebugMenu()); }}},
|
Menu::create({{"Back", [=] { this->enterMenu(createDebugMenu()); }}},
|
||||||
kDebugFont, kDebugEntryHeightMissions);
|
kDebugFont, kDebugEntryHeightMissions);
|
||||||
|
|
||||||
const std::array<std::string, 80> w{{
|
static constexpr std::array<char const*, 80> w{{
|
||||||
"Intro Movie",
|
"Intro Movie",
|
||||||
"Hospital Info Scene",
|
"Hospital Info Scene",
|
||||||
"Police Station Info Scene",
|
"Police Station Info Scene",
|
||||||
|
Loading…
Reference in New Issue
Block a user