mirror of
https://git.kittycat.homes/zoe/codename-routes.git
synced 2024-08-15 03:18:26 +00:00
fucking signals, how do they work
This commit is contained in:
parent
d6b6114c11
commit
bcd4a1b031
6 changed files with 50 additions and 23 deletions
Binary file not shown.
|
@ -15,7 +15,6 @@ mode = 1
|
||||||
tile_set = ExtResource( 1 )
|
tile_set = ExtResource( 1 )
|
||||||
cell_size = Vector2( 32, 16 )
|
cell_size = Vector2( 32, 16 )
|
||||||
format = 1
|
format = 1
|
||||||
tile_data = PoolIntArray( -65538, 0, 131075, -65537, 0, 131073, -131072, 0, 0, -2, 0, 131073, -1, 0, 131075, -65536, 0, 0, 0, 0, 0, 65536, 0, 0, 131072, 0, 0, 196608, 0, 0 )
|
|
||||||
|
|
||||||
[node name="Worldcam" type="Camera2D" parent="."]
|
[node name="Worldcam" type="Camera2D" parent="."]
|
||||||
current = true
|
current = true
|
||||||
|
|
|
@ -14,3 +14,10 @@ tokio = {version = "1.18.0", features = ["sync"]}
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
pathfinding = "3.0.12"
|
pathfinding = "3.0.12"
|
||||||
toml = "0.5.9"
|
toml = "0.5.9"
|
||||||
|
|
||||||
|
[profile.dev.package."*"]
|
||||||
|
opt-level = 3
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
opt-level=1
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ lazy_static! {
|
||||||
|
|
||||||
#[derive(NativeClass)]
|
#[derive(NativeClass)]
|
||||||
#[inherit(Node)]
|
#[inherit(Node)]
|
||||||
|
#[register_with(Self::register)]
|
||||||
pub struct StateServer {
|
pub struct StateServer {
|
||||||
#[property]
|
#[property]
|
||||||
a: u64,
|
a: u64,
|
||||||
|
@ -34,17 +35,24 @@ impl StateServer {
|
||||||
|
|
||||||
#[export]
|
#[export]
|
||||||
fn _ready(&self, _owner: &Node) {
|
fn _ready(&self, _owner: &Node) {
|
||||||
godot_print!("hello!")
|
//godot_print!("hello world")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[export]
|
#[export]
|
||||||
fn foo(&self, _owner: &Node) {
|
fn generate_world(&self, _owner: &Node) {
|
||||||
godot_print!("bar")
|
let mut new_world = world::World::new(3, 3, 3);
|
||||||
}
|
|
||||||
|
|
||||||
#[export]
|
|
||||||
fn generate_world(&self, _owner: &Node){
|
|
||||||
let new_world = world::World::new(3,3,3);
|
|
||||||
new_world.generate();
|
new_world.generate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// signals
|
||||||
|
impl StateServer {
|
||||||
|
fn register(builder: &ClassBuilder<StateServer>) {
|
||||||
|
builder.signal("jumpled").done();
|
||||||
|
builder
|
||||||
|
.signal("changed_tile")
|
||||||
|
.with_param("position", VariantType::Vector3)
|
||||||
|
.with_param("new_type", VariantType::GodotString)
|
||||||
|
.done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -10,27 +10,41 @@ pub struct World {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl World {
|
impl World {
|
||||||
pub fn generate(&self) {
|
pub fn generate(&mut self) {
|
||||||
|
let mut tiles = get_vec3(self.xsize, self.ysize, self.zsize);
|
||||||
|
godot_print!("{:#?}", tiles);
|
||||||
for x in 0..self.xsize {
|
for x in 0..self.xsize {
|
||||||
for y in 0..self.ysize {
|
for y in 0..self.ysize {
|
||||||
for z in 0..self.zsize {
|
for z in 0..self.zsize {
|
||||||
godot_print!("hello, {} {} {}", x, y, z);
|
let tile = tiles::Tile::new(tiles::Tiletypes::Dirt);
|
||||||
// self.tiles[x][y][z] = tiles::Tile::new(tiles::Tiletypes::Dirt, x, y, z);
|
tiles[x][y][z] = tile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.tiles = tiles;
|
||||||
|
godot_print!("{:?}", self.tiles);
|
||||||
}
|
}
|
||||||
pub fn new(xsize: usize, ysize: usize, zsize: usize) -> World {
|
pub fn new(xsize: usize, ysize: usize, zsize: usize) -> World {
|
||||||
let z: Vec<tiles::Tile> = Vec::with_capacity(zsize);
|
|
||||||
let mut y: Vec<Vec<tiles::Tile>> = Vec::with_capacity(ysize);
|
|
||||||
let mut x: Vec<Vec<Vec<tiles::Tile>>> = Vec::with_capacity(xsize);
|
|
||||||
y.push(z);
|
|
||||||
x.push(y);
|
|
||||||
World {
|
World {
|
||||||
xsize,
|
xsize,
|
||||||
ysize,
|
ysize,
|
||||||
zsize,
|
zsize,
|
||||||
tiles: x,
|
tiles: get_vec3(xsize, ysize, zsize),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_vec3(xsize: usize, ysize: usize, zsize: usize) -> Vec<Vec<Vec<tiles::Tile>>> {
|
||||||
|
let mut zvec: Vec<tiles::Tile> = Vec::with_capacity(zsize);
|
||||||
|
zvec.resize(zsize, tiles::Tile::new(tiles::Tiletypes::Air));
|
||||||
|
|
||||||
|
let mut yvec: Vec<Vec<tiles::Tile>> = Vec::with_capacity(ysize);
|
||||||
|
yvec.resize(ysize, zvec.clone());
|
||||||
|
|
||||||
|
let mut xvec: Vec<Vec<Vec<tiles::Tile>>> = Vec::with_capacity(xsize);
|
||||||
|
xvec.resize(ysize, yvec.clone());
|
||||||
|
|
||||||
|
yvec.push(zvec);
|
||||||
|
xvec.push(yvec);
|
||||||
|
xvec
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub enum Tiletypes {
|
pub enum Tiletypes {
|
||||||
Air,
|
Air,
|
||||||
Water,
|
Water,
|
||||||
|
@ -6,15 +7,13 @@ pub enum Tiletypes {
|
||||||
Sand,
|
Sand,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct Tile {
|
pub struct Tile {
|
||||||
kind: Tiletypes,
|
kind: Tiletypes,
|
||||||
x: usize,
|
|
||||||
y: usize,
|
|
||||||
z: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tile {
|
impl Tile {
|
||||||
pub fn new(kind: Tiletypes, x: usize, y: usize, z: usize) -> Tile {
|
pub fn new(kind: Tiletypes) -> Tile {
|
||||||
Tile { kind, x, y, z }
|
Tile { kind }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue