Exemplo n.º 1
0
    // This syncs everything except the behavior sources
    void SyncDatabase()
    {
        if (currentBatchName != null)
        {
            // Wait for end of batch before sync'ing.
            return;
        }

        using (Util.Profile("SyncDatabase"))
        {
            UpdateRequest request = new UpdateRequest();
            request.jsonObject = db.Save();
            Util.Maybe <UpdateResponse> maybeResponse = voosEngine.CommunicateWithAgent <UpdateRequest, UpdateResponse>(request);
            if (maybeResponse.IsEmpty())
            {
                throw new System.Exception("Failed to sync behavior database. Cannot proceed.");
            }

            brainIdsHandlingCollisions.Clear();
            brainIdsHandlingCollisions.AddRange(maybeResponse.Value.brainsHandlingCollisions);
            onBrainsHandlingCollisionsChanged?.Invoke();
        }
    }