void InitializeHologram() { instance = MachineVisual.Create(machineInfo, transform); Renderer[] machineRenderers = instance.machineRenderers; for (int i = 0, len = machineRenderers.Length; i < len; ++i) { Renderer machineRenderer = machineRenderers[i]; machineRenderer.sharedMaterial = hologramMaterial; machineRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; } instance.categoryRenderer.enabled = false; instance.textRenderer.enabled = false; }
public void Initialize() { transform.localPosition = bounds.min; if (machineInfo.prefab) { instance = MachineVisual.Create(machineInfo, transform); } else { GameObject instanceGameObject = GameObject.CreatePrimitive(PrimitiveType.Cube); instance = instanceGameObject.AddComponent <MachineVisual>(); instance.transform.SetParent(transform, false); Destroy(instance.GetComponent <BoxCollider>()); Transform instanceTransform = instance.transform; instanceTransform.localPosition = (Vector3)machineInfo.size * 0.5f; instanceTransform.localScale = machineInfo.size; } gameObject.SetAllLayers(Layer.machines); inventory = Inventory.CreateInventory(machineInfo); if (machineInfo.purchaseItem.itemInfo != null) { canOutput = true; machinePurchaser = gameObject.AddComponent <MachinePurchaser>(); machinePurchaser.machine = this; if (!machinePlacer) { machinePlacer = gameObject.AddComponent <MachinePlacer>(); machinePlacer.machine = this; } } if (machineInfo.sellItem.itemInfo != null) { canInput = true; machineSeller = gameObject.AddComponent <MachineSeller>(); machineSeller.machine = this; } if (machineInfo.assembler) { canInput = true; canOutput = true; machineAssembler = gameObject.AddComponent <MachineAssembler>(); machineAssembler.machine = this; if (!machinePlacer) { machinePlacer = gameObject.AddComponent <MachinePlacer>(); machinePlacer.machine = this; } } if (machinePurchaser) { machinePurchaser.Initialize(); } if (machineSeller) { machineSeller.Initialize(); } if (machineAssembler) { machineAssembler.Initialize(); } if (machinePlacer) { machinePlacer.Initialize(); } Dictionary <Vector3Int, Conveyor> conveyors = ConveyorSystem.instance.conveyors; for (int x = bounds.min.x, lenx = bounds.max.x; x <= lenx; ++x) { for (int y = bounds.min.y, leny = bounds.max.y; y <= leny; ++y) { for (int z = bounds.min.z, lenz = bounds.max.z; z <= lenz; ++z) { if (conveyors.TryGetValue(new Vector3Int(x, y, z), out Conveyor conveyor)) { conveyor.LinkMachine(this); } } } } FindConveyors(); RecycleInvalidConveyors(); }