85 lines
2.6 KiB
C#
Raw Normal View History

using System;
using System.IO;
using System.Text;
using Syroot.IO;
using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX
{
public class AirstrikeStyle : StyleBase
{
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
public int PlaneSprite;
public int BombsCount;
public int DropDistance;
public int HorizontalSpeed;
public int Sound;
public WeaponAirstrikeAction Action;
public StyleBase Style;
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
/// <summary>
/// Loads the data from the given <see cref="Stream"/>.
/// </summary>
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
public override void Load(Stream stream)
{
using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
{
PlaneSprite = reader.ReadInt32();
BombsCount = reader.ReadInt32();
DropDistance = reader.ReadInt32();
HorizontalSpeed = reader.ReadInt32();
Sound = reader.ReadInt32();
Action = reader.ReadEnum<WeaponAirstrikeAction>(false);
switch (Action)
{
case WeaponAirstrikeAction.Launcher:
Style = reader.Load<LauncherStyle>();
break;
case WeaponAirstrikeAction.Mines:
Style = reader.Load<MineStyle>();
break;
}
}
}
/// <summary>
/// Saves the data into the given <paramref name="stream"/>.
/// </summary>
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
public override void Save(Stream stream)
{
using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII, true))
{
writer.Write(PlaneSprite);
writer.Write(BombsCount);
writer.Write(DropDistance);
writer.Write(HorizontalSpeed);
writer.Write(Sound);
writer.Write(Action, true);
if (Action != WeaponAirstrikeAction.Worms)
{
writer.Save(Style);
}
}
}
}
public enum WeaponAirstrikeAction : int
{
Mines,
Worms,
Launcher
}
}