Beispiel #1
0
    //-------------------------------------------------------------------------------------------------------
    // SnapShot:  single-shot save current Player state to World-saves

    internal void SnapShot()
    {
        Debug.Log("SnapShot: " + Player);
        if (Player.Equals(""))
        {
            return;                             // no active player
        }
        // CT snapshot source
        if (ctsnapshot != null)
        {
            ctsnapshot.close();
        }
        ctsnapshot = new CTlib.CThttp(Session + "/" + Inventory + "/_" + Player, blocksPerSegment, true, true, true, Server);
        ctsnapshot.login(user, password);
        ctsnapshot.setAsync(AsyncMode);

//        serverConnect();  // reset Player folder paths

        string CTstateString = CTserdes.serialize(this, JSON_Format ? CTserdes.Format.JSON : CTserdes.Format.CSV);

        if (CTstateString == null)
        {
            return;                                     // meh
        }
        // archive World state
        ctsnapshot.setTime(ServerTime());
        ctsnapshot.putData(CTchannel, CTstateString);
        ctsnapshot.flush();
    }
Beispiel #2
0
    //-------------------------------------------------------------------------------------------------------
    // OneShot:  single-shot save current Player state to GamePlay

    internal void OneShot()
    {
        Debug.Log("OneShot, Player: " + Player);
        if (Player.Equals(""))
        {
            return;       // no active player
        }
        serverConnect();  // reset Player folder paths

        string CTstateString = CTserdes.serialize(this, JSON_Format ? CTserdes.Format.JSON : CTserdes.Format.CSV);

        if (CTstateString == null)
        {
            return;                             // meh
        }
        // update GamePlay
        ctplayer.setTime(ServerTime());
        ctplayer.putData(CTchannel, CTstateString);
        ctplayer.flush();
    }
Beispiel #3
0
    double BPS = 10, PPS = 10, FPS = 10; // block, point, frame per second info

    void Update()
    {
        nups++;
        stopWatchF += Time.deltaTime;
        if (ctplayer == null)
        {
            serverConnect();
        }

        if (ctplayer == null || newSession || replayActive || gamePaused || Player.Equals(Observer) /* || CTlist.Count==0 */)
        {
            // No writes for you!
            if (stopWatchF > fpsInterval)
            {
                FPS          = Math.Round(nups / stopWatchF);
                fpsText.text = "FPS: " + BPS + "/" + FPS; // info
                BPS          = 0;                         // reset til next update
                stopWatchF   = stopWatchP = stopWatchB = nups = npts = 0;
            }
            activeWrite = false;
            return;
        }

        activeWrite = true;                 // flag important global state:  actively creating files via CTput
        if (maxPointRate < blockRate)
        {
            maxPointRate = blockRate;                                     // firewall
        }
        float pointInterval = 1f / maxPointRate;

        stopWatchP += Time.deltaTime;
        if (stopWatchP >= pointInterval)
        {
            string CTstateString = CTserdes.serialize(this, JSON_Format ? CTserdes.Format.JSON : CTserdes.Format.CSV);
            if (CTstateString == null)
            {
                return;                                         // meh
            }
            ctplayer.setTime(ServerTime());
            ctplayer.putData(CTchannel, CTstateString);
            npts++;
            stopWatchP = 0f;
        }

        float blockInterval = 1f / blockRate;

        pollInterval = blockInterval;                  // CTget poll at fraction of block interval?

        stopWatchB += Time.deltaTime;
        if (stopWatchB >= blockInterval)
        {
//			BPS = Math.Round(1F / stopWatchB);        // moving average
            PPS        = Math.Round(npts / stopWatchB);
            stopWatchB = npts = 0;
            ctplayer.flush();                       // flush data to CT
        }

        // calc/display metrics
        if (stopWatchF > fpsInterval)
        {
            FPS          = Math.Round(nups / stopWatchF);
            fpsText.text = "FPS: " + BPS + "/" + FPS;
            BPS          = 0; // reset til next update
            stopWatchF   = nups = 0;
        }
    }