コード例 #1
0
    public void RemoveEntityOnKernel(string entityId, ParcelScene scene)
    {
        RemoveEntityEvent   removeEntityEvent   = new RemoveEntityEvent();
        RemoveEntityPayload removeEntityPayLoad = new RemoveEntityPayload();

        removeEntityPayLoad.entityId = entityId;
        removeEntityEvent.payload    = removeEntityPayLoad;

        WebInterface.SendSceneEvent(scene.sceneData.id, BuilderInWorldSettings.STATE_EVENT_NAME, removeEntityEvent);
        OnKernelUpdated?.Invoke();
    }
コード例 #2
0
    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);
        OnKernelUpdated?.Invoke();
    }
コード例 #3
0
    // ReSharper disable Unity.PerformanceAnalysis
    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);
        OnKernelUpdated?.Invoke();
    }