2021-04-13 18:06:25 +00:00
|
|
|
#include <furi.h>
|
2021-04-26 12:19:14 +00:00
|
|
|
#include "scene.h"
|
2021-08-05 20:49:04 +00:00
|
|
|
#include "assets/items.h"
|
2021-04-13 18:06:25 +00:00
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
static void scene_proceed_action(SceneState* state) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(state);
|
|
|
|
state->prev_action = state->action;
|
2021-08-05 20:49:04 +00:00
|
|
|
state->action = roll_new(state->prev_action, ACTIONS_NUM);
|
2021-04-13 18:06:25 +00:00
|
|
|
state->action_timeout = default_timeout[state->action];
|
|
|
|
}
|
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
static void scene_action_handler(SceneState* state) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(state);
|
2021-08-05 20:49:04 +00:00
|
|
|
if(state->action == MINDCONTROL) {
|
|
|
|
if(state->player_v.x != 0 || state->player_v.y != 0) {
|
|
|
|
state->action_timeout = default_timeout[state->action];
|
|
|
|
}
|
2021-04-13 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(state->action_timeout > 0) {
|
|
|
|
state->action_timeout--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-26 12:19:14 +00:00
|
|
|
void dolphin_scene_update_state(SceneState* state, uint32_t t, uint32_t dt) {
|
2021-04-13 18:06:25 +00:00
|
|
|
furi_assert(state);
|
2021-04-26 12:19:14 +00:00
|
|
|
scene_action_handler(state);
|
2021-04-13 18:06:25 +00:00
|
|
|
|
|
|
|
switch(state->action) {
|
|
|
|
case INTERACT:
|
|
|
|
if(state->action_timeout == 0) {
|
|
|
|
if(state->prev_action == MINDCONTROL) {
|
|
|
|
state->action = MINDCONTROL;
|
|
|
|
} else {
|
2021-04-26 12:19:14 +00:00
|
|
|
scene_proceed_action(state);
|
2021-04-13 18:06:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2021-08-05 20:49:04 +00:00
|
|
|
|
2021-04-13 18:06:25 +00:00
|
|
|
default:
|
2021-08-05 20:49:04 +00:00
|
|
|
|
2021-04-13 18:06:25 +00:00
|
|
|
if(state->action_timeout == 0) {
|
2021-04-26 12:19:14 +00:00
|
|
|
scene_proceed_action(state);
|
2021-04-13 18:06:25 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|