< Summary

Class:BIWEntity
Assembly:BuilderEntity
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BuilderMode/BuilderEntity/BIWEntity.cs
Covered lines:219
Uncovered lines:97
Coverable lines:316
Total lines:700
Line coverage:69.3% (219 of 316)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BIWEntity()0%110100%
Init(...)0%440100%
GetCatalogItemAssociated()0%8.038092.31%
HasShape()0%2100%
HasMovedSinceLastReport()0%2100%
HasScaledSinceLastReport()0%2100%
HasRotatedSinceLastReport()0%2100%
PositionReported()0%2100%
ScaleReported()0%2100%
RotationReported()0%2100%
CheckErrors()0%550100%
SetEntityBoundariesError(...)0%110100%
Select()0%110100%
Deselect()0%330100%
ToggleShowStatus()0%2.062075%
ToggleLockStatus()0%110100%
ShapeLoadFinish(...)0%2.52050%
Delete()0%220100%
Dispose()0%10.147060%
DestroyColliders()0%3.13077.78%
AddRotation(...)0%2100%
SetRotation(...)0%2100%
GetEulerRotation()0%2100%
InitRotation()0%220100%
HasSmartItemComponent()0%220100%
HasSmartItemActions()0%2100%
GetSmartItemParameters()0%2100%
GetSmartItemActions()0%2100%
GetIsLockedValue()0%330100%
SetIsLockedValue(...)0%440100%
SetDescriptiveName(...)0%3.013088.89%
GetDescriptiveName()0%330100%
ResetTransfrom()0%6200%
ShapeInit()0%66095%
HandleAnimation()0%2.152066.67%
DefaultAnimationStop()0%12300%
DefaultAnimationSample(...)0%15.555025%
SetOriginalMaterials()0%26.978033.33%
SetEntityAsVoxel()0%2100%
SaveOriginalMaterial()0%15.115092.31%
SetEditMaterial()0%84.071009.52%
OnNameUpdate(...)0%2.52050%
OnShapeUpdate(...)0%220100%
CreateCollidersForEntity(...)0%2016075%
IsEntityNFT()0%330100%
IsEntityAFloor()0%330100%
IsEntityAVoxel()0%8.198085.71%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/MainScripts/DCL/Controllers/BuilderMode/BuilderEntity/BIWEntity.cs

#LineLine coverage
 1using DCL;
 2using DCL.Components;
 3using DCL.Configuration;
 4using DCL.Controllers;
 5using DCL.Helpers;
 6using DCL.Models;
 7using System;
 8using System.Collections.Generic;
 9using UnityEngine;
 10
 11public class BIWEntity
 12{
 113    public GameObject gameObject => rootEntity.gameObject;
 014    public Transform transform => rootEntity.gameObject.transform;
 15
 016    public IDCLEntity rootEntity { protected set; get; }
 17    public string entityUniqueId;
 18
 19    public event Action<BIWEntity> OnShapeFinishLoading;
 20    public event Action<BIWEntity> OnStatusUpdate;
 21    public event Action<BIWEntity> OnDelete;
 22    public event Action<BIWEntity> OnErrorStatusChange;
 23
 024    public bool isDeleted { get; private set; }
 25    public bool isLocked
 26    {
 9927        get { return GetIsLockedValue(); }
 28        set
 29        {
 4130            SetIsLockedValue(value);
 4131            OnStatusUpdate?.Invoke(this);
 032        }
 33    }
 34
 35    private bool isSelectedValue = false;
 36
 37    public bool isSelected
 38    {
 039        get { return isSelectedValue; }
 40        set
 41        {
 3942            isSelectedValue = value;
 3943            OnStatusUpdate?.Invoke(this);
 044        }
 45    }
 46
 47    private bool isNewValue = false;
 48
 49    public bool isNew
 50    {
 051        get { return isNewValue; }
 52        set
 53        {
 11554            isNewValue = value;
 11555            OnStatusUpdate?.Invoke(this);
 056        }
 57    }
 58
 14659    private bool isVisibleValue = true;
 60
 61    public bool isVisible
 62    {
 063        get { return isVisibleValue; }
 64        set
 65        {
 15766            isVisibleValue = value;
 15767            if (rootEntity != null && rootEntity.gameObject != null)
 15568                rootEntity.gameObject?.SetActive(isVisibleValue);
 15769            OnStatusUpdate?.Invoke(this);
 070        }
 71    }
 72
 073    public bool isVoxel { get; set; } = false;
 74
 75    private CatalogItem associatedCatalogItem;
 76
 077    public bool isFloor { get; set; } = false;
 078    public bool isNFT { get; private set; } = false;
 79
 80    private bool isShapeComponentSet = false;
 81
 82    private Animation[] meshAnimations;
 83
 84    private Vector3 currentRotation;
 85    private Transform originalParent;
 86
 87    private Material[] originalMaterials;
 88
 89    private Material editMaterial;
 90
 14691    private Dictionary<string, List<GameObject>> collidersGameObjectDictionary = new Dictionary<string, List<GameObject>
 92
 93    private Vector3 lastPositionReported;
 94    private Vector3 lastScaleReported;
 95    private Quaternion lastRotationReported;
 96
 97    #region Error Handler definition
 98
 099    public bool hasError  { get; private set; } = false;
 100
 0101    public bool hasMissingCatalogItemError { get; private set; } = false;
 0102    public bool isInsideBoundariesError { get; private set; } = false;
 103
 104    #endregion
 105
 106    public void Init(IDCLEntity entity, Material editMaterial)
 107    {
 120108        rootEntity = entity;
 120109        rootEntity.OnShapeUpdated += OnShapeUpdate;
 120110        rootEntity.OnNameChange += OnNameUpdate;
 111
 120112        this.editMaterial = editMaterial;
 120113        isVoxel = false;
 114
 115
 120116        entityUniqueId = rootEntity.scene.sceneData.id + rootEntity.entityId;
 120117        if (rootEntity.gameObject != null)
 119118            isVisible = rootEntity.gameObject.activeSelf;
 119
 120120        isShapeComponentSet = false;
 120121        InitRotation();
 122
 120123        if (rootEntity.meshRootGameObject && rootEntity.meshesInfo.renderers.Length > 0)
 124        {
 7125            ShapeInit();
 126        }
 120127    }
 128
 129    public CatalogItem GetCatalogItemAssociated()
 130    {
 260131        if (associatedCatalogItem != null)
 17132            return associatedCatalogItem;
 133
 243134        if (rootEntity == null)
 1135            return null;
 136
 137        //We get the catalog reference
 242138        IAssetCatalogReferenceHolder catalogHolder = rootEntity.TryGetComponent<IAssetCatalogReferenceHolder>();
 242139        if (catalogHolder == null)
 196140            return null;
 141
 142        //we get the assetId to search in the catalog for the item
 46143        string assetId = catalogHolder.GetAssetId();
 144
 145        //We try to get the item from the main catalog that is usable right now
 46146        if (!string.IsNullOrEmpty(assetId) && DataStore.i.builderInWorld.catalogItemDict.TryGetValue(assetId, out associ
 9147            return associatedCatalogItem;
 148
 149        //If the item doesn't exist in the catalog, we fallback to the catalog of the scene
 37150        if (!string.IsNullOrEmpty(assetId) && DataStore.i.builderInWorld.currentSceneCatalogItemDict.TryGetValue(assetId
 0151            return associatedCatalogItem;
 152
 153        //Error 404: Item not found, we show a pink box to represent the item
 37154        return null;
 155    }
 156
 0157    public bool HasShape() { return isShapeComponentSet; }
 158
 0159    public bool HasMovedSinceLastReport() { return Vector3.Distance(lastPositionReported, rootEntity.gameObject.transfor
 160
 0161    public bool HasScaledSinceLastReport() { return Math.Abs(lastScaleReported.magnitude - rootEntity.gameObject.transfo
 162
 0163    public bool HasRotatedSinceLastReport() { return Quaternion.Angle(lastRotationReported, rootEntity.gameObject.transf
 164
 0165    public void PositionReported() { lastPositionReported = rootEntity.gameObject.transform.position; }
 166
 0167    public void ScaleReported() { lastScaleReported = rootEntity.gameObject.transform.lossyScale; }
 168
 0169    public void RotationReported() { lastRotationReported = rootEntity.gameObject.transform.rotation; }
 170
 171    #region Error Handling
 172
 173    public void CheckErrors()
 174    {
 100175        bool isCurrentlyWithError = false;
 176
 177        //If the entity doesn't have a catalog item associated, we can be sure that the item is deleted
 100178        if (GetCatalogItemAssociated() == null)
 179        {
 92180            hasMissingCatalogItemError = true;
 92181            isCurrentlyWithError = true;
 182        }
 183
 184        //If entity is not inside boundaries it has an error
 100185        if (isInsideBoundariesError)
 42186            isCurrentlyWithError = true;
 187
 100188        bool hasErrorPreviously = hasError;
 100189        hasError = isCurrentlyWithError;
 190
 100191        if (isCurrentlyWithError != hasErrorPreviously)
 81192            OnErrorStatusChange?.Invoke(this);
 33193    }
 194
 195    public void SetEntityBoundariesError(bool isInsideBoundaries)
 196    {
 38197        isInsideBoundariesError = !isInsideBoundaries;
 38198        CheckErrors();
 38199    }
 200
 201    #endregion
 202
 203    public void Select()
 204    {
 26205        isSelected = true;
 26206        originalParent = rootEntity.gameObject.transform.parent;
 26207        SetEditMaterial();
 26208        lastPositionReported = rootEntity.gameObject.transform.position;
 26209        lastScaleReported = rootEntity.gameObject.transform.lossyScale;
 26210        lastRotationReported = rootEntity.gameObject.transform.rotation;
 26211    }
 212
 213    public void Deselect()
 214    {
 25215        if (!isSelected)
 12216            return;
 217
 13218        isNew = false;
 13219        isSelected = false;
 13220        if (rootEntity.gameObject != null)
 13221            rootEntity.gameObject.transform.SetParent(originalParent);
 222
 13223        SetOriginalMaterials();
 13224    }
 225
 226    public void ToggleShowStatus()
 227    {
 3228        rootEntity.gameObject.SetActive(!rootEntity.gameObject.activeSelf);
 3229        isVisible = rootEntity.gameObject.activeSelf;
 3230        OnStatusUpdate?.Invoke(this);
 0231    }
 232
 6233    public void ToggleLockStatus() { isLocked = !isLocked; }
 234
 1235    public void ShapeLoadFinish(ISharedComponent component) { OnShapeFinishLoading?.Invoke(this); }
 236
 237    public void Delete()
 238    {
 13239        Deselect();
 13240        Dispose();
 13241        isDeleted = true;
 13242        OnDelete?.Invoke(this);
 1243    }
 244
 245    public void Dispose()
 246    {
 17247        if (rootEntity != null)
 248        {
 17249            rootEntity.OnShapeUpdated -= OnShapeUpdate;
 17250            rootEntity.OnNameChange -= OnNameUpdate;
 251
 17252            if (isNFT)
 253            {
 0254                foreach (KeyValuePair<Type, ISharedComponent> kvp in rootEntity.sharedComponents)
 255                {
 0256                    if (kvp.Value.GetClassId() == (int) CLASS_ID.NFT_SHAPE)
 257                    {
 0258                        BIWNFTController.i.StopUsingNFT(((NFTShape.Model) kvp.Value.GetModel()).assetId);
 0259                        break;
 260                    }
 261                }
 262            }
 263
 17264            DCL.Environment.i.world.sceneBoundsChecker?.EvaluateEntityPosition(rootEntity);
 17265            DCL.Environment.i.world.sceneBoundsChecker?.RemoveEntityToBeChecked(rootEntity);
 266        }
 267
 17268        DestroyColliders();
 269
 17270        associatedCatalogItem = null;
 17271    }
 272
 273    public void DestroyColliders()
 274    {
 178275        foreach (List<GameObject> entityColliderGameObject in collidersGameObjectDictionary.Values)
 276        {
 20277            for (int i = entityColliderGameObject.Count - 1; i > 0; i--)
 278            {
 0279                GameObject.Destroy(entityColliderGameObject[i]);
 280            }
 281        }
 282
 79283        collidersGameObjectDictionary.Clear();
 79284    }
 285
 286    #region Components
 287
 288    #region Transfrom
 289
 0290    public void AddRotation(Vector3 newRotation) { currentRotation += newRotation; }
 291
 0292    public void SetRotation(Vector3 newRotation) { currentRotation = newRotation; }
 293
 0294    public Vector3 GetEulerRotation() { return currentRotation; }
 295
 296    public void InitRotation()
 297    {
 298        //TODO : We need to implement the initial rotation from the transform component instead of getting the current r
 120299        if (rootEntity.gameObject != null)
 119300            currentRotation = rootEntity.gameObject.transform.eulerAngles;
 120301    }
 302
 303    #endregion
 304
 305    #region SmartItem
 306
 307    public bool HasSmartItemComponent()
 308    {
 39309        if (rootEntity == null)
 1310            return false;
 311
 38312        return rootEntity.components.ContainsKey(CLASS_ID_COMPONENT.SMART_ITEM);
 313    }
 314
 0315    public bool HasSmartItemActions() { return GetCatalogItemAssociated().HasActions(); }
 316
 0317    public SmartItemParameter[] GetSmartItemParameters() { return GetCatalogItemAssociated().parameters; }
 318
 0319    public SmartItemAction[] GetSmartItemActions() { return GetCatalogItemAssociated().actions; }
 320
 321    #endregion
 322
 323    #region Locked
 324
 325    public bool GetIsLockedValue()
 326    {
 260327        foreach (KeyValuePair<Type, ISharedComponent> kvp in rootEntity.sharedComponents)
 328        {
 40329            if (kvp.Value.GetClassId() == (int) CLASS_ID.LOCKED_ON_EDIT)
 330            {
 18331                return ((DCLLockedOnEdit.Model) kvp.Value.GetModel()).isLocked;
 332            }
 333        }
 334
 81335        return isFloor;
 18336    }
 337
 338    public void SetIsLockedValue(bool isLocked)
 339    {
 43340        bool foundComponent = false;
 341
 116342        foreach (KeyValuePair<Type, ISharedComponent> kvp in rootEntity.sharedComponents)
 343        {
 15344            if (kvp.Value.GetClassId() == (int) CLASS_ID.LOCKED_ON_EDIT)
 345            {
 8346                ((DCLLockedOnEdit) kvp.Value).SetIsLocked(isLocked);
 8347                foundComponent = true;
 348            }
 349        }
 350
 43351        if (!foundComponent)
 352        {
 35353            ParcelScene scene = rootEntity.scene as ParcelScene;
 35354            DCLLockedOnEdit entityLocked = (DCLLockedOnEdit) scene.SharedComponentCreate(Guid.NewGuid().ToString(), Conv
 35355            entityLocked.SetIsLocked(isLocked);
 35356            scene.SharedComponentAttach(rootEntity.entityId, entityLocked.id);
 357        }
 43358    }
 359
 360    #endregion
 361
 362    #region DescriptiveName
 363
 364    public void SetDescriptiveName(string newName)
 365    {
 20366        if (rootEntity.TryGetSharedComponent(CLASS_ID.NAME, out ISharedComponent nameComponent))
 367        {
 16368            ((DCLName) nameComponent).SetNewName(newName);
 16369        }
 370        else
 371        {
 4372            ParcelScene scene = rootEntity.scene as ParcelScene;
 4373            DCLName name = (DCLName) scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAM
 4374            name.SetNewName(newName);
 4375            scene.SharedComponentAttach(rootEntity.entityId, name.id);
 376        }
 377
 20378        OnStatusUpdate?.Invoke(this);
 0379    }
 380
 381    public string GetDescriptiveName()
 382    {
 147383        if (rootEntity != null && rootEntity.TryGetSharedComponent(CLASS_ID.NAME, out ISharedComponent nameComponent))
 384        {
 23385            return ((DCLName.Model) nameComponent.GetModel()).value;
 386        }
 387
 124388        return "";
 389    }
 390
 391    #endregion
 392
 393    #endregion
 394
 395    public void ResetTransfrom()
 396    {
 0397        currentRotation = Vector3.zero;
 0398        rootEntity.gameObject.transform.eulerAngles = currentRotation;
 0399        rootEntity.gameObject.transform.localScale = Vector3.one;
 0400        OnStatusUpdate?.Invoke(this);
 0401    }
 402
 403    void ShapeInit()
 404    {
 37405        isShapeComponentSet = true;
 406
 37407        isFloor = IsEntityAFloor();
 37408        isNFT = IsEntityNFT();
 409
 37410        CreateCollidersForEntity(rootEntity);
 411
 37412        if (isFloor)
 4413            isLocked = true;
 414
 37415        if (IsEntityAVoxel())
 0416            SetEntityAsVoxel();
 417
 37418        HandleAnimation();
 419
 37420        if (isNFT)
 421        {
 6422            foreach (KeyValuePair<Type, ISharedComponent> keyValuePairBaseDisposable in rootEntity.sharedComponents)
 423            {
 2424                if (keyValuePairBaseDisposable.Value.GetClassId() == (int) CLASS_ID.NFT_SHAPE)
 425                {
 2426                    BIWNFTController.i.UseNFT(((NFTShape.Model) keyValuePairBaseDisposable.Value.GetModel()).assetId);
 2427                    break;
 428                }
 429            }
 430        }
 431
 37432        SaveOriginalMaterial();
 433
 37434        DCL.Environment.i.world.sceneBoundsChecker.AddPersistent(rootEntity);
 37435        SetEntityBoundariesError(DCL.Environment.i.world.sceneBoundsChecker.IsEntityInsideSceneBoundaries(rootEntity));
 37436    }
 437
 438    private void HandleAnimation()
 439    {
 440        // We don't want animation to be running on editor
 37441        meshAnimations = rootEntity.gameObject.GetComponentsInChildren<Animation>();
 37442        if (HasSmartItemComponent())
 443        {
 0444            DefaultAnimationStop();
 0445        }
 446        else
 447        {
 37448            DefaultAnimationSample(0);
 449        }
 37450    }
 451
 452    private void DefaultAnimationStop()
 453    {
 0454        if (meshAnimations == null)
 0455            return;
 456
 0457        for (int i = 0; i < meshAnimations.Length; i++)
 458        {
 0459            meshAnimations[i].Stop();
 460        }
 0461    }
 462
 463    private void DefaultAnimationSample(float time)
 464    {
 37465        if (meshAnimations == null || meshAnimations.Length == 0)
 37466            return;
 467
 0468        for (int i = 0; i < meshAnimations.Length; i++)
 469        {
 0470            meshAnimations[i].Stop();
 0471            meshAnimations[i].clip?.SampleAnimation(meshAnimations[i].gameObject, time);
 472        }
 0473    }
 474
 475    void SetOriginalMaterials()
 476    {
 13477        if (rootEntity.meshesInfo.renderers == null)
 12478            return;
 1479        if (isNFT)
 0480            return;
 481
 1482        int matCont = 0;
 2483        foreach (Renderer renderer in rootEntity.meshesInfo.renderers)
 484        {
 0485            if (renderer == null)
 486                continue;
 0487            Material[] materials = new Material[renderer.sharedMaterials.Length];
 488
 0489            for (int i = 0; i < renderer.sharedMaterials.Length; i++)
 490            {
 0491                if (isNFT && matCont == 0)
 492                {
 0493                    materials[i] = renderer.sharedMaterials[i];
 0494                    matCont++;
 0495                    continue;
 496                }
 497
 0498                materials[i] = originalMaterials[matCont];
 0499                matCont++;
 500            }
 501
 0502            renderer.sharedMaterials = materials;
 503        }
 1504    }
 505
 506    void SetEntityAsVoxel()
 507    {
 0508        isVoxel = true;
 0509        rootEntity.gameObject.tag = BIWSettings.VOXEL_TAG;
 0510    }
 511
 512    void SaveOriginalMaterial()
 513    {
 37514        if (rootEntity.meshesInfo == null ||
 515            rootEntity.meshesInfo.renderers == null ||
 516            rootEntity.meshesInfo.renderers.Length == 0)
 24517            return;
 518
 13519        if (isNFT)
 2520            return;
 521
 11522        int totalMaterials = 0;
 44523        foreach (Renderer renderer in rootEntity.meshesInfo.renderers)
 524        {
 11525            if (renderer == null)
 526                continue;
 11527            totalMaterials += renderer.sharedMaterials.Length;
 528        }
 529
 11530        if (!isNFT || (isNFT && originalMaterials == null))
 11531            originalMaterials = new Material[totalMaterials];
 532
 11533        int matCont = 0;
 44534        foreach (Renderer renderer in rootEntity.meshesInfo.renderers)
 535        {
 11536            if (renderer == null)
 537                continue;
 538
 44539            for (int i = 0; i < renderer.sharedMaterials.Length; i++)
 540            {
 11541                if (isNFT && matCont == 0)
 542                {
 0543                    matCont++;
 0544                    continue;
 545                }
 546
 11547                originalMaterials[matCont] = renderer.sharedMaterials[i];
 11548                matCont++;
 549            }
 550        }
 11551    }
 552
 553    void SetEditMaterial()
 554    {
 33555        if (rootEntity.meshesInfo == null ||
 556            rootEntity.meshesInfo.renderers == null ||
 557            rootEntity.meshesInfo.renderers.Length < 1)
 33558            return;
 559
 0560        if (isNFT)
 0561            return;
 562
 0563        int matCont = 0;
 0564        foreach (Renderer renderer in rootEntity.meshesInfo.renderers)
 565        {
 0566            if (renderer == null)
 567                continue;
 568
 0569            Material[] materials = new Material[renderer.sharedMaterials.Length];
 570
 0571            for (int i = 0; i < renderer.sharedMaterials.Length; i++)
 572            {
 0573                if (isNFT && matCont == 0)
 574                {
 0575                    materials[i] = renderer.sharedMaterials[i];
 0576                    matCont++;
 0577                    continue;
 578                }
 579
 0580                materials[i] = editMaterial;
 0581                matCont++;
 582            }
 583
 0584            renderer.sharedMaterials = materials;
 585        }
 0586    }
 587
 17588    void OnNameUpdate(object model) { OnStatusUpdate?.Invoke(this); }
 589
 590    void OnShapeUpdate(IDCLEntity entity)
 591    {
 30592        ShapeInit();
 593
 30594        if (isSelected)
 7595            SetEditMaterial();
 30596    }
 597
 598    void CreateCollidersForEntity(IDCLEntity entity)
 599    {
 37600        MeshesInfo meshInfo = entity.meshesInfo;
 37601        if (meshInfo == null ||
 602            meshInfo.currentShape == null ||
 603            !meshInfo.currentShape.IsVisible())
 23604            return;
 605
 14606        if (collidersGameObjectDictionary.ContainsKey(entity.scene.sceneData.id + entity.entityId) && !isNFT)
 0607            return;
 608
 14609        if (entity.children.Count > 0)
 610        {
 0611            using (var iterator = entity.children.GetEnumerator())
 612            {
 0613                while (iterator.MoveNext())
 614                {
 0615                    CreateCollidersForEntity(iterator.Current.Value);
 616                }
 0617            }
 618        }
 619
 620        //Note: When we are duplicating the GLTF and NFT component, their colliders are duplicated too
 621        //So we eliminate any previous collider to ensure that only 1 collider remain active
 14622        Transform[] children = rootEntity.gameObject.transform.GetComponentsInChildren<Transform>();
 160623        foreach (Transform child in children)
 624        {
 66625            if (child.gameObject.layer ==  BIWSettings.COLLIDER_SELECTION_LAYER)
 626            {
 0627                GameObject.Destroy(child.gameObject);
 628            }
 629        }
 630
 14631        List<GameObject> colliderList = new List<GameObject>();
 632
 66633        for (int i = 0; i < meshInfo.renderers.Length; i++)
 634        {
 19635            if (meshInfo.renderers[i] == null)
 636                continue;
 19637            GameObject entityColliderChildren = new GameObject(entity.entityId);
 19638            entityColliderChildren.layer = BIWSettings.COLLIDER_SELECTION_LAYER_INDEX;
 639
 19640            Transform t = entityColliderChildren.transform;
 19641            t.SetParent(meshInfo.renderers[i].transform);
 19642            t.ResetLocalTRS();
 643
 19644            var meshCollider = entityColliderChildren.AddComponent<MeshCollider>();
 645
 19646            if (meshInfo.renderers[i] is SkinnedMeshRenderer)
 647            {
 0648                Mesh meshColliderForSkinnedMesh = new Mesh();
 0649                (meshInfo.renderers[i] as SkinnedMeshRenderer).BakeMesh(meshColliderForSkinnedMesh);
 0650                meshCollider.sharedMesh = meshColliderForSkinnedMesh;
 0651                t.localScale = new Vector3(1 / meshInfo.renderers[i].gameObject.transform.lossyScale.x, 1 / meshInfo.ren
 0652            }
 653            else
 654            {
 19655                meshCollider.sharedMesh = meshInfo.renderers[i].GetComponent<MeshFilter>().sharedMesh;
 656            }
 657
 19658            meshCollider.enabled = true;
 19659            colliderList.Add(entityColliderChildren);
 660
 19661            if (isNFT)
 662            {
 8663                if (collidersGameObjectDictionary.ContainsKey(entity.scene.sceneData.id + entity.entityId))
 6664                    collidersGameObjectDictionary.Remove(entity.scene.sceneData.id + entity.entityId);
 665
 666
 8667                collidersGameObjectDictionary.Add(entity.scene.sceneData.id + entity.entityId, colliderList);
 668
 8669                colliderList = new List<GameObject>();
 670            }
 671        }
 672
 14673        if (!isNFT)
 12674            collidersGameObjectDictionary.Add(entity.scene.sceneData.id + entity.entityId, colliderList);
 14675    }
 676
 677    public bool IsEntityNFT()
 678    {
 157679        foreach (KeyValuePair<Type, ISharedComponent> keyValuePairBaseDisposable in rootEntity.sharedComponents)
 680        {
 42681            if (keyValuePairBaseDisposable.Value.GetClassId() == (int) CLASS_ID.NFT_SHAPE)
 3682                return true;
 683        }
 684
 35685        return false;
 3686    }
 687
 37688    bool IsEntityAFloor() { return GetCatalogItemAssociated()?.category == BIWSettings.FLOOR_CATEGORY; }
 689
 690    bool IsEntityAVoxel()
 691    {
 37692        if (rootEntity.meshesInfo?.currentShape == null)
 23693            return false;
 14694        if (rootEntity.meshesInfo.renderers?.Length <= 0)
 1695            return false;
 13696        if (rootEntity.meshesInfo.mergedBounds.size != Vector3.one)
 13697            return false;
 0698        return true;
 699    }
 700}

Methods/Properties

gameObject()
transform()
rootEntity(DCL.Models.IDCLEntity)
rootEntity()
isDeleted()
isDeleted(System.Boolean)
isLocked()
isLocked(System.Boolean)
isSelected()
isSelected(System.Boolean)
isNew()
isNew(System.Boolean)
BIWEntity()
isVisible()
isVisible(System.Boolean)
isVoxel()
isVoxel(System.Boolean)
isFloor()
isFloor(System.Boolean)
isNFT()
isNFT(System.Boolean)
hasError()
hasError(System.Boolean)
hasMissingCatalogItemError()
hasMissingCatalogItemError(System.Boolean)
isInsideBoundariesError()
isInsideBoundariesError(System.Boolean)
Init(DCL.Models.IDCLEntity, UnityEngine.Material)
GetCatalogItemAssociated()
HasShape()
HasMovedSinceLastReport()
HasScaledSinceLastReport()
HasRotatedSinceLastReport()
PositionReported()
ScaleReported()
RotationReported()
CheckErrors()
SetEntityBoundariesError(System.Boolean)
Select()
Deselect()
ToggleShowStatus()
ToggleLockStatus()
ShapeLoadFinish(DCL.Components.ISharedComponent)
Delete()
Dispose()
DestroyColliders()
AddRotation(UnityEngine.Vector3)
SetRotation(UnityEngine.Vector3)
GetEulerRotation()
InitRotation()
HasSmartItemComponent()
HasSmartItemActions()
GetSmartItemParameters()
GetSmartItemActions()
GetIsLockedValue()
SetIsLockedValue(System.Boolean)
SetDescriptiveName(System.String)
GetDescriptiveName()
ResetTransfrom()
ShapeInit()
HandleAnimation()
DefaultAnimationStop()
DefaultAnimationSample(System.Single)
SetOriginalMaterials()
SetEntityAsVoxel()
SaveOriginalMaterial()
SetEditMaterial()
OnNameUpdate(System.Object)
OnShapeUpdate(DCL.Models.IDCLEntity)
CreateCollidersForEntity(DCL.Models.IDCLEntity)
IsEntityNFT()
IsEntityAFloor()
IsEntityAVoxel()