-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add content pack system #7
Conversation
We can't use the default gravity since our gravity direction is non-uniform: instead of always being down, it's directed towards the 0-Z axis.
If there are different types, we might want to use an ECS in here, such as hecs. |
Ah, right, good point
That's a good suggestion, but currently it will be an overkill in my view. Let's think about it later with more entities added. |
Fixed in last commits |
@@ -105,7 +100,7 @@ impl Physics { | |||
terrain: &TerrainBody, | |||
) { | |||
//Note: real world power is -11, but our scales are different | |||
const GRAVITY: f32 = 6.6743e-8; | |||
const GRAVITY: f32 = 1e-3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason the working magic number is 1e-3, at least my demo cubes fall and collide more or less realistically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very solid contribution, thank you!
Just a few questions to resolve before we land this
Cargo.toml
Outdated
@@ -1,6 +1,6 @@ | |||
[workspace] | |||
resolver = "2" | |||
members = ["lib/ffi"] | |||
members = ["lib/ffi", "lib/content_packs"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you consider dashes instead of underscores for file names?
} | ||
|
||
impl CameraController { | ||
pub fn new(camera: Camera) -> CameraController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ->Self
} | ||
} | ||
|
||
pub fn camera(&self) -> &Camera { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be easier to just expose the camera field as pub
?
let entry = entry.unwrap(); | ||
let path = entry.path(); | ||
if let Some(ext) = path.extension() { | ||
if ext == "ron" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we assert if it's not "ron"? just ignoring it doesn't sound polite
lib/content_packs/src/definitions.rs
Outdated
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: a bunch of empty lines?
did you run cargo fmt
on the project?
lib/content_packs/src/game.rs
Outdated
@@ -0,0 +1,230 @@ | |||
use std::collections::{HashMap, HashSet}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formatting: I really like to have a single use
statement per crate, e.g.
use std::{fs, time, {f32::consts::PI}, path::Path, sync::Arc};
Can we have that here please?
lib/content_packs/src/game.rs
Outdated
pub struct QuitEvent; | ||
|
||
impl Game { | ||
pub fn new(event_loop: &EventLoop<()>, mods_directory: &Path) -> Game { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: -> Self
lib/ffi/Cargo.toml
Outdated
@@ -9,7 +9,7 @@ crate-type = ["cdylib"] | |||
[dependencies] | |||
vandals-and-heroes = { path = "../.." } | |||
raw-window-handle = "0.6.2" | |||
log = "0.4.22" | |||
log = "0.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need the FFI? I was hoping you'd be comfortable with Rust modules by now
Notable changes:
render
andphysics
modules for content pack systemcontent_packs
workspace member. This should probably be moved somewhere else and should replacebin/game
in the future.bin/game/main.rs
is not working also: frames are rendered without any pauses. Probably there should another timer system implemented, need input from @kvark.physics.step
(so I don't apply forces directly to each rigidbody), as I've seen no harm in doing that.Key concepts of content pack system:
root
pack (underdata/packs/root
), but I plan to add a system to support additional packs that can override and extendroot
pack.ObjectDesc
- description of the object, read from RON file.ObjectTemplate
- preloaded object ready for instantiation in a level.Object
- object instance