| | 1 | | using System; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | internal 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] |
| | 33 | | internal 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 | |
|
| 55 | 63 | | Vector2Int ISceneData.coords => coords; |
| 127 | 64 | | Vector2Int ISceneData.size => size; |
| 222 | 65 | | string ISceneData.id => id; |
| 54 | 66 | | string ISceneData.name => name; |
| 53 | 67 | | string ISceneData.thumbnailUrl => thumbnailUrl; |
| 51 | 68 | | bool ISceneData.isOwner => isOwner; |
| 51 | 69 | | bool ISceneData.isOperator => isOperator; |
| 51 | 70 | | bool ISceneData.isContributor => isContributor; |
| 185 | 71 | | bool ISceneData.isDeployed => isDeployed; |
| 2 | 72 | | int ISceneData.entitiesCount => entitiesCount; |
| 2 | 73 | | string ISceneData.authorThumbnail => authorThumbnail; |
| 2 | 74 | | string ISceneData.authorName => authorName; |
| 6 | 75 | | string[] ISceneData.requiredPermissions => requiredPermissions; |
| 2 | 76 | | bool ISceneData.isMatureContent => isMatureContent; |
| 2 | 77 | | bool ISceneData.allowVoiceChat => allowVoiceChat; |
| 3 | 78 | | string ISceneData.description => description; |
| 0 | 79 | | string[] ISceneData.contributors => contributors; |
| 0 | 80 | | string[] ISceneData.admins => admins; |
| 0 | 81 | | string[] ISceneData.bannedUsers => bannedUsers; |
| 51 | 82 | | bool ISceneData.isEditable => isEditable; |
| 51 | 83 | | Vector2Int[] ISceneData.parcels => parcels; |
| 0 | 84 | | string ISceneData.projectId => projectId; |
| 0 | 85 | | bool ISceneData.isEmpty => isEmpty; |
| 0 | 86 | | DeployedScene.Source ISceneData.source => source; |
| | 87 | |
|
| 0 | 88 | | public SceneData() { } |
| | 89 | |
|
| 1 | 90 | | public SceneData(DeployedScene deployedScene) |
| | 91 | | { |
| 1 | 92 | | coords = deployedScene.@base; |
| 1 | 93 | | id = deployedScene.id; |
| 1 | 94 | | name = deployedScene.title; |
| 1 | 95 | | description = deployedScene.description; |
| 1 | 96 | | thumbnailUrl = deployedScene.navmapThumbnail; |
| 1 | 97 | | isOwner = deployedScene?.land?.role == LandRole.OWNER; |
| 1 | 98 | | isOperator = !isOwner; |
| 1 | 99 | | isContributor = false; |
| 1 | 100 | | isDeployed = true; |
| 1 | 101 | | authorName = deployedScene.author; |
| 1 | 102 | | requiredPermissions = deployedScene.requiredPermissions; |
| 1 | 103 | | bannedUsers = deployedScene.bannedUsers; |
| 1 | 104 | | isEditable = deployedScene.source != DeployedScene.Source.SDK; |
| 1 | 105 | | parcels = deployedScene.parcels; |
| 1 | 106 | | projectId = deployedScene.projectId; |
| 1 | 107 | | isEmpty = deployedScene.isEmpty; |
| 1 | 108 | | source = deployedScene.source; |
| | 109 | |
|
| 1 | 110 | | isMatureContent = false; |
| 1 | 111 | | if (!string.IsNullOrEmpty(deployedScene.contentRating)) |
| | 112 | | { |
| 0 | 113 | | isMatureContent = deployedScene.contentRating.Equals(CONTENT_MATURE_SYMBOL, StringComparison.OrdinalIgnoreCa |
| | 114 | | || deployedScene.contentRating.Equals(CONTENT_ADULTS_ONLY_SYMBOL, StringComparison.Ordinal |
| | 115 | | } |
| | 116 | |
|
| 1 | 117 | | if (deployedScene.parcels.Length < 2) |
| | 118 | | { |
| 1 | 119 | | size = new Vector2Int(1, 1); |
| 1 | 120 | | } |
| | 121 | | else |
| | 122 | | { |
| 0 | 123 | | int minX = deployedScene.parcels[0].x; |
| 0 | 124 | | int maxX = deployedScene.parcels[0].x; |
| 0 | 125 | | int minY = deployedScene.parcels[0].y; |
| 0 | 126 | | int maxY = deployedScene.parcels[0].y; |
| | 127 | |
|
| 0 | 128 | | for (int i = 1; i < deployedScene.parcels.Length; i++) |
| | 129 | | { |
| 0 | 130 | | minX = Mathf.Min(minX, deployedScene.parcels[i].x); |
| 0 | 131 | | minY = Mathf.Min(minY, deployedScene.parcels[i].y); |
| 0 | 132 | | maxX = Mathf.Max(maxX, deployedScene.parcels[i].x); |
| 0 | 133 | | maxY = Mathf.Max(maxY, deployedScene.parcels[i].y); |
| | 134 | | } |
| | 135 | |
|
| 0 | 136 | | size = new Vector2Int(Mathf.Abs(maxX - minX), Mathf.Abs(maxY - minY)); |
| | 137 | | } |
| 0 | 138 | | } |
| | 139 | | } |