<commit_before>﻿using UnityEngine;

public class Projectile: MonoBehaviour {
  public LayerMask collisionMask;

  float speed;
  const float damage = 1.0f;
  const float lifeTime = 2.0f;

  void Start() {
    Destroy(gameObject, lifeTime);
  }

  void Update() {
    float distance = Time.deltaTime * speed;
    CheckCollision(distance);
    transform.Translate(Vector3.forward * distance);
  }

  public void SetSpeed(float newSpeed) {
    speed = newSpeed;
  }

  void CheckCollision(float distance) {
    Ray ray = new Ray(transform.position, transform.forward);
    RaycastHit hit;

    if (Physics.Raycast(ray, out hit, distance, collisionMask, QueryTriggerInteraction.Collide)) {
      OnObjectHit(hit);
    }
  }

  void OnObjectHit(RaycastHit hit) {
    IDamageable damageable = hit.collider.GetComponent<IDamageable>();

    if (damageable != null) {
      damageable.TakeHit(damage, hit);
    }

    Destroy(gameObject);
  }
}
<commit_msg>Fix projectile spawn issue<commit_after>﻿using UnityEngine;
using System.Runtime.Remoting.Contexts;

public class Projectile: MonoBehaviour {
  public LayerMask collisionMask;

  float speed;
  const float damage = 1.0f;
  const float lifeTime = 2.0f;
  const float targetSurfaceThickness = 0.1f;

  void Start() {
    Destroy(gameObject, lifeTime);

    Collider[] collisions = Physics.OverlapSphere(transform.position, 0.1f, collisionMask);

    if (collisions.Length > 0) {
      OnObjectHit(collisions[0]);
    }
  }

  void Update() {
    float distance = Time.deltaTime * speed;
    CheckCollision(distance);
    transform.Translate(Vector3.forward * distance);
  }

  public void SetSpeed(float newSpeed) {
    speed = newSpeed;
  }

  void CheckCollision(float distance) {
    Ray ray = new Ray(transform.position, transform.forward);
    RaycastHit hit;

    if (Physics.Raycast(ray, out hit, distance + targetSurfaceThickness, collisionMask, QueryTriggerInteraction.Collide)) {
      OnObjectHit(hit);
    }
  }

  void OnObjectHit(RaycastHit hit) {
    IDamageable damageable = hit.collider.GetComponent<IDamageable>();

    if (damageable != null) {
      damageable.TakeHit(damage, hit);
    }

    Destroy(gameObject);
  }

  void OnObjectHit(Collider aCollider) {
    IDamageable damageable = aCollider.GetComponent<IDamageable>();

    if (damageable != null) {
      damageable.TakeDamage(damage);
    }

    Destroy(gameObject);
  }
}

{'fraction_non_alphanumeric': 0.10574521232306411, 'fraction_numerical': 0.006661115736885929, 'mean_word_length': 3.638996138996139, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, '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': '6316217', 'n_tokens_mistral': 792, 'n_tokens_neox': 753, 'n_words': 166}