예제 #1
0
        public override System.Object ToOriginalObject()
        {
            var snapShot = new SyncEntitySnapshot();

            snapShot.sceneUID       = sceneUID;
            snapShot.mirrorObjectID = mirrorObjectID;
            snapShot.timeStamp      = timeStamp;

            var syncStates = new List <SyncComponentSnapshot>();

            foreach (var encodedState in encodedMembers)
            {
                try {
                    var memeberWraper = JsonUtility.FromJson <MemberWrapper>(encodedState);

                    if (memeberWraper.type != "SyncStateSnapshot")
                    {
                        throw new System.Exception("bad json");
                    }

                    syncStates.Add(JsonUtility.FromJson <SyncComponentSnapshot>(memeberWraper.json));
                }
                catch {
                    throw;
                }
            }

            snapShot.syncStates = syncStates.ToArray();

            return(snapShot);
        }
예제 #2
0
        public SyncEntitySnapshot GetSnapshot()
        {
            var snapshot = new SyncEntitySnapshot();

            snapshot.sceneUID       = sceneUID;
            snapshot.mirrorObjectID = mirrorObjectID;

            var componentSnapshots = new List <SyncComponentSnapshot>();

            foreach (var state in syncStates)
            {
                componentSnapshots.Add(state.GetSnapshot());
            }
            snapshot.syncStates = componentSnapshots.ToArray();

            return(snapshot);
        }
예제 #3
0
        public void SyncToSnapshot(SyncEntitySnapshot snapshot)
        {
            if (snapshot.sceneUID != sceneUID)
            {
                Debug.LogWarning("[Sync Fail]");
                return;
            }

            foreach (var stateSnapshot in snapshot.syncStates)
            {
                foreach (var state in syncStates)
                {
                    if (state.innerID == stateSnapshot.innerID)
                    {
                        state.SyncToSnapshot(stateSnapshot);
                    }
                }
            }
        }