Beispiel #1
0
        public InserterData addInserter(Vector3 pos)
        {
            InserterData ins = new InserterData();

            inserters.Add(ins);

            GameObject go   = GameObject.Instantiate(inserterPrefab, pos, Quaternion.identity) as GameObject;
            Inserter   comp = go.GetComponent <Inserter>();

            comp.target = ins;
            inserterGO.Add(comp);

            //surroundingCheck(pos, p, comp);
            return(ins);
        }
Beispiel #2
0
        void surroundingCheck(Vector3 pos, InserterData inserterData, Inserter inserter)
        {
            // inserter check
            // generator to belt
            // belt to storage
            // generator to storage
            // assembler to storage
            // generator to assembler
            // get inserter's surrounding
            Vector3[] offsets = new Vector3[4] {
                Vector3.left, Vector3.right, Vector3.forward, Vector3.back
            };
            RaycastHit hit;

            ISimData[] adjacentTypes = new ISimData[4];
            for (int i = 0; i < 4; ++i)
            {
                if (Physics.Raycast(pos + offsets[i] + Vector3.up * 2f, Vector3.down, out hit, 2f, LayerMask.GetMask("Default")))
                {
                    ISimView simData = hit.collider.GetComponent <ISimView>();
                    adjacentTypes[i] = simData.getTarget();
                }
            }
            for (int i = 0; i < 4; ++i)
            {
                ProducerData generator = adjacentTypes[i] as ProducerData;
                if (generator != null)
                {
                    BeltData belt = adjacentTypes[(i + 2) % 4] as BeltData;
                    if (belt != null)
                    {
                    }
                    inserterData.expectedItemId = generator.itemId;
                    inserterData.source         = generator;
                    inserterData.target         = belt;
                    inserterData.targetPos      = 0f;
                    inserterData.source         = (ISimData)generator;
                    inserterData.target         = (ISimData)belt;
                    inserterData.targetPos      = 0f;
                    inserter.head = generator.ToString();
                    if (belt != null)
                    {
                        inserter.head = belt.ToString();
                    }
                }
            }
        }