예제 #1
0
    public void SetDescriptiveName(string newName)
    {
        if (rootEntity.TryGetSharedComponent(CLASS_ID.NAME, out BaseDisposable nameComponent))
        {
            ((DCLName)nameComponent).SetNewName(newName);
        }
        else
        {
            ParcelScene scene = rootEntity.scene as ParcelScene;
            DCLName     name  = (DCLName)scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAME));
            name.SetNewName(newName);
            scene.SharedComponentAttach(rootEntity.entityId, name.id);
        }

        onStatusUpdate?.Invoke(this);
    }
예제 #2
0
    public void BuilderInWorldEntityComponents()
    {
        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);

        DCLBuilderInWorldEntity biwEntity = Utils.GetOrCreateComponent <DCLBuilderInWorldEntity>(scene.entities[entityId].gameObject);

        biwEntity.Init(scene.entities[entityId], null);

        Assert.IsTrue(biwEntity.entityUniqueId == scene.sceneData.id + scene.entities[entityId].entityId, "Entity id is not created correctly, this can lead to weird behaviour");

        SmartItemComponent.Model model = new SmartItemComponent.Model();
        string jsonModel = JsonConvert.SerializeObject(model);

        scene.EntityComponentCreateOrUpdateFromUnity(entityId, CLASS_ID_COMPONENT.SMART_ITEM, jsonModel);

        Assert.IsTrue(biwEntity.HasSmartItemComponent());

        DCLName name = (DCLName)scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.NAME));

        scene.SharedComponentAttach(biwEntity.rootEntity.entityId, name.id);

        DCLName dclName = biwEntity.rootEntity.TryGetComponent <DCLName>();

        Assert.IsNotNull(dclName);

        string newName = "TestingName";

        dclName.SetNewName(newName);
        Assert.AreEqual(newName, biwEntity.GetDescriptiveName());


        DCLLockedOnEdit entityLocked = (DCLLockedOnEdit)scene.SharedComponentCreate(Guid.NewGuid().ToString(), Convert.ToInt32(CLASS_ID.LOCKED_ON_EDIT));

        scene.SharedComponentAttach(biwEntity.rootEntity.entityId, entityLocked.id);

        DCLLockedOnEdit dclLockedOnEdit = biwEntity.rootEntity.TryGetComponent <DCLLockedOnEdit>();

        Assert.IsNotNull(dclLockedOnEdit);

        bool isLocked = true;

        dclLockedOnEdit.SetIsLocked(isLocked);
        Assert.AreEqual(biwEntity.IsLocked, isLocked);
    }