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

public class BeltManager : MonoBehaviour
{
    public ItemManager itemManager = null;
    public List<GameObject> beltPlates = new List<GameObject>();

    public GameObject BeltPlatePrefab = null;

    [Header("Transform")]
    public Transform BeltTopTransform = null;
    public float BeltRadius = 8.5f;
    public int BeltCapacity = 10;
    public float BeltOffset = 0.0f;

    [Header("Speed Control")]
    public float BeltSpeedTarget = 0.5f;
    public float BeltAccelerationTime = 1.0f;
    public float BeltSpeedCurrentOffset = 0.0f;
    float BeltSpeedVelocity = 0.0f;

    #region Events
    void Start()
    {
        if (!BeltTopTransform) BeltTopTransform = this.transform;

        FillBelt();
    }

    void FixedUpdate()
    {
        BeltSpeedCurrentOffset = Mathf.SmoothDamp(BeltSpeedCurrentOffset, BeltSpeedTarget, ref BeltSpeedVelocity, BeltAccelerationTime);
        BeltOffset += BeltSpeedCurrentOffset;

        for (int i = 0; i < BeltCapacity; i++)
        {
            if (beltPlates[i] != null)
            {
                Vector3 pos = IndexToPosition(i);
                pos.y = beltPlates[i].transform.localPosition.y;
                beltPlates[i].transform.localPosition = pos;

                Vector3 lookPoint = BeltTopTransform.position;
                lookPoint.y = pos.y;

                beltPlates[i].transform.LookAt(lookPoint);
            }
        }
    }

    void OnDrawGizmosSelected()
    {
        if (!BeltTopTransform) BeltTopTransform = this.transform;

        Gizmos.DrawWireSphere(BeltTopTransform.position, BeltRadius);

        for (int i = 0; i < BeltCapacity; i++)
            Gizmos.DrawWireSphere(DegreesToPosition(IndexToDegrees(i)), 0.5f);


    }
    #endregion

    public void FillBelt()
    {
        for (int i = 0; i < BeltCapacity; i++)
        {
            Vector3 pos = IndexToPosition(i);
            GameObject go = GameObject.Instantiate(BeltPlatePrefab, pos, Quaternion.identity, BeltTopTransform);
            beltPlates.Add(go);
            BeltPlateController bpc = go.GetComponent<BeltPlateController>();
            bpc.beltIndex = i;
        }
    }

    public void ClearBelt()
    {
        for (int i = 0; i < beltPlates.Count; i++)
        {
            if (beltPlates[i] != null)
            {
                GameObject.Destroy(beltPlates[i]);
                beltPlates[i] = null;
            }
        }
    }

    public void AddItemToBeltPlate(GameObject _beltPlateObj)
    {
        GameObject model = itemManager.GetItemModel();
        BeltPlateController bpc = _beltPlateObj.GetComponent<BeltPlateController>();

        Vector3 pos = bpc.itemAnchor.position;
        GameObject go = GameObject.Instantiate(model, pos, Quaternion.identity, bpc.itemAnchor);

        //go.transform.LookAt(BeltTopTransform);
    }

    float IndexToDegrees(int i)<commit_msg>Removed warning.<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

public class BeltManager : MonoBehaviour
{
    public ItemManager itemManager = null;
    public List<GameObject> beltPlates = new List<GameObject>();

    public GameObject BeltPlatePrefab = null;

    [Header("Transform")]
    public Transform BeltTopTransform = null;
    public float BeltRadius = 8.5f;
    public int BeltCapacity = 10;
    public float BeltOffset = 0.0f;

    [Header("Speed Control")]
    public float BeltSpeedTarget = 0.5f;
    public float BeltAccelerationTime = 1.0f;
    public float BeltSpeedCurrentOffset = 0.0f;
    float BeltSpeedVelocity = 0.0f;

    #region Events
    void Start()
    {
        if (!BeltTopTransform) BeltTopTransform = this.transform;

        FillBelt();
    }

    void FixedUpdate()
    {
        BeltSpeedCurrentOffset = Mathf.SmoothDamp(BeltSpeedCurrentOffset, BeltSpeedTarget, ref BeltSpeedVelocity, BeltAccelerationTime);
        BeltOffset += BeltSpeedCurrentOffset;

        for (int i = 0; i < BeltCapacity; i++)
        {
            if (beltPlates[i] != null)
            {
                Vector3 pos = IndexToPosition(i);
                pos.y = beltPlates[i].transform.localPosition.y;
                beltPlates[i].transform.localPosition = pos;

                Vector3 lookPoint = BeltTopTransform.position;
                lookPoint.y = pos.y;

                beltPlates[i].transform.LookAt(lookPoint);
            }
        }
    }

    void OnDrawGizmosSelected()
    {
        if (!BeltTopTransform) BeltTopTransform = this.transform;

        Gizmos.DrawWireSphere(BeltTopTransform.position, BeltRadius);

        for (int i = 0; i < BeltCapacity; i++)
            Gizmos.DrawWireSphere(DegreesToPosition(IndexToDegrees(i)), 0.5f);


    }
    #endregion

    public void FillBelt()
    {
        for (int i = 0; i < BeltCapacity; i++)
        {
            Vector3 pos = IndexToPosition(i);
            GameObject go = GameObject.Instantiate(BeltPlatePrefab, pos, Quaternion.identity, BeltTopTransform);
            beltPlates.Add(go);
            BeltPlateController bpc = go.GetComponent<BeltPlateController>();
            bpc.beltIndex = i;
        }
    }

    public void ClearBelt()
    {
        for (int i = 0; i < beltPlates.Count; i++)
        {
            if (beltPlates[i] != null)
            {
                GameObject.Destroy(beltPlates[i]);
                beltPlates[i] = null;
            }
        }
    }

    public void AddItemToBeltPlate(GameObject _beltPlateObj)
    {
        GameObject model = itemManager.GetItemModel();
        BeltPlateController bpc = _beltPlateObj.GetComponent<BeltPlateController>();

        Vector3 pos = bpc.itemAnchor.position;
        GameObject.Instantiate(model, pos, Quaternion.identity, bpc.itemAnchor);

        //go.transform.LookAt(BeltTopTransform);
    }

    float IndexToDegrees(int i)
{'fraction_non_alphanumeric': 0.09645437741556041, 'fraction_numerical': 0.008065871282137456, 'mean_word_length': 2.3513513513513513, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 11, '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': '2361543', 'n_tokens_mistral': 1881, 'n_tokens_neox': 1721, 'n_words': 364}