Skip to content
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

Move hookline adjustment where cursor is set. #14

Merged
merged 1 commit into from
Jan 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,18 +652,18 @@ impl ClientNativeImpl {
match stage {
hashlink::lru_cache::Entry::Occupied(mut stage) => {
let stage = stage.get_mut();
for (id, local_char) in game
for id in game
.game_data
.local
.local_players
.iter()
.filter_map(|(id, local_char)| {
.keys()
.filter_map(|id| {
character_infos.get(id).and_then(|char| {
char.stage_id.map(|stage_id| (id, stage_id, local_char))
char.stage_id.map(|stage_id| (id, stage_id))
})
})
.filter_map(|(id, find_stage_id, local_char)| {
(find_stage_id == stage_id).then_some((id, local_char))
.filter_map(|(id, find_stage_id)| {
(find_stage_id == stage_id).then_some(id)
})
{
if let Some(mut char) = pred_stage.world.characters.remove(id) {
Expand All @@ -683,15 +683,6 @@ impl ClientNativeImpl {
char.lerped_hook = unpredicted_char.lerped_hook;
}
}
char.hook_collision =
char.hook_collision.map(|mut hook_col| {
let dir = hook_col.end - hook_col.start;
let dir_len = length(&dir);
let dir = normalize(&local_char.cursor_pos);
let dir = vec2::new(dir.x as f32, dir.y as f32);
hook_col.end = hook_col.start + dir * dir_len;
hook_col
});
stage.world.characters.insert(*id, char);
}

Expand Down Expand Up @@ -818,6 +809,15 @@ impl ClientNativeImpl {
player.lerped_cursor_pos = client_player.input.inp.cursor.to_vec2();
player.lerped_dyn_cam_offset =
client_player.input.inp.dyn_cam_offset.to_vec2();

player.hook_collision = player.hook_collision.map(|mut hook_col| {
let dir = hook_col.end - hook_col.start;
let dir_len = length(&dir);
let dir = normalize(&client_player.cursor_pos);
let dir = vec2::new(dir.x as f32, dir.y as f32);
hook_col.end = hook_col.start + dir * dir_len;
hook_col
});
}

// update freecam position
Expand Down
Loading