public void ApplyDeltaPacket(GameStateDeltaPacket p) { /*for (int i = 0; i < p.CoordsX.Length; i++) * { * var pos = new Point2(p.CoordsX[i], p.CoordsY[i]); * var v = world.GetVoxel(pos); * if (v == null) throw new InvalidOperationException("Server world is bigger than client world!"); * v.ChangeType(gameplayObjectsSerializer.GetVoxelType(p.Types[i])); * v.Data.DataValue = p.DataValues[i]; * v.Data.MagicLevel = p.MagicLevels[i]; * v.Data.Height = p.Heights[i]; * }*/ applySerializedGamestate(p.SerializedGamestate, state); }
public GameStateDeltaPacket CreateDeltaPacket(IEnumerable <GameVoxel> voxelsToSerialize) { var packet = new GameStateDeltaPacket(); /*packet.CoordsX = voxelsToSerialize.Select(v => v.Coord.X).ToArray(); * packet.CoordsY = voxelsToSerialize.Select(v => v.Coord.Y).ToArray(); * packet.Types = voxelsToSerialize.Select(v => gameplayObjectsSerializer.Serialize(v.Type)).ToArray(); * packet.DataValues = voxelsToSerialize.Select(v => v.Data.DataValue).ToArray(); * packet.MagicLevels = voxelsToSerialize.Select(v => v.Data.MagicLevel).ToArray(); * packet.Heights = voxelsToSerialize.Select(v => v.Data.Height).ToArray();*/ packet.SerializedGamestate = createSerializedGamestate(state, voxelsToSerialize); return(packet); }