<commit_before>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class PlayerController : MonoBehaviour {
    public float Speed = 6.0f;

    private const float fireDistance = 20.0f;   // Max distance of a shot
    private const float fireCooldown = 0.2f;    // Time between shots
    private const float reloadCooldown = 2.0f;  // Time to reload
    private const float damage = 50.0f;   // Amount of damage to deal on a successful shot
    private const int startAmmo = 18;     // Amount of (unloaded) ammo at starting
    private const float interactionDistance = 4.0f; // Distance at which the player can interact with an object

    public const int MagazineCount = 6;  // Number of rounds when the weapon is fully loaded
    public const float MaxHealth = 100;   // How much health the player has at starting

    int m_floorMask;                      // A layer mask so that a ray can be cast just at gameobjects on the floor layer.
    Rigidbody m_playerRigidbody;          // Reference to the player's rigidbody.
    LineRenderer gunRenderer;             // Reference to the player's line renderer to use for gunfire.
    float currentFireCooldown = -0.1f;    // How much cooldown is left before the player can fire again.
    float currentReloadCooldown = -0.1f;  // How much cooldown is left before the player has reloaded. 
    int currentRemainingAmmo;             // Amount of (unloaded) ammo remaining
    int currentMagazineCount;             // Number of currently loaded bullets
    float currentHealth;                  // Current health
    Vector3 m_movement;                   // The vector to store the direction of the player's movement.
    private GameObject m_player;
    private GameObject[] interactives;
    private int goldStolen = 0;

	void Start() 
    {
        gunRenderer = GetComponent<LineRenderer>();
        currentRemainingAmmo = startAmmo - MagazineCount;
        currentMagazineCount = MagazineCount;
        currentHealth = MaxHealth;

        m_player = GameObject.FindGameObjectWithTag("Player");
        interactives = GameObject.FindGameObjectsWithTag("Interactive");
	}

	void Awake() 
    {
        m_floorMask = LayerMask.GetMask("Floor");

        m_playerRigidbody = GetComponent<Rigidbody>();
	}

    void Update() 
    {
        //Keyboard Controls
        var x = 0;
        var z = 0;
        if(Input.GetKey(KeyCode.W))
        {
            z = 1;
        }
        if(Input.GetKey(KeyCode.A))
        {
            x = -1;
        }
        if(Input.GetKey(KeyCode.S))
        {
            z = -1;
        }
        if(Input.GetKey(KeyCode.D))
        {
            x = 1;
        }
		Move(x,z);
        //Turn the player
		Turning();

        // Interact logic
        if (Input.GetKeyDown(KeyCode.E))
        {
            // Find the closest interactable
            GameObject selected = null;
            float selectedDistance = 0.0f;
            foreach (var interactive in interactives)
            {
                var distance = (interactive.transform.position - transform.position).magnitude;
                if (distance < interactionDistance && 
                    (selected == null || selectedDistance > distance))
                {
                    selected = interactive;
                    selectedDistance = distance;
                }
            }
            if (selected != null)
            {
                // Differentiate the interaction required
                if (selected.name == "Safe")<commit_msg>Fixed the issue where interactive objects would still be interacted with even if disabled (potentially blocking other objects).<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class PlayerController : MonoBehaviour {
    public float Speed = 6.0f;

    private const float fireDistance = 20.0f;   // Max distance of a shot
    private const float fireCooldown = 0.2f;    // Time between shots
    private const float reloadCooldown = 2.0f;  // Time to reload
    private const float damage = 50.0f;   // Amount of damage to deal on a successful shot
    private const int startAmmo = 18;     // Amount of (unloaded) ammo at starting
    private const float interactionDistance = 4.0f; // Distance at which the player can interact with an object

    public const int MagazineCount = 6;  // Number of rounds when the weapon is fully loaded
    public const float MaxHealth = 100;   // How much health the player has at starting

    int m_floorMask;                      // A layer mask so that a ray can be cast just at gameobjects on the floor layer.
    Rigidbody m_playerRigidbody;          // Reference to the player's rigidbody.
    LineRenderer gunRenderer;             // Reference to the player's line renderer to use for gunfire.
    float currentFireCooldown = -0.1f;    // How much cooldown is left before the player can fire again.
    float currentReloadCooldown = -0.1f;  // How much cooldown is left before the player has reloaded. 
    int currentRemainingAmmo;             // Amount of (unloaded) ammo remaining
    int currentMagazineCount;             // Number of currently loaded bullets
    float currentHealth;                  // Current health
    Vector3 m_movement;                   // The vector to store the direction of the player's movement.
    private GameObject m_player;
    private GameObject[] interactives;
    private int goldStolen = 0;

	void Start() 
    {
        gunRenderer = GetComponent<LineRenderer>();
        currentRemainingAmmo = startAmmo - MagazineCount;
        currentMagazineCount = MagazineCount;
        currentHealth = MaxHealth;

        m_player = GameObject.FindGameObjectWithTag("Player");
        interactives = GameObject.FindGameObjectsWithTag("Interactive");
	}

	void Awake() 
    {
        m_floorMask = LayerMask.GetMask("Floor");

        m_playerRigidbody = GetComponent<Rigidbody>();
	}

    void Update() 
    {
        //Keyboard Controls
        var x = 0;
        var z = 0;
        if(Input.GetKey(KeyCode.W))
        {
            z = 1;
        }
        if(Input.GetKey(KeyCode.A))
        {
            x = -1;
        }
        if(Input.GetKey(KeyCode.S))
        {
            z = -1;
        }
        if(Input.GetKey(KeyCode.D))
        {
            x = 1;
        }
		Move(x,z);
        //Turn the player
		Turning();

        // Interact logic
        if (Input.GetKeyDown(KeyCode.E))
        {
            // Find the closest interactable
            GameObject selected = null;
            float selectedDistance = 0.0f;
            foreach (var interactive in interactives)
            {
                var distance = (interactive.transform.position - transform.position).magnitude;
                if (distance < interactionDistance && 
                    (selected == null || selectedDistance > distance) &&
                    interactive.activeSelf)
                {
                    selected = interactive;
                    selectedDistance = distance;
                }
            }
            if (selected != null)
            {
                // Differentiate the interaction required
                if (selected.name == "Safe")
{'fraction_non_alphanumeric': 0.07630853994490358, 'fraction_numerical': 0.009366391184573003, 'mean_word_length': 1.8997603833865815, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2743791', 'n_tokens_mistral': 1971, 'n_tokens_neox': 1852, 'n_words': 629}