<commit_before>﻿using UnityEngine;

public class PhysicsIgnoreByTags : MonoBehaviour
{
    public string[] ignoreCollisionTags;

    protected Collider physicCollider;
    public virtual Collider PhysicCollider
    {
        get
        {
            if (physicCollider == null)
                physicCollider = GetComponent<Collider>();
            return physicCollider;
        }
    }

    protected CharacterController physicCharacterController;
    public virtual CharacterController PhysicCharacterController
    {
        get
        {
            if (physicCharacterController == null)
                physicCharacterController = GetComponent<CharacterController>();
            return physicCharacterController;
        }
    }

    void IgnoreCollision(Collider collider1, Collider collider2)
    {
        for (int i = 0; i < ignoreCollisionTags.Length; ++i)
        {
            string ignoreCollisionTag = ignoreCollisionTags[i];
            if (ignoreCollisionTag != null && ignoreCollisionTag.Equals(collider1.tag))
            {
                Physics.IgnoreCollision(collider1, collider2, true);
                break;
            }
        }
    }

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        IgnoreCollision(hit.collider, PhysicCharacterController);
    }

    void OnCollisionEnter(Collision collision)
    {
        IgnoreCollision(collision.collider, PhysicCollider);
    }

    void OnTriggerEnter(Collider collider)
    {
        IgnoreCollision(collider, PhysicCollider);
    }
}<commit_msg>Improve physic ignore by tags<commit_after>﻿using UnityEngine;

public class PhysicsIgnoreByTags : MonoBehaviour
{
    public string[] ignoreCollisionTags;

    protected Collider physicCollider;
    public virtual Collider PhysicCollider
    {
        get
        {
            if (physicCollider == null)
                physicCollider = GetComponent<Collider>();
            return physicCollider;
        }
    }

    protected CharacterController physicCharacterController;
    public virtual CharacterController PhysicCharacterController
    {
        get
        {
            if (physicCharacterController == null)
                physicCharacterController = GetComponent<CharacterController>();
            return physicCharacterController;
        }
    }

    void IgnoreCollision(Collider collider1, Collider collider2)
    {
        for (int i = 0; i < ignoreCollisionTags.Length; ++i)
        {
            string ignoreCollisionTag = ignoreCollisionTags[i];
            if (ignoreCollisionTag != null && ignoreCollisionTag.Equals(collider1.tag))
            {
                Physics.IgnoreCollision(collider1, collider2, true);
                break;
            }
        }
    }

    void Awake()
    {
        if (PhysicCollider != null)
            IgnoreCollisionByRadius(PhysicCollider, PhysicCollider.bounds.size.x);
        if (PhysicCharacterController != null)
            IgnoreCollisionByRadius(PhysicCharacterController, PhysicCharacterController.bounds.size.x);
    }

    void OnDrawGizmos()
    {
        Gizmos.color = Color.cyan;
        if (PhysicCollider != null)
            Gizmos.DrawWireSphere(PhysicCollider.bounds.center, PhysicCollider.bounds.size.x);
        if (PhysicCharacterController != null)
            Gizmos.DrawWireSphere(PhysicCharacterController.bounds.center, PhysicCharacterController.bounds.size.x);
    }

    void IgnoreCollisionByRadius(Collider targetCol, float radius)
    {
        Collider[] colliders = Physics.OverlapSphere(targetCol.bounds.center, radius);
        for (int i = 0; i < colliders.Length; ++i)
        {
            Collider foundCol = colliders[i];
            IgnoreCollision(foundCol, targetCol);
        }
    }

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        IgnoreCollision(hit.collider, PhysicCharacterController);
    }

    void OnCollisionEnter(Collision collision)
    {
        IgnoreCollision(collision.collider, PhysicCollider);
    }

    void OnTriggerEnter(Collider collider)
    {
        IgnoreCollision(collider, PhysicCollider);
    }
}
{'fraction_non_alphanumeric': 0.07580174927113703, 'fraction_numerical': 0.0031584062196307093, 'mean_word_length': 2.4365609348914856, 'pattern_counts': {'":': 0, '<': 10, '<?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': '1214477', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1083, 'n_words': 205}