示例#1
0
        public PlayerSnapshot Snapshot(GameEntity playerEntity, SerializationContext context)
        {
            SnapshotTick = playerEntity.Game.CurrentTick;

            var manager = playerEntity.Manager;
            var races   = manager.RacesToBeingRelationship[playerEntity.Id].Values;

            RacesSnapshot.Clear();
            RacesSnapshot.AddRange(races);

            var items = manager.EntityItemsToContainerRelationship[playerEntity.Id];

            ItemsSnapshot.Clear();
            ItemsSnapshot.AddRange(items, i => new InventoryItemSnapshot().Snapshot(i, context));

            var abilities = GetSlottedAbilities(playerEntity, manager);

            AbilitiesSnapshot.Clear();
            AbilitiesSnapshot.AddRange(abilities);

            LogEntriesSnapshot.Clear();
            LogEntriesSnapshot.AddRange(GetLogEntries(playerEntity.Player));

            return(this);
        }
示例#2
0
        public LevelSnapshot Snapshot(GameEntity levelEntity, SerializationContext context)
        {
            var level = levelEntity.Level;

            if (level.VisibleTerrainSnapshot == null)
            {
                level.VisibleTerrainSnapshot = (byte[])level.VisibleTerrain.Clone();
            }
            else
            {
                level.VisibleTerrain.CopyTo(level.VisibleTerrainSnapshot, 0);
            }

            var manager = levelEntity.Manager;
            var actors  = GetActors(levelEntity, manager);

            ActorsSnapshot.Clear();
            ActorsSnapshot.AddRange(actors);

            var items = GetItems(levelEntity, manager);

            ItemsSnapshot.Clear();
            ItemsSnapshot.AddRange(items, i => new LevelItemSnapshot().Snapshot(i, context));

            var abilities = GetConnections(levelEntity, manager);

            ConnectionsSnapshot.Clear();
            ConnectionsSnapshot.AddRange(abilities);

            return(this);
        }