scene_dolphin_state.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <furi.h>
  2. #include "scene.h"
  3. #include "assets/items.h"
  4. static void scene_proceed_action(SceneState* state) {
  5. furi_assert(state);
  6. state->prev_action = state->action;
  7. state->action = roll_new(state->prev_action, ACTIONS_NUM);
  8. state->action_timeout = default_timeout[state->action];
  9. }
  10. static void scene_action_handler(SceneState* state) {
  11. furi_assert(state);
  12. if(state->action == MINDCONTROL) {
  13. if(state->player_v.x != 0 || state->player_v.y != 0) {
  14. state->action_timeout = default_timeout[state->action];
  15. }
  16. }
  17. if(state->action_timeout > 0) {
  18. state->action_timeout--;
  19. }
  20. }
  21. void dolphin_scene_update_state(SceneState* state, uint32_t t, uint32_t dt) {
  22. furi_assert(state);
  23. scene_action_handler(state);
  24. switch(state->action) {
  25. case INTERACT:
  26. if(state->action_timeout == 0) {
  27. if(state->prev_action == MINDCONTROL) {
  28. state->action = MINDCONTROL;
  29. } else {
  30. scene_proceed_action(state);
  31. }
  32. }
  33. break;
  34. default:
  35. if(state->action_timeout == 0) {
  36. scene_proceed_action(state);
  37. }
  38. break;
  39. }
  40. }