< Summary

Class:SceneData
Assembly:BuilderProjectsPanel
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Scripts/ScenesController/SceneData.cs
Covered lines:41
Uncovered lines:19
Coverable lines:60
Total lines:139
Line coverage:68.3% (41 of 60)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
get_coords()0%110100%
get_size()0%110100%
get_id()0%110100%
get_name()0%110100%
get_thumbnailUrl()0%110100%
get_isOwner()0%110100%
get_isOperator()0%110100%
get_isContributor()0%110100%
get_isDeployed()0%110100%
get_entitiesCount()0%110100%
get_authorThumbnail()0%110100%
get_authorName()0%110100%
get_requiredPermissions()0%110100%
get_isMatureContent()0%110100%
get_allowVoiceChat()0%110100%
get_description()0%110100%
get_contributors()0%2100%
get_admins()0%2100%
get_bannedUsers()0%2100%
get_isEditable()0%110100%
get_parcels()0%110100%
get_projectId()0%2100%
get_isEmpty()0%2100%
get_source()0%2100%
SceneData()0%2100%
SceneData(...)0%13.399062.16%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/HUD/BuilderProjectsPanel/Scripts/ScenesController/SceneData.cs

#LineLine coverage
 1using System;
 2using UnityEngine;
 3
 4internal interface ISceneData
 5{
 6    Vector2Int coords { get; }
 7    Vector2Int size { get; }
 8    string id { get; }
 9    string name { get; }
 10    string thumbnailUrl { get; }
 11    bool isOwner { get; }
 12    bool isOperator { get; }
 13    bool isContributor { get; }
 14    bool isDeployed { get; }
 15    int entitiesCount { get; }
 16    string authorThumbnail { get; }
 17    string authorName { get; }
 18    string[] requiredPermissions { get; }
 19    bool isMatureContent { get; }
 20    bool allowVoiceChat { get; }
 21    string description { get; }
 22    string[] contributors { get; }
 23    string[] admins { get;  }
 24    string[] bannedUsers { get;  }
 25    bool isEditable { get; }
 26    Vector2Int[] parcels { get; }
 27    string projectId { get; }
 28    bool isEmpty { get; }
 29    DeployedScene.Source source { get; }
 30}
 31
 32[Serializable]
 33internal class SceneData : ISceneData
 34{
 35    private const string CONTENT_MATURE_SYMBOL = "M";
 36    private const string CONTENT_ADULTS_ONLY_SYMBOL = "AO";
 37
 38    public Vector2Int coords;
 39    public Vector2Int size;
 40    public string id;
 41    public string name;
 42    public string thumbnailUrl;
 43    public bool isOwner;
 44    public bool isOperator;
 45    public bool isContributor;
 46    public bool isDeployed;
 47    public int entitiesCount;
 48    public string authorThumbnail;
 49    public string authorName;
 50    public string[] requiredPermissions;
 51    public bool isMatureContent;
 52    public bool allowVoiceChat;
 53    public string description;
 54    public string[] contributors;
 55    public string[] admins;
 56    public string[] bannedUsers;
 57    public bool isEditable;
 58    public Vector2Int[] parcels;
 59    public string projectId;
 60    public bool isEmpty;
 61    public DeployedScene.Source source;
 62
 5563    Vector2Int ISceneData.coords => coords;
 12764    Vector2Int ISceneData.size => size;
 22265    string ISceneData.id => id;
 5466    string ISceneData.name => name;
 5367    string ISceneData.thumbnailUrl => thumbnailUrl;
 5168    bool ISceneData.isOwner => isOwner;
 5169    bool ISceneData.isOperator => isOperator;
 5170    bool ISceneData.isContributor => isContributor;
 18571    bool ISceneData.isDeployed => isDeployed;
 272    int ISceneData.entitiesCount => entitiesCount;
 273    string ISceneData.authorThumbnail => authorThumbnail;
 274    string ISceneData.authorName => authorName;
 675    string[] ISceneData.requiredPermissions => requiredPermissions;
 276    bool ISceneData.isMatureContent => isMatureContent;
 277    bool ISceneData.allowVoiceChat => allowVoiceChat;
 378    string ISceneData.description => description;
 079    string[] ISceneData.contributors => contributors;
 080    string[] ISceneData.admins => admins;
 081    string[] ISceneData.bannedUsers => bannedUsers;
 5182    bool ISceneData.isEditable => isEditable;
 5183    Vector2Int[] ISceneData.parcels => parcels;
 084    string ISceneData.projectId => projectId;
 085    bool ISceneData.isEmpty => isEmpty;
 086    DeployedScene.Source ISceneData.source => source;
 87
 088    public SceneData() { }
 89
 190    public SceneData(DeployedScene deployedScene)
 91    {
 192        coords = deployedScene.@base;
 193        id = deployedScene.id;
 194        name = deployedScene.title;
 195        description = deployedScene.description;
 196        thumbnailUrl = deployedScene.navmapThumbnail;
 197        isOwner = deployedScene?.land?.role == LandRole.OWNER;
 198        isOperator = !isOwner;
 199        isContributor = false;
 1100        isDeployed = true;
 1101        authorName = deployedScene.author;
 1102        requiredPermissions = deployedScene.requiredPermissions;
 1103        bannedUsers = deployedScene.bannedUsers;
 1104        isEditable = deployedScene.source != DeployedScene.Source.SDK;
 1105        parcels = deployedScene.parcels;
 1106        projectId = deployedScene.projectId;
 1107        isEmpty = deployedScene.isEmpty;
 1108        source = deployedScene.source;
 109
 1110        isMatureContent = false;
 1111        if (!string.IsNullOrEmpty(deployedScene.contentRating))
 112        {
 0113            isMatureContent = deployedScene.contentRating.Equals(CONTENT_MATURE_SYMBOL, StringComparison.OrdinalIgnoreCa
 114                              || deployedScene.contentRating.Equals(CONTENT_ADULTS_ONLY_SYMBOL, StringComparison.Ordinal
 115        }
 116
 1117        if (deployedScene.parcels.Length < 2)
 118        {
 1119            size = new Vector2Int(1, 1);
 1120        }
 121        else
 122        {
 0123            int minX = deployedScene.parcels[0].x;
 0124            int maxX = deployedScene.parcels[0].x;
 0125            int minY = deployedScene.parcels[0].y;
 0126            int maxY = deployedScene.parcels[0].y;
 127
 0128            for (int i = 1; i < deployedScene.parcels.Length; i++)
 129            {
 0130                minX = Mathf.Min(minX, deployedScene.parcels[i].x);
 0131                minY = Mathf.Min(minY, deployedScene.parcels[i].y);
 0132                maxX = Mathf.Max(maxX, deployedScene.parcels[i].x);
 0133                maxY = Mathf.Max(maxY, deployedScene.parcels[i].y);
 134            }
 135
 0136            size = new Vector2Int(Mathf.Abs(maxX - minX), Mathf.Abs(maxY - minY));
 137        }
 0138    }
 139}