| | 1 | | using System; |
| | 2 | | using DCL.Builder; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL.Builder |
| | 6 | | { |
| | 7 | | internal interface ISceneData |
| | 8 | | { |
| | 9 | | Vector2Int coords { get; } |
| | 10 | | Vector2Int size { get; } |
| | 11 | | string id { get; } |
| | 12 | | string name { get; } |
| | 13 | | string thumbnailUrl { get; } |
| | 14 | | bool isOwner { get; } |
| | 15 | | bool isOperator { get; } |
| | 16 | | bool isContributor { get; } |
| | 17 | | bool isDeployed { get; } |
| | 18 | | int entitiesCount { get; } |
| | 19 | | string authorThumbnail { get; } |
| | 20 | | string authorName { get; } |
| | 21 | | string[] requiredPermissions { get; } |
| | 22 | | bool isMatureContent { get; } |
| | 23 | | bool allowVoiceChat { get; } |
| | 24 | | string description { get; } |
| | 25 | | string[] contributors { get; } |
| | 26 | | string[] admins { get; } |
| | 27 | | string[] bannedUsers { get; } |
| | 28 | | bool isEditable { get; } |
| | 29 | | Vector2Int[] parcels { get; } |
| | 30 | | string projectId { get; } |
| | 31 | | bool isEmpty { get; } |
| | 32 | | Scene.Source source { get; } |
| | 33 | | } |
| | 34 | |
|
| | 35 | | [Serializable] |
| | 36 | | internal class SceneData : ISceneData |
| | 37 | | { |
| | 38 | | private const string CONTENT_MATURE_SYMBOL = "M"; |
| | 39 | | private const string CONTENT_ADULTS_ONLY_SYMBOL = "AO"; |
| | 40 | |
|
| | 41 | | public Vector2Int coords; |
| | 42 | | public Vector2Int size; |
| | 43 | | public string id; |
| | 44 | | public string name; |
| | 45 | | public string thumbnailUrl; |
| | 46 | | public bool isOwner; |
| | 47 | | public bool isOperator; |
| | 48 | | public bool isContributor; |
| | 49 | | public bool isDeployed; |
| | 50 | | public int entitiesCount; |
| | 51 | | public string authorThumbnail; |
| | 52 | | public string authorName; |
| | 53 | | public string[] requiredPermissions; |
| | 54 | | public bool isMatureContent; |
| | 55 | | public bool allowVoiceChat; |
| | 56 | | public string description; |
| | 57 | | public string[] contributors; |
| | 58 | | public string[] admins; |
| | 59 | | public string[] bannedUsers; |
| | 60 | | public bool isEditable; |
| | 61 | | public Vector2Int[] parcels; |
| | 62 | | public string projectId; |
| | 63 | | public bool isEmpty; |
| | 64 | | public Scene.Source source; |
| | 65 | |
|
| 29 | 66 | | Vector2Int ISceneData.coords => coords; |
| 65 | 67 | | Vector2Int ISceneData.size => size; |
| 85 | 68 | | string ISceneData.id => id; |
| 28 | 69 | | string ISceneData.name => name; |
| 27 | 70 | | string ISceneData.thumbnailUrl => thumbnailUrl; |
| 25 | 71 | | bool ISceneData.isOwner => isOwner; |
| 25 | 72 | | bool ISceneData.isOperator => isOperator; |
| 25 | 73 | | bool ISceneData.isContributor => isContributor; |
| 85 | 74 | | bool ISceneData.isDeployed => isDeployed; |
| 2 | 75 | | int ISceneData.entitiesCount => entitiesCount; |
| 2 | 76 | | string ISceneData.authorThumbnail => authorThumbnail; |
| 2 | 77 | | string ISceneData.authorName => authorName; |
| 6 | 78 | | string[] ISceneData.requiredPermissions => requiredPermissions; |
| 2 | 79 | | bool ISceneData.isMatureContent => isMatureContent; |
| 2 | 80 | | bool ISceneData.allowVoiceChat => allowVoiceChat; |
| 3 | 81 | | string ISceneData.description => description; |
| 0 | 82 | | string[] ISceneData.contributors => contributors; |
| 0 | 83 | | string[] ISceneData.admins => admins; |
| 0 | 84 | | string[] ISceneData.bannedUsers => bannedUsers; |
| 25 | 85 | | bool ISceneData.isEditable => isEditable; |
| 25 | 86 | | Vector2Int[] ISceneData.parcels => parcels; |
| 0 | 87 | | string ISceneData.projectId => projectId; |
| 0 | 88 | | bool ISceneData.isEmpty => isEmpty; |
| 0 | 89 | | Scene.Source ISceneData.source => source; |
| | 90 | |
|
| 0 | 91 | | public SceneData() { } |
| | 92 | |
|
| 1 | 93 | | public SceneData(Scene scene) |
| | 94 | | { |
| 1 | 95 | | coords = scene.@base; |
| 1 | 96 | | id = scene.id; |
| 1 | 97 | | name = scene.title; |
| 1 | 98 | | description = scene.description; |
| 1 | 99 | | thumbnailUrl = scene.navmapThumbnail; |
| 1 | 100 | | isOwner = scene?.land?.role == LandRole.OWNER; |
| 1 | 101 | | isOperator = !isOwner; |
| 1 | 102 | | isContributor = false; |
| 1 | 103 | | isDeployed = true; |
| 1 | 104 | | authorName = scene.author; |
| 1 | 105 | | requiredPermissions = scene.requiredPermissions; |
| 1 | 106 | | bannedUsers = scene.bannedUsers; |
| 1 | 107 | | isEditable = scene.source != Scene.Source.SDK; |
| 1 | 108 | | parcels = scene.parcels; |
| 1 | 109 | | projectId = scene.projectId; |
| 1 | 110 | | isEmpty = scene.isEmpty; |
| 1 | 111 | | source = scene.source; |
| | 112 | |
|
| 1 | 113 | | isMatureContent = false; |
| 1 | 114 | | if (!string.IsNullOrEmpty(scene.contentRating)) |
| | 115 | | { |
| 0 | 116 | | isMatureContent = scene.contentRating.Equals(CONTENT_MATURE_SYMBOL, StringComparison.OrdinalIgnoreCase) |
| | 117 | | || scene.contentRating.Equals(CONTENT_ADULTS_ONLY_SYMBOL, StringComparison.OrdinalIgno |
| | 118 | | } |
| | 119 | |
|
| 1 | 120 | | if (scene.parcels.Length < 2) |
| | 121 | | { |
| 1 | 122 | | size = new Vector2Int(1, 1); |
| 1 | 123 | | } |
| | 124 | | else |
| | 125 | | { |
| 0 | 126 | | int minX = scene.parcels[0].x; |
| 0 | 127 | | int maxX = scene.parcels[0].x; |
| 0 | 128 | | int minY = scene.parcels[0].y; |
| 0 | 129 | | int maxY = scene.parcels[0].y; |
| | 130 | |
|
| 0 | 131 | | for (int i = 1; i < scene.parcels.Length; i++) |
| | 132 | | { |
| 0 | 133 | | minX = Mathf.Min(minX, scene.parcels[i].x); |
| 0 | 134 | | minY = Mathf.Min(minY, scene.parcels[i].y); |
| 0 | 135 | | maxX = Mathf.Max(maxX, scene.parcels[i].x); |
| 0 | 136 | | maxY = Mathf.Max(maxY, scene.parcels[i].y); |
| | 137 | | } |
| | 138 | |
|
| 0 | 139 | | size = new Vector2Int(Mathf.Abs(maxX - minX), Mathf.Abs(maxY - minY)); |
| | 140 | | } |
| 0 | 141 | | } |
| | 142 | | } |
| | 143 | | } |