Beispiel #1
0
    public SceneData(DeployedScene deployedScene)
    {
        coords              = deployedScene.@base;
        id                  = deployedScene.id;
        name                = deployedScene.title;
        description         = deployedScene.description;
        thumbnailUrl        = deployedScene.navmapThumbnail;
        isOwner             = deployedScene?.land.role == LandRole.OWNER;
        isOperator          = !isOwner;
        isContributor       = false;
        isDeployed          = true;
        authorName          = deployedScene.author;
        requiredPermissions = deployedScene.requiredPermissions;
        bannedUsers         = deployedScene.bannedUsers;
        isEditable          = deployedScene.source != DeployedScene.Source.SDK;
        parcels             = deployedScene.parcels;
        projectId           = deployedScene.projectId;
        isEmpty             = deployedScene.isEmpty;
        source              = deployedScene.source;

        isMatureContent = false;
        if (!string.IsNullOrEmpty(deployedScene.contentRating))
        {
            isMatureContent = deployedScene.contentRating.Equals(CONTENT_MATURE_SYMBOL, StringComparison.OrdinalIgnoreCase) ||
                              deployedScene.contentRating.Equals(CONTENT_ADULTS_ONLY_SYMBOL, StringComparison.OrdinalIgnoreCase);
        }

        if (deployedScene.parcels.Length < 2)
        {
            size = new Vector2Int(1, 1);
        }
        else
        {
            int minX = deployedScene.parcels[0].x;
            int maxX = deployedScene.parcels[0].x;
            int minY = deployedScene.parcels[0].y;
            int maxY = deployedScene.parcels[0].y;

            for (int i = 1; i < deployedScene.parcels.Length; i++)
            {
                minX = Mathf.Min(minX, deployedScene.parcels[i].x);
                minY = Mathf.Min(minY, deployedScene.parcels[i].y);
                maxX = Mathf.Max(maxX, deployedScene.parcels[i].x);
                maxY = Mathf.Max(maxY, deployedScene.parcels[i].y);
            }

            size = new Vector2Int(Mathf.Abs(maxX - minX), Mathf.Abs(maxY - minY));
        }
    }
    private static LandWithAccess ProcessLand(Land land, DeployedScene[] scenes)
    {
        List <DeployedScene> scenesInLand = new List <DeployedScene>();

        LandWithAccess result = new LandWithAccess(land);

        for (int i = 0; i < result.parcels.Length; i++)
        {
            DeployedScene sceneInParcel = scenes.FirstOrDefault(scene => scene.parcels.Contains(result.parcels[i]) && !scenesInLand.Contains(scene));
            if (sceneInParcel != null)
            {
                sceneInParcel.sceneLand = result;
                scenesInLand.Add(sceneInParcel);
            }
        }

        result.scenes = scenesInLand;

        return(result);
    }