<commit_before>//
// Created by dar on 12/22/15.
//

#ifndef C003_PLAYERRENDER_H
#define C003_PLAYERRENDER_H

#include "DefaultEntityRender.h"
#include <core/map/entity/EntityPlayer.h>
#include <core/map/Map.h>

class PlayerRender : public DefaultEntityRender {
public:
    PlayerRender() : DefaultEntityRender("player", "shader") { }

    virtual void render(const Entity *const entity, glm::mat4 projectionMatrix, glm::mat4 viewMatrix, double scale) override {
        const EntityPlayer *const player = ((const EntityPlayer *const) entity);
        if (player->getToy() == nullptr || player->getEjectTime() > 0.0) {
            this->texture.bindTexture(0);
            this->shaderProgram.useProgram();
            this->shaderProgram.setUniform("projectionMatrix", projectionMatrix);
            this->shaderProgram.setUniform("gSampler", texture.getBoundId());

            glm::mat4x4 tmpModelMatrixVal;
            tmpModelMatrixVal = glm::translate(this->modelMatrix, glm::vec3(0.0f - (entity->getX() - entity->getWidth() / 2) * scale,
                                                                            0.0f - (entity->getY() - entity->getHeight() / 2) * scale, 0.0f));

            tmpModelMatrixVal = glm::translate(tmpModelMatrixVal, glm::vec3(0.5 * scale, 0.5 * scale, 0.0)); // Translate to the middle of the entity
            tmpModelMatrixVal = glm::rotate(tmpModelMatrixVal, (const float) entity->getAngle(), glm::vec3(0.0f, 0.0f, 1.0f)); // Apply rotation
            tmpModelMatrixVal = glm::translate(tmpModelMatrixVal, glm::vec3(-0.5 * scale, -0.5 * scale, 0.0)); // Translate back to the origin


            double oldScale = scale;
            scale *= player->getEjectTime() >= 0.0 ? 1.0 - player->getEjectTime() : -player->getEjectTime();

            tmpModelMatrixVal = glm::scale(tmpModelMatrixVal, glm::vec3(scale, scale, 1.0f));

            tmpModelMatrixVal = glm::translate(tmpModelMatrixVal, glm::vec3(0.5 * (oldScale - scale) / scale, 0.5 * (oldScale - scale) / scale, 0.0)); // Translate to the center of scaling

            shaderProgram.setUniform("modelViewMatrix", viewMatrix * tmpModelMatrixVal);
            shaderProgram.setUniform("texPosX", 1.0f / this->texture.getWidth() + (float) (this->getTexPos(entity) % atlasSize) / atlasSize);
            shaderProgram.setUniform("texPosY", 1.0f / this->texture.getWidth() + (float) (this->getTexPos(entity) / atlasSize) / atlasSize);

            glBindVertexArray(this->vao);
            glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
        }
    }

protected:
    virtual int getTexPos(const Entity *const entity) override {
        const EntityPlayer *const player = ((const EntityPlayer *const) entity);
        return (int) std::fmod((sin(player->getTailAnimation()) + 1.0) * 8, 16.0);
    }

};

#endif //C003_PLAYERRENDER_H<commit_msg>Hidden the player in editor mode<commit_after>//
// Created by dar on 12/22/15.
//

#ifndef C003_PLAYERRENDER_H
#define C003_PLAYERRENDER_H

#include "DefaultEntityRender.h"
#include <core/map/entity/EntityPlayer.h>
#include <core/map/Map.h>

class PlayerRender : public DefaultEntityRender {
public:
    PlayerRender() : DefaultEntityRender("player", "shader") { }

    virtual void render(const Entity *const entity, glm::mat4 projectionMatrix, glm::mat4 viewMatrix, double scale) override {
#ifndef EDITOR
        const EntityPlayer *const player = ((const EntityPlayer *const) entity);
        if (player->getToy() == nullptr || player->getEjectTime() > 0.0) {
            this->texture.bindTexture(0);
            this->shaderProgram.useProgram();
            this->shaderProgram.setUniform("projectionMatrix", projectionMatrix);
            this->shaderProgram.setUniform("gSampler", texture.getBoundId());

            glm::mat4x4 tmpModelMatrixVal;
            tmpModelMatrixVal = glm::translate(this->modelMatrix, glm::vec3(0.0f - (entity->getX() - entity->getWidth() / 2) * scale,
                                                                            0.0f - (entity->getY() - entity->getHeight() / 2) * scale, 0.0f));

            tmpModelMatrixVal = glm::translate(tmpModelMatrixVal, glm::vec3(0.5 * scale, 0.5 * scale, 0.0)); // Translate to the middle of the entity
            tmpModelMatrixVal = glm::rotate(tmpModelMatrixVal, (const float) entity->getAngle(), glm::vec3(0.0f, 0.0f, 1.0f)); // Apply rotation
            tmpModelMatrixVal = glm::translate(tmpModelMatrixVal, glm::vec3(-0.5 * scale, -0.5 * scale, 0.0)); // Translate back to the origin


            double oldScale = scale;
            scale *= player->getEjectTime() >= 0.0 ? 1.0 - player->getEjectTime() : -player->getEjectTime();

            tmpModelMatrixVal = glm::scale(tmpModelMatrixVal, glm::vec3(scale, scale, 1.0f));

            tmpModelMatrixVal = glm::translate(tmpModelMatrixVal, glm::vec3(0.5 * (oldScale - scale) / scale, 0.5 * (oldScale - scale) / scale, 0.0)); // Translate to the center of scaling

            shaderProgram.setUniform("modelViewMatrix", viewMatrix * tmpModelMatrixVal);
            shaderProgram.setUniform("texPosX", 1.0f / this->texture.getWidth() + (float) (this->getTexPos(entity) % atlasSize) / atlasSize);
            shaderProgram.setUniform("texPosY", 1.0f / this->texture.getWidth() + (float) (this->getTexPos(entity) / atlasSize) / atlasSize);

            glBindVertexArray(this->vao);
            glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
        }
#endif
    }

protected:
    virtual int getTexPos(const Entity *const entity) override {
        const EntityPlayer *const player = ((const EntityPlayer *const) entity);
        return (int) std::fmod((sin(player->getTailAnimation()) + 1.0) * 8, 16.0);
    }

};

#endif //C003_PLAYERRENDER_H
{'fraction_non_alphanumeric': 0.14283213723087695, 'fraction_numerical': 0.027306143882373533, 'mean_word_length': 2.981881533101045, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7227280', 'n_tokens_mistral': 1840, 'n_tokens_neox': 1759, 'n_words': 373}