< Summary

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

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
BIWEntity()0%110100%
Initialize(...)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%220100%
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%660100%
HandleAnimation()0%2.152066.67%
DefaultAnimationStop()0%12300%
DefaultAnimationSample(...)0%15.555025%
SetOriginalMaterials()0%26.978033.33%
SetEntityAsVoxel()0%110100%
SaveOriginalMaterial()0%15.115092.31%
SetEditMaterial()0%10.6910080.95%
OnNameUpdate(...)0%2.52050%
OnShapeUpdate(...)0%220100%
CreateCollidersForEntity(...)0%19.0116077.27%
IsEntityNFT()0%330100%
IsEntityAFloor()0%330100%
IsEntityAVoxel()0%880100%

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
 26    public bool isLocked
 27    {
 9928        get { return GetIsLockedValue(); }
 29        set
 30        {
 4531            SetIsLockedValue(value);
 4532            OnStatusUpdate?.Invoke(this);
 033        }
 34    }
 35
 36    private bool isSelectedValue = false;
 37
 38    public bool isSelected
 39    {
 040        get { return isSelectedValue; }
 41        set
 42        {
 3943            isSelectedValue = value;
 3944            OnStatusUpdate?.Invoke(this);
 045        }
 46    }
 47
 48    private bool isNewValue = false;
 49
 50    public bool isNew
 51    {
 052        get { return isNewValue; }
 53        set
 54        {
 11455            isNewValue = value;
 11456            OnStatusUpdate?.Invoke(this);
 057        }
 58    }
 59
 14560    private bool isVisibleValue = true;
 61
 62    public bool isVisible
 63    {
 064        get { return isVisibleValue; }
 65        set
 66        {
 15667            isVisibleValue = value;
 68
 15669            if (rootEntity != null && rootEntity.gameObject != null)
 70            {
 15471                rootEntity.gameObject.SetActive(isVisibleValue);
 72            }
 73
 15674            OnStatusUpdate?.Invoke(this);
 075        }
 76    }
 77
 078    public bool isVoxel { get; set; } = false;
 79
 80    private CatalogItem associatedCatalogItem;
 81
 082    public bool isFloor { get; set; } = false;
 083    public bool isNFT { get; private set; } = false;
 84
 85    private bool isShapeComponentSet = false;
 86
 87    private Animation[] meshAnimations;
 88
 89    private Vector3 currentRotation;
 90    private Transform originalParent;
 91
 92    private Material[] originalMaterials;
 93
 94    private Material editMaterial;
 95
 14596    private Dictionary<string, List<GameObject>> collidersGameObjectDictionary = new Dictionary<string, List<GameObject>
 97
 98    private Vector3 lastPositionReported;
 99    private Vector3 lastScaleReported;
 100    private Quaternion lastRotationReported;
 101
 102    #region Error Handler definition
 103
 0104    public bool hasError  { get; private set; } = false;
 105
 0106    public bool hasMissingCatalogItemError { get; private set; } = false;
 0107    public bool isInsideBoundariesError { get; private set; } = false;
 108
 109    #endregion
 110
 111    public void Initialize(IDCLEntity entity, Material editMaterial)
 112    {
 119113        rootEntity = entity;
 119114        rootEntity.OnShapeUpdated += OnShapeUpdate;
 119115        rootEntity.OnNameChange += OnNameUpdate;
 116
 119117        this.editMaterial = editMaterial;
 119118        isVoxel = false;
 119
 120
 119121        entityUniqueId = rootEntity.scene.sceneData.id + rootEntity.entityId;
 119122        if (rootEntity.gameObject != null)
 118123            isVisible = rootEntity.gameObject.activeSelf;
 124
 119125        isShapeComponentSet = false;
 119126        InitRotation();
 127
 119128        if (rootEntity.meshRootGameObject && rootEntity.meshesInfo.renderers.Length > 0)
 129        {
 7130            ShapeInit();
 131        }
 119132    }
 133
 134    public CatalogItem GetCatalogItemAssociated()
 135    {
 279136        if (associatedCatalogItem != null)
 44137            return associatedCatalogItem;
 138
 235139        if (rootEntity == null)
 1140            return null;
 141
 142        //We get the catalog reference
 234143        IAssetCatalogReferenceHolder catalogHolder = rootEntity.TryGetComponent<IAssetCatalogReferenceHolder>();
 234144        if (catalogHolder == null)
 183145            return null;
 146
 147        //we get the assetId to search in the catalog for the item
 51148        string assetId = catalogHolder.GetAssetId();
 149
 150        //We try to get the item from the main catalog that is usable right now
 51151        if (!string.IsNullOrEmpty(assetId) && DataStore.i.builderInWorld.catalogItemDict.TryGetValue(assetId, out associ
 14152            return associatedCatalogItem;
 153
 154        //If the item doesn't exist in the catalog, we fallback to the catalog of the scene
 37155        if (!string.IsNullOrEmpty(assetId) && DataStore.i.builderInWorld.currentSceneCatalogItemDict.TryGetValue(assetId
 0156            return associatedCatalogItem;
 157
 158        //Error 404: Item not found, we show a pink box to represent the item
 37159        return null;
 160    }
 161
 0162    public bool HasShape() { return isShapeComponentSet; }
 163
 0164    public bool HasMovedSinceLastReport() { return Vector3.Distance(lastPositionReported, rootEntity.gameObject.transfor
 165
 0166    public bool HasScaledSinceLastReport() { return Math.Abs(lastScaleReported.magnitude - rootEntity.gameObject.transfo
 167
 0168    public bool HasRotatedSinceLastReport() { return Quaternion.Angle(lastRotationReported, rootEntity.gameObject.transf
 169
 0170    public void PositionReported() { lastPositionReported = rootEntity.gameObject.transform.position; }
 171
 0172    public void ScaleReported() { lastScaleReported = rootEntity.gameObject.transform.lossyScale; }
 173
 0174    public void RotationReported() { lastRotationReported = rootEntity.gameObject.transform.rotation; }
 175
 176    #region Error Handling
 177
 178    public void CheckErrors()
 179    {
 110180        bool isCurrentlyWithError = false;
 181
 182        //If the entity doesn't have a catalog item associated, we can be sure that the item is deleted
 110183        if (GetCatalogItemAssociated() == null)
 184        {
 86185            hasMissingCatalogItemError = true;
 86186            isCurrentlyWithError = true;
 187        }
 188
 189        //If entity is not inside boundaries it has an error
 110190        if (isInsideBoundariesError)
 49191            isCurrentlyWithError = true;
 192
 110193        bool hasErrorPreviously = hasError;
 110194        hasError = isCurrentlyWithError;
 195
 110196        if (isCurrentlyWithError != hasErrorPreviously)
 80197            OnErrorStatusChange?.Invoke(this);
 44198    }
 199
 200    public void SetEntityBoundariesError(bool isInsideBoundaries)
 201    {
 48202        isInsideBoundariesError = !isInsideBoundaries;
 48203        CheckErrors();
 48204    }
 205
 206    #endregion
 207
 208    public void Select()
 209    {
 26210        isSelected = true;
 26211        originalParent = rootEntity.gameObject.transform.parent;
 26212        SetEditMaterial();
 26213        lastPositionReported = rootEntity.gameObject.transform.position;
 26214        lastScaleReported = rootEntity.gameObject.transform.lossyScale;
 26215        lastRotationReported = rootEntity.gameObject.transform.rotation;
 26216    }
 217
 218    public void Deselect()
 219    {
 25220        if (!isSelected)
 12221            return;
 222
 13223        isNew = false;
 13224        isSelected = false;
 13225        if (rootEntity.gameObject != null)
 13226            rootEntity.gameObject.transform.SetParent(originalParent);
 227
 13228        SetOriginalMaterials();
 13229    }
 230
 231    public void ToggleShowStatus()
 232    {
 3233        rootEntity.gameObject.SetActive(!rootEntity.gameObject.activeSelf);
 3234        isVisible = rootEntity.gameObject.activeSelf;
 3235        OnStatusUpdate?.Invoke(this);
 0236    }
 237
 6238    public void ToggleLockStatus() { isLocked = !isLocked; }
 239
 24240    public void ShapeLoadFinish(ISharedComponent component) { OnShapeFinishLoading?.Invoke(this); }
 241
 242    public void Delete()
 243    {
 13244        Deselect();
 13245        Dispose();
 13246        isDeleted = true;
 13247        OnDelete?.Invoke(this);
 1248    }
 249
 250    public void Dispose()
 251    {
 17252        if (rootEntity != null)
 253        {
 17254            rootEntity.OnShapeUpdated -= OnShapeUpdate;
 17255            rootEntity.OnNameChange -= OnNameUpdate;
 256
 17257            if (isNFT)
 258            {
 0259                foreach (KeyValuePair<Type, ISharedComponent> kvp in rootEntity.sharedComponents)
 260                {
 0261                    if (kvp.Value.GetClassId() == (int) CLASS_ID.NFT_SHAPE)
 262                    {
 0263                        BIWNFTController.i.StopUsingNFT(((NFTShape.Model) kvp.Value.GetModel()).assetId);
 0264                        break;
 265                    }
 266                }
 267            }
 268
 17269            DCL.Environment.i.world.sceneBoundsChecker?.EvaluateEntityPosition(rootEntity);
 17270            DCL.Environment.i.world.sceneBoundsChecker?.RemoveEntityToBeChecked(rootEntity);
 271        }
 272
 17273        DestroyColliders();
 274
 17275        associatedCatalogItem = null;
 17276    }
 277
 278    public void DestroyColliders()
 279    {
 212280        foreach (List<GameObject> entityColliderGameObject in collidersGameObjectDictionary.Values)
 281        {
 40282            for (int i = entityColliderGameObject.Count - 1; i > 0; i--)
 283            {
 0284                GameObject.Destroy(entityColliderGameObject[i]);
 285            }
 286        }
 287
 86288        collidersGameObjectDictionary.Clear();
 86289    }
 290
 291    #region Components
 292
 293    #region Transfrom
 294
 0295    public void AddRotation(Vector3 newRotation) { currentRotation += newRotation; }
 296
 0297    public void SetRotation(Vector3 newRotation) { currentRotation = newRotation; }
 298
 0299    public Vector3 GetEulerRotation() { return currentRotation; }
 300
 301    public void InitRotation()
 302    {
 303        //TODO : We need to implement the initial rotation from the transform component instead of getting the current r
 119304        if (rootEntity.gameObject != null)
 118305            currentRotation = rootEntity.gameObject.transform.eulerAngles;
 119306    }
 307
 308    #endregion
 309
 310    #region SmartItem
 311
 312    public bool HasSmartItemComponent()
 313    {
 49314        if (rootEntity == null)
 1315            return false;
 316
 48317        return rootEntity.components.ContainsKey(CLASS_ID_COMPONENT.SMART_ITEM);
 318    }
 319
 0320    public bool HasSmartItemActions() { return GetCatalogItemAssociated().HasActions(); }
 321
 0322    public SmartItemParameter[] GetSmartItemParameters() { return GetCatalogItemAssociated().parameters; }
 323
 0324    public SmartItemAction[] GetSmartItemActions() { return GetCatalogItemAssociated().actions; }
 325
 326    #endregion
 327
 328    #region Locked
 329
 330    public bool GetIsLockedValue()
 331    {
 260332        foreach (KeyValuePair<Type, ISharedComponent> kvp in rootEntity.sharedComponents)
 333        {
 40334            if (kvp.Value.GetClassId() == (int) CLASS_ID.LOCKED_ON_EDIT)
 335            {
 18336                return ((DCLLockedOnEdit.Model) kvp.Value.GetModel()).isLocked;
 337            }
 338        }
 339
 81340        return isFloor;
 18341    }
 342
 343    public void SetIsLockedValue(bool isLocked)
 344    {
 47345        bool foundComponent = false;
 346
 144347        foreach (KeyValuePair<Type, ISharedComponent> kvp in rootEntity.sharedComponents)
 348        {
 25349            if (kvp.Value.GetClassId() == (int) CLASS_ID.LOCKED_ON_EDIT)
 350            {
 11351                ((DCLLockedOnEdit) kvp.Value).SetIsLocked(isLocked);
 11352                foundComponent = true;
 353            }
 354        }
 355
 47356        if (!foundComponent)
 357        {
 36358            ParcelScene scene = rootEntity.scene as ParcelScene;
 36359            DCLLockedOnEdit entityLocked = (DCLLockedOnEdit) scene.SharedComponentCreate(Guid.NewGuid().ToString(), Conv
 36360            entityLocked.SetIsLocked(isLocked);
 36361            scene.SharedComponentAttach(rootEntity.entityId, entityLocked.id);
 362        }
 47363    }
 364
 365    #endregion
 366
 367    #region DescriptiveName
 368
 369    public void SetDescriptiveName(string newName)
 370    {
 19371        if (rootEntity.TryGetSharedComponent(CLASS_ID.NAME, out ISharedComponent nameComponent))
 372        {
 15373            ((DCLName) nameComponent).SetNewName(newName);
 15374        }
 375        else
 376        {
 4377            ParcelScene scene = rootEntity.scene as ParcelScene;
 4378            DCLName name = (DCLName) scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAM
 4379            name.SetNewName(newName);
 4380            scene.SharedComponentAttach(rootEntity.entityId, name.id);
 381        }
 382
 19383        OnStatusUpdate?.Invoke(this);
 0384    }
 385
 386    public string GetDescriptiveName()
 387    {
 145388        if (rootEntity != null && rootEntity.TryGetSharedComponent(CLASS_ID.NAME, out ISharedComponent nameComponent))
 389        {
 22390            return ((DCLName.Model) nameComponent.GetModel()).value;
 391        }
 392
 123393        return "";
 394    }
 395
 396    #endregion
 397
 398    #endregion
 399
 400    public void ResetTransfrom()
 401    {
 0402        currentRotation = Vector3.zero;
 0403        rootEntity.gameObject.transform.eulerAngles = currentRotation;
 0404        rootEntity.gameObject.transform.localScale = Vector3.one;
 0405        OnStatusUpdate?.Invoke(this);
 0406    }
 407
 408    void ShapeInit()
 409    {
 47410        isShapeComponentSet = true;
 411
 47412        isFloor = IsEntityAFloor();
 47413        isNFT = IsEntityNFT();
 414
 47415        CreateCollidersForEntity(rootEntity);
 416
 47417        if (isFloor)
 8418            isLocked = true;
 419
 47420        if (IsEntityAVoxel())
 7421            SetEntityAsVoxel();
 422
 47423        HandleAnimation();
 424
 47425        if (isNFT)
 426        {
 6427            foreach (KeyValuePair<Type, ISharedComponent> keyValuePairBaseDisposable in rootEntity.sharedComponents)
 428            {
 2429                if (keyValuePairBaseDisposable.Value.GetClassId() == (int) CLASS_ID.NFT_SHAPE)
 430                {
 2431                    BIWNFTController.i.UseNFT(((NFTShape.Model) keyValuePairBaseDisposable.Value.GetModel()).assetId);
 2432                    break;
 433                }
 434            }
 435        }
 436
 47437        SaveOriginalMaterial();
 438
 47439        DCL.Environment.i.world.sceneBoundsChecker.AddPersistent(rootEntity);
 47440        SetEntityBoundariesError(DCL.Environment.i.world.sceneBoundsChecker.IsEntityInsideSceneBoundaries(rootEntity));
 47441    }
 442
 443    private void HandleAnimation()
 444    {
 445        // We don't want animation to be running on editor
 47446        meshAnimations = rootEntity.gameObject.GetComponentsInChildren<Animation>();
 47447        if (HasSmartItemComponent())
 448        {
 0449            DefaultAnimationStop();
 0450        }
 451        else
 452        {
 47453            DefaultAnimationSample(0);
 454        }
 47455    }
 456
 457    private void DefaultAnimationStop()
 458    {
 0459        if (meshAnimations == null)
 0460            return;
 461
 0462        for (int i = 0; i < meshAnimations.Length; i++)
 463        {
 0464            meshAnimations[i].Stop();
 465        }
 0466    }
 467
 468    private void DefaultAnimationSample(float time)
 469    {
 47470        if (meshAnimations == null || meshAnimations.Length == 0)
 47471            return;
 472
 0473        for (int i = 0; i < meshAnimations.Length; i++)
 474        {
 0475            meshAnimations[i].Stop();
 0476            meshAnimations[i].clip?.SampleAnimation(meshAnimations[i].gameObject, time);
 477        }
 0478    }
 479
 480    void SetOriginalMaterials()
 481    {
 13482        if (rootEntity.meshesInfo.renderers == null)
 12483            return;
 1484        if (isNFT)
 0485            return;
 486
 1487        int matCont = 0;
 2488        foreach (Renderer renderer in rootEntity.meshesInfo.renderers)
 489        {
 0490            if (renderer == null)
 491                continue;
 0492            Material[] materials = new Material[renderer.sharedMaterials.Length];
 493
 0494            for (int i = 0; i < renderer.sharedMaterials.Length; i++)
 495            {
 0496                if (isNFT && matCont == 0)
 497                {
 0498                    materials[i] = renderer.sharedMaterials[i];
 0499                    matCont++;
 0500                    continue;
 501                }
 502
 0503                materials[i] = originalMaterials[matCont];
 0504                matCont++;
 505            }
 506
 0507            renderer.sharedMaterials = materials;
 508        }
 1509    }
 510
 511    void SetEntityAsVoxel()
 512    {
 7513        isVoxel = true;
 7514        rootEntity.gameObject.tag = BIWSettings.VOXEL_TAG;
 7515    }
 516
 517    void SaveOriginalMaterial()
 518    {
 47519        if (rootEntity.meshesInfo == null ||
 520            rootEntity.meshesInfo.renderers == null ||
 521            rootEntity.meshesInfo.renderers.Length == 0)
 23522            return;
 523
 24524        if (isNFT)
 2525            return;
 526
 22527        int totalMaterials = 0;
 88528        foreach (Renderer renderer in rootEntity.meshesInfo.renderers)
 529        {
 22530            if (renderer == null)
 531                continue;
 22532            totalMaterials += renderer.sharedMaterials.Length;
 533        }
 534
 22535        if (!isNFT || (isNFT && originalMaterials == null))
 22536            originalMaterials = new Material[totalMaterials];
 537
 22538        int matCont = 0;
 88539        foreach (Renderer renderer in rootEntity.meshesInfo.renderers)
 540        {
 22541            if (renderer == null)
 542                continue;
 543
 88544            for (int i = 0; i < renderer.sharedMaterials.Length; i++)
 545            {
 22546                if (isNFT && matCont == 0)
 547                {
 0548                    matCont++;
 0549                    continue;
 550                }
 551
 22552                originalMaterials[matCont] = renderer.sharedMaterials[i];
 22553                matCont++;
 554            }
 555        }
 22556    }
 557
 558    void SetEditMaterial()
 559    {
 39560        if (rootEntity.meshesInfo == null ||
 561            rootEntity.meshesInfo.renderers == null ||
 562            rootEntity.meshesInfo.renderers.Length < 1)
 33563            return;
 564
 6565        if (isNFT)
 0566            return;
 567
 6568        int matCont = 0;
 24569        foreach (Renderer renderer in rootEntity.meshesInfo.renderers)
 570        {
 6571            if (renderer == null)
 572                continue;
 573
 6574            Material[] materials = new Material[renderer.sharedMaterials.Length];
 575
 24576            for (int i = 0; i < renderer.sharedMaterials.Length; i++)
 577            {
 6578                if (isNFT && matCont == 0)
 579                {
 0580                    materials[i] = renderer.sharedMaterials[i];
 0581                    matCont++;
 0582                    continue;
 583                }
 584
 6585                materials[i] = editMaterial;
 6586                matCont++;
 587            }
 588
 6589            renderer.sharedMaterials = materials;
 590        }
 6591    }
 592
 16593    void OnNameUpdate(object model) { OnStatusUpdate?.Invoke(this); }
 594
 595    void OnShapeUpdate(IDCLEntity entity)
 596    {
 40597        ShapeInit();
 598
 40599        if (isSelected)
 13600            SetEditMaterial();
 40601    }
 602
 603    void CreateCollidersForEntity(IDCLEntity entity)
 604    {
 47605        MeshesInfo meshInfo = entity.meshesInfo;
 47606        if (meshInfo == null ||
 607            meshInfo.currentShape == null ||
 608            !meshInfo.currentShape.IsVisible())
 22609            return;
 610
 25611        if (collidersGameObjectDictionary.ContainsKey(entity.scene.sceneData.id + entity.entityId) && !isNFT)
 1612            return;
 613
 24614        if (entity.children.Count > 0)
 615        {
 0616            using (var iterator = entity.children.GetEnumerator())
 617            {
 0618                while (iterator.MoveNext())
 619                {
 0620                    CreateCollidersForEntity(iterator.Current.Value);
 621                }
 0622            }
 623        }
 624
 625        //Note: When we are duplicating the GLTF and NFT component, their colliders are duplicated too
 626        //So we eliminate any previous collider to ensure that only 1 collider remain active
 24627        Transform[] children = rootEntity.gameObject.transform.GetComponentsInChildren<Transform>();
 390628        foreach (Transform child in children)
 629        {
 171630            if (child.gameObject.layer ==  BIWSettings.COLLIDER_SELECTION_LAYER)
 631            {
 0632                GameObject.Destroy(child.gameObject);
 633            }
 634        }
 635
 24636        List<GameObject> colliderList = new List<GameObject>();
 637
 106638        for (int i = 0; i < meshInfo.renderers.Length; i++)
 639        {
 29640            if (meshInfo.renderers[i] == null)
 641                continue;
 29642            GameObject entityColliderChildren = new GameObject(entity.entityId);
 29643            entityColliderChildren.layer = BIWSettings.COLLIDER_SELECTION_LAYER_INDEX;
 644
 29645            Transform t = entityColliderChildren.transform;
 29646            t.SetParent(meshInfo.renderers[i].transform);
 29647            t.ResetLocalTRS();
 648
 29649            var meshCollider = entityColliderChildren.AddComponent<MeshCollider>();
 650
 29651            if (meshInfo.renderers[i] is SkinnedMeshRenderer skr)
 652            {
 0653                Mesh meshColliderForSkinnedMesh = new Mesh();
 0654                skr.BakeMesh(meshColliderForSkinnedMesh);
 0655                meshCollider.sharedMesh = meshColliderForSkinnedMesh;
 0656                t.localScale = new Vector3(1 / meshInfo.renderers[i].gameObject.transform.lossyScale.x, 1 / meshInfo.ren
 0657            }
 658            else
 659            {
 29660                meshCollider.sharedMesh = meshInfo.renderers[i].GetComponent<MeshFilter>().sharedMesh;
 661            }
 662
 29663            meshCollider.enabled = true;
 29664            colliderList.Add(entityColliderChildren);
 665
 29666            if (isNFT)
 667            {
 8668                if (collidersGameObjectDictionary.ContainsKey(entity.scene.sceneData.id + entity.entityId))
 6669                    collidersGameObjectDictionary.Remove(entity.scene.sceneData.id + entity.entityId);
 670
 8671                collidersGameObjectDictionary.Add(entity.scene.sceneData.id + entity.entityId, colliderList);
 672
 8673                colliderList = new List<GameObject>();
 674            }
 675        }
 676
 24677        if (!isNFT)
 22678            collidersGameObjectDictionary.Add(entity.scene.sceneData.id + entity.entityId, colliderList);
 24679    }
 680
 681    public bool IsEntityNFT()
 682    {
 235683        foreach (KeyValuePair<Type, ISharedComponent> keyValuePairBaseDisposable in rootEntity.sharedComponents)
 684        {
 71685            if (keyValuePairBaseDisposable.Value.GetClassId() == (int) CLASS_ID.NFT_SHAPE)
 3686                return true;
 687        }
 688
 45689        return false;
 3690    }
 691
 47692    bool IsEntityAFloor() { return GetCatalogItemAssociated()?.category == BIWSettings.FLOOR_CATEGORY; }
 693
 694    bool IsEntityAVoxel()
 695    {
 47696        if (rootEntity.meshesInfo?.currentShape == null)
 22697            return false;
 25698        if (rootEntity.meshesInfo.renderers?.Length <= 0)
 1699            return false;
 24700        if (rootEntity.meshesInfo.mergedBounds.size != Vector3.one)
 17701            return false;
 7702        return true;
 703    }
 704}

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)
Initialize(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()