Пример #1
0
    void PushItemtoNextNode()      // must run every like 0.5 sec or something anyway make a another parent function to call this on start
    //maybe check if item has been in list for (InserterSpeed) time and THEN move it to next node
    {
        BeltS         nextB = NextBeltScript;
        MachineScript nextM = NextMachineScript;

        NextNode = GetNextNode();                                                                                                                                   //get nextbelt before every pushitem call

        if (NextType == "Assembly")                                                                                                                                 //pushing from inserter to machine
        {
            if (nextM != null && this.CurrentItemsScript.CurrentItems.Count > 0 && nextM.CurrentItemsScript.CurrentItems.Count < nextM.CurrentItemsScript.Capacity) // && NextMachineScript.CurrentItemsScript.CurrentItems.Count < NextMachineScript.Recipe.NumofRequiremtns) {

            //if(CurrentItemsScript.CurrentItems[0].ID == nextM.Recipe.Requirements.ID){
            {
                if (nextM.Recipe.Requirements.Contains(CurrentItemsScript.CurrentItems[0])) //don't push if its not in requirements
                //push item
                {
                    nextM.InputItems.Add(this.CurrentItemsScript.CurrentItems[0]);
                    this.CurrentItemsScript.CurrentItems.Remove(this.CurrentItemsScript.CurrentItems[0]);
                }
            }
        }
        else if (NextType == "Belt")    //pushing from inserter to belt
        //check stuff before pushing
        {
            if (nextB != null && this.CurrentItemsScript.CurrentItems.Count > 0 && nextB.CurrentItemsScript.CurrentItems.Count < nextB.CurrentItemsScript.Capacity)
            {
                nextB.CurrentItemsScript.CurrentItems.Add(this.CurrentItemsScript.CurrentItems[0]);
                this.CurrentItemsScript.CurrentItems.Remove(this.CurrentItemsScript.CurrentItems[0]);
            }
        }
    }
Пример #2
0
    public GameObject GetNextNode()
    {
        GameObject next;         // next belt

        Debug.DrawRay(Ob.transform.position, Ob.transform.forward, Color.blue, 0.1f);
        Debug.DrawRay(Ob.transform.position, Vector3.up, Color.red, 0.3f);

        RaycastHit hit;
        Ray        ray = new Ray(Ob.transform.position, Ob.transform.forward);

        //IF NEXT OBJECT IS BELT
        if (Physics.Raycast(ray, out hit, 1f) && hit.collider.transform.tag == "Belt")  //change to include all objects or use layer //stop creating that way
        {
            next           = hit.collider.gameObject;
            NextBeltScript = next.GetComponent <BeltS>();
            NextType       = "Belt";
        }
        else if (Physics.Raycast(ray, out hit, 1f) && hit.collider.transform.tag == "Assembly")
        {
            //IF NEXT OBJECT IS MACHINE
            next = hit.collider.gameObject;
            NextMachineScript = next.GetComponent <MachineScript>();
            NextType          = "Assembly";
        }
        else
        {
            NextBeltScript = null;
            next           = null;
        }

        return(next);
    }
Пример #3
0
    IEnumerator PushItemtoNextNode()      // must run every like 0.5 sec or something anyway make a another parent function to call this on start
    //maybe check if item has been in list for (beltspeed) time and THEN move it to next node
    {
        BeltS next = GetNextBelt();          //get nextbeltscript before every pushitem

        //check stuff before pushing

        //GLITCHES APPEAR HERE ITEM THAT ARE NOT SUPPOSED TO BE THERE ARE SUDDENLY THERE

        if (next != null && this.CurrentItemsScript.CurrentItems.Count > 0 && next.CurrentItemsScript.CurrentItems.Count < CurrentItemsScript.Capacity)
        {
            ItemValues tempITEM = this.CurrentItemsScript.CurrentItems[0];             //removing THEN checking if removed then adding
            //removing item from this node
            this.CurrentItemsScript.CurrentItems.Remove(this.CurrentItemsScript.CurrentItems[0]);
            //adding to next node currentItems list
            next.CurrentItemsScript.CurrentItems.Add(tempITEM);
        }


        //redo function //sometimes glitches and stops all current StartCourountines
        yield return(new WaitForSecondsRealtime(BeltSpeed));

        StartCoroutine(this.PushItemtoNextNode());
    }