-
Notifications
You must be signed in to change notification settings - Fork 11
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
Allow user to click on the level where they want to place a new entity instead of just placing it at the origin #20
Comments
The idea - just like we have edit systems and populate systems, we should also have initialize systems for initializing entities. Initialize systems are similar to edit systems: they use Unlike edit systems, only one initialize system is active at any given time. This allows the initialize system to take control over the entire input. The initialize system must return a value - probably an enum, but maybe an |
Something like this: fn vpeol_2d_initialize_position(
mut edit: YoleckEdit<&mut Vpeol2dPosition>,
mut cameras_query: Query<&VpeolCameraState>,
buttons: Res<Input<MouseButton>>,
) -> Option<YoleckInitialize> {
let mut position = edit.get_single_mut().ok()?;
// I think `cursor_ray` is `None` if the cursor is inside the egui window, but if it isn't I
// should probably make it so it does. That would mean clicking inside the egui window should
// not be considered as clicking to set the position.
let cursor_position = camera_state
.iter()
.find_map(|camera_state| camera_state.cursor_ray)?;
position.0 = cursor_position.origin.truncate();
if buttons.just_released(MouseButton::Left) {
Some(YoleckInitialize::Done)
} else {
None
}
} |
Note that there are still default values - we just immediately start to edit them. |
Not sure if the next initialize system should start in the exact same frame. I worry that Maybe a good heuristic is that if an initialize system returns |
Actually, maybe returning an I should probably just use an explicit Actually, do I need abort? Maybe abort should be done externally (e.g. - always done when the user hits |
Currently, when adding a new entity in the editor, all the
YoleckComponent
s are initialized to their default value. For the position component, this usually means the origin. This can get a bit cumbersome:It could be nice if instead of just spawning the thing at the origin, the user would click in the world space where they want to place the new entity.
Note that because there is no position in Yoleck's core (it's part of Vpeol), this will have to be user-customizable. On the plus size this could mean that the same mechanism can be used for other initializations.
The text was updated successfully, but these errors were encountered: