[ClientRpc] private void RpcSetupAreaInstallation(NetworkIdentity segNetId, NetworkIdentity installationNetId, int corridorId, int segmentId, int dir)
    {
        GameObject wallObj                   = segNetId.gameObject.transform.Find("Wall" + dir.ToString()).gameObject;
        GameObject installationObj           = installationNetId.gameObject;
        AreaSegmentInstallation installation = currentArea.corridors[corridorId].segments[segmentId].installations[dir];

        installationObj.transform.SetParent(wallObj.transform);
        installationObj.transform.localPosition = new Vector3(0, 0, -1);
        switch (installation.type)
        {
        case "door":
            installationObj.AddComponent <DoorInstallation>();
            installationObj.GetComponent <DoorInstallation>().attachedWall     = wallObj;
            installationObj.GetComponent <DoorInstallation>().installationName = installation.name;
            installationObj.GetComponent <SpriteRenderer>().sprite             = currentArea.tileset.doorSprites[dir];
            installationObj.GetComponent <DoorInstallation>().directionId      = dir;
            break;

        case "interactive":
            installationObj.AddComponent <InteractiveInstallation>();
            installationObj.GetComponent <InteractiveInstallation>().attachedWall         = wallObj;
            installationObj.GetComponent <InteractiveInstallation>().installationName     = installation.name;
            installationObj.GetComponent <InteractiveInstallation>().interfaceOverlayName = installation.overlayName;
            installationObj.GetComponent <SpriteRenderer>().sprite = currentArea.tileset.getInstallationSprite(installation.name, dir);
            break;
        }
    }
    public void SpawnArea()
    {
        Area area = currentArea;

        RpcSpawnArea(area.starship.index);
        foreach (AreaCorridor corridor in area.corridors)
        {
            RpcSpawnCorridor(corridor.x, corridor.y, corridor.segments.Count);
            foreach (AreaSegment segment in corridor.segments)
            {
                RpcSpawnSegment(corridor.index, segment.index, segment.netId);
                for (int i = 0; i < 4; i++)
                {
                    AreaSegmentInstallation inst = segment.installations[i];
                    if (inst != null)
                    {
                        RpcSpawnInstallation(corridor.index, segment.index, i, inst.type, inst.name, inst.netId);
                    }
                    AreaSegmentWall wall = segment.walls[i];
                    if (wall != null)
                    {
                        //RpcSpawnWall(corridor.index, segment.index, i);
                    }
                }
            }
        }
    }
    public void SpawnAreaObject()
    {
        GameObject areaObj = currentAreaObj;

        NetworkServer.Spawn(areaObj);
        for (int i = 0; i < currentArea.corridors.Count; i++)
        {
            AreaCorridor corridor = currentArea.corridors[i];
            for (int j = 0; j < corridor.segments.Count; j++)
            {
                AreaSegment seg             = corridor.segments[j];
                Vector3     segmentLocation = new Vector3(seg.x * segmentWidth, -1 * seg.y * segmentHeight, 0);
                NetworkServer.Spawn(seg.netId.gameObject);
                RpcSetupAreaSegment(areaObj.GetComponent <NetworkIdentity>(), seg.netId, corridor.index, seg.index, segmentLocation);
                for (int k = 0; k < 4; k++)
                {
                    if (seg.walls[k] != null)
                    {
                        AreaSegmentInstallation installation = seg.installations[k];
                        if (installation != null)
                        {
                            NetworkServer.Spawn(installation.netId.gameObject);
                            RpcSetupAreaInstallation(seg.netId, installation.netId, corridor.index, seg.index, k);
                        }
                    }
                }
            }
        }
    }
    public GameObject GenerateAreaObject()
    {
        Area       area    = currentArea;
        GameObject areaObj = GameObject.Instantiate <GameObject>(areaObject);

        if (area.isStarship)
        {
            areaObj.transform.Find("Sky").gameObject.GetComponent <SpriteRenderer>().sprite = spaceSkySprites[area.starship.currentSector.skySpriteIndex];
        }
        for (int i = 0; i < area.corridors.Count; i++)
        {
            AreaCorridor corridor = area.corridors[i];
            for (int j = 0; j < corridor.segments.Count; j++)
            {
                AreaSegment seg             = corridor.segments[j];
                Vector3     segmentLocation = new Vector3(seg.x * segmentWidth, -1 * seg.y * segmentHeight, 0);
                GameObject  areaSegment     = GameObject.Instantiate <GameObject>(segmentObject);
                seg.netId = areaSegment.GetComponent <NetworkIdentity>();
                areaSegment.transform.SetParent(areaObj.transform);
                areaSegment.transform.localPosition = segmentLocation;
                for (int k = 0; k < 4; k++)
                {
                    GameObject installationObj;
                    GameObject wallObj = areaSegment.transform.Find("Wall" + k.ToString()).gameObject;
                    if (seg.walls[k] == null)
                    {
                        GameObject.Destroy(wallObj);
                    }
                    else
                    {
                        area.tileset.setWallSprite(wallObj, seg.walls[k]);
                        AreaSegmentInstallation installation = seg.installations[k];
                        if (installation != null)
                        {
                            installationObj    = GameObject.Instantiate(installationPrefabs[k]);
                            installation.netId = installationObj.GetComponent <NetworkIdentity>();
                            installationObj.transform.SetParent(wallObj.transform);
                            installationObj.transform.localPosition = new Vector3(0, 0, -1);
                            switch (installation.type)
                            {
                            case "door":
                                installationObj.AddComponent <DoorInstallation>();
                                installationObj.GetComponent <DoorInstallation>().attachedWall     = wallObj;
                                installationObj.GetComponent <DoorInstallation>().installationName = installation.name;
                                installationObj.GetComponent <SpriteRenderer>().sprite             = area.tileset.doorSprites[k];
                                installationObj.GetComponent <DoorInstallation>().directionId      = k;
                                break;

                            case "interactive":
                                installationObj.AddComponent <InteractiveInstallation>();
                                installationObj.GetComponent <InteractiveInstallation>().attachedWall         = wallObj;
                                installationObj.GetComponent <InteractiveInstallation>().installationName     = installation.name;
                                installationObj.GetComponent <InteractiveInstallation>().interfaceOverlayName = installation.overlayName;
                                installationObj.GetComponent <SpriteRenderer>().sprite = area.tileset.getInstallationSprite(installation.name, k);
                                break;
                            }
                        }
                    }
                }
            }
        }
        return(areaObj);
    }