Skip to content

Commit

Permalink
Merge pull request #194 from AnthonyTornetta/190-create-infrastructur…
Browse files Browse the repository at this point in the history
…e-for-biomes

190 create infrastructure for biomes
  • Loading branch information
AnthonyTornetta authored Oct 22, 2023
2 parents 54944f2 + 5868f8b commit c5c4cd1
Show file tree
Hide file tree
Showing 86 changed files with 5,643 additions and 2,085 deletions.
23 changes: 23 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ walkdir = "2.4.0"

toml = "0.8.2"
lz4_flex = "0.11.1"
thread-priority = "0.13.1"

bevy_kira_audio = "0.17.0"

Expand Down
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Cosmos

A multiplayer block-based space exploration game, written in rust using the [Bevy](https://www.bevyengine.org/) engine.

If you're interested, join our new discord server here:
Expand All @@ -12,13 +13,14 @@ Cosmos has ships that you can pilot through space. (And yes those are working la
Build your own ship block by block and walk inside while flying through space.
![](./showcase/inside_ship.png)

Once you reach your destination, make a *hopefully safer than this* landing.
Once you reach your destination, make a _hopefully safer than this_ landing.
![](./showcase/ship_on_ground.png)

## Compilation

To get started, install your OS dependencies [here](https://bevyengine.org/learn/book/getting-started/setup/#install-os-dependencies). The dependencies section is all you need to do.

This project requires the latest nightly rust to compile. To swap to nightly, run the command
This project requires the latest nightly rust to compile. To swap to nightly, run the command

`rustup default nightly`.

Expand All @@ -32,29 +34,27 @@ For the server, navigate to the cosmos_server directory and run

For release builds, append the `--release` flag to the build/run commands.

To compile the workspace (not normally necessary), navigate to the root directory of the repo and run
To compile the workspace (not normally necessary), navigate to the root directory of the repo and run

`cargo build`


## Documentation

To view the cosmos documentation, run the following commands
The first time you view the cosmos documentation, run the following commands

```console
cargo install mdbook
cargo install mdbook-mermaid
```

Then navigate to the docs folder and run `mdbook-mermaid install`

To view the documentation, navigate to the `docs/` directory. To have it update as you modify it, run `mdbook serve` and navigate to the URL it provides, or to just build it run `mdbook build`.
Every time you want to view the documentation, navigate to the `docs/` directory. To have it update as you modify it, run `mdbook serve` and navigate to the URL it provides, or to just build it run `mdbook build`.

# Cosmos Roadmap

See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the list of current features/bugs in development.

## Release 0.0.5a - The Aesthetic Release (In Progress)

- [ ] Biosphere Improvements
- [ ] Ice biosphere glaciers
- [ ] Water block
Expand All @@ -64,8 +64,8 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the
- [ ] Undergrowth
- [ ] 1 More tree type
- [ ] Groundwork for biomes
- [ ] Plane,
- [ ] Redwood forest,
- [ ] Plane,
- [ ] Redwood forest,
- [ ] 1 Additional forest
- [ ] Ocean
- [ ] On-planet skybox
Expand Down Expand Up @@ -93,17 +93,20 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the
- [x] Abstract the 3d block GUI camera
- [x] Fix the 3d block GUI camera to not render anything except GUI blocks
- [ ] Fix seeing through cracks in blocks
- [x] Lods
- [x] Reduced detail rendering of far away chunks to see the entire planet
- [x] Update to bevy 0.11
- [x] Update physics
- [x] Update bevy

## Release 0.0.4a

- [x] Galaxy Generation
- [x] Stars procedurally generated in spiral-like pattern based on seed
- [x] Stars procedurally generated in spiral-like pattern based on seed
- [x] Create star
- [x] Light emits from star
- [x] Load star within system
- [x] Planets generate around stars
- [x] Planets generate around stars
- [x] Biospheres depend on how close they are to the sun
- [x] Dynamic biospheres based off temperature
- [x] Only generate if planet is close enough to player
Expand Down Expand Up @@ -133,9 +136,10 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the
- [x] Create free camera

## Release 0.0.3a

- [x] Infinite universe
- [x] (**Client**) Player can travel any distance from 0,0,0 with no noticable issues, and everything moves relaitve to player
- [x] (**Server**)
- [x] (**Server**)
- [x] Objects move relative to player world they are a part of
- [x] Player world moves relative to its player
- [x] Players can be a part of the same world if they are close enough
Expand All @@ -148,7 +152,7 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the
- [x] (**Client**)
- [x] Unload objects that are too far away
- [x] Request entities that server sends if they don't have the entity for them
- [x] (**Server**)
- [x] (**Server**)
- [x] Unload objects that are too far from any player
- [x] Load objects that are close to a player & send that info to client
- [x] Only send information about objects to clients that are close enough to have them loaded
Expand All @@ -158,6 +162,7 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the
- [x] 3d models for blocks

## Release 0.0.2a

- [x] Improved state management
- [x] Client state management
- [x] Server state management
Expand Down Expand Up @@ -208,6 +213,7 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the
- [x] Implement console commands

## Release 0.0.1a

- [x] Player Movement
- [x] FPS Camera
- [x] Dynamic Input system
Expand Down Expand Up @@ -243,7 +249,6 @@ See [the issues page](https://github.com/AnthonyTornetta/Cosmos/issues) for the
- [x] Add Crosshair
- [x] Support re-sizable window


## Everything that will still have to be done after 0.0.5a

- [ ] GUI to interact with inventory
Expand Down
3 changes: 3 additions & 0 deletions cosmos_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ bincode = { workspace = true }
local-ip-address = { workspace = true }
bevy_rapier3d = { workspace = true }
bigdecimal = { workspace = true }
futures-lite = { workspace = true }

serde_json = { workspace = true }
image = { workspace = true }
Expand All @@ -54,3 +55,5 @@ rayon = { workspace = true }
bevy_kira_audio = { workspace = true }

toml = { workspace = true }

thread-priority = { workspace = true }
3 changes: 2 additions & 1 deletion cosmos_client/assets/blocks/grass.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"texture": {
"all": "grass_side",
"top": "grass_top",
"bottom": "dirt"
"bottom": "dirt",
"lod": "grass_top"
}
}
Binary file added cosmos_client/assets/images/blocks/cactus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cosmos_client/assets/images/blocks/sand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 25 additions & 12 deletions cosmos_client/src/asset/asset_loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize};

use crate::state::game_state::GameState;

#[derive(Resource, Debug)]
#[derive(Resource, Debug, Clone)]
struct LoadingTextureAtlas {
unlocalized_name: String,
id: u16,
Expand Down Expand Up @@ -65,6 +65,8 @@ struct AssetsLoadingID(usize);
pub struct MaterialDefinition {
/// The main material used to draw blocks
pub material: Handle<StandardMaterial>,
/// The material used to render things far away
pub far_away_material: Handle<StandardMaterial>,
/// The unlit version of the main material
pub unlit_material: Handle<StandardMaterial>,
/// All the textures packed into an atlas.
Expand All @@ -86,13 +88,15 @@ impl MaterialDefinition {
pub fn new(
unlocalized_name: String,
material: Handle<StandardMaterial>,
lod_material: Handle<StandardMaterial>,
unlit_material: Handle<StandardMaterial>,
atlas: CosmosTextureAtlas,
) -> Self {
Self {
atlas,
id: 0,
material,
far_away_material: lod_material,
unlit_material,
padding: DEFAULT_PADDING,
unlocalized_name,
Expand All @@ -111,6 +115,12 @@ impl MaterialDefinition {
&self.unlit_material
}

#[inline]
/// Gets the material for this that should be used for far away (lod) blocks
pub fn far_away_material(&self) -> &Handle<StandardMaterial> {
&self.far_away_material
}

#[inline]
/// Returns the UV coordinates for the texture atlas given the block's index
///
Expand Down Expand Up @@ -389,12 +399,13 @@ fn create_materials(
) {
if !event_reader.is_empty() {
if let Some(atlas) = texture_atlases.from_id("cosmos:main") {
let default_material = create_main_material(atlas.texture_atlas.texture.clone(), false);
let unlit_default_material = create_main_material(atlas.texture_atlas.texture.clone(), true);
let default_material = materials.add(create_main_material(atlas.texture_atlas.texture.clone(), false));
let unlit_default_material = materials.add(create_main_material(atlas.texture_atlas.texture.clone(), true));

material_registry.register(MaterialDefinition {
material: materials.add(default_material),
unlit_material: materials.add(unlit_default_material),
material: default_material.clone(),
far_away_material: default_material.clone(),
unlit_material: unlit_default_material.clone(),
atlas: atlas.clone(),
padding: DEFAULT_PADDING,
id: 0,
Expand All @@ -406,19 +417,21 @@ fn create_materials(

material_registry.register(MaterialDefinition {
material: material.clone(),
far_away_material: default_material.clone(),
unlit_material: material.clone(),
atlas: atlas.clone(),
padding: DEFAULT_PADDING,
id: 0,
unlocalized_name: "cosmos:illuminated".into(),
});

let transparent_material = create_transparent_material(atlas.texture_atlas.texture.clone(), false);
let unlit_transparent_material = create_transparent_material(atlas.texture_atlas.texture.clone(), true);
let transparent_material = materials.add(create_transparent_material(atlas.texture_atlas.texture.clone(), false));
let unlit_transparent_material = materials.add(create_transparent_material(atlas.texture_atlas.texture.clone(), true));

material_registry.register(MaterialDefinition {
material: materials.add(transparent_material),
unlit_material: materials.add(unlit_transparent_material),
material: transparent_material,
far_away_material: default_material.clone(),
unlit_material: unlit_transparent_material,
atlas: atlas.clone(),
padding: DEFAULT_PADDING,
id: 0,
Expand All @@ -430,7 +443,7 @@ fn create_materials(
}
}

#[derive(Debug)]
#[derive(Debug, Clone)]
/// Contains information that links the block faces to their texture indices.
///
/// This could also link non-face imformation to their texture indices.
Expand All @@ -448,7 +461,7 @@ impl BlockTextureIndicies {
}
}

#[derive(Debug)]
#[derive(Debug, Clone)]
/// Links blocks to their correspoding atlas index.
pub struct BlockTextureIndex {
indices: BlockTextureIndicies,
Expand Down Expand Up @@ -499,7 +512,7 @@ struct ReadBlockInfo {
model: Option<String>,
}

#[derive(Debug)]
#[derive(Debug, Clone)]
/// Every block will have information about how to render it -- even air
pub struct BlockRenderingInfo {
/// This maps textures ids to the various parts of its model.
Expand Down
6 changes: 3 additions & 3 deletions cosmos_client/src/block/lighting.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Handles all the blocks with lighting in the game
use bevy::{
prelude::{App, Color, OnExit, Res, ResMut},
prelude::{warn, App, Color, OnExit, Res, ResMut},
reflect::Reflect,
};
use cosmos_core::{
Expand All @@ -27,7 +27,7 @@ pub struct BlockLightProperties {
pub shadows_disabled: bool,
}

#[derive(Debug, Reflect, Default, Serialize, Deserialize)]
#[derive(Debug, Clone, Reflect, Default, Serialize, Deserialize)]
/// This links up a block to its block light properties
pub struct BlockLighting {
/// The properties this block has
Expand Down Expand Up @@ -59,7 +59,7 @@ fn register_light(lighting: BlockLightProperties, registry: &mut Registry<BlockL
unlocalized_name: block.unlocalized_name().to_owned(),
});
} else {
println!("[Block Lighting] Missing block {name}");
warn!("[Block Lighting] Missing block {name}");
}
}

Expand Down
Loading

0 comments on commit c5c4cd1

Please sign in to comment.