<commit_before>class Cart{
    Hub @hub;
    Entity @self;
    float speed;
    bool trigger;
    float stopTime;
    float endTime;
    float a;
    float b;
    float c;
    
    Component::Physics @minecartPhysics;
    Component::Physics @stopPhysics;
    
    Cart(Entity @entity){
        @hub = Managers();
        @self = @entity;
        speed = 20.0f;
        stopTime = 0.0f;
        endTime = 7.5f;
        
        // Calculate second grade equation.
        float t = endTime;
        c = speed;
        a = (3.0f * c - 300.0f / t) / (t * t);
        b = 100.0f / (t * t) - 2.0f * a * t / 3.0f - 2.0f * c / t;
        
        Entity @stopTrigger = self.GetParent().GetChild("GateAndLever").GetChild("StopTrigger");
        @minecartPhysics = self.GetPhysics();
        @stopPhysics = stopTrigger.GetPhysics();
        
        trigger = false;
        RegisterUpdate();
        RegisterTrigger(stopPhysics, minecartPhysics, "OnTrigger");
    }
    
    //Update carts movements and send it's position to Player Script.
    void Update(float deltaTime){
        self.position.z -= speed*deltaTime;
        
        if (self.position.z < 450.0f && stopTime < endTime){
            stopTime += deltaTime;
            float t = stopTime;
            float zPos = a * t * t * t / 3.0f + b * t * t / 2.0f + c * t;
            self.position.z = 450.0f - zPos;
        } else if (stopTime >= endTime && !trigger) {
            self.position.z = 400.0f;
            speed = 0.0f;
        } else if (trigger){
            if (speed < 20.0f)
                speed += 0.0664f;
        }
        
        
    }
    
    void ReceiveMessage(int signal){
        if (signal == 1)
            trigger = true;
    }
    
    void OnTrigger(Component::Physics @trigger, Component::Physics @enterer) {
        print("WOW! WHAT A COLLISION!");
    }
}<commit_msg>Cart script uses trigger data to start braking before the lever.<commit_after>class Cart{
    Hub @hub;
    Entity @self;
    float speed;
    bool trigger;
    float stopTime;
    float endTime;
    float a;
    float b;
    float c;
    bool hasHitPlane;
    
    Component::Physics @minecartPhysics;
    Component::Physics @stopPhysics;
    
    Cart(Entity @entity){
        @hub = Managers();
        @self = @entity;
        speed = 20.0f;
        stopTime = 0.0f;
        endTime = 7.5f;
        hasHitPlane = false;
        
        // Calculate second grade equation.
        float t = endTime;
        c = speed;
        a = (3.0f * c - 300.0f / t) / (t * t);
        b = 100.0f / (t * t) - 2.0f * a * t / 3.0f - 2.0f * c / t;
        
        Entity @stopTrigger = self.GetParent().GetChild("GateAndLever").GetChild("StopTrigger");
        @minecartPhysics = self.GetPhysics();
        @stopPhysics = stopTrigger.GetPhysics();
        
        trigger = false;
        RegisterUpdate();
        RegisterTrigger(stopPhysics, minecartPhysics, "OnTrigger");
    }
    
    //Update carts movements and send it's position to Player Script.
    void Update(float deltaTime){
        self.position.z -= speed*deltaTime;
        
        // Braking phase
        if (hasHitPlane && stopTime < endTime){
            stopTime += deltaTime;
            float t = stopTime;
            float zPos = a * t * t * t / 3.0f + b * t * t / 2.0f + c * t;
            self.position.z = 450.0f - zPos;
        }
        // Stopping phase
        else if (stopTime >= endTime && !trigger) {
            self.position.z = 400.0f;
            speed = 0.0f;
        }
        // Start again after lever has been pulled
        else if (trigger){
            if (speed < 20.0f)
                speed += 0.0664f;
        }
    }
    
    void ReceiveMessage(int signal){
        if (signal == 1)
            trigger = true;
    }
    
    void OnTrigger(Component::Physics @trigger, Component::Physics @enterer) {
        print("WOW! WHAT A COLLISION!");
        hasHitPlane = true;
    }
}
{'fraction_non_alphanumeric': 0.11950165268243071, 'fraction_numerical': 0.02440884820747521, 'mean_word_length': 1.6001321877065433, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5731398', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1239, 'n_words': 328}