Skip to content

Commit

Permalink
Removed stupid hardness registry and added tons of colored hull blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyTornetta committed Oct 28, 2023
1 parent c314cf3 commit 12c55ba
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 189 deletions.
12 changes: 10 additions & 2 deletions cosmos_core/src/block/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ pub struct BlockBuilder {
properties: Vec<BlockProperty>,
unlocalized_name: String,
density: f32,
hardness: f32,
}

impl BlockBuilder {
/// Starts the building process for a block
///
/// * `unlocalized_name` This should be unique for that block with the following formatting: `mod_id:block_identifier`. Such as: `cosmos:laser_cannon`
pub fn new(unlocalized_name: impl Into<String>, density: f32) -> Self {
pub fn new(unlocalized_name: impl Into<String>, density: f32, hardness: f32) -> Self {
Self {
properties: Vec::new(),
unlocalized_name: unlocalized_name.into(),
density,
hardness,
}
}

Expand All @@ -37,6 +39,12 @@ impl BlockBuilder {

/// Creates that block
pub fn create(&self) -> Block {
Block::new(&self.properties, u16::MAX, self.unlocalized_name.clone(), self.density)
Block::new(
&self.properties,
u16::MAX,
self.unlocalized_name.clone(),
self.density,
self.hardness,
)
}
}
78 changes: 55 additions & 23 deletions cosmos_core/src/block/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,157 +23,189 @@ fn add_cosmos_blocks(
let id = loading.register_loader(&mut start_writer);

blocks.register(
BlockBuilder::new("cosmos:stone", 10.0)
BlockBuilder::new("cosmos:stone", 10.0, 50.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:grass", 3.0)
BlockBuilder::new("cosmos:grass", 3.0, 20.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:dirt", 3.0)
BlockBuilder::new("cosmos:dirt", 3.0, 20.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:cherry_leaf", 0.1)
BlockBuilder::new("cosmos:cherry_leaf", 0.1, 1.0)
.add_property(BlockProperty::Transparent)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:redwood_log", 3.0)
BlockBuilder::new("cosmos:redwood_log", 3.0, 30.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:redwood_leaf", 0.1)
BlockBuilder::new("cosmos:redwood_leaf", 0.1, 1.0)
.add_property(BlockProperty::Transparent)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:ship_core", 2.0)
BlockBuilder::new("cosmos:ship_core", 2.0, 20.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.add_property(BlockProperty::ShipOnly)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:energy_cell", 2.0)
BlockBuilder::new("cosmos:energy_cell", 2.0, 20.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:reactor", 2.0)
BlockBuilder::new("cosmos:reactor", 2.0, 20.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:laser_cannon", 2.0)
BlockBuilder::new("cosmos:laser_cannon", 2.0, 20.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:ship_hull", 4.0)
BlockBuilder::new("cosmos:ship_hull_grey", 4.0, 100.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:thruster", 2.0)
BlockBuilder::new("cosmos:thruster", 2.0, 20.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:light", 0.1)
BlockBuilder::new("cosmos:light", 0.1, 20.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:glass", 4.0)
BlockBuilder::new("cosmos:glass", 4.0, 100.0)
.add_property(BlockProperty::Transparent)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:ice".to_owned(), 1.9)
BlockBuilder::new("cosmos:ice".to_owned(), 1.9, 40.0)
.add_property(BlockProperty::Transparent)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:molten_stone", 10.0)
BlockBuilder::new("cosmos:molten_stone", 10.0, 50.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:water".to_owned(), 2.0)
BlockBuilder::new("cosmos:water".to_owned(), 2.0, 50.0)
.add_property(BlockProperty::Transparent)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:cheese", 10.0)
BlockBuilder::new("cosmos:cheese", 10.0, 50.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:short_grass", 0.1)
BlockBuilder::new("cosmos:short_grass", 0.1, 1.0)
.add_property(BlockProperty::Opaque)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:sand", 4.0)
BlockBuilder::new("cosmos:sand", 4.0, 10.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:cactus", 0.8)
BlockBuilder::new("cosmos:cactus", 0.8, 10.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

blocks.register(
BlockBuilder::new("cosmos:build_block", 2.0)
BlockBuilder::new("cosmos:build_block", 2.0, 20.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);

// Grey registered above to keep id consistency (move down here in future)
let ship_hulls = [
"black",
"dark_grey",
"white",
"blue",
"dark_blue",
"brown",
"green",
"dark_green",
"orange",
"dark_orange",
"pink",
"dark_pink",
"purple",
"dark_purple",
"red",
"dark_red",
"yellow",
"dark_yellow",
"mint",
];

for ship_hull in ship_hulls {
blocks.register(
BlockBuilder::new(format!("cosmos:ship_hull_{ship_hull}"), 4.0, 100.0)
.add_property(BlockProperty::Opaque)
.add_property(BlockProperty::Full)
.create(),
);
}

loading.finish_loading(id, &mut end_writer);
}

Expand All @@ -187,7 +219,7 @@ fn add_air_block(
let id = loader.register_loader(&mut add_loader_event);

blocks.register(
BlockBuilder::new("cosmos:air", 0.0)
BlockBuilder::new("cosmos:air", 0.0, 0.0)
.add_property(BlockProperty::Transparent)
.add_property(BlockProperty::Empty)
.create(),
Expand Down
106 changes: 0 additions & 106 deletions cosmos_core/src/block/hardness/mod.rs

This file was deleted.

Loading

0 comments on commit 12c55ba

Please sign in to comment.