| | 1 | | using DCL.Helpers; |
| | 2 | | using DCL.Helpers.NFT; |
| | 3 | | using System.Collections; |
| | 4 | | using System.Collections.Generic; |
| | 5 | | using System.IO; |
| | 6 | | using System.Runtime.Serialization.Formatters.Binary; |
| | 7 | | using DCL.Components; |
| | 8 | | using DCL.Controllers; |
| | 9 | | using DCL.Models; |
| | 10 | | using UnityEngine; |
| | 11 | | using UnityEngine.UI; |
| | 12 | |
|
| | 13 | | public static class BuilderInWorldTestHelper |
| | 14 | | { |
| | 15 | | public static DCLBuilderInWorldEntity CreateSmartItemEntity(BuilderInWorldEntityHandler entityHandler, ParcelScene s |
| | 16 | | { |
| 1 | 17 | | if (model == null) |
| 1 | 18 | | model = new SmartItemComponent.Model(); |
| | 19 | |
|
| 1 | 20 | | DCLBuilderInWorldEntity entity = entityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero); |
| | 21 | |
|
| 1 | 22 | | scene.EntityComponentCreateOrUpdateWithModel(entity.rootEntity.entityId, CLASS_ID_COMPONENT.SMART_ITEM, model); |
| | 23 | |
|
| 1 | 24 | | return entity; |
| | 25 | | } |
| | 26 | |
|
| | 27 | | public static CatalogItemAdapter CreateCatalogItemAdapter(GameObject gameObject) |
| | 28 | | { |
| 1 | 29 | | CatalogItemAdapter adapter = Utils.GetOrCreateComponent<CatalogItemAdapter>(gameObject); |
| 1 | 30 | | adapter.onFavoriteColor = Color.white; |
| 1 | 31 | | adapter.offFavoriteColor = Color.white; |
| 1 | 32 | | adapter.favImg = Utils.GetOrCreateComponent<Image>(gameObject); |
| 1 | 33 | | adapter.smartItemGO = gameObject; |
| 1 | 34 | | adapter.lockedGO = gameObject; |
| 1 | 35 | | adapter.canvasGroup = Utils.GetOrCreateComponent<CanvasGroup>(gameObject); |
| | 36 | |
|
| 1 | 37 | | GameObject newGameObject = new GameObject(); |
| 1 | 38 | | newGameObject.transform.SetParent(gameObject.transform); |
| 1 | 39 | | adapter.thumbnailImg = Utils.GetOrCreateComponent<RawImage>(newGameObject); |
| 1 | 40 | | return adapter; |
| | 41 | | } |
| | 42 | |
|
| | 43 | | public static void CreateTestCatalogLocalMultipleFloorObjects() |
| | 44 | | { |
| 4 | 45 | | AssetCatalogBridge.i.ClearCatalog(); |
| 4 | 46 | | string jsonPath = TestAssetsUtils.GetPathRaw() + "/BuilderInWorldCatalog/multipleSceneObjectsCatalog.json"; |
| | 47 | |
|
| 4 | 48 | | if (File.Exists(jsonPath)) |
| | 49 | | { |
| 4 | 50 | | string jsonValue = File.ReadAllText(jsonPath); |
| 4 | 51 | | AssetCatalogBridge.i.AddFullSceneObjectCatalog(jsonValue); |
| | 52 | | } |
| 4 | 53 | | } |
| | 54 | |
|
| | 55 | | public static void CreateTestCatalogLocalSingleObject() |
| | 56 | | { |
| 17 | 57 | | AssetCatalogBridge.i.ClearCatalog(); |
| 17 | 58 | | string jsonPath = TestAssetsUtils.GetPathRaw() + "/BuilderInWorldCatalog/sceneObjectCatalog.json"; |
| | 59 | |
|
| 17 | 60 | | if (File.Exists(jsonPath)) |
| | 61 | | { |
| 17 | 62 | | string jsonValue = File.ReadAllText(jsonPath); |
| 17 | 63 | | AssetCatalogBridge.i.AddFullSceneObjectCatalog(jsonValue); |
| | 64 | | } |
| 17 | 65 | | } |
| | 66 | |
|
| | 67 | | public static void CreateTestSmartItemCatalogLocalSingleObject() |
| | 68 | | { |
| 1 | 69 | | AssetCatalogBridge.i.ClearCatalog(); |
| 1 | 70 | | string jsonPath = TestAssetsUtils.GetPathRaw() + "/BuilderInWorldCatalog/smartItemSceneObjectCatalog.json"; |
| | 71 | |
|
| 1 | 72 | | if (File.Exists(jsonPath)) |
| | 73 | | { |
| 1 | 74 | | string jsonValue = File.ReadAllText(jsonPath); |
| 1 | 75 | | AssetCatalogBridge.i.AddFullSceneObjectCatalog(jsonValue); |
| | 76 | | } |
| 1 | 77 | | } |
| | 78 | |
|
| | 79 | | public static void CreateNFT() |
| | 80 | | { |
| 3 | 81 | | string jsonPath = TestAssetsUtils.GetPathRaw() + "/BuilderInWorldCatalog/nftAsset.json"; |
| | 82 | |
|
| 3 | 83 | | if (File.Exists(jsonPath)) |
| | 84 | | { |
| 3 | 85 | | string jsonValue = File.ReadAllText(jsonPath); |
| 3 | 86 | | NFTOwner owner = NFTOwner.defaultNFTOwner; |
| 3 | 87 | | owner.assets.Add(JsonUtility.FromJson<NFTInfo>(jsonValue)); |
| 3 | 88 | | BuilderInWorldNFTController.i.NftsFeteched(owner); |
| | 89 | | } |
| 3 | 90 | | } |
| | 91 | | } |