void ChangeEntityComponent(EntitySingleComponentPayload payload, ParcelScene scene)
    {
        modifyEntityComponentEvent.payload = payload;

        WebInterface.SceneEvent <ModifyEntityComponentEvent> sceneEvent = new WebInterface.SceneEvent <ModifyEntityComponentEvent>();
        sceneEvent.sceneId   = scene.sceneData.id;
        sceneEvent.eventType = BuilderInWorldSettings.STATE_EVENT_NAME;
        sceneEvent.payload   = modifyEntityComponentEvent;


        //Note (Adrian): We use Newtonsoft instead of JsonUtility because we need to deal with super classes, JsonUtility doesn't encode them
        string message = JsonConvert.SerializeObject(sceneEvent, Formatting.None, new JsonSerializerSettings
        {
            ReferenceLoopHandling = ReferenceLoopHandling.Ignore
        });

        WebInterface.BuilderInWorldMessage(BuilderInWorldSettings.SCENE_EVENT_NAME, message);
    }
    void SendNewEntityToKernel(string sceneId, string entityId, ComponentPayload[] componentsPayload)
    {
        AddEntityEvent addEntityEvent = new AddEntityEvent();

        entityPayload.entityId   = entityId;
        entityPayload.components = componentsPayload;

        addEntityEvent.payload = entityPayload;

        WebInterface.SceneEvent <AddEntityEvent> sceneEvent = new WebInterface.SceneEvent <AddEntityEvent>();
        sceneEvent.sceneId   = sceneId;
        sceneEvent.eventType = BuilderInWorldSettings.STATE_EVENT_NAME;
        sceneEvent.payload   = addEntityEvent;


        //Note(Adrian): We use Newtonsoft instead of JsonUtility because we need to deal with super classes, JsonUtility doesn't encode them
        string message = JsonConvert.SerializeObject(sceneEvent);

        WebInterface.BuilderInWorldMessage(BuilderInWorldSettings.SCENE_EVENT_NAME, message);
    }
    public void EntityTransformReport(IDCLEntity entity, ParcelScene scene)
    {
        entitySingleComponentPayload.entityId    = entity.entityId;
        entitySingleComponentPayload.componentId = (int)CLASS_ID_COMPONENT.TRANSFORM;

        entityTransformComponentModel.position = WorldStateUtils.ConvertUnityToScenePosition(entity.gameObject.transform.position, scene);
        entityTransformComponentModel.rotation = new QuaternionRepresentation(entity.gameObject.transform.rotation);
        entityTransformComponentModel.scale    = entity.gameObject.transform.localScale;

        entitySingleComponentPayload.data = entityTransformComponentModel;

        modifyEntityComponentEvent.payload = entitySingleComponentPayload;

        WebInterface.SceneEvent <ModifyEntityComponentEvent> sceneEvent = new WebInterface.SceneEvent <ModifyEntityComponentEvent>();
        sceneEvent.sceneId   = scene.sceneData.id;
        sceneEvent.eventType = BuilderInWorldSettings.STATE_EVENT_NAME;
        sceneEvent.payload   = modifyEntityComponentEvent;


        //Note (Adrian): We use Newtonsoft instead of JsonUtility because we need to deal with super classes, JsonUtility doesn't encode them
        string message = JsonConvert.SerializeObject(sceneEvent);

        WebInterface.BuilderInWorldMessage(BuilderInWorldSettings.SCENE_EVENT_NAME, message);
    }