continuous teleporting

This commit is contained in:
jacob 2025-05-16 17:54:24 -05:00
parent e4a4e33232
commit 1943b2d81b
2 changed files with 12 additions and 14 deletions

View File

@ -172,7 +172,7 @@ INTERNAL struct sim_ent *spawn_test_explosion(struct sim_snapshot *world, struct
INTERNAL void test_teleport(struct sim_ent *ent, struct v2 pos)
{
++ent->continuity_gen;
//++ent->continuity_gen;
struct xform xf = sim_ent_get_xform(ent);
xf.og = pos;
sim_ent_set_xform(ent, xf);
@ -572,12 +572,10 @@ void sim_step(struct sim_step_ctx *ctx)
}
if (flags & SIM_CONTROL_FLAG_TELEPORT_TEST) {
if (!(old_control.flags & SIM_CONTROL_FLAG_TELEPORT_TEST)) {
logf_info("Teleport (test)");
struct sim_ent *ent = sim_ent_from_id(world, player->player_control_ent);
if (ent->valid) {
test_teleport(ent, player->player_cursor_pos);
}
logf_info("Teleport (test)");
struct sim_ent *ent = sim_ent_from_id(world, player->player_control_ent);
if (ent->valid) {
test_teleport(ent, player->player_cursor_pos);
}
}

View File

@ -25,7 +25,8 @@
struct bind_state {
b32 is_held; /* Is this bind held down this frame */
u32 num_presses; /* How many times was this bind pressed since last frame */
u32 num_presses; /* How many times was this bind's pressed since last frame */
u32 num_repeats; /* How many times was this bind's key repeated since last frame */
u32 num_presses_and_repeats; /* Same as `num_presses` but includes key repeats as well */
u32 num_releases; /* How many times was this bind released since last frame */
};
@ -160,9 +161,8 @@ GLOBAL READONLY enum user_bind_kind g_binds[SYS_BTN_COUNT] = {
[SYS_BTN_MWHEELDOWN] = USER_BIND_KIND_ZOOM_OUT,
[SYS_BTN_M3] = USER_BIND_KIND_PAN,
#if RTC
#if COLLIDER_DEBUG
/* Debug */
[SYS_BTN_FORWARD_SLASH] = USER_BIND_KIND_RESET_COLLIDER_GJK_STEPS,
[SYS_BTN_COMMA] = USER_BIND_KIND_DECR_COLLIDER_GJK_STEPS,
[SYS_BTN_PERIOD] = USER_BIND_KIND_INCR_COLLIDER_GJK_STEPS
@ -608,12 +608,10 @@ INTERNAL void user_update(void)
}
if (event->kind == SYS_EVENT_KIND_BUTTON_UP) {
#if DEVELOPER
/* Escape quit */
if (event->button == SYS_BTN_ESC) {
app_exit();
}
#endif
}
/* Update mouse pos */
@ -641,7 +639,9 @@ INTERNAL void user_update(void)
if (pressed) {
if (!out_of_bounds) {
++G.bind_states[bind].num_presses_and_repeats;
if (!event->is_repeat) {
if (event->is_repeat) {
++G.bind_states[bind].num_repeats;
} else {
++G.bind_states[bind].num_presses;
}
}
@ -1622,7 +1622,7 @@ INTERNAL void user_update(void)
if (explode_state.num_presses_and_repeats) {
control.flags |= SIM_CONTROL_FLAG_EXPLODE_TEST;
}
if (teleport_state.num_presses_and_repeats) {
if (teleport_state.num_presses_and_repeats || (G.debug_camera && teleport_state.is_held)) {
control.flags |= SIM_CONTROL_FLAG_TELEPORT_TEST;
}