| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using DCL.Components; |
| | 5 | | using DCL.Controllers; |
| | 6 | | using DCL.Models; |
| | 7 | | using UnityEditor; |
| | 8 | | using UnityEngine; |
| | 9 | |
|
| | 10 | | namespace DCL.Builder |
| | 11 | | { |
| | 12 | | public static class EntityComponentsUtils |
| | 13 | | { |
| | 14 | | public static void AddTransformComponent(IParcelScene scene, IDCLEntity entity, DCLTransform.Model model) |
| | 15 | | { |
| 31 | 16 | | scene.EntityComponentCreateOrUpdateWithModel(entity.entityId, CLASS_ID_COMPONENT.TRANSFORM, model); |
| 31 | 17 | | } |
| | 18 | |
|
| | 19 | | public static NFTShape AddNFTShapeComponent(IParcelScene scene, IDCLEntity entity, NFTShape.Model model, string |
| | 20 | | { |
| 1 | 21 | | id = EnsureId(id); |
| | 22 | |
|
| 1 | 23 | | NFTShape nftShape = (NFTShape) scene.SharedComponentCreate(id, Convert.ToInt32(CLASS_ID.NFT_SHAPE)); |
| 1 | 24 | | nftShape.model = model; |
| 1 | 25 | | scene.SharedComponentAttach(entity.entityId, nftShape.id); |
| 1 | 26 | | return nftShape; |
| | 27 | | } |
| | 28 | |
|
| | 29 | | public static GLTFShape AddGLTFComponent(IParcelScene scene, IDCLEntity entity, GLTFShape.Model model, string id |
| | 30 | | { |
| 15 | 31 | | id = EnsureId(id); |
| | 32 | |
|
| 15 | 33 | | GLTFShape gltfComponent = (GLTFShape) scene.SharedComponentCreate(id, Convert.ToInt32(CLASS_ID.GLTF_SHAPE)); |
| 15 | 34 | | gltfComponent.model = model; |
| 15 | 35 | | scene.SharedComponentAttach(entity.entityId, gltfComponent.id); |
| 15 | 36 | | return gltfComponent; |
| | 37 | | } |
| | 38 | |
|
| | 39 | | public static DCLName AddNameComponent(IParcelScene scene, IDCLEntity entity, DCLName.Model model, string id = " |
| | 40 | | { |
| 19 | 41 | | id = EnsureId(id); |
| | 42 | |
|
| 19 | 43 | | DCLName name = (DCLName) scene.SharedComponentCreate(id, Convert.ToInt32(CLASS_ID.NAME)); |
| 19 | 44 | | name.UpdateFromModel(model); |
| 19 | 45 | | scene.SharedComponentAttach(entity.entityId, name.id); |
| 19 | 46 | | return name; |
| | 47 | | } |
| | 48 | |
|
| | 49 | | public static DCLLockedOnEdit AddLockedOnEditComponent(IParcelScene scene, IDCLEntity entity, DCLLockedOnEdit.Mo |
| | 50 | | { |
| 50 | 51 | | id = EnsureId(id); |
| | 52 | |
|
| 50 | 53 | | DCLLockedOnEdit lockedOnEditComponent = (DCLLockedOnEdit) scene.SharedComponentCreate(id, Convert.ToInt32(CL |
| 50 | 54 | | lockedOnEditComponent.UpdateFromModel(model); |
| 50 | 55 | | scene.SharedComponentAttach(entity.entityId, lockedOnEditComponent.id); |
| 50 | 56 | | return lockedOnEditComponent; |
| | 57 | | } |
| | 58 | |
|
| | 59 | | private static string EnsureId(string currentId) |
| | 60 | | { |
| 85 | 61 | | if (string.IsNullOrEmpty(currentId)) |
| 0 | 62 | | return Guid.NewGuid().ToString(); |
| 85 | 63 | | return currentId; |
| | 64 | | } |
| | 65 | | } |
| | 66 | | } |