<commit_before>#include <cmath>

#include <glm/gtc/matrix_transform.hpp>
#include <SDL2/SDL.h>

#include <zombye/core/game.hpp>
#include <zombye/ecs/entity_manager.hpp>
#include <zombye/gameplay/states/play_state.hpp>
#include <zombye/input/input_manager.hpp>
#include <zombye/input/input_system.hpp>
#include <zombye/input/joystick.hpp>
#include <zombye/input/mouse.hpp>
#include <zombye/physics/shapes/box_shape.hpp>
#include <zombye/physics/physics_component.hpp>
#include <zombye/rendering/animation_component.hpp>
#include <zombye/rendering/camera_component.hpp>
#include <zombye/rendering/rendering_system.hpp>
#include <zombye/scripting/scripting_system.hpp>
#include <zombye/utils/logger.hpp>
#include <zombye/utils/state_machine.hpp>

zombye::play_state::play_state(zombye::state_machine *sm) : sm_(sm) {
    auto input = sm->get_game()->input();
    input_ = input->create_manager();

    input_->register_action("FIRE", []() {
        zombye::log("<NAME>!");
    });

    input_->register_action("FIRE_END", []() {
        zombye::log("No more peng :(");
    });

    auto first_joystick = input->first_joystick();

    if(first_joystick) {
        input_->register_event("FIRE", first_joystick->button_A());
        input_->register_event("FIRE", first_joystick->button_B());

        input_->register_up_event("FIRE_END", first_joystick->button_A());
        input_->register_up_event("FIRE_END", first_joystick->button_B());
    }

    input_->register_event("FIRE", input->mouse()->left_button());
    input_->register_keyboard_event("FIRE", "space");

    input_->register_up_event("FIRE_END", input->mouse()->left_button());
    input_->register_keyboard_up_event("FIRE_END", "space");
}

void zombye::play_state::enter() {
    zombye::log("enter play state");

    auto& game = *sm_->get_game();

    auto& scripting_system = game.scripting_system();
    scripting_system.begin_module("MyModule");
    scripting_system.load_script("scripts/test.as");
    scripting_system.end_module();
    scripting_system.exec("void main()", "MyModule");
}

void zombye::play_state::leave() {
    zombye::log("leave play state");
}<commit_msg>Register test actions for play state and connect them to the input.<commit_after>#include <cmath>

#include <glm/gtc/matrix_transform.hpp>
#include <SDL2/SDL.h>

#include <zombye/core/game.hpp>
#include <zombye/ecs/entity_manager.hpp>
#include <zombye/gameplay/states/play_state.hpp>
#include <zombye/input/input_manager.hpp>
#include <zombye/input/input_system.hpp>
#include <zombye/input/joystick.hpp>
#include <zombye/input/mouse.hpp>
#include <zombye/physics/shapes/box_shape.hpp>
#include <zombye/physics/physics_component.hpp>
#include <zombye/rendering/animation_component.hpp>
#include <zombye/rendering/camera_component.hpp>
#include <zombye/rendering/rendering_system.hpp>
#include <zombye/scripting/scripting_system.hpp>
#include <zombye/utils/logger.hpp>
#include <zombye/utils/state_machine.hpp>

zombye::play_state::play_state(zombye::state_machine *sm) : sm_(sm) {
    auto input = sm->get_game()->input();
    input_ = input->create_manager();

    /*input_->register_action("FIRE", []() {
        zombye::log("Peng Peng!");
    });*/
    input_->register_actions(*sm->get_game(), "scripts/input/play_state.as");

    input_->register_action("FIRE_END", []() {
        zombye::log("No more peng :(");
    });

    auto first_joystick = input->first_joystick();

    if(first_joystick) {
        input_->register_event("FIRE", first_joystick->button_A());
        input_->register_event("FIRE", first_joystick->button_B());

        input_->register_up_event("FIRE_END", first_joystick->button_A());
        input_->register_up_event("FIRE_END", first_joystick->button_B());
    }

    input_->register_event("FIRE", input->mouse()->left_button());
    input_->register_keyboard_event("FIRE", "space");
    input_->register_up_event("FIRE_END", input->mouse()->left_button());
    input_->register_keyboard_up_event("FIRE_END", "space");

    input_->register_keyboard_event("move_forward_begin", "w");
    input_->register_keyboard_up_event("move_forward_end", "w");
    input_->register_keyboard_event("move_backward_begin", "s");
    input_->register_keyboard_up_event("move_backward_end", "s");
    input_->register_keyboard_event("move_right_begin", "d");
    input_->register_keyboard_up_event("move_right_end", "d");
    input_->register_keyboard_event("move_left_begin", "a");
    input_->register_keyboard_up_event("move_left_end", "a");
}

void zombye::play_state::enter() {
    zombye::log("enter play state");

    auto& game = *sm_->get_game();

    auto& scripting_system = game.scripting_system();
    scripting_system.begin_module("MyModule");
    scripting_system.load_script("scripts/test.as");
    scripting_system.end_module();
    scripting_system.exec("void main()", "MyModule");
}

void zombye::play_state::leave() {
    zombye::log("leave play state");
}
{'fraction_non_alphanumeric': 0.16946750354322737, 'fraction_numerical': 0.00040494027130998176, 'mean_word_length': 5.474442988204456, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 96, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2267409', 'n_tokens_mistral': 1749, 'n_tokens_neox': 1710, 'n_words': 214}