private void Start() { SystemUpdate.self.RegisterPerFrameUpdate(this); for (int i = 0; i < line_count; ++i) { ProducerData gen = addGeneratorCheat(new Vector3(0f, 0f, i * 2f), 1, 9999); BeltData belt = addBelt(new Vector3(4f, 0f, i * 2f), new Vector3(12f, 0f, i * 2f)); AssemblerData assem = addAssembler(new Vector3(16f, 0, i * 2f)); assem.setReqItems(new ushort[] { 1 }, new ushort[] { 2 }); //assem.req_itemIds[0] = 1; //assem.req_Count[0] = 2; assem.productItemId = 2; assem.productItemCount = 1; assem.cycleDuration = 3f; StorageData stor = addStorage(new Vector3(20f, 0, i * 2f)); InserterData ins = addInserter(new Vector3(2f, 0f, i * 2f)); ins.source = gen; ins.target = belt; //ins.targetPos = 0f; ins.expectedItemId = 1; InserterData ins2 = addInserter(new Vector3(14f, 0, i * 2f)); ins2.source = belt; //ins2.sourcePos = 8f; ins2.target = assem; ins2.expectedItemId = 1; InserterData ins3 = addInserter(new Vector3(18f, 0, i * 2f)); ins3.source = assem; ins3.target = stor; ins3.expectedItemId = 2; SimDataUtility.addPair(gen, ins); SimDataUtility.addInserterToBelt(belt, ins, 0f); SimDataUtility.addInserterToBelt(belt, ins2, 8f); SimDataUtility.addPair(assem, ins2); SimDataUtility.addPair(assem, ins3); SimDataUtility.addPair(stor, ins3); gen.wakeup(); ins.wakeup(); ins2.wakeup(); ins3.wakeup(); assem.wakeup(); belt.wakeup(); } }
public void wakeup() { if (output != null && currentInput != null) { if (output.canInsert() && currentInput.canRemove()) { output.attemptToRemove(expectedItem); currentInput.attemptToInsert(expectedItem); alternate++; alternate %= inputs.Length; currentInput = inputs[alternate]; } } }
public void addStraightBelt(Vector3 fromPos, Vector3 toPos) { BeltData p = new BeltData(); belts.Add(p); GameObject go = GameObject.Instantiate(beltPrefab, (fromPos + toPos) / 2f, Quaternion.identity) as GameObject; Belt comp = go.GetComponent <Belt>(); comp.target = p; beltGO.Add(comp); Vector3[] temp = new Vector3[2]; temp[0] = fromPos; temp[1] = toPos; comp.refreshMesh(temp); }
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(); } } } }
private void Start_parallele() { for (int i = 0; i < line_count; ++i) { ProducerData gen = addGeneratorCheat(new Vector3(0f, 0f, i * 2f), 1, 9999); BeltData belt = addBelt(new Vector3(4f, 0f, i * 2f), new Vector3(12f, 0f, i * 2f)); StorageData stor = addStorage(new Vector3(14f, 0, i * 2f)); InserterData ins = addInserter(new Vector3(2f, 0f, i * 2f)); ins.source = gen; ins.target = belt; //ins.targetPos = 0f; ins.expectedItemId = 1; InserterData ins2 = addInserter(new Vector3(13f, 0, i * 2f)); ins2.source = belt; //ins2.sourcePos = 8f; ins2.target = stor; ins2.expectedItemId = 1; } }