mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 09:03:52 +00:00
feat(editor): NPC scatter tool, adjacent tile creation, multi-tile prep
- Scatter tool: place N creatures in a radius around cursor position with random rotation and uniform disk distribution - File > Add Adjacent Tile: creates and exports a blank tile N/S/E/W of current (foundation for multi-tile zone editing) - Scatter UI: count slider (1-30), radius slider (10-200) - Scatter places all copies with same stats/behavior as template
This commit is contained in:
parent
6e24e08818
commit
48026421c9
5 changed files with 67 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
#include <random>
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
|
||||
|
|
@ -102,6 +103,23 @@ bool NpcSpawner::saveToFile(const std::string& path) const {
|
|||
return true;
|
||||
}
|
||||
|
||||
void NpcSpawner::scatter(const CreatureSpawn& base, const glm::vec3& center,
|
||||
float radius, int count) {
|
||||
std::mt19937 rng(static_cast<uint32_t>(center.x * 100 + center.y * 37));
|
||||
std::uniform_real_distribution<float> distAngle(0.0f, 6.2831853f);
|
||||
std::uniform_real_distribution<float> distDist(0.0f, radius);
|
||||
std::uniform_real_distribution<float> distRot(0.0f, 360.0f);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
float angle = distAngle(rng);
|
||||
float dist = std::sqrt(distDist(rng) / radius) * radius;
|
||||
CreatureSpawn s = base;
|
||||
s.position = center + glm::vec3(std::cos(angle) * dist, std::sin(angle) * dist, 0.0f);
|
||||
s.orientation = distRot(rng);
|
||||
placeCreature(s);
|
||||
}
|
||||
}
|
||||
|
||||
bool NpcSpawner::loadFromFile(const std::string& path) {
|
||||
// Simple JSON-ish parser for our format — full JSON parsing would need a library
|
||||
LOG_INFO("NPC spawn loading not yet implemented for: ", path);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue