refactoring hex coords
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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(¢er, self.rotation))
|
||||
.map(|p| HexCoord::from_axial(p + self.origin).rotate_around(¢er, self.rotation))
|
||||
.collect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user