/// <summary> /// Saves the file to the specified stream. /// </summary> /// <param name="stream">The stream to save to.</param> public override void Save(Stream stream) { BinaryWriter writer = new BinaryWriter(stream, Encoding.GetEncoding("EUC-KR")); writer.Write(BLOCK_COUNT); long[] offsets = new long[BLOCK_COUNT]; for (int i = 0; i < BLOCK_COUNT; i++) { writer.Write(i); writer.Write(0); } offsets[0] = stream.Position; writer.Write((int)Type); writer.Write(Width); writer.Write(Height); writer.Write(GridCount); writer.Write(GridSize); writer.Write(StartPosition.X); writer.Write(StartPosition.Y); for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { writer.Write(Positions[x, y].IsUsed); writer.Write(Positions[x, y].Position); } } offsets[1] = stream.Position; writer.Write(SpawnPoints.Count); SpawnPoints.ForEach(spawnPoint => { writer.Write(spawnPoint.Position); writer.WriteByteString(spawnPoint.Name); }); offsets[2] = stream.Position; writer.Write(Textures.Count); Textures.ForEach(texture => { writer.WriteByteString(texture); }); offsets[3] = stream.Position; writer.Write(Tiles.Count); Tiles.ForEach(tile => { writer.Write(tile.Layer1); writer.Write(tile.Layer2); writer.Write(tile.Offset1); writer.Write(tile.Offset2); writer.Write(tile.BlendingEnabled ? 1 : 0); writer.Write((int)tile.Rotation); writer.Write(tile.TileType); }); offsets[4] = stream.Position; writer.WriteByteString(Name); writer.Write(IsUnderground ? 1 : 0); writer.WriteByteString(BackgroundMusicFilePath); writer.WriteByteString(SkyFilePath); writer.Write(EconomyCheckRate); writer.Write(PopulationBase); writer.Write(PopulationGrowthRate); writer.Write(MetalConsumption); writer.Write(StoneConsumption); writer.Write(WoodConsumption); writer.Write(LeatherConsumption); writer.Write(ClothConsumption); writer.Write(AlchemyConsumption); writer.Write(ChemicalConsumption); writer.Write(IndustrialConsumption); writer.Write(MedicineConsumption); writer.Write(FoodConsumption); for (int i = 0; i < BLOCK_COUNT; i++) { stream.Seek(sizeof(int) + i * sizeof(int) * 2 + sizeof(int), SeekOrigin.Begin); writer.Write((int)offsets[i]); } }
/// <summary> /// Writes the block data to the underlying stream. /// </summary> /// <param name="writer">The writer.</param> public override void Write(BinaryWriter writer) { base.Write(writer); writer.WriteByteString(SpawnName); writer.Write(NormalSpawnPoints.Count); NormalSpawnPoints.ForEach(spawn => { writer.WriteByteString(spawn.Name); writer.Write(spawn.Monster); writer.Write(spawn.Count); }); writer.Write(TacticalSpawnPoints.Count); TacticalSpawnPoints.ForEach(spawn => { writer.WriteByteString(spawn.Name); writer.Write(spawn.Monster); writer.Write(spawn.Count); }); writer.Write(Interval); writer.Write(Limit); writer.Write(Range); writer.Write(TacticalVariable); }
/// <summary> /// Saves the file to the specified stream. /// </summary> /// <param name="stream">The stream to save to.</param> public override void Save(Stream stream) { BinaryWriter writer = new BinaryWriter(stream, Encoding.GetEncoding("EUC-KR")); writer.Write((short)ModelFiles.Count); ModelFiles.ForEach(modelFile => { writer.WriteString(modelFile); writer.Write((byte)0); }); writer.Write((short)TextureFiles.Count); TextureFiles.ForEach(texture => { writer.WriteString(texture.FilePath); writer.Write((byte)0); writer.Write((short)(texture.UseSkinShader ? 1 : 0)); writer.Write((short)(texture.AlphaEnabled ? 1 : 0)); writer.Write((short)(texture.TwoSided ? 1 : 0)); writer.Write((short)(texture.AlphaTestEnabled ? 1 : 0)); writer.Write(texture.AlphaReference); writer.Write((short)(texture.DepthTestEnabled ? 1 : 0)); writer.Write((short)(texture.DepthWriteEnabled ? 1 : 0)); writer.Write((short)texture.BlendType); writer.Write((short)(texture.UseSpecularShader ? 1 : 0)); writer.Write(texture.Alpha); writer.Write((short)texture.GlowType); writer.Write(texture.GlowColour.ToVector3()); }); writer.Write((short)EffectFiles.Count); EffectFiles.ForEach(effectFile => { writer.WriteString(effectFile); writer.Write((byte)0); }); writer.Write((short)Objects.Count); Objects.ForEach(@object => { writer.Write((int)@object.BoundingCylinder.Radius); writer.Write((int)@object.BoundingCylinder.Center.X); writer.Write((int)@object.BoundingCylinder.Center.Y); writer.Write((short)@object.Parts.Count); if (@object.Parts.Count > 0) { @object.Parts.ForEach(part => { writer.Write(part.Model); writer.Write(part.Texture); if (part.Position != Vector3.Zero) { writer.Write((byte)ModelListPropertyType.Position); writer.Write((byte)(sizeof(float) * 3)); writer.Write(part.Position); } if (part.Rotation != Quaternion.Zero) { writer.Write((byte)ModelListPropertyType.Rotation); writer.Write((byte)(sizeof(float) * 4)); writer.Write(part.Rotation, true); } if (part.Scale != Vector3.Zero) { writer.Write((byte)ModelListPropertyType.Scale); writer.Write((byte)(sizeof(float) * 3)); writer.Write(part.Scale); } if (part.AxisRotation != Quaternion.Zero) { writer.Write((byte)ModelListPropertyType.AxisRotation); writer.Write((byte)(sizeof(float) * 4)); writer.Write(part.AxisRotation, true); } if (part.Parent != 0) { writer.Write((byte)ModelListPropertyType.Parent); writer.Write((byte)sizeof(short)); writer.Write(part.Parent); } if (part.Collision != 0) { writer.Write((byte)ModelListPropertyType.Collision); writer.Write((byte)sizeof(short)); writer.Write((short)part.Collision); } if (string.Compare(part.AnimationFilePath, string.Empty) != 0) { writer.Write((byte)ModelListPropertyType.ConstantAnimation); writer.WriteByteString(part.AnimationFilePath); } if (part.VisibleRangeSet != 0) { writer.Write((byte)ModelListPropertyType.VisibleRangeSet); writer.Write((byte)sizeof(short)); writer.Write(part.VisibleRangeSet); } if (!part.UseLightmap) { writer.Write((byte)ModelListPropertyType.UseLightmap); writer.Write((byte)sizeof(short)); writer.Write((short)0); } if (part.BoneIndex != 0) { writer.Write((byte)ModelListPropertyType.BoneIndex); writer.Write((byte)sizeof(short)); writer.Write(part.BoneIndex); } if (part.DummyIndex != 0) { writer.Write((byte)ModelListPropertyType.DummyIndex); writer.Write((byte)sizeof(short)); writer.Write(part.DummyIndex); } for (int i = 0; i < part.MonsterAnimations.Length; i++) { string animationFile = part.MonsterAnimations[i]; if (string.Compare(animationFile, string.Empty) != 0) { writer.Write((byte)((byte)ModelListPropertyType.Animation + i)); writer.WriteByteString(animationFile); } } for (int i = 0; i < part.AvatarAnimations.Length; i++) { string animationFile = part.AvatarAnimations[i]; if (string.Compare(animationFile, string.Empty) != 0) { writer.Write((byte)((byte)ModelListPropertyType.Animation + ModelListPart.MONSTER_ANIMATION_COUNT + i)); writer.WriteByteString(animationFile); } } writer.Write((byte)0); }); writer.Write((short)@object.Effects.Count); @object.Effects.ForEach(effect => { writer.Write((short)effect.EffectType); writer.Write(effect.Effect); if (effect.Position != Vector3.Zero) { writer.Write((byte)ModelListPropertyType.Position); writer.Write((byte)(sizeof(float) * 3)); writer.Write(effect.Position); } if (effect.Rotation != Quaternion.Zero) { writer.Write((byte)ModelListPropertyType.Rotation); writer.Write((byte)(sizeof(float) * 4)); writer.Write(effect.Rotation, true); } if (effect.Scale != Vector3.Zero) { writer.Write((byte)ModelListPropertyType.Scale); writer.Write((byte)(sizeof(float) * 3)); writer.Write(effect.Scale); } if (effect.Parent != 0) { writer.Write((byte)ModelListPropertyType.Parent); writer.Write((byte)sizeof(short)); writer.Write(effect.Parent); } writer.Write((byte)0); }); writer.Write(@object.BoundingBox.Minimum); writer.Write(@object.BoundingBox.Maximum); } }); }
/// <summary> /// Writes the block data to the underlying stream. /// </summary> /// <param name="writer">The writer.</param> public virtual void Write(BinaryWriter writer) { writer.WriteByteString(Name); writer.Write(WarpID); writer.Write(EventID); writer.Write(ObjectType); writer.Write(ObjectID); writer.Write(MapPosition.X); writer.Write(MapPosition.Y); writer.Write(Rotation); writer.Write(Position); writer.Write(Scale); }
/// <summary> /// Writes the block data to the underlying stream. /// </summary> /// <param name="writer">The writer.</param> public override void Write(BinaryWriter writer) { base.Write(writer); writer.WriteByteString(FilePath); }
/// <summary> /// Writes the block data to the underlying stream. /// </summary> /// <param name="writer">The writer.</param> public override void Write(BinaryWriter writer) { base.Write(writer); writer.Write(AI); writer.WriteByteString(ConversationFile); }