formatting
parent
c9d7e17a60
commit
c42859ded8
|
|
@ -80,7 +80,7 @@ fn debug_painter(
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (index, key) in vec![
|
for (index, key) in vec![
|
||||||
KeyCode::Key1,
|
KeyCode::Key1,
|
||||||
KeyCode::Key2,
|
KeyCode::Key2,
|
||||||
|
|
@ -91,7 +91,10 @@ fn debug_painter(
|
||||||
KeyCode::Key7,
|
KeyCode::Key7,
|
||||||
KeyCode::Key8,
|
KeyCode::Key8,
|
||||||
KeyCode::Key9,
|
KeyCode::Key9,
|
||||||
].iter().enumerate() {
|
]
|
||||||
|
.iter()
|
||||||
|
.enumerate()
|
||||||
|
{
|
||||||
if key_input.just_pressed(*key) {
|
if key_input.just_pressed(*key) {
|
||||||
brush.tile = index as u8 + 1;
|
brush.tile = index as u8 + 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ impl Default for KinematicBundle {
|
||||||
#[derive(Component, Reflect, Default)]
|
#[derive(Component, Reflect, Default)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
pub struct KinematicState {
|
pub struct KinematicState {
|
||||||
// TODO: fork rapier2d to make it reflect?
|
|
||||||
#[reflect(ignore)]
|
#[reflect(ignore)]
|
||||||
pub last_move: Option<MoveShapeOutput>,
|
pub last_move: Option<MoveShapeOutput>,
|
||||||
pub did_jump: bool,
|
pub did_jump: bool,
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,12 @@ impl Plugin for Terrain2DPlugin {
|
||||||
);
|
);
|
||||||
|
|
||||||
app.register_type::<TerrainChunk2D>()
|
app.register_type::<TerrainChunk2D>()
|
||||||
.insert_resource(Terrain2D::new(Some(WORLD_WIDTH * 2), Some(0), Some(0), Some(WORLD_WIDTH)))
|
.insert_resource(Terrain2D::new(
|
||||||
|
Some(WORLD_WIDTH * 2),
|
||||||
|
Some(0),
|
||||||
|
Some(0),
|
||||||
|
Some(WORLD_WIDTH),
|
||||||
|
))
|
||||||
.add_event::<TerrainEvent2D>()
|
.add_event::<TerrainEvent2D>()
|
||||||
.add_system_to_stage(TerrainStages::Simulation, terrain_simulation)
|
.add_system_to_stage(TerrainStages::Simulation, terrain_simulation)
|
||||||
.add_system_to_stage(TerrainStages::EventHandler, emit_terrain_events)
|
.add_system_to_stage(TerrainStages::EventHandler, emit_terrain_events)
|
||||||
|
|
@ -69,7 +74,6 @@ pub enum TerrainStages {
|
||||||
ChunkSync,
|
ChunkSync,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add simulation boundaries
|
|
||||||
fn terrain_simulation(mut terrain: ResMut<Terrain2D>, frame_counter: Res<FrameCounter>) {
|
fn terrain_simulation(mut terrain: ResMut<Terrain2D>, frame_counter: Res<FrameCounter>) {
|
||||||
let simulation_frame = (frame_counter.frame % u8::MAX as u64) as u8 + 1;
|
let simulation_frame = (frame_counter.frame % u8::MAX as u64) as u8 + 1;
|
||||||
|
|
||||||
|
|
@ -318,7 +322,7 @@ impl Terrain2D {
|
||||||
|
|
||||||
pub fn set_texel(&mut self, global: &Vector2I, id: TexelID, simulation_frame: Option<u8>) {
|
pub fn set_texel(&mut self, global: &Vector2I, id: TexelID, simulation_frame: Option<u8>) {
|
||||||
if !self.is_within_boundaries(global) {
|
if !self.is_within_boundaries(global) {
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let index = global_to_chunk_index(global);
|
let index = global_to_chunk_index(global);
|
||||||
let changed = match self.index_to_chunk_mut(&index) {
|
let changed = match self.index_to_chunk_mut(&index) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use crate::util::Vector2I;
|
||||||
use super::TexelID;
|
use super::TexelID;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use std::{collections::HashMap, borrow::Cow};
|
use std::{borrow::Cow, collections::HashMap};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref ID_MAP: HashMap<TexelID, TexelBehaviour2D> = {
|
static ref ID_MAP: HashMap<TexelID, TexelBehaviour2D> = {
|
||||||
|
|
@ -158,7 +158,6 @@ impl Default for TexelBehaviour2D {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: change form-based functions like is_solid to behaviour based (e.g. has_collision)
|
|
||||||
impl TexelBehaviour2D {
|
impl TexelBehaviour2D {
|
||||||
pub const OUT_OF_BOUNDS: Self = TexelBehaviour2D {
|
pub const OUT_OF_BOUNDS: Self = TexelBehaviour2D {
|
||||||
name: Cow::Borrowed(":)"),
|
name: Cow::Borrowed(":)"),
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
mod collision_layers;
|
mod collision_layers;
|
||||||
|
pub mod frame_counter;
|
||||||
pub mod math;
|
pub mod math;
|
||||||
mod segment2_i32;
|
mod segment2_i32;
|
||||||
mod vector2;
|
mod vector2;
|
||||||
mod vector2_i32;
|
mod vector2_i32;
|
||||||
pub mod frame_counter;
|
|
||||||
|
|
||||||
pub use collision_layers::*;
|
pub use collision_layers::*;
|
||||||
pub use segment2_i32::*;
|
pub use segment2_i32::*;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue