IEnumerator constructAll(List <Service> services, List <IslandGO> islandGOs)
        {
            Dictionary <ServiceSlice, List <Service> > serviceSliceMap = distributeServicesToSlices(services);

            foreach (KeyValuePair <ServiceSlice, List <Service> > kvp in serviceSliceMap)
            {
                constructServicesAndComponents(kvp.Value, kvp.Key);
                yield return(null);
            }

            foreach (IslandGO islandGO in islandGOs)
            {
                if (islandGO == null)
                {
                    continue;
                }
                else
                {
                    if (!islandGO.isIslandEmpty())
                    {
                        foreach (Region region in islandGO.getRegions())
                        {
                            foreach (Building b in region.getBuildings())
                            {
                                ServiceLayerGO serviceLayer = b.GetComponent <ServiceLayerGO>();
                                if (serviceLayer != null)
                                {
                                    serviceLayer.createDownwardConnections();

                                    List <ServiceNodeScript> snsList = serviceLayer.getServiceNodes();
                                    foreach (ServiceNodeScript sns in snsList)
                                    {
                                        sns.constructServiceConnections();
                                    }
                                }
                            }
                        }
                    }
                }
            }


            Debug.Log("Finished with Service-GameObject construction!");
            status = Status.Finished;
            cb();
        }
        IEnumerator constructAll(List <Service> services, List <Island> Islands)
        {
            Dictionary <ServiceSlice, List <Service> > serviceSliceMap = distributeServicesToSlices(services);

            foreach (KeyValuePair <ServiceSlice, List <Service> > kvp in serviceSliceMap)
            {
                constructServicesAndComponents(kvp.Value, kvp.Key);
                yield return(null);
            }

            foreach (Island Island in Islands)
            {
                if (Island == null)
                {
                    continue;
                }
                else
                {
                    if (!Island.IsIslandEmpty())
                    {
                        foreach (Region region in Island.Regions)
                        {
                            foreach (Building b in region.Buildings)
                            {
                                ServiceLayerGO serviceLayer = b.GetComponent <ServiceLayerGO>();
                                if (serviceLayer != null)
                                {
                                    serviceLayer.createDownwardConnections();

                                    List <ServiceNodeScript> snsList = serviceLayer.getServiceNodes();
                                    foreach (ServiceNodeScript sns in snsList)
                                    {
                                        sns.constructServiceConnections();
                                    }
                                }
                            }
                        }
                    }
                }
            }
            ServiceGameObjectsBuilt(new ServiceGameObjectsBuiltEventArgs(Islands));
        }
        private void constructServicesAndComponents(List <Service> services, ServiceSlice serviceSlice)
        {
            foreach (Service service in services)
            {
                CompilationUnit serviceCU = service.getServiceCU();
                if (serviceCU != null && serviceCU.getGameObject() != null)
                {
                    GameObject serviceGO = Instantiate(interfacePrefab, transform.position, Quaternion.identity);
                    serviceGO.layer = LayerMask.NameToLayer("InteractionSystemLayer");
                    serviceGO.name  = service.getName();
                    Vector3 cuPosition = serviceCU.getGameObject().transform.position;
                    cuPosition.y = 0f;
                    serviceGO.transform.position   = cuPosition + new Vector3(0f, serviceSlice.height, 0f);
                    serviceGO.transform.localScale = new Vector3(GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize);
                    serviceGO.transform.SetParent(serviceSlice.transform);
                    ServiceNodeScript sns = serviceGO.AddComponent <ServiceNodeScript>();
                    serviceGO.AddComponent <TextLabelComponent>();
                    ServiceLayerGO slGO = serviceCU.getGameObject().GetComponent <ServiceLayerGO>();
                    slGO.addServiceNode(sns);
                    #region construct ServiceComponents
                    List <ServiceComponent> implementingComponents = service.getImplementingComponents();
                    List <ServiceComponent> referencingComponents  = service.getReferencingComponents();
                    foreach (ServiceComponent sc in implementingComponents)
                    {
                        CompilationUnit componentCU = sc.getImplementationCU();
                        GameObject      scGO        = Instantiate(implementationPrefab, transform.position, Quaternion.identity);
                        scGO.layer                = LayerMask.NameToLayer("InteractionSystemLayer");
                        scGO.name                 = sc.getName();
                        cuPosition                = componentCU.getGameObject().transform.position;
                        cuPosition.y              = 0f;
                        scGO.transform.position   = cuPosition + new Vector3(0f, serviceSlice.height, 0f);
                        scGO.transform.localScale = new Vector3(GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize);
                        scGO.transform.SetParent(serviceSlice.transform);
                        ServiceNodeScript scGOcomponent = scGO.AddComponent <ServiceNodeScript>();
                        scGO.AddComponent <TextLabelComponent>();
                        scGOcomponent.addConnectedServiceNode(sns);
                        sns.addConnectedServiceNode(scGOcomponent);
                        scGOcomponent.disableServiceNode();
                        ServiceLayerGO sl = componentCU.getGameObject().GetComponent <ServiceLayerGO>();
                        sl.addServiceNode(scGOcomponent);
                    }
                    foreach (ServiceComponent sc in referencingComponents)
                    {
                        CompilationUnit componentCU = sc.getImplementationCU();
                        GameObject      scGO        = Instantiate(referencePrefab, transform.position, Quaternion.identity);
                        scGO.layer                = LayerMask.NameToLayer("InteractionSystemLayer");
                        scGO.name                 = sc.getName();
                        cuPosition                = componentCU.getGameObject().transform.position;
                        cuPosition.y              = 0f;
                        scGO.transform.position   = cuPosition + new Vector3(0f, serviceSlice.height, 0f);
                        scGO.transform.localScale = new Vector3(GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize, GlobalVar.serviceNodeSize);
                        scGO.transform.SetParent(serviceSlice.transform);
                        ServiceNodeScript scGOcomponent = scGO.AddComponent <ServiceNodeScript>();
                        scGO.AddComponent <TextLabelComponent>();
                        scGOcomponent.addConnectedServiceNode(sns);
                        sns.addConnectedServiceNode(scGOcomponent);

                        scGOcomponent.disableServiceNode();
                        ServiceLayerGO sl = componentCU.getGameObject().GetComponent <ServiceLayerGO>();
                        sl.addServiceNode(scGOcomponent);
                    }
                    #endregion
                    sns.disableServiceNode();
                }
            }
        }