refactoring hex coords

This commit is contained in:
2026-03-14 19:55:53 -04:00
parent c5da119109
commit 912ee376c6
36 changed files with 595 additions and 698 deletions

View File

@@ -9,6 +9,7 @@ edition = "2021"
bevy = "0.18.0"
serde = { version = "1.0.228", features = ["derive"] }
world_generation = { path = "../../engine/world_generation" }
hex = { path = "../../engine/hex" }
[features]

View File

@@ -1,5 +1,5 @@
use bevy::prelude::*;
use world_generation::hex_utils::HexCoord;
use hex::prelude::*;
#[derive(Default, Debug, Reflect)]
pub struct CoordsCollection
@@ -51,11 +51,11 @@ impl CoordsCollection
pub fn get_coords(&self) -> Vec<HexCoord>
{
let center = HexCoord::from_hex(self.origin);
let center = HexCoord::from_axial(self.origin);
return self
.points
.iter()
.map(|p| HexCoord::from_hex(p + self.origin).rotate_around(&center, self.rotation))
.map(|p| HexCoord::from_axial(p + self.origin).rotate_around(&center, self.rotation))
.collect();
}
}

View File

@@ -1,13 +1,15 @@
use bevy::prelude::*;
use world_generation::hex_utils::*;
use hex::prelude::*;
#[derive(Message)]
pub enum TileModifiedEvent {
pub enum TileModifiedEvent
{
HeightChanged(HexCoord, f32),
TypeChanged(HexCoord, usize),
}
#[derive(Message)]
pub struct ChunkModifiedEvent {
pub struct ChunkModifiedEvent
{
pub index: usize,
}

View File

@@ -1,18 +1,21 @@
use bevy::prelude::*;
use world_generation::hex_utils::HexCoord;
use hex::prelude::*;
#[derive(Resource, Default)]
pub struct TileUnderCursor(pub Option<TileContact>);
#[derive(Clone, Copy)]
pub struct TileContact {
pub struct TileContact
{
pub tile: HexCoord,
pub point: Vec3,
pub surface: Vec3,
}
impl TileContact {
pub fn new(tile: HexCoord, contact: Vec3, surface: Vec3) -> Self {
impl TileContact
{
pub fn new(tile: HexCoord, contact: Vec3, surface: Vec3) -> Self
{
return Self {
tile,
point: contact,