Beispiel #1
0
    public void SmartItemComponent()
    {
        SmartItemComponent.Model model = new SmartItemComponent.Model();

        string testFloatKey = "TestFloat";
        float  testFloat    = 20f;

        string intKey  = "Speed";
        int    testInt = 10;

        string stringKey  = "TextExample";
        string testString = "unit test example";

        string onClickKey = "OnClick";


        Dictionary <object, object> onClickDict = new Dictionary <object, object>();

        onClickDict.Add(testFloatKey, testFloat);

        model.values = new Dictionary <object, object>();
        model.values.Add(intKey, testInt);
        model.values.Add(testFloatKey, testFloat);
        model.values.Add(stringKey, testString);
        model.values.Add(onClickKey, onClickDict);

        string jsonModel = JsonUtility.ToJson(model);

        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);
        SmartItemComponent smartItemComponent = null;

        //Note (Adrian): This shouldn't work this way, we should have a function to create the component from Model directly
        scene.EntityComponentCreateOrUpdateFromUnity(entityId, CLASS_ID_COMPONENT.SMART_ITEM, jsonModel);

        if (scene.entities[entityId].TryGetBaseComponent(CLASS_ID_COMPONENT.SMART_ITEM, out BaseComponent baseComponent))
        {
            //Note (Adrian): We can't wait to set the component 1 frame in production, so we set it like production
            smartItemComponent = ((SmartItemComponent)baseComponent);
            smartItemComponent.SetModel(model);
        }
        else
        {
            Assert.Fail("Smart Compoenent not found");
        }

        Assert.AreEqual(testInt, smartItemComponent.model.values[intKey]);
        Assert.AreEqual(testFloat, smartItemComponent.model.values[testFloatKey]);
        Assert.AreEqual(testString, smartItemComponent.model.values[stringKey]);

        Dictionary <object, object> onClickDictFromComponent = (Dictionary <object, object>)smartItemComponent.model.values[onClickKey];

        Assert.AreEqual(testFloat, onClickDictFromComponent[testFloatKey]);
    }
Beispiel #2
0
    void SelectedEntity(int number)
    {
        if (!filteredList[number].rootEntity.TryGetBaseComponent(CLASS_ID_COMPONENT.SMART_ITEM, out BaseComponent component))
        {
            return;
        }

        selectedComponent = (SmartItemComponent)component;
        GenerateActionDropdownContent(selectedComponent.model.actions);

        GenerateParametersFromSelectedOption();
    }
Beispiel #3
0
    internal void EntityDeselected()
    {
        if (entityInformationView.currentEntity == null)
        {
            return;
        }

        if (entityInformationView.currentEntity.rootEntity.TryGetBaseComponent(CLASS_ID_COMPONENT.SMART_ITEM, out IEntityComponent component))
        {
            SmartItemComponent smartItemComponent = (SmartItemComponent)component;
            OnSmartItemComponentUpdate?.Invoke(entityInformationView.currentEntity);
        }
    }
Beispiel #4
0
    public void EntityDeselected()
    {
        if (currentEntity == null)
        {
            return;
        }

        if (currentEntity.rootEntity.TryGetBaseComponent(CLASS_ID_COMPONENT.SMART_ITEM, out BaseComponent component))
        {
            SmartItemComponent smartItemComponent = (SmartItemComponent)component;
            OnSmartItemComponentUpdate?.Invoke(currentEntity);
        }
    }
Beispiel #5
0
    public void SmartItemComponent()
    {
        SmartItemComponent.Model model = new SmartItemComponent.Model();

        string testFloatKey = "TestFloat";
        float  testFloat    = 20f;

        string intKey  = "Speed";
        int    testInt = 10;

        string stringKey  = "TextExample";
        string testString = "unit test example";

        string onClickKey = "OnClick";


        Dictionary <object, object> onClickDict = new Dictionary <object, object>();

        onClickDict.Add(testFloatKey, testFloat);

        model.values = new Dictionary <object, object>();
        model.values.Add(intKey, testInt);
        model.values.Add(testFloatKey, testFloat);
        model.values.Add(stringKey, testString);
        model.values.Add(onClickKey, onClickDict);

        SmartItemComponent smartItemComponent = null;

        scene.EntityComponentCreateOrUpdateWithModel(ENTITY_ID, CLASS_ID_COMPONENT.SMART_ITEM, model);

        if (scene.entities[ENTITY_ID].TryGetBaseComponent(CLASS_ID_COMPONENT.SMART_ITEM, out IEntityComponent baseComponent))
        {
            //Note (Adrian): We can't wait to set the component 1 frame in production, so we set it like production
            smartItemComponent = ((SmartItemComponent)baseComponent);
            smartItemComponent.UpdateFromModel(model);
        }
        else
        {
            Assert.Fail("Smart Component not found");
        }

        Assert.AreEqual(testInt, smartItemComponent.GetValues()[intKey]);
        Assert.AreEqual(testFloat, smartItemComponent.GetValues()[testFloatKey]);
        Assert.AreEqual(testString, smartItemComponent.GetValues()[stringKey]);

        Dictionary <object, object> onClickDictFromComponent = (Dictionary <object, object>)smartItemComponent.GetValues()[onClickKey];

        Assert.AreEqual(testFloat, onClickDictFromComponent[testFloatKey]);
    }
    internal void EntityDeselected()
    {
        if (entityInformationView.currentEntity == null)
        {
            return;
        }

        if (entityInformationView.currentEntity.rootEntity.TryGetBaseComponent(CLASS_ID_COMPONENT.SMART_ITEM, out IEntityComponent component))
        {
            //TODO: we do an early return since the smart item component is not implemented yet
            return;

            SmartItemComponent smartItemComponent = (SmartItemComponent)component;
            OnSmartItemComponentUpdate?.Invoke(entityInformationView.currentEntity);
        }
    }
    public void UpdateSmartItemComponent(DCLBuilderInWorldEntity entity, ParcelScene scene)
    {
        SmartItemComponent smartItemComponent = entity.rootEntity.TryGetComponent <SmartItemComponent>();

        if (smartItemComponent == null)
        {
            return;
        }


        entitySingleComponentPayload.entityId    = entity.rootEntity.entityId;
        entitySingleComponentPayload.componentId = (int)CLASS_ID_COMPONENT.SMART_ITEM;

        entitySingleComponentPayload.data = smartItemComponent.GetValues();

        ChangeEntityComponent(entitySingleComponentPayload, scene);
    }
 public void SetSmartItemParameters(SmartItemComponent smartItemComponent)
 {
     SetSmartItemParameters(smartItemComponent.model.parameters);
 }