Skip to content

Commit

Permalink
Initial attempt at coastal saltmarsh biome
Browse files Browse the repository at this point in the history
  • Loading branch information
drey7925 committed Dec 20, 2024
1 parent b9b81a6 commit adc4024
Show file tree
Hide file tree
Showing 12 changed files with 323 additions and 62 deletions.
8 changes: 4 additions & 4 deletions perovskite_core/proto/blocks.proto
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ message FluidPhysicsInfo {

// How deep surface effects extend for, in blocks.
double surface_thickness = 5;
// Speed of movement when in the fluid, blocks/sec
// Speed of movement when in the fluid and within surface effects, blocks/sec
double surf_horizontal_speed = 6;
// Speed when not pressing jump or lower keys, blocks/sec. Positive means
// Speed when not pressing jump or lower keys, blocks/sec and within surface effects. Positive means
// upward
double surf_vertical_speed = 7;
// Speed when pressing jump. Positive means upward
// Speed when pressing jump when in the surface. Positive means upward
double surf_jump_speed = 8;
// Speed when pressing the lower key. Positive means upward.
// Speed when pressing the lower key when in the surface. Positive means upward.
double surf_sink_speed = 9;
}

Expand Down
13 changes: 12 additions & 1 deletion perovskite_game_api/src/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,10 @@ impl BlockBuilder {
pub fn set_plant_like_appearance(mut self, appearance: PlantLikeAppearanceBuilder) -> Self {
self.client_info.render_info = Some(RenderInfo::PlantLike(appearance.render_info));
// TODO: this should be separated out into its own control. For now, this is a reasonable default
self.client_info.physics_info = Some(PhysicsInfo::Air(Empty {}));
if !appearance.is_solid {
self.client_info.physics_info = Some(PhysicsInfo::Air(Empty {}));
}
self.client_info.allow_light_propagation = true;
self
}

Expand Down Expand Up @@ -681,6 +684,7 @@ impl Default for CubeAppearanceBuilder {

pub struct PlantLikeAppearanceBuilder {
render_info: PlantLikeRenderInfo,
is_solid: bool,
}
impl PlantLikeAppearanceBuilder {
/// Constructs a new plant-like appearance builder, with a dummy texture and reasonable defaults.
Expand All @@ -690,6 +694,7 @@ impl PlantLikeAppearanceBuilder {
tex: make_texture_ref(FALLBACK_UNKNOWN_TEXTURE.to_string()),
wave_effect_scale: 0.1,
},
is_solid: false,
}
}
/// Sets the block's texture.
Expand All @@ -706,6 +711,12 @@ impl PlantLikeAppearanceBuilder {
self.render_info.wave_effect_scale = scale;
self
}

/// Sets whether the block is a physics obstacle or can be walked through
pub fn set_is_solid(mut self, is_solid: bool) -> Self {
self.is_solid = is_solid;
self
}
}
impl Default for PlantLikeAppearanceBuilder {
fn default() -> Self {
Expand Down
45 changes: 45 additions & 0 deletions perovskite_game_api/src/default_game/basic_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ pub const STONE: StaticBlockName = StaticBlockName("default:stone");

/// Beach sand.
pub const SAND: StaticBlockName = StaticBlockName("default:sand");
pub const SILT_DRY: StaticBlockName = StaticBlockName("default:silt_dry");
pub const SILT_DAMP: StaticBlockName = StaticBlockName("default:silt_damp");
pub const CLAY: StaticBlockName = StaticBlockName("default:clay");

/// Desert materials.
pub const DESERT_STONE: StaticBlockName = StaticBlockName("default:desert_stone");
Expand Down Expand Up @@ -93,6 +96,9 @@ const DIRT_GRASS_SIDE_TEXTURE: StaticTextureName = StaticTextureName("default:di
const GRASS_TOP_TEXTURE: StaticTextureName = StaticTextureName("default:grass_top");
const STONE_TEXTURE: StaticTextureName = StaticTextureName("default:stone");
const SAND_TEXTURE: StaticTextureName = StaticTextureName("default:sand");
const SILT_DRY_TEXTURE: StaticTextureName = StaticTextureName("default:silt_dry");
const SILT_DAMP_TEXTURE: StaticTextureName = StaticTextureName("default:silt_damp");
const CLAY_TEXTURE: StaticTextureName = StaticTextureName("default:clay");
const DESERT_STONE_TEXTURE: StaticTextureName = StaticTextureName("default:desert_stone");
const DESERT_SAND_TEXTURE: StaticTextureName = StaticTextureName("default:desert_sand");
const GLASS_TEXTURE: StaticTextureName = StaticTextureName("default:glass");
Expand Down Expand Up @@ -516,6 +522,10 @@ fn register_core_blocks(game_builder: &mut GameBuilder) -> Result<()> {
include_texture_bytes!(game_builder, GRASS_TOP_TEXTURE, "textures/grass_top.png")?;
include_texture_bytes!(game_builder, STONE_TEXTURE, "textures/stone.png")?;
include_texture_bytes!(game_builder, SAND_TEXTURE, "textures/sand.png")?;
include_texture_bytes!(game_builder, SILT_DRY_TEXTURE, "textures/silt_dry.png")?;
include_texture_bytes!(game_builder, SILT_DAMP_TEXTURE, "textures/silt_damp.png")?;
include_texture_bytes!(game_builder, CLAY_TEXTURE, "textures/clay.png")?;

include_texture_bytes!(
game_builder,
DESERT_STONE_TEXTURE,
Expand Down Expand Up @@ -630,6 +640,41 @@ fn register_core_blocks(game_builder: &mut GameBuilder) -> Result<()> {
.set_falls_down(true),
)?;

let _silt_dry = game_builder.add_block(
BlockBuilder::new(SILT_DRY)
.add_block_group(GRANULAR)
.set_cube_single_texture(SILT_DRY_TEXTURE)
.set_display_name("Silt (dry)"),
)?;
// TODO: damp silt should dry out when far from water, on a stochastic timer
let _silt_damp = game_builder.add_block(
BlockBuilder::new(SILT_DAMP)
.add_block_group(GRANULAR)
.set_cube_single_texture(SILT_DAMP_TEXTURE)
.set_display_name("Silt (damp)")
.set_dropped_item(SILT_DRY.0, 1)
.add_modifier(Box::new(|bt| {
// TODO tune these
bt.client_info.physics_info = Some(PhysicsInfo::Fluid(FluidPhysicsInfo {
horizontal_speed: 0.75,
vertical_speed: -0.1,
jump_speed: 0.2,
sink_speed: -0.1,
surface_thickness: 0.2,
surf_horizontal_speed: 2.,
surf_vertical_speed: -0.1,
surf_jump_speed: 0.1,
surf_sink_speed: -0.1,
}))
})),
)?;
let clay = game_builder.add_block(
BlockBuilder::new(CLAY)
.add_block_group(GRANULAR)
.set_cube_single_texture(CLAY_TEXTURE)
.set_display_name("Clay block"),
)?;

let desert_stone = game_builder.add_block(
BlockBuilder::new(DESERT_STONE)
.add_block_group(BRITTLE)
Expand Down
32 changes: 32 additions & 0 deletions perovskite_game_api/src/default_game/foliage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ pub const MAPLE_PLANKS_TEX: StaticTextureName = StaticTextureName("default:maple
pub const TALL_GRASS: StaticBlockName = StaticBlockName("default:tall_grass");
pub const TALL_GRASS_TEX: StaticTextureName = StaticTextureName("default:tall_grass");

pub const MARSH_GRASS: StaticBlockName = StaticBlockName("default:marsh_grass");
pub const MARSH_GRASS_TEX: StaticTextureName = StaticTextureName("default:marsh_grass_tex");

pub const TALL_REED: StaticBlockName = StaticBlockName("default:tall_reed");
pub const TALL_REED_TEX: StaticTextureName = StaticTextureName("default:tall_reed");

pub const CACTUS: StaticBlockName = StaticBlockName("default:cactus");
pub const CACTUS_TOP_TEX: StaticTextureName = StaticTextureName("default:cactus_top");
pub const CACTUS_SIDE_TEX: StaticTextureName = StaticTextureName("default:cactus_side");
Expand All @@ -44,6 +50,8 @@ pub(crate) fn register_foliage(builder: &mut GameBuilder) -> Result<()> {
include_texture_bytes!(builder, MAPLE_LEAVES_TEX, "textures/maple_leaves.png")?;
include_texture_bytes!(builder, MAPLE_PLANKS_TEX, "textures/maple_planks.png")?;
include_texture_bytes!(builder, TALL_GRASS_TEX, "textures/tall_grass.png")?;
include_texture_bytes!(builder, MARSH_GRASS_TEX, "textures/marsh_grass.png")?;
include_texture_bytes!(builder, TALL_REED_TEX, "textures/tall_reed.png")?;
include_texture_bytes!(builder, CACTUS_TOP_TEX, "textures/cactus_top.png")?;
include_texture_bytes!(builder, CACTUS_SIDE_TEX, "textures/cactus_side.png")?;
include_texture_bytes!(builder, STICK_TEX, "textures/stick.png")?;
Expand Down Expand Up @@ -74,6 +82,30 @@ pub(crate) fn register_foliage(builder: &mut GameBuilder) -> Result<()> {
.set_allow_light_propagation(true)
.set_no_drops(),
)?;
builder.add_block(
BlockBuilder::new(MARSH_GRASS)
.set_plant_like_appearance(
PlantLikeAppearanceBuilder::new().set_texture(MARSH_GRASS_TEX),
)
.set_display_name("Marsh grass")
.set_inventory_texture(MARSH_GRASS_TEX)
.set_allow_light_propagation(true)
.set_no_drops(),
)?;

builder.add_block(
BlockBuilder::new(TALL_REED)
.set_plant_like_appearance(
PlantLikeAppearanceBuilder::new()
.set_texture(TALL_REED_TEX)
.set_wave_effect_scale(0.0)
.set_is_solid(true),
)
.set_display_name("Marsh grass")
.set_inventory_texture(TALL_REED_TEX)
.set_allow_light_propagation(true)
.set_no_drops(),
)?;
builder.register_smelting_fuel(RecipeSlot::Group(item_groups::TREE_TRUNK.to_string()), 8);
builder.register_smelting_fuel(RecipeSlot::Group(item_groups::TREE_LEAVES.to_string()), 1);

Expand Down
4 changes: 2 additions & 2 deletions perovskite_game_api/src/default_game/mapgen/karst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::default_game::basic_blocks::{

const PROFILE_INPUT_SCALE: f64 = 1.0 / 160.0;
const VALLEY_INPUT_SCALE: f64 = 1.0 / 800.0;
const SLOW_MODULATOR_INPUT_SCALE: f64 = 1.0 / 320.0;
const MODULATING_INPUT_SCALE: f64 = 1.0 / 80.0;
const SLOW_MODULATOR_INPUT_SCALE: f64 = 1.0 / 640.0;
const MODULATING_INPUT_SCALE: f64 = 1.0 / 160.0;
const MODULATION_SLOPE_INPUT_SCALE: f64 = 1.0 / 80.0;
const LIMESTONE_NOISE_SCALE: Vector3<f64> = Vector3::new(0.5, 0.03, 0.5);
const LIMESTONE_SLOW_NOISE_SCALE: f64 = 1.0 / 40.0;
Expand Down
Loading

0 comments on commit adc4024

Please sign in to comment.