diff --git a/src/build.xml b/src/build.xml
index 1369b5a..08c2e82 100644
--- a/src/build.xml
+++ b/src/build.xml
@@ -1,5 +1,6 @@
+
Syroot
@@ -10,6 +11,7 @@
MIT
https://gitlab.com/Syroot/Worms
team17;worms
+ https://gitlab.com/Syroot/Worms
@@ -33,4 +35,5 @@
true
true
+
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Actions/ActionConverter.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Actions/ActionConverter.cs
index 242b270..8f89509 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Actions/ActionConverter.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Actions/ActionConverter.cs
@@ -1,37 +1,38 @@
-using System;
-using System.IO;
-using Syroot.BinaryData;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- internal class ActionConverter : IBinaryConverter
- {
- // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
-
- public object? Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
- ByteConverter byteConverter)
- {
- ExplosionAction explosionAction = instance switch
- {
- LauncherStyle launcherStyle => launcherStyle.ExplosionAction,
- ClusterTarget clusterTarget => clusterTarget.ExplosionAction,
- _ => throw new NotImplementedException(),
- };
- return explosionAction switch
+using System;
+using System.IO;
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ internal class ActionConverter : IBinaryConverter
+ {
+ // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
+
+ ///
+ public object? Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
+ ByteConverter byteConverter)
+ {
+ ExplosionAction explosionAction = instance switch
{
- ExplosionAction.None => null,
- ExplosionAction.Bounce => stream.ReadObject(),
- ExplosionAction.Dig => stream.ReadObject(),
- ExplosionAction.Home => stream.ReadObject(),
- ExplosionAction.Roam => stream.ReadObject(),
- _ => throw new NotImplementedException(),
- };
- }
-
- public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
- ByteConverter byteConverter)
- {
- stream.WriteObject(value);
- }
- }
-}
+ LauncherStyle launcherStyle => launcherStyle.ExplosionAction,
+ ClusterTarget clusterTarget => clusterTarget.ExplosionAction,
+ _ => throw new NotImplementedException()
+ };
+ return explosionAction switch
+ {
+ ExplosionAction.Home => stream.ReadObject(),
+ ExplosionAction.Bounce => stream.ReadObject(),
+ ExplosionAction.Roam => stream.ReadObject(),
+ ExplosionAction.Dig => stream.ReadObject(),
+ _ => null
+ };
+ }
+
+ ///
+ public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
+ ByteConverter byteConverter)
+ {
+ stream.WriteObject(value);
+ }
+ }
+}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/CollisionFlags.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/CollisionFlags.cs
index bcedc70..a5a8281 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/CollisionFlags.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/CollisionFlags.cs
@@ -1,12 +1,11 @@
using System;
-using Syroot.BinaryData;
namespace Syroot.Worms.Armageddon.ProjectX
{
[Flags]
public enum CollisionFlags : int
{
- None = 0,
+ None,
Unused0 = 1 << 0,
Terrain = 1 << 1,
WormsOnTerrain = 1 << 2,
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Library.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Library.cs
index 643ffac..8ef1328 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Library.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Library.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -13,13 +14,17 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// Represents a library stored in a PXL file which contains reusable weapons, files and scripts.
/// Used by WA PX. S. https://worms2d.info/Project_X/Library_file.
///
- public class Library : List, ILoadableFile, ISaveableFile
+ public class Library : IList, ILoadableFile, ISaveableFile
{
// ---- CONSTANTS ----------------------------------------------------------------------------------------------
private const int _signature = 0x1BCD0102;
private const byte _version = 0x00;
+ // ---- FIELDS -------------------------------------------------------------------------------------------------
+
+ private readonly List _list = new List();
+
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
///
@@ -42,8 +47,17 @@ namespace Syroot.Worms.Armageddon.ProjectX
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
+ ///
+ public int Count => _list.Count;
+
+ ///
+ /// Gets or sets the ProjectX library version.
+ ///
public byte Version { get; set; }
+ ///
+ bool ICollection.IsReadOnly => false;
+
// ---- OPERATORS ----------------------------------------------------------------------------------------------
///
@@ -53,8 +67,57 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// All matching entries.
public IEnumerable this[string key] => this.Where(x => x.Key == key);
+ ///
+ public LibraryItem this[int index]
+ {
+ get => _list[index];
+ set => _list[index] = value;
+ }
+
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
+ ///
+ public void Add(LibraryItem item) => _list.Add(item);
+
+ ///
+ public void Clear() => _list.Clear();
+
+ ///
+ public bool Contains(LibraryItem item) => _list.Contains(item);
+
+ ///
+ public void CopyTo(LibraryItem[] array, int arrayIndex) => _list.CopyTo(array, arrayIndex);
+
+ ///
+ public IEnumerator GetEnumerator() => _list.GetEnumerator();
+
+ ///
+ /// Gets all attached files.
+ ///
+ /// The enumeration of attached files.
+ public IEnumerable GetFiles()
+ => this.Where(x => x.Type == LibraryItemType.File).Select(x => (byte[])x.Value);
+
+ ///
+ /// Gets all attached scripts.
+ ///
+ /// The enumeration of attached scripts.
+ public IEnumerable GetScripts()
+ => this.Where(x => x.Type == LibraryItemType.Script).Select(x => (string)x.Value);
+
+ ///
+ /// Gets all attached weapons.
+ ///
+ /// The enumeration of attached weapons.
+ public IEnumerable GetWeapons()
+ => this.Where(x => x.Type == LibraryItemType.Weapon).Select(x => (Weapon)x.Value);
+
+ ///
+ public int IndexOf(LibraryItem item) => _list.IndexOf(item);
+
+ ///
+ public void Insert(int index, LibraryItem item) => _list.Insert(index, item);
+
///
/// Loads the data from the given .
///
@@ -71,7 +134,7 @@ namespace Syroot.Worms.Armageddon.ProjectX
throw new InvalidDataException("Invalid PXL file version.");
// Read the items.
- Clear();
+ _list.Clear();
int itemCount = reader.ReadInt32();
for (int i = 0; i < itemCount; i++)
{
@@ -80,13 +143,13 @@ namespace Syroot.Worms.Armageddon.ProjectX
switch (type)
{
case LibraryItemType.File:
- Add(new LibraryItem(name, reader.ReadBytes(reader.ReadInt32())));
+ _list.Add(new LibraryItem(name, reader.ReadBytes(reader.ReadInt32())));
break;
case LibraryItemType.Script:
- Add(new LibraryItem(name, reader.ReadString(StringCoding.Int32CharCount)));
+ _list.Add(new LibraryItem(name, reader.ReadString(StringCoding.Int32CharCount)));
break;
case LibraryItemType.Weapon:
- Add(new LibraryItem(name, reader.Load()));
+ _list.Add(new LibraryItem(name, reader.Load()));
break;
}
}
@@ -102,6 +165,12 @@ namespace Syroot.Worms.Armageddon.ProjectX
Load(stream);
}
+ ///
+ public bool Remove(LibraryItem item) => _list.Remove(item);
+
+ ///
+ public void RemoveAt(int index) => _list.RemoveAt(index);
+
///
/// Saves the data into the given .
///
@@ -116,7 +185,7 @@ namespace Syroot.Worms.Armageddon.ProjectX
// Write the items.
writer.Write(Count);
- foreach (LibraryItem item in this)
+ foreach (LibraryItem item in _list)
{
writer.WriteEnum(item.Type, true);
writer.Write(item.Key, StringCoding.Int32CharCount);
@@ -147,26 +216,13 @@ namespace Syroot.Worms.Armageddon.ProjectX
Save(stream);
}
- ///
- /// Gets all attached files.
- ///
- /// The enumeration of attached files.
- public IEnumerable GetFiles()
- => this.Where(x => x.Type == LibraryItemType.File).Select(x => (byte[])x.Value);
+ // ---- METHODS ------------------------------------------------------------------------------------------------
- ///
- /// Gets all attached scripts.
- ///
- /// The enumeration of attached scripts.
- public IEnumerable GetScripts()
- => this.Where(x => x.Type == LibraryItemType.Script).Select(x => (string)x.Value);
-
- ///
- /// Gets all attached weapons.
- ///
- /// The enumeration of attached weapons.
- public IEnumerable GetWeapons()
- => this.Where(x => x.Type == LibraryItemType.Weapon).Select(x => (Weapon)x.Value);
+ ///
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)_list).GetEnumerator();
+ }
}
///
@@ -232,19 +288,11 @@ namespace Syroot.Worms.Armageddon.ProjectX
///
public enum LibraryItemType : byte
{
- ///
- /// The entry is a raw file in form of a byte array.
- ///
+ /// The entry is a raw file in form of a byte array.
File = 2,
-
- ///
- /// The entry is a script in form of a string.
- ///
+ /// The entry is a script in form of a string.
Script = 4,
-
- ///
- /// The entry is a weapon in form of a instance.
- ///
+ /// The entry is a weapon in form of a instance.
Weapon = 8
}
}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Mine.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Mine.cs
index c3d79c3..63854b1 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Mine.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Mine.cs
@@ -1,21 +1,17 @@
-using System.Runtime.InteropServices;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public struct Mine
- {
- public int Sensitivity;
-
- public int TimeBeforeOn;
-
- public CollisionFlags SensitiveTo;
-
- public int FuseTime;
-
- public int ExplosionBias;
-
- public int ExplosionPower;
-
- public int MaxDamage;
- }
-}
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public struct Mine
+ {
+ // ---- FIELDS -------------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int Sensitivity;
+ [BinaryMember(Order = 2)] public int TimeBeforeOn;
+ [BinaryMember(Order = 3)] public CollisionFlags SensitiveTo;
+ [BinaryMember(Order = 4)] public int FuseTime;
+ [BinaryMember(Order = 5)] public int ExplosionBias;
+ [BinaryMember(Order = 6)] public int ExplosionPower;
+ [BinaryMember(Order = 7)] public int MaxDamage;
+ }
+}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Scheme.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Scheme.cs
index 151c5ac..2c838d8 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Scheme.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Scheme.cs
@@ -1,189 +1,199 @@
using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
-using Syroot.BinaryData;
-using Syroot.Worms.IO;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- ///
- /// Represents a scheme stored in a PXS file which contains game settings, weapon tables, required libraries and
- /// attached files and scripts.
- /// Used by WA PX. S. https://worms2d.info/Project_X/Scheme_file.
- ///
- public class Scheme : ILoadableFile, ISaveableFile
- {
- // ---- CONSTANTS ----------------------------------------------------------------------------------------------
-
- private const string _signature = "SCHM OF WAPX";
- private const int _weaponsPerTable = 71;
-
- // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
-
- ///
- /// Initializes a new instance of the class.
- ///
- public Scheme() { }
-
- ///
- /// Initializes a new instance of the class, loading the data from the given
- /// .
- ///
- /// The to load the data from.
- public Scheme(Stream stream) => Load(stream);
-
- ///
- /// Initializes a new instance of the class, loading the data from the given file.
- ///
- /// The name of the file to load the data from.
- public Scheme(string fileName) => Load(fileName);
-
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int Version { get; set; }
-
- public SchemeFlags Flags { get; set; }
-
- public IList WeaponTables { get; set; } = new List();
-
- public IDictionary Files { get; set; } = new Dictionary();
-
- public IDictionary Scripts { get; set; } = new Dictionary();
-
- public IList Libraries { get; set; } = new List();
-
- public string GameSchemeName { get; set; } = String.Empty;
-
- public Armageddon.Scheme? GameScheme { get; set; }
-
- // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
-
- ///
- public void Load(Stream stream)
- {
- using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
-
- // Read the header.
- if (reader.ReadString(_signature.Length) != _signature)
- throw new InvalidDataException("Invalid PXS file signature.");
- Version = reader.ReadInt32();
-
- // Read the scheme flags.
- Flags = reader.ReadStruct();
-
- // Read the weapon tables.
- int weaponTableCount = reader.ReadInt32();
- WeaponTables = new List(weaponTableCount);
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using Syroot.BinaryData;
+using Syroot.Worms.IO;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ ///
+ /// Represents a scheme stored in a PXS file which contains game settings, weapon tables, required libraries and
+ /// attached files and scripts.
+ /// Used by WA PX. S. https://worms2d.info/Project_X/Scheme_file.
+ ///
+ public class Scheme : ILoadableFile, ISaveableFile
+ {
+ // ---- CONSTANTS ----------------------------------------------------------------------------------------------
+
+ private const string _signature = "SCHM OF WAPX";
+ private const int _weaponsPerTable = 71;
+
+ // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Scheme() { }
+
+ ///
+ /// Initializes a new instance of the class, loading the data from the given
+ /// .
+ ///
+ /// The to load the data from.
+ public Scheme(Stream stream) => Load(stream);
+
+ ///
+ /// Initializes a new instance of the class, loading the data from the given file.
+ ///
+ /// The name of the file to load the data from.
+ public Scheme(string fileName) => Load(fileName);
+
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ public int Version { get; set; }
+
+ public SchemeFlags Flags { get; set; }
+
+ public IList WeaponTables { get; set; } = new List();
+
+ public IDictionary Files { get; set; } = new Dictionary();
+
+ public IDictionary Scripts { get; set; } = new Dictionary();
+
+ public IList Libraries { get; set; } = new List();
+
+ public string GameSchemeName { get; set; } = String.Empty;
+
+ public Armageddon.Scheme? GameScheme { get; set; }
+
+ // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
+
+ ///
+ public void Load(Stream stream)
+ {
+ using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
+
+ // Read the header.
+ if (reader.ReadString(_signature.Length) != _signature)
+ throw new InvalidDataException("Invalid PXS file signature.");
+ Version = reader.ReadInt32();
+
+ // Read the scheme flags.
+ Flags = reader.ReadStruct();
+
+ // Read the weapon tables.
+ int weaponTableCount = reader.ReadInt32();
+ WeaponTables = new List(weaponTableCount);
for (int i = 0; i < weaponTableCount; i++)
{
Weapon[] weaponTable = new Weapon[_weaponsPerTable];
for (int j = 0; j < _weaponsPerTable; j++)
weaponTable[j] = reader.Load();
WeaponTables.Add(weaponTable);
- }
-
- // Read a placeholder array.
- reader.Seek(sizeof(int));
-
- // Read attached files.
- int filesCount = reader.ReadInt32();
- Files = new Dictionary(filesCount);
- for (int i = 0; i < filesCount; i++)
- {
- string name = reader.ReadString(StringCoding.Int32CharCount);
- int length = reader.ReadInt32();
- Files.Add(name, reader.ReadBytes(length));
- }
-
- // Read attached scripts.
- int scriptsCount = reader.ReadInt32();
- Scripts = new Dictionary(scriptsCount);
- for (int i = 0; i < scriptsCount; i++)
- Scripts.Add(reader.ReadString(StringCoding.Int32CharCount),
- reader.ReadString(StringCoding.Int32CharCount));
-
- // Read required libraries.
- int librariesCount = reader.ReadInt32();
- Libraries = new List(reader.ReadStrings(librariesCount, StringCoding.Int32CharCount));
-
- // Read a possibly attached scheme file.
- if (reader.ReadBoolean())
- {
- reader.Seek(sizeof(int)); // Scheme length not required due to intelligent loading.
- GameScheme = reader.Load();
- GameSchemeName = reader.ReadString(StringCoding.Int32CharCount);
- }
- }
-
- ///
- public void Load(string fileName)
- {
- using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
- Load(stream);
- }
-
- ///
- public void Save(Stream stream)
- {
- using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
-
- // Write the header.
- writer.Write(_signature, StringCoding.Raw);
- writer.Write(Version);
-
- // Write the scheme flags.
- writer.WriteStruct(Flags);
-
- // Write the weapon tables.
- writer.Write(WeaponTables.Count);
+ }
+
+ // Read a placeholder array.
+ reader.Seek(sizeof(int));
+
+ // Read attached files.
+ int filesCount = reader.ReadInt32();
+ Files = new Dictionary(filesCount);
+ for (int i = 0; i < filesCount; i++)
+ {
+ string name = reader.ReadString(StringCoding.Int32CharCount);
+ int length = reader.ReadInt32();
+ Files.Add(name, reader.ReadBytes(length));
+ }
+
+ // Read attached scripts.
+ int scriptsCount = reader.ReadInt32();
+ Scripts = new Dictionary(scriptsCount);
+ for (int i = 0; i < scriptsCount; i++)
+ Scripts.Add(reader.ReadString(StringCoding.Int32CharCount),
+ reader.ReadString(StringCoding.Int32CharCount));
+
+ // Read required libraries.
+ int librariesCount = reader.ReadInt32();
+ Libraries = new List(reader.ReadStrings(librariesCount, StringCoding.Int32CharCount));
+
+ // Read a possibly attached scheme file.
+ if (reader.ReadBoolean())
+ {
+ byte[] schemeData = reader.ReadBytes(reader.ReadInt32());
+ using MemoryStream schemeStream = new MemoryStream(schemeData);
+ GameScheme = schemeStream.Load();
+ GameSchemeName = reader.ReadString(StringCoding.Int32CharCount);
+ }
+ else
+ {
+ GameScheme = null;
+ GameSchemeName = String.Empty;
+ }
+ }
+
+ ///
+ public void Load(string fileName)
+ {
+ using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
+ Load(stream);
+ }
+
+ ///
+ public void Save(Stream stream)
+ {
+ using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
+
+ // Write the header.
+ writer.Write(_signature, StringCoding.Raw);
+ writer.Write(Version);
+
+ // Write the scheme flags.
+ writer.WriteStruct(Flags);
+
+ // Write the weapon tables.
+ writer.Write(WeaponTables.Count);
foreach (Weapon[] weaponTable in WeaponTables)
- for (int i = 0; i < _weaponsPerTable; i++)
- writer.Save(weaponTable[i]);
-
- // Write a placeholder array.
- writer.Write(0);
-
- // Write attached files.
- writer.Write(Files.Count);
- foreach (KeyValuePair file in Files)
- {
- writer.Write(file.Key, StringCoding.Int32CharCount);
- writer.Write(file.Value.Length);
- writer.Write(file.Value);
- }
-
- // Write attached scripts.
- writer.Write(Scripts.Count);
- foreach (KeyValuePair script in Scripts)
- {
- writer.Write(script.Key, StringCoding.Int32CharCount);
- writer.Write(script.Value, StringCoding.Int32CharCount);
- }
-
- // Write required libraries.
- writer.Write(Libraries.Count);
- writer.Write(Libraries);
-
- // Write a possibly attached scheme file.
- if (GameScheme != null)
- {
- byte[] schemeBytes;
- using (MemoryStream schemeStream = new MemoryStream())
- {
- GameScheme.Save(schemeStream);
- schemeBytes = schemeStream.ToArray();
- }
- writer.Write(schemeBytes.Length);
- writer.Write(GameSchemeName, StringCoding.Int32CharCount);
- }
- }
-
- ///
- public void Save(string fileName)
- {
- using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
- Save(stream);
- }
- }
-}
+ for (int i = 0; i < _weaponsPerTable; i++)
+ writer.Save(weaponTable[i]);
+
+ // Write a placeholder array.
+ writer.Write(0);
+
+ // Write attached files.
+ writer.Write(Files.Count);
+ foreach (KeyValuePair file in Files)
+ {
+ writer.Write(file.Key, StringCoding.Int32CharCount);
+ writer.Write(file.Value.Length);
+ writer.Write(file.Value);
+ }
+
+ // Write attached scripts.
+ writer.Write(Scripts.Count);
+ foreach (KeyValuePair script in Scripts)
+ {
+ writer.Write(script.Key, StringCoding.Int32CharCount);
+ writer.Write(script.Value, StringCoding.Int32CharCount);
+ }
+
+ // Write required libraries.
+ writer.Write(Libraries.Count);
+ writer.Write(Libraries, StringCoding.Int32CharCount);
+
+ // Write a possibly attached scheme file.
+ if (GameScheme != null)
+ {
+ writer.Write(true);
+ using MemoryStream schemeStream = new MemoryStream();
+ GameScheme.Save(schemeStream);
+
+ writer.Write((int)schemeStream.Position);
+ schemeStream.Position = 0;
+ schemeStream.CopyTo(writer);
+ writer.Write(GameSchemeName, StringCoding.Int32CharCount);
+ }
+ else
+ {
+ writer.Write(false);
+ }
+ }
+
+ ///
+ public void Save(string fileName)
+ {
+ using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
+ Save(stream);
+ }
+ }
+}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/SchemeFlags.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/SchemeFlags.cs
index da4711c..7946b9c 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/SchemeFlags.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/SchemeFlags.cs
@@ -1,56 +1,29 @@
-using System.Runtime.InteropServices;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- ///
- /// Represents global Project X scheme flags affecting general game behavior.
- ///
- [StructLayout(LayoutKind.Sequential)]
- public struct SchemeFlags
- {
- [MarshalAs(UnmanagedType.I1)]
- public bool CyclicMaps;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool UnderwaterJetpack;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool UnderwaterRope;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool Unused1;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool Unused2;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool Unused3;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool Unused4;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool Unused5;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool Unused6;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool Unused7;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool Unused8;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool ShotDoesntEndTurn;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool LoseControlDoesntEndTurn;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool FiringPausesTimer;
-
- [MarshalAs(UnmanagedType.I1)]
- public bool EnableSchemePowers;
- }
-}
+using System.Runtime.InteropServices;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ ///
+ /// Represents global Project X scheme flags affecting general game behavior.
+ ///
+ [StructLayout(LayoutKind.Sequential)]
+ public struct SchemeFlags
+ {
+ // ---- FIELDS -------------------------------------------------------------------------------------------------
+
+ public bool CyclicMaps;
+ public bool UnderwaterJetpack;
+ public bool UnderwaterRope;
+ public bool Unused1;
+ public bool Unused2;
+ public bool Unused3;
+ public bool Unused4;
+ public bool Unused5;
+ public bool Unused6;
+ public bool Unused7;
+ public bool Unused8;
+ public bool ShotDoesntEndTurn;
+ public bool LoseControlDoesntEndTurn;
+ public bool FiringPausesTimer;
+ public bool EnableSchemePowers;
+ }
+}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Sound.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Sound.cs
index bb54fc9..7bd671b 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Sound.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Sound.cs
@@ -1,19 +1,15 @@
-using Syroot.BinaryData;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public struct Sound
- {
- public short SoundIndex;
-
- [BinaryMember(BooleanCoding = BooleanCoding.Word)]
- public bool RepeatSound;
-
- [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
- public bool UseExplosionSound;
-
- public int SoundBeforeExplosion;
-
- public int DelayBeforeExplosion;
- }
-}
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public struct Sound
+ {
+ // ---- FIELDS -------------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public ushort SoundIndex;
+ [BinaryMember(Order = 2, BooleanCoding = BooleanCoding.Word)] public bool RepeatSound;
+ [BinaryMember(Order = 3, BooleanCoding = BooleanCoding.Dword)] public bool UseExplosionSound;
+ [BinaryMember(Order = 4)] public int SoundBeforeExplosion;
+ [BinaryMember(Order = 5)] public int DelayBeforeExplosion;
+ }
+}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Sprite.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Sprite.cs
index 5f92f1d..bcf867c 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Sprite.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Sprite.cs
@@ -1,30 +1,27 @@
-using System.Runtime.InteropServices;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public struct Sprite
- {
- public int SpriteNumber;
-
- public SpriteAnimationType AnimationType;
-
- public int TrailSprite;
-
- public int TrailAmount;
-
- public int TrailVanishSpeed;
-
- public int Unknown;
- }
-
- public enum SpriteAnimationType : int
- {
- HorizontalVelocity,
- Cycle,
- TrackMovement,
- TrackSpeed,
- SlowCycle,
- FasterCycle,
- FastCycle
- }
-}
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public struct Sprite
+ {
+ // ---- FIELDS -------------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int SpriteNumber;
+ [BinaryMember(Order = 2)] public SpriteAnimationType AnimationType;
+ [BinaryMember(Order = 3)] public int TrailSprite;
+ [BinaryMember(Order = 4)] public int TrailAmount;
+ [BinaryMember(Order = 5)] public int TrailVanishSpeed;
+ [BinaryMember(Order = 6)] public int Unknown;
+ }
+
+ public enum SpriteAnimationType : int
+ {
+ HorizontalVelocity,
+ Cycle,
+ TrackMovement,
+ TrackSpeed,
+ SlowCycle,
+ FasterCycle,
+ FastCycle
+ }
+}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/AirstrikeStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/AirstrikeStyle.cs
index 5a2539c..769a7ea 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/AirstrikeStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/AirstrikeStyle.cs
@@ -6,20 +6,19 @@ namespace Syroot.Worms.Armageddon.ProjectX
{
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
- public int PlaneSprite;
+ [BinaryMember(Order = 1)] public int PlaneSprite;
- public int BombsCount;
+ [BinaryMember(Order = 2)] public int BombsCount;
- public int DropDistance;
+ [BinaryMember(Order = 3)] public int DropDistance;
- public int HorizontalSpeed;
+ [BinaryMember(Order = 4)] public int HorizontalSpeed;
- public int Sound;
+ [BinaryMember(Order = 5)] public int Sound;
- public WeaponAirstrikeSubstyle AirstrikeSubstyle;
+ [BinaryMember(Order = 6)] public WeaponAirstrikeSubstyle AirstrikeSubstyle;
- [BinaryMember(Converter = typeof(AirstrikeSubstyleConverter))]
- public IStyle? Style;
+ [BinaryMember(Order = 7, Converter = typeof(AirstrikeSubstyleConverter))] public IStyle? Style;
}
public enum WeaponAirstrikeSubstyle : int
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/AirstrikeSubstyleConverter.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/AirstrikeSubstyleConverter.cs
index 4204e2e..adca190 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/AirstrikeSubstyleConverter.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/AirstrikeSubstyleConverter.cs
@@ -1,33 +1,35 @@
-using System;
-using System.IO;
-using Syroot.BinaryData;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class AirstrikeSubstyleConverter : IBinaryConverter
- {
- // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
-
- public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
- ByteConverter byteConverter)
- {
- WeaponAirstrikeSubstyle airstrikeSubstyle = instance switch
- {
- AirstrikeStyle airstrikeStyle => airstrikeStyle.AirstrikeSubstyle,
- _ => throw new NotImplementedException(),
- };
- return airstrikeSubstyle switch
- {
- WeaponAirstrikeSubstyle.Launcher => stream.ReadObject(),
- WeaponAirstrikeSubstyle.Mines => stream.ReadObject(),
- _ => throw new NotImplementedException(),
- };
- }
-
- public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
- ByteConverter byteConverter)
- {
- stream.WriteObject(value);
- }
- }
+using System;
+using System.IO;
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class AirstrikeSubstyleConverter : IBinaryConverter
+ {
+ // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
+
+ ///
+ public object? Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
+ ByteConverter byteConverter)
+ {
+ WeaponAirstrikeSubstyle airstrikeSubstyle = instance switch
+ {
+ AirstrikeStyle airstrikeStyle => airstrikeStyle.AirstrikeSubstyle,
+ _ => throw new NotImplementedException(),
+ };
+ return airstrikeSubstyle switch
+ {
+ WeaponAirstrikeSubstyle.Mines => stream.ReadObject(),
+ WeaponAirstrikeSubstyle.Launcher => stream.ReadObject(),
+ _ => null
+ };
+ }
+
+ ///
+ public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
+ ByteConverter byteConverter)
+ {
+ stream.WriteObject(value);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BaseballBatStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BaseballBatStyle.cs
index 4fbd093..f81b822 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BaseballBatStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BaseballBatStyle.cs
@@ -1,11 +1,13 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class BaseballBatStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int Damage { get; set; }
-
- public int PushPower { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class BaseballBatStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int Damage { get; set; }
+
+ [BinaryMember(Order = 2)] public int PushPower { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BattleAxeStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BattleAxeStyle.cs
index a2ac7a1..3707f6f 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BattleAxeStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BattleAxeStyle.cs
@@ -1,9 +1,11 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class BattleAxeStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int PercentualDamage { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class BattleAxeStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int PercentualDamage { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BlowtorchStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BlowtorchStyle.cs
index 57acc77..ca9fb19 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BlowtorchStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BlowtorchStyle.cs
@@ -1,15 +1,17 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class BlowtorchStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int Damage { get; set; }
-
- public int PushPower { get; set; }
-
- public int ImpactAngle { get; set; }
-
- public int TunellingTime { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class BlowtorchStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int Damage { get; set; }
+
+ [BinaryMember(Order = 2)] public int PushPower { get; set; }
+
+ [BinaryMember(Order = 3)] public int ImpactAngle { get; set; }
+
+ [BinaryMember(Order = 4)] public int TunellingTime { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BowStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BowStyle.cs
index 81d1b35..3142a7c 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BowStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/BowStyle.cs
@@ -1,9 +1,11 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class BowStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int Damage { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class BowStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int Damage { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/CanisterStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/CanisterStyle.cs
index 23b29b7..7a88f64 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/CanisterStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/CanisterStyle.cs
@@ -1,15 +1,17 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class CanisterStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int SpriteInactive { get; set; }
-
- public int SpriteActive { get; set; }
-
- public int DiseasePoints { get; set; }
-
- public int MaxDamage { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class CanisterStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int SpriteInactive { get; set; }
+
+ [BinaryMember(Order = 2)] public int SpriteActive { get; set; }
+
+ [BinaryMember(Order = 3)] public int DiseasePoints { get; set; }
+
+ [BinaryMember(Order = 4)] public int MaxDamage { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/DragonballStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/DragonballStyle.cs
index ceac0cd..2edd3bf 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/DragonballStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/DragonballStyle.cs
@@ -1,21 +1,23 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class DragonballStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int FiringSound { get; set; }
-
- public int ImpactSound { get; set; }
-
- public int BallSprite { get; set; }
-
- public int Damage { get; set; }
-
- public int Angle { get; set; }
-
- public int Force { get; set; }
-
- public int BallTime { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class DragonballStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int FiringSound { get; set; }
+
+ [BinaryMember(Order = 2)] public int ImpactSound { get; set; }
+
+ [BinaryMember(Order = 3)] public int BallSprite { get; set; }
+
+ [BinaryMember(Order = 4)] public int Damage { get; set; }
+
+ [BinaryMember(Order = 5)] public int Angle { get; set; }
+
+ [BinaryMember(Order = 6)] public int Force { get; set; }
+
+ [BinaryMember(Order = 7)] public int BallTime { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/FirepunchStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/FirepunchStyle.cs
index 0e1eb58..be040ea 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/FirepunchStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/FirepunchStyle.cs
@@ -1,15 +1,17 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class FirepunchStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int Damage { get; set; }
-
- public int Angle { get; set; }
-
- public int PushPower { get; set; }
-
- public int JumpHeight { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class FirepunchStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int Damage { get; set; }
+
+ [BinaryMember(Order = 2)] public int Angle { get; set; }
+
+ [BinaryMember(Order = 3)] public int PushPower { get; set; }
+
+ [BinaryMember(Order = 4)] public int JumpHeight { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/FlamethrowerStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/FlamethrowerStyle.cs
index 28f108d..e8436a7 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/FlamethrowerStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/FlamethrowerStyle.cs
@@ -6,15 +6,14 @@ namespace Syroot.Worms.Armageddon.ProjectX
{
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
- public int FuelAmount { get; set; }
+ [BinaryMember(Order = 1)] public int FuelAmount { get; set; }
- public int FireIntensity { get; set; }
+ [BinaryMember(Order = 2)] public int FireIntensity { get; set; }
- public int FireAmount { get; set; }
+ [BinaryMember(Order = 3)] public int FireAmount { get; set; }
- public int FireBurnTime { get; set; }
+ [BinaryMember(Order = 4)] public int FireBurnTime { get; set; }
- [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
- public bool RemainOnTerrain { get; set; }
+ [BinaryMember(Order = 5, BooleanCoding = BooleanCoding.Dword)] public bool RemainOnTerrain { get; set; }
}
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/GunStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/GunStyle.cs
index 57ab1ec..f4f8d37 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/GunStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/GunStyle.cs
@@ -1,35 +1,37 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class GunStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int BulletCount { get; set; }
-
- public int ReloadTime { get; set; }
-
- public int BulletSpread { get; set; }
-
- public int Burst { get; set; }
-
- public int BurstSpread { get; set; }
-
- public CollisionFlags Collisions { get; set; }
-
- public int ExplosionBias { get; set; }
-
- public int ExplosionPower { get; set; }
-
- public int MaxDamage { get; set; }
-
- public int DamageSpread { get; set; }
-
- public int ExpEffect { get; set; }
-
- public int Range1 { get; set; }
-
- public int Range2 { get; set; }
-
- public int Range3 { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class GunStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int BulletCount { get; set; }
+
+ [BinaryMember(Order = 2)] public int ReloadTime { get; set; }
+
+ [BinaryMember(Order = 3)] public int BulletSpread { get; set; }
+
+ [BinaryMember(Order = 4)] public int Burst { get; set; }
+
+ [BinaryMember(Order = 5)] public int BurstSpread { get; set; }
+
+ [BinaryMember(Order = 6)] public CollisionFlags Collisions { get; set; }
+
+ [BinaryMember(Order = 7)] public int ExplosionBias { get; set; }
+
+ [BinaryMember(Order = 8)] public int ExplosionPower { get; set; }
+
+ [BinaryMember(Order = 9)] public int MaxDamage { get; set; }
+
+ [BinaryMember(Order = 10)] public int DamageSpread { get; set; }
+
+ [BinaryMember(Order = 11)] public int ExpEffect { get; set; }
+
+ [BinaryMember(Order = 12)] public int Range1 { get; set; }
+
+ [BinaryMember(Order = 13)] public int Range2 { get; set; }
+
+ [BinaryMember(Order = 14)] public int Range3 { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/JetpackStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/JetpackStyle.cs
index f741c9c..e801372 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/JetpackStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/JetpackStyle.cs
@@ -1,9 +1,11 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class JetpackStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int Fuel { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class JetpackStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int Fuel { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/KamikazeStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/KamikazeStyle.cs
index b817810..9500722 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/KamikazeStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/KamikazeStyle.cs
@@ -1,19 +1,21 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class KamikazeStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int FlyingTime { get; set; }
-
- public int ExplosionDamage { get; set; }
-
- public int FireSound { get; set; }
-
- public int Damage { get; set; }
-
- public int ImpactForce { get; set; }
-
- public int ImpactAngle { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class KamikazeStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int FlyingTime { get; set; }
+
+ [BinaryMember(Order = 2)] public int ExplosionDamage { get; set; }
+
+ [BinaryMember(Order = 3)] public int FireSound { get; set; }
+
+ [BinaryMember(Order = 4)] public int Damage { get; set; }
+
+ [BinaryMember(Order = 5)] public int ImpactForce { get; set; }
+
+ [BinaryMember(Order = 6)] public int ImpactAngle { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/LauncherStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/LauncherStyle.cs
index 40cc990..9c26ee4 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/LauncherStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/LauncherStyle.cs
@@ -1,74 +1,71 @@
-using Syroot.BinaryData;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class LauncherStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int SpriteSize { get; set; }
-
- public int FixedSpeed { get; set; }
-
- [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
- public bool RunAway { get; set; }
-
- public CollisionFlags Collisions { get; set; }
-
- public int ExplosionBias { get; set; }
-
- public int ExplosionPushPower { get; set; }
-
- public int ExplosionDamage { get; set; }
-
- public int ExplosionDamageVariation { get; set; }
-
- public int ExplosionUnknown { get; set; }
-
- public Sprite Sprite { get; set; }
-
- public int VariableSpeed { get; set; }
-
- public int WindFactor { get; set; }
-
- public int MotionRandomness { get; set; }
-
- public int GravityFactor { get; set; }
-
- public int ExplosionCountdown { get; set; }
-
- public int ExplosionTimer { get; set; }
-
- public Sound Sound { get; set; }
-
- [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
- public bool ExplodeOnSpace { get; set; }
-
- public ExplosionAction ExplosionAction { get; set; }
-
- [BinaryMember(Converter = typeof(ActionConverter))]
- public IAction? Action { get; set; }
-
- [BinaryMember(OffsetOrigin = OffsetOrigin.Begin, Offset = 180)]
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class LauncherStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int SpriteSize { get; set; }
+
+ [BinaryMember(Order = 2)] public int FixedSpeed { get; set; }
+
+ [BinaryMember(Order = 3, BooleanCoding = BooleanCoding.Dword)] public bool RunAway { get; set; }
+
+ [BinaryMember(Order = 4)] public CollisionFlags Collisions { get; set; }
+
+ [BinaryMember(Order = 5)] public int ExplosionBias { get; set; }
+
+ [BinaryMember(Order = 6)] public int ExplosionPushPower { get; set; }
+
+ [BinaryMember(Order = 7)] public int ExplosionDamage { get; set; }
+
+ [BinaryMember(Order = 8)] public int ExplosionDamageVariation { get; set; }
+
+ [BinaryMember(Order = 9)] public int ExplosionUnknown { get; set; }
+
+ [BinaryMember(Order = 10)] public Sprite Sprite { get; set; }
+
+ [BinaryMember(Order = 11)] public int VariableSpeed { get; set; }
+
+ [BinaryMember(Order = 12)] public int WindFactor { get; set; }
+
+ [BinaryMember(Order = 13)] public int MotionRandomness { get; set; }
+
+ [BinaryMember(Order = 14)] public int GravityFactor { get; set; }
+
+ [BinaryMember(Order = 15)] public int ExplosionCountdown { get; set; }
+
+ [BinaryMember(Order = 16)] public int ExplosionTimer { get; set; }
+
+ [BinaryMember(Order = 17)] public Sound Sound { get; set; }
+
+ [BinaryMember(Order = 18, BooleanCoding = BooleanCoding.Dword)] public bool ExplodeOnSpace { get; set; }
+
+ [BinaryMember(Order = 19)] public ExplosionAction ExplosionAction { get; set; }
+
+ [BinaryMember(Order = 20, Converter = typeof(ActionConverter))] public IAction? Action { get; set; }
+
+ [BinaryMember(Order = 21, OffsetOrigin = OffsetOrigin.Begin, Offset = 180)]
public ExplosionTarget ExplosionTarget { get; set; }
- [BinaryMember(Offset = sizeof(int), Converter = typeof(TargetConverter))]
- public ITarget? Target { get; set; }
- }
-
- public enum ExplosionAction : int
- {
- None,
- Home,
- Bounce,
- Roam,
- Dig
- }
-
- public enum ExplosionTarget : int
- {
- None,
- Clusters,
- Fire
- }
+ [BinaryMember(Order = 22, Offset = sizeof(int), Converter = typeof(TargetConverter))]
+ public ITarget? Target { get; set; }
+ }
+
+ public enum ExplosionAction : int
+ {
+ None,
+ Home,
+ Bounce,
+ Roam,
+ Dig
+ }
+
+ public enum ExplosionTarget : int
+ {
+ None,
+ Clusters,
+ Fire
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/MineStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/MineStyle.cs
index c798032..4ddfaf6 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/MineStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/MineStyle.cs
@@ -1,9 +1,11 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class MineStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public Mine Mine;
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class MineStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public Mine Mine;
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/NinjaRopeStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/NinjaRopeStyle.cs
index d547a08..f373989 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/NinjaRopeStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/NinjaRopeStyle.cs
@@ -1,13 +1,15 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class NinjaRopeStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int ShotCount { get; set; }
-
- public int Length { get; set; }
-
- public int AngleRestriction { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class NinjaRopeStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int ShotCount { get; set; }
+
+ [BinaryMember(Order = 2)] public int Length { get; set; }
+
+ [BinaryMember(Order = 3)] public int AngleRestriction { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/NuclearTestStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/NuclearTestStyle.cs
index 3b93769..b30f79b 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/NuclearTestStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/NuclearTestStyle.cs
@@ -1,11 +1,13 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class NuclearTestStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int WaterRise { get; set; }
-
- public int DiseasePoints { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class NuclearTestStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int WaterRise { get; set; }
+
+ [BinaryMember(Order = 2)] public int DiseasePoints { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/ParachuteStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/ParachuteStyle.cs
index d541903..391da81 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/ParachuteStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/ParachuteStyle.cs
@@ -1,9 +1,11 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class ParachuteStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int WindResponse { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class ParachuteStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int WindResponse { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/PneumaticDrillStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/PneumaticDrillStyle.cs
index 2f3417b..9554b65 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/PneumaticDrillStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/PneumaticDrillStyle.cs
@@ -1,15 +1,17 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class PneumaticDrillStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int Damage { get; set; }
-
- public int PushPower { get; set; }
-
- public int ImpactAngle { get; set; }
-
- public int TunellingTime { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class PneumaticDrillStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int Damage { get; set; }
+
+ [BinaryMember(Order = 2)] public int PushPower { get; set; }
+
+ [BinaryMember(Order = 3)] public int ImpactAngle { get; set; }
+
+ [BinaryMember(Order = 4)] public int TunellingTime { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/ProdStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/ProdStyle.cs
index d2ea303..e366221 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/ProdStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/ProdStyle.cs
@@ -1,13 +1,15 @@
+using Syroot.BinaryData;
+
namespace Syroot.Worms.Armageddon.ProjectX
{
public class ProdStyle : IStyle
{
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
- public int Damage { get; set; }
+ [BinaryMember(Order = 1)] public int Damage { get; set; }
- public int Force { get; set; }
+ [BinaryMember(Order = 2)] public int Force { get; set; }
- public int Angle { get; set; }
+ [BinaryMember(Order = 3)] public int Angle { get; set; }
}
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/SuicideBomberStyle.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/SuicideBomberStyle.cs
index 33f525b..f3b71cb 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/SuicideBomberStyle.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Styles/SuicideBomberStyle.cs
@@ -1,11 +1,13 @@
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class SuicideBomberStyle : IStyle
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int DiseasePoints { get; set; }
-
- public int Damage { get; set; }
- }
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class SuicideBomberStyle : IStyle
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int DiseasePoints { get; set; }
+
+ [BinaryMember(Order = 2)] public int Damage { get; set; }
+ }
}
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Syroot.Worms.Armageddon.ProjectX.csproj b/src/library/Syroot.Worms.Armageddon.ProjectX/Syroot.Worms.Armageddon.ProjectX.csproj
index a454efb..9907911 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Syroot.Worms.Armageddon.ProjectX.csproj
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Syroot.Worms.Armageddon.ProjectX.csproj
@@ -1,14 +1,20 @@
-
-
-
- Syroot.Worms.Armageddon.ProjectX
- .NET library for loading and modifying files of Worms Armageddon ProjectX.
- Overhaul implementation and documentation.
- $(PackageTags);project x;worms armageddon
- 4.0.0
-
-
-
-
-
+
+
+
+
+
+ Syroot.Worms.Armageddon.ProjectX
+ .NET library for loading and modifying files of Worms Armageddon ProjectX.
+ Overhaul implementation and documentation.
+ $(PackageTags);project x;worms armageddon
+ 4.0.0
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/ClusterTarget.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/ClusterTarget.cs
index b69c584..ac3fbd6 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/ClusterTarget.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/ClusterTarget.cs
@@ -1,55 +1,53 @@
-using Syroot.BinaryData;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- public class ClusterTarget : ITarget
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public int ClusterCount { get; set; }
-
- public int DispersionPower { get; set; }
-
- public int Speed { get; set; }
-
- public int EjectionAngle { get; set; }
-
- public int DispersionAngle { get; set; }
-
- public CollisionFlags Collisions { get; set; }
-
- public int ExplosionBias { get; set; }
-
- public int ExplosionPushPower { get; set; }
-
- public int ExplosionDamage { get; set; }
-
- public int ExplosionDamageVariation { get; set; }
-
- public int SpriteCount { get; set; }
-
- public Sprite Sprite { get; set; }
-
- public int Acceleration { get; set; }
-
- public int WindResponse { get; set; }
-
- public int MotionRandomness { get; set; }
-
- public int GravityFactor { get; set; }
-
- public int Unused1 { get; set; }
-
- public int Unused2 { get; set; }
-
- public Sound Sound { get; set; }
-
- [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
- public bool ExplodeOnSpace { get; set; }
-
- public ExplosionAction ExplosionAction { get; set; }
-
- [BinaryMember(Converter = typeof(ActionConverter))]
- public IAction? Action { get; set; }
- }
-}
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ public class ClusterTarget : ITarget
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public int ClusterCount { get; set; }
+
+ [BinaryMember(Order = 2)] public int DispersionPower { get; set; }
+
+ [BinaryMember(Order = 3)] public int Speed { get; set; }
+
+ [BinaryMember(Order = 4)] public int EjectionAngle { get; set; }
+
+ [BinaryMember(Order = 5)] public int DispersionAngle { get; set; }
+
+ [BinaryMember(Order = 6)] public CollisionFlags Collisions { get; set; }
+
+ [BinaryMember(Order = 7)] public int ExplosionBias { get; set; }
+
+ [BinaryMember(Order = 8)] public int ExplosionPushPower { get; set; }
+
+ [BinaryMember(Order = 9)] public int ExplosionDamage { get; set; }
+
+ [BinaryMember(Order = 10)] public int ExplosionDamageVariation { get; set; }
+
+ [BinaryMember(Order = 11)] public int SpriteCount { get; set; }
+
+ [BinaryMember(Order = 12)] public Sprite Sprite { get; set; }
+
+ [BinaryMember(Order = 13)] public int Acceleration { get; set; }
+
+ [BinaryMember(Order = 14)] public int WindResponse { get; set; }
+
+ [BinaryMember(Order = 15)] public int MotionRandomness { get; set; }
+
+ [BinaryMember(Order = 16)] public int GravityFactor { get; set; }
+
+ [BinaryMember(Order = 17)] public int Unused1 { get; set; }
+
+ [BinaryMember(Order = 18)] public int Unused2 { get; set; }
+
+ [BinaryMember(Order = 19)] public Sound Sound { get; set; }
+
+ [BinaryMember(Order = 20, BooleanCoding = BooleanCoding.Dword)] public bool ExplodeOnSpace { get; set; }
+
+ [BinaryMember(Order = 21)] public ExplosionAction ExplosionAction { get; set; }
+
+ [BinaryMember(Order = 22, Converter = typeof(ActionConverter))] public IAction? Action { get; set; }
+ }
+}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/FireTarget.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/FireTarget.cs
index 766c78c..fe60e14 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/FireTarget.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/FireTarget.cs
@@ -6,13 +6,12 @@ namespace Syroot.Worms.Armageddon.ProjectX
{
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
- public int Power { get; set; }
+ [BinaryMember(Order = 1)] public int Power { get; set; }
- public int Spread { get; set; }
+ [BinaryMember(Order = 2)] public int Spread { get; set; }
- public int Time { get; set; }
+ [BinaryMember(Order = 3)] public int Time { get; set; }
- [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
- public bool StayBetweenTurns { get; set; }
+ [BinaryMember(Order = 4, BooleanCoding = BooleanCoding.Dword)] public bool StayBetweenTurns { get; set; }
}
}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/TargetConverter.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/TargetConverter.cs
index b4b95cb..9e4cbdd 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/TargetConverter.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Targets/TargetConverter.cs
@@ -1,34 +1,35 @@
-using System;
-using System.IO;
-using Syroot.BinaryData;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- internal class TargetConverter : IBinaryConverter
- {
- // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
-
- public object? Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
- ByteConverter byteConverter)
- {
- ExplosionTarget explosionTarget = instance switch
- {
- LauncherStyle launcherStyle => launcherStyle.ExplosionTarget,
- _ => throw new NotImplementedException(),
- };
- return explosionTarget switch
+using System;
+using System.IO;
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ internal class TargetConverter : IBinaryConverter
+ {
+ // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
+
+ ///
+ public object? Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
+ ByteConverter byteConverter)
+ {
+ ExplosionTarget explosionTarget = instance switch
{
- ExplosionTarget.None => null,
- ExplosionTarget.Clusters => stream.ReadObject(),
- ExplosionTarget.Fire => stream.ReadObject(),
- _ => throw new NotImplementedException(),
- };
- }
-
- public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
- ByteConverter byteConverter)
- {
- stream.WriteObject(value);
- }
- }
-}
+ LauncherStyle launcherStyle => launcherStyle.ExplosionTarget,
+ _ => throw new NotImplementedException(),
+ };
+ return explosionTarget switch
+ {
+ ExplosionTarget.Clusters => stream.ReadObject(),
+ ExplosionTarget.Fire => stream.ReadObject(),
+ _ => null,
+ };
+ }
+
+ ///
+ public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
+ ByteConverter byteConverter)
+ {
+ stream.WriteObject(value);
+ }
+ }
+}
diff --git a/src/library/Syroot.Worms.Armageddon.ProjectX/Weapon.cs b/src/library/Syroot.Worms.Armageddon.ProjectX/Weapon.cs
index 22d76ac..f01b978 100644
--- a/src/library/Syroot.Worms.Armageddon.ProjectX/Weapon.cs
+++ b/src/library/Syroot.Worms.Armageddon.ProjectX/Weapon.cs
@@ -1,449 +1,398 @@
using System;
-using System.Diagnostics;
-using System.IO;
-using System.Text;
-using Syroot.BinaryData;
-using Syroot.Worms.IO;
-
-namespace Syroot.Worms.Armageddon.ProjectX
-{
- [DebuggerDisplay("Weapon Name={Name}")]
- public class Weapon : ILoadable, ISaveable
- {
- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
-
- public WeaponVersion Version { get; set; }
-
- public long Checksum { get; set; }
-
- public int TableRow { get; set; }
-
- public bool Remembered { get; set; }
-
- public bool UsableInCavern { get; set; }
-
- public int Shots { get; set; }
-
- public bool ShotEndsTurn { get; set; }
-
- public int RetreatTime { get; set; }
-
- public int Unknown1 { get; set; }
-
- public int CrateChance { get; set; }
-
- public int CrateCount { get; set; }
-
- public int Unknown2 { get; set; }
-
- public WeaponActivation Activation { get; set; }
-
- public int NotUsed { get; set; }
-
- public int ThrowHerdCount { get; set; }
-
- public int AirstrikeSubtype { get; set; }
-
- public WeaponSpacebarAction SpacebarAction { get; set; }
-
- public WeaponCrosshairAction CrosshairAction { get; set; }
-
- public WeaponThrowAction ThrowAction { get; set; }
-
- public IStyle? Style { get; set; }
-
- public bool AmmunitionOverride { get; set; }
-
- public int Ammunition { get; set; }
-
- public int Unknown3 { get; set; }
-
- public int WeaponSprite { get; set; }
-
- public string NameLong { get; set; } = String.Empty;
-
- public string Name { get; set; } = String.Empty;
-
- public string GridImageFile { get; set; } = String.Empty;
-
- public string GfxDirectoryFile { get; set; } = String.Empty;
-
- public string[] SpriteNames { get; } = new string[5];
-
- public bool DelayOverride { get; set; }
-
- public int Delay { get; set; }
-
- public bool UseLibrary { get; set; }
-
- public string LibraryName { get; set; } = String.Empty;
-
- public string LibraryWeaponName { get; set; } = String.Empty;
-
- public string AimSpriteEven { get; set; } = String.Empty;
-
- public string AimSpriteUphill { get; set; } = String.Empty;
-
- public string AimSpriteDownhill { get; set; } = String.Empty;
-
- public string PickSpriteEven { get; set; } = String.Empty;
-
- public string PickSpriteUphill { get; set; } = String.Empty;
-
- public string PickSpriteDownhill { get; set; } = String.Empty;
-
- public string FireSpriteEven { get; set; } = String.Empty;
-
- public string FireSpriteUphill { get; set; } = String.Empty;
-
- public string FireSpriteDownhill { get; set; } = String.Empty;
-
- public bool AimSpriteOverride { get; set; }
-
- public bool PickSpriteOverride { get; set; }
-
- public bool FireSpriteOverride { get; set; }
-
- public bool Utility { get; set; }
-
- // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
-
- ///
- public void Load(Stream stream)
- {
- using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
-
- // Read the header.
- long offset = reader.Position;
- Version = reader.ReadEnum(true);
- Checksum = reader.ReadInt64();
-
- // Read general settings.
- TableRow = reader.ReadInt32();
- Remembered = reader.ReadBoolean(BooleanCoding.Dword);
- UsableInCavern = reader.ReadBoolean(BooleanCoding.Dword);
- Shots = reader.ReadInt32();
- ShotEndsTurn = reader.ReadBoolean(BooleanCoding.Dword);
- RetreatTime = reader.ReadInt32();
- Unknown1 = reader.ReadInt32();
- CrateChance = reader.ReadInt32();
- CrateCount = reader.ReadInt32();
- Unknown2 = reader.ReadInt32();
-
- // Read the activation and the corresponding weapon settings.
- Activation = reader.ReadEnum(false);
- switch (Activation)
- {
- case WeaponActivation.Airstrike:
- AirstrikeSubtype = reader.ReadInt32();
- Style = reader.ReadObject();
- break;
- case WeaponActivation.Crosshair:
- NotUsed = reader.ReadInt32();
- CrosshairAction = reader.ReadEnum(false);
- switch (CrosshairAction)
- {
- case WeaponCrosshairAction.Bow:
- Style = reader.ReadObject();
- break;
- case WeaponCrosshairAction.Flamethrower:
- Style = reader.ReadObject();
- break;
- case WeaponCrosshairAction.Gun:
- Style = reader.ReadObject();
- break;
- case WeaponCrosshairAction.Launcher:
- Style = reader.ReadObject();
- break;
- }
- break;
- case WeaponActivation.Spacebar:
- SpacebarAction = reader.ReadEnum(false);
- switch (SpacebarAction)
- {
- case WeaponSpacebarAction.Armageddon:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.BaseballBat:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.BattleAxe:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.Blowtorch:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.Dragonball:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.Firepunch:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.Jetpack:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.Kamikaze:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.NinjaRope:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.NuclearTest:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.Parachute:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.PneumaticDrill:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.Prod:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.SuicideBomber:
- Style = reader.ReadObject();
- break;
- case WeaponSpacebarAction.Bungee:
- case WeaponSpacebarAction.Earthquake:
- case WeaponSpacebarAction.Freeze:
- case WeaponSpacebarAction.Girder:
- case WeaponSpacebarAction.ScalesOfJustice:
- case WeaponSpacebarAction.SelectWorm:
- case WeaponSpacebarAction.SkipGo:
- case WeaponSpacebarAction.Surrender:
- case WeaponSpacebarAction.Teleport:
- case WeaponSpacebarAction.Utility:
- Style = null;
- break;
- }
- break;
- case WeaponActivation.Throw:
- ThrowHerdCount = reader.ReadInt32();
- ThrowAction = reader.ReadEnum(false);
- switch (ThrowAction)
- {
- case WeaponThrowAction.Canister:
- Style = reader.ReadObject();
- break;
- case WeaponThrowAction.Launcher:
- Style = reader.ReadObject();
- break;
- case WeaponThrowAction.Mine:
- Style = reader.ReadObject();
- break;
- }
- break;
- }
-
- // Read additional settings.
- reader.Position = offset + 468;
- AmmunitionOverride = reader.ReadBoolean(BooleanCoding.Dword);
- Ammunition = reader.ReadInt32();
- Unknown3 = reader.ReadInt32();
- WeaponSprite = reader.ReadInt32();
- NameLong = reader.ReadString(StringCoding.Int32CharCount);
- Name = reader.ReadString(StringCoding.Int32CharCount);
- GridImageFile = reader.ReadString(StringCoding.Int32CharCount);
+using System.Diagnostics;
+using System.IO;
+using System.Text;
+using Syroot.BinaryData;
+using Syroot.Worms.IO;
+
+namespace Syroot.Worms.Armageddon.ProjectX
+{
+ [DebuggerDisplay("Weapon Name={Name}")]
+ public class Weapon : ILoadable, ISaveable
+ {
+ // ---- PROPERTIES ---------------------------------------------------------------------------------------------
+
+ [BinaryMember(Order = 1)] public WeaponVersion Version { get; set; }
+
+ [BinaryMember(Order = 2)] public long Checksum { get; set; }
+
+ [BinaryMember(Order = 3)] public int TableRow { get; set; }
+
+ [BinaryMember(Order = 4)] public bool Remembered { get; set; }
+
+ [BinaryMember(Order = 5)] public bool UsableInCavern { get; set; }
+
+ [BinaryMember(Order = 6)] public int Shots { get; set; }
+
+ [BinaryMember(Order = 7)] public bool ShotEndsTurn { get; set; }
+
+ [BinaryMember(Order = 8)] public int RetreatTime { get; set; }
+
+ [BinaryMember(Order = 9)] public int Unknown1 { get; set; }
+
+ [BinaryMember(Order = 10)] public int CrateChance { get; set; }
+
+ [BinaryMember(Order = 11)] public int CrateCount { get; set; }
+
+ [BinaryMember(Order = 12)] public int Unknown2 { get; set; }
+
+ [BinaryMember(Order = 13)] public WeaponActivation Activation { get; set; }
+
+ [BinaryMember(Order = 14)] public int NotUsed { get; set; }
+
+ [BinaryMember(Order = 15)] public int ThrowHerdCount { get; set; }
+
+ [BinaryMember(Order = 16)] public int AirstrikeSubtype { get; set; }
+
+ [BinaryMember(Order = 17)] public WeaponSpacebarAction SpacebarAction { get; set; }
+
+ [BinaryMember(Order = 18)] public WeaponCrosshairAction CrosshairAction { get; set; }
+
+ [BinaryMember(Order = 19)] public WeaponThrowAction ThrowAction { get; set; }
+
+ [BinaryMember(Order = 20)] public IStyle? Style { get; set; }
+
+ [BinaryMember(Order = 21)] public bool AmmunitionOverride { get; set; }
+
+ [BinaryMember(Order = 22)] public int Ammunition { get; set; }
+
+ [BinaryMember(Order = 23)] public int Unknown3 { get; set; }
+
+ [BinaryMember(Order = 24)] public int WeaponSprite { get; set; }
+
+ [BinaryMember(Order = 25)] public string NameLong { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 26)] public string Name { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 27)] public string GridImageFile { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 28)] public string GfxDirectoryFile { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 29)] public string[] SpriteNames { get; } = new string[5];
+
+ [BinaryMember(Order = 30)] public bool DelayOverride { get; set; }
+
+ [BinaryMember(Order = 31)] public int Delay { get; set; }
+
+ [BinaryMember(Order = 32)] public bool UseLibrary { get; set; }
+
+ [BinaryMember(Order = 33)] public string LibraryName { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 34)] public string LibraryWeaponName { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 35)] public string AimSpriteEven { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 36)] public string AimSpriteUphill { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 37)] public string AimSpriteDownhill { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 38)] public string PickSpriteEven { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 39)] public string PickSpriteUphill { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 40)] public string PickSpriteDownhill { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 41)] public string FireSpriteEven { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 42)] public string FireSpriteUphill { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 43)] public string FireSpriteDownhill { get; set; } = String.Empty;
+
+ [BinaryMember(Order = 44)] public bool AimSpriteOverride { get; set; }
+
+ [BinaryMember(Order = 45)] public bool PickSpriteOverride { get; set; }
+
+ [BinaryMember(Order = 46)] public bool FireSpriteOverride { get; set; }
+
+ [BinaryMember(Order = 47)] public bool Utility { get; set; }
+
+ // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
+
+ ///
+ public void Load(Stream stream)
+ {
+ using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
+
+ // Read the header.
+ long offset = reader.Position;
+ Version = reader.ReadEnum(true);
+ Checksum = reader.ReadInt64();
+
+ // Read general settings.
+ TableRow = reader.ReadInt32();
+ Remembered = reader.ReadBoolean(BooleanCoding.Dword);
+ UsableInCavern = reader.ReadBoolean(BooleanCoding.Dword);
+ Shots = reader.ReadInt32();
+ ShotEndsTurn = reader.ReadBoolean(BooleanCoding.Dword);
+ RetreatTime = reader.ReadInt32();
+ Unknown1 = reader.ReadInt32();
+ CrateChance = reader.ReadInt32();
+ CrateCount = reader.ReadInt32();
+ Unknown2 = reader.ReadInt32();
+
+ // Read the activation and the corresponding weapon settings.
+ Activation = reader.ReadEnum(false);
+ switch (Activation)
+ {
+ case WeaponActivation.Airstrike:
+ AirstrikeSubtype = reader.ReadInt32();
+ Style = reader.ReadObject();
+ break;
+ case WeaponActivation.Crosshair:
+ NotUsed = reader.ReadInt32();
+ CrosshairAction = reader.ReadEnum(false);
+ Style = CrosshairAction switch
+ {
+ WeaponCrosshairAction.Bow => reader.ReadObject(),
+ WeaponCrosshairAction.Flamethrower => reader.ReadObject(),
+ WeaponCrosshairAction.Gun => reader.ReadObject(),
+ WeaponCrosshairAction.Launcher => reader.ReadObject(),
+ _ => null
+ };
+ break;
+ case WeaponActivation.Spacebar:
+ SpacebarAction = reader.ReadEnum(false);
+ Style = SpacebarAction switch
+ {
+ WeaponSpacebarAction.Armageddon => reader.ReadObject(),
+ WeaponSpacebarAction.BaseballBat => reader.ReadObject(),
+ WeaponSpacebarAction.BattleAxe => reader.ReadObject(),
+ WeaponSpacebarAction.Blowtorch => reader.ReadObject(),
+ WeaponSpacebarAction.Dragonball => reader.ReadObject(),
+ WeaponSpacebarAction.Firepunch => reader.ReadObject(),
+ WeaponSpacebarAction.Jetpack => reader.ReadObject(),
+ WeaponSpacebarAction.Kamikaze => reader.ReadObject(),
+ WeaponSpacebarAction.NinjaRope => reader.ReadObject(),
+ WeaponSpacebarAction.NuclearTest => reader.ReadObject(),
+ WeaponSpacebarAction.Parachute => reader.ReadObject(),
+ WeaponSpacebarAction.PneumaticDrill => reader.ReadObject(),
+ WeaponSpacebarAction.Prod => reader.ReadObject(),
+ WeaponSpacebarAction.SuicideBomber => reader.ReadObject(),
+ _ => null
+ };
+ break;
+ case WeaponActivation.Throw:
+ ThrowHerdCount = reader.ReadInt32();
+ ThrowAction = reader.ReadEnum(false);
+ Style = ThrowAction switch
+ {
+ WeaponThrowAction.Canister => reader.ReadObject(),
+ WeaponThrowAction.Launcher => reader.ReadObject(),
+ WeaponThrowAction.Mine => reader.ReadObject(),
+ _ => null
+ };
+ break;
+ }
+
+ // Read additional settings.
+ reader.Position = offset + 468;
+ AmmunitionOverride = reader.ReadBoolean(BooleanCoding.Dword);
+ Ammunition = reader.ReadInt32();
+ Unknown3 = reader.ReadInt32();
+ WeaponSprite = reader.ReadInt32();
+ NameLong = reader.ReadString(StringCoding.Int32CharCount);
+ Name = reader.ReadString(StringCoding.Int32CharCount);
+ GridImageFile = reader.ReadString(StringCoding.Int32CharCount);
GfxDirectoryFile = reader.ReadString(StringCoding.Int32CharCount);
- for (int i = 0; i < SpriteNames.Length; i++)
- SpriteNames[i] = reader.ReadString(StringCoding.Int32CharCount);
- DelayOverride = reader.ReadBoolean(BooleanCoding.Dword);
- Delay = reader.ReadInt32();
-
- UseLibrary = reader.ReadBoolean();
- if (UseLibrary)
- {
- LibraryName = reader.ReadString(StringCoding.Int32CharCount);
- LibraryWeaponName = reader.ReadString(StringCoding.Int32CharCount);
- }
-
- AimSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
- AimSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
- AimSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
- PickSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
- PickSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
- PickSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
- FireSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
- FireSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
- FireSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
- AimSpriteOverride = reader.ReadBoolean();
- PickSpriteOverride = reader.ReadBoolean();
- FireSpriteOverride = reader.ReadBoolean();
- if (Version == WeaponVersion.Version_0_8_0)
- Utility = reader.ReadBoolean();
- }
-
- ///
- public void Save(Stream stream)
- {
- using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
-
- // Write the header.
- long offset = writer.Position;
- writer.WriteEnum(Version, true);
- writer.Write(Checksum);
-
- // Write the general settings.
- writer.Write(TableRow);
- writer.Write(Remembered, BooleanCoding.Dword);
- writer.Write(UsableInCavern, BooleanCoding.Dword);
- writer.Write(Shots);
- writer.Write(ShotEndsTurn, BooleanCoding.Dword);
- writer.Write(RetreatTime);
- writer.Write(Unknown1);
- writer.Write(CrateChance);
- writer.Write(CrateCount);
- writer.Write(Unknown2);
-
- // Write the activation and the corresponding weapon settings.
- writer.WriteEnum(Activation, true);
- switch (Activation)
- {
- case WeaponActivation.Airstrike:
- writer.Write(AirstrikeSubtype);
- writer.WriteObject(Style);
- break;
- case WeaponActivation.Crosshair:
- writer.Write(NotUsed);
- writer.WriteEnum(CrosshairAction, true);
- if (CrosshairAction != WeaponCrosshairAction.None)
- writer.WriteObject(Style);
- break;
- case WeaponActivation.Spacebar:
- writer.WriteEnum(SpacebarAction, true);
- switch (SpacebarAction)
- {
- case WeaponSpacebarAction.Armageddon:
- case WeaponSpacebarAction.BaseballBat:
- case WeaponSpacebarAction.BattleAxe:
- case WeaponSpacebarAction.Blowtorch:
- case WeaponSpacebarAction.Dragonball:
- case WeaponSpacebarAction.Firepunch:
- case WeaponSpacebarAction.Jetpack:
- case WeaponSpacebarAction.Kamikaze:
- case WeaponSpacebarAction.NinjaRope:
- case WeaponSpacebarAction.NuclearTest:
- case WeaponSpacebarAction.Parachute:
- case WeaponSpacebarAction.PneumaticDrill:
- case WeaponSpacebarAction.Prod:
- case WeaponSpacebarAction.SuicideBomber:
- writer.WriteObject(Style);
- break;
- }
- break;
- case WeaponActivation.Throw:
- writer.Write(ThrowHerdCount);
- writer.WriteEnum(ThrowAction, true);
- if (ThrowAction != WeaponThrowAction.None)
- writer.WriteObject(Style);
- break;
- }
-
- // Write additional settings.
- writer.Position = offset + 468;
- writer.Write(AmmunitionOverride, BooleanCoding.Dword);
- writer.Write(Ammunition);
- writer.Write(Unknown3);
- writer.Write(WeaponSprite);
- writer.Write(NameLong, StringCoding.Int32CharCount);
- writer.Write(Name, StringCoding.Int32CharCount);
- writer.Write(GridImageFile, StringCoding.Int32CharCount);
- writer.Write(GfxDirectoryFile, StringCoding.Int32CharCount);
- writer.Write(SpriteNames, StringCoding.Int32CharCount);
- writer.Write(DelayOverride, BooleanCoding.Dword);
- writer.Write(Delay);
-
- writer.Write(UseLibrary);
- if (UseLibrary)
- {
- writer.Write(LibraryName, StringCoding.Int32CharCount);
- writer.Write(LibraryWeaponName, StringCoding.Int32CharCount);
- }
-
- writer.Write(AimSpriteEven, StringCoding.Int32CharCount);
- writer.Write(AimSpriteUphill, StringCoding.Int32CharCount);
- writer.Write(AimSpriteDownhill, StringCoding.Int32CharCount);
- writer.Write(PickSpriteEven, StringCoding.Int32CharCount);
- writer.Write(PickSpriteUphill, StringCoding.Int32CharCount);
- writer.Write(PickSpriteDownhill, StringCoding.Int32CharCount);
- writer.Write(FireSpriteEven, StringCoding.Int32CharCount);
- writer.Write(FireSpriteUphill, StringCoding.Int32CharCount);
- writer.Write(FireSpriteDownhill, StringCoding.Int32CharCount);
- writer.Write(AimSpriteOverride);
- writer.Write(PickSpriteOverride);
- writer.Write(FireSpriteOverride);
- if (Version == WeaponVersion.Version_0_8_0)
- writer.Write(Utility);
- }
- }
-
- public enum WeaponVersion : int
- {
- Version_0_8_0_pre = 0x5ABBDD05,
- Version_0_8_0 = 0x5ABBDD06
- }
-
- public enum WeaponActivation : int
- {
- None,
- Crosshair,
- Throw,
- Airstrike,
- Spacebar
- }
-
- public enum WeaponSpacebarAction : int
- {
- None,
- Firepunch,
- BaseballBat,
- Dragonball,
- Kamikaze,
- SuicideBomber,
- NinjaRope,
- Bungee,
- PneumaticDrill,
- Prod,
- Teleport,
- Blowtorch,
- Parachute,
- Surrender,
- SkipGo,
- SelectWorm,
- NuclearTest,
- Girder,
- BattleAxe,
- Utility,
- Freeze,
- Earthquake,
- ScalesOfJustice,
- Jetpack,
- Armageddon
- }
-
- public enum WeaponCrosshairAction : int
- {
- None,
- Flamethrower,
- Gun,
- Launcher,
- Bow
- }
-
- public enum WeaponThrowAction : int
- {
- None,
- Mine,
- Launcher,
- Canister
- }
-
- public enum WeaponSpriteNameIndex
- {
- Unknown0,
- Launcher,
- Cluster,
- Home,
- Unknown4
- }
-}
+ for (int i = 0; i < SpriteNames.Length; i++)
+ SpriteNames[i] = reader.ReadString(StringCoding.Int32CharCount);
+ DelayOverride = reader.ReadBoolean(BooleanCoding.Dword);
+ Delay = reader.ReadInt32();
+
+ UseLibrary = reader.ReadBoolean();
+ if (UseLibrary)
+ {
+ LibraryName = reader.ReadString(StringCoding.Int32CharCount);
+ LibraryWeaponName = reader.ReadString(StringCoding.Int32CharCount);
+ }
+
+ AimSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
+ AimSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
+ AimSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
+ PickSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
+ PickSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
+ PickSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
+ FireSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
+ FireSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
+ FireSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
+ AimSpriteOverride = reader.ReadBoolean();
+ PickSpriteOverride = reader.ReadBoolean();
+ FireSpriteOverride = reader.ReadBoolean();
+ if (Version == WeaponVersion.Version_0_8_0)
+ Utility = reader.ReadBoolean();
+ }
+
+ ///
+ public void Save(Stream stream)
+ {
+ using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
+
+ // Write the header.
+ long offset = writer.Position;
+ writer.WriteEnum(Version, true);
+ writer.Write(Checksum);
+
+ // Write the general settings.
+ writer.Write(TableRow);
+ writer.Write(Remembered, BooleanCoding.Dword);
+ writer.Write(UsableInCavern, BooleanCoding.Dword);
+ writer.Write(Shots);
+ writer.Write(ShotEndsTurn, BooleanCoding.Dword);
+ writer.Write(RetreatTime);
+ writer.Write(Unknown1);
+ writer.Write(CrateChance);
+ writer.Write(CrateCount);
+ writer.Write(Unknown2);
+
+ // Write the activation and the corresponding weapon settings.
+ writer.WriteEnum(Activation, true);
+ switch (Activation)
+ {
+ case WeaponActivation.Airstrike:
+ writer.Write(AirstrikeSubtype);
+ writer.WriteObject(Style);
+ break;
+ case WeaponActivation.Crosshair:
+ writer.Write(NotUsed);
+ writer.WriteEnum(CrosshairAction, true);
+ if (CrosshairAction != WeaponCrosshairAction.None)
+ writer.WriteObject(Style);
+ break;
+ case WeaponActivation.Spacebar:
+ writer.WriteEnum(SpacebarAction, true);
+ switch (SpacebarAction)
+ {
+ case WeaponSpacebarAction.Armageddon:
+ case WeaponSpacebarAction.BaseballBat:
+ case WeaponSpacebarAction.BattleAxe:
+ case WeaponSpacebarAction.Blowtorch:
+ case WeaponSpacebarAction.Dragonball:
+ case WeaponSpacebarAction.Firepunch:
+ case WeaponSpacebarAction.Jetpack:
+ case WeaponSpacebarAction.Kamikaze:
+ case WeaponSpacebarAction.NinjaRope:
+ case WeaponSpacebarAction.NuclearTest:
+ case WeaponSpacebarAction.Parachute:
+ case WeaponSpacebarAction.PneumaticDrill:
+ case WeaponSpacebarAction.Prod:
+ case WeaponSpacebarAction.SuicideBomber:
+ writer.WriteObject(Style);
+ break;
+ }
+ break;
+ case WeaponActivation.Throw:
+ writer.Write(ThrowHerdCount);
+ writer.WriteEnum(ThrowAction, true);
+ if (ThrowAction != WeaponThrowAction.None)
+ writer.WriteObject(Style);
+ break;
+ }
+
+ // Write additional settings.
+ writer.Position = offset + 468;
+ writer.Write(AmmunitionOverride, BooleanCoding.Dword);
+ writer.Write(Ammunition);
+ writer.Write(Unknown3);
+ writer.Write(WeaponSprite);
+ writer.Write(NameLong, StringCoding.Int32CharCount);
+ writer.Write(Name, StringCoding.Int32CharCount);
+ writer.Write(GridImageFile, StringCoding.Int32CharCount);
+ writer.Write(GfxDirectoryFile, StringCoding.Int32CharCount);
+ writer.Write(SpriteNames, StringCoding.Int32CharCount);
+ writer.Write(DelayOverride, BooleanCoding.Dword);
+ writer.Write(Delay);
+
+ writer.Write(UseLibrary);
+ if (UseLibrary)
+ {
+ writer.Write(LibraryName, StringCoding.Int32CharCount);
+ writer.Write(LibraryWeaponName, StringCoding.Int32CharCount);
+ }
+
+ writer.Write(AimSpriteEven, StringCoding.Int32CharCount);
+ writer.Write(AimSpriteUphill, StringCoding.Int32CharCount);
+ writer.Write(AimSpriteDownhill, StringCoding.Int32CharCount);
+ writer.Write(PickSpriteEven, StringCoding.Int32CharCount);
+ writer.Write(PickSpriteUphill, StringCoding.Int32CharCount);
+ writer.Write(PickSpriteDownhill, StringCoding.Int32CharCount);
+ writer.Write(FireSpriteEven, StringCoding.Int32CharCount);
+ writer.Write(FireSpriteUphill, StringCoding.Int32CharCount);
+ writer.Write(FireSpriteDownhill, StringCoding.Int32CharCount);
+ writer.Write(AimSpriteOverride);
+ writer.Write(PickSpriteOverride);
+ writer.Write(FireSpriteOverride);
+ if (Version == WeaponVersion.Version_0_8_0)
+ writer.Write(Utility);
+ }
+ }
+
+ public enum WeaponVersion : int
+ {
+ Version_0_8_0_pre = 0x5ABBDD05,
+ Version_0_8_0 = 0x5ABBDD06
+ }
+
+ public enum WeaponActivation : int
+ {
+ None,
+ Crosshair,
+ Throw,
+ Airstrike,
+ Spacebar
+ }
+
+ public enum WeaponSpacebarAction : int
+ {
+ None,
+ Firepunch,
+ BaseballBat,
+ Dragonball,
+ Kamikaze,
+ SuicideBomber,
+ NinjaRope,
+ Bungee,
+ PneumaticDrill,
+ Prod,
+ Teleport,
+ Blowtorch,
+ Parachute,
+ Surrender,
+ SkipGo,
+ SelectWorm,
+ NuclearTest,
+ Girder,
+ BattleAxe,
+ Utility,
+ Freeze,
+ Earthquake,
+ ScalesOfJustice,
+ Jetpack,
+ Armageddon
+ }
+
+ public enum WeaponCrosshairAction : int
+ {
+ None,
+ Flamethrower,
+ Gun,
+ Launcher,
+ Bow
+ }
+
+ public enum WeaponThrowAction : int
+ {
+ None,
+ Mine,
+ Launcher,
+ Canister
+ }
+
+ public enum WeaponSpriteNameIndex
+ {
+ Unknown0,
+ Launcher,
+ Cluster,
+ Home,
+ Unknown4
+ }
+}
diff --git a/src/library/Syroot.Worms.Armageddon/Syroot.Worms.Armageddon.csproj b/src/library/Syroot.Worms.Armageddon/Syroot.Worms.Armageddon.csproj
index 703a628..0d718ce 100644
--- a/src/library/Syroot.Worms.Armageddon/Syroot.Worms.Armageddon.csproj
+++ b/src/library/Syroot.Worms.Armageddon/Syroot.Worms.Armageddon.csproj
@@ -1,14 +1,18 @@
+
+
true
- Syroot.Worms.Armageddon
.NET library for loading and modifying files of Team17's Worms Armageddon.
Overhaul implementation and documentation. Implement W:A V3 scheme format.
$(PackageTags);worms armageddon
4.0.0
+
+
+
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Mgame/Syroot.Worms.Mgame.csproj b/src/library/Syroot.Worms.Mgame/Syroot.Worms.Mgame.csproj
index de5ddb6..99d0af9 100644
--- a/src/library/Syroot.Worms.Mgame/Syroot.Worms.Mgame.csproj
+++ b/src/library/Syroot.Worms.Mgame/Syroot.Worms.Mgame.csproj
@@ -1,13 +1,18 @@
+
+
- Syroot.Worms.Mgame
.NET library for loading and modifying files of Mgame Worms clients.
Overhaul implementation and documentation.
$(PackageTags);online worms;worms world party aqua
4.0.0
+
+
+
+
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.WorldParty/Syroot.Worms.WorldParty.csproj b/src/library/Syroot.Worms.WorldParty/Syroot.Worms.WorldParty.csproj
index 2950c5e..d1eda10 100644
--- a/src/library/Syroot.Worms.WorldParty/Syroot.Worms.WorldParty.csproj
+++ b/src/library/Syroot.Worms.WorldParty/Syroot.Worms.WorldParty.csproj
@@ -1,5 +1,7 @@
+
+
Syroot.Worms.WorldParty
.NET library for loading and modifying files of Team17's Worms World Party.
@@ -7,7 +9,10 @@
$(PackageTags);worms world party
4.0.0
+
+
+
\ No newline at end of file
diff --git a/src/library/Syroot.Worms.Worms2/Syroot.Worms.Worms2.csproj b/src/library/Syroot.Worms.Worms2/Syroot.Worms.Worms2.csproj
index 0b395d5..e119822 100644
--- a/src/library/Syroot.Worms.Worms2/Syroot.Worms.Worms2.csproj
+++ b/src/library/Syroot.Worms.Worms2/Syroot.Worms.Worms2.csproj
@@ -1,13 +1,17 @@
+
+
- Syroot.Worms.Worms2
.NET library for loading and modifying files of Team17's Worms 2.
Overhaul implementation and documentation.
$(PackageTags);worms 2
4.0.0
+
+
+
\ No newline at end of file
diff --git a/src/library/Syroot.Worms/IO/BinaryStreamExtensions.cs b/src/library/Syroot.Worms/IO/BinaryStreamExtensions.cs
index 208ba6a..f5c95bc 100644
--- a/src/library/Syroot.Worms/IO/BinaryStreamExtensions.cs
+++ b/src/library/Syroot.Worms/IO/BinaryStreamExtensions.cs
@@ -14,19 +14,6 @@ namespace Syroot.Worms.IO
// ---- Reading ----
- ///
- /// Reads an instance from the current stream.
- ///
- /// The type of the class to instantiate.
- /// The extended instance.
- /// The instance.
- public static T Load(this BinaryStream self) where T : ILoadable, new()
- {
- T instance = new T();
- instance.Load(self.BaseStream);
- return instance;
- }
-
///
/// Reads an RGBA 32-bit color.
///
@@ -78,17 +65,6 @@ namespace Syroot.Worms.IO
// ---- Writing ----
- ///
- /// Writes the given instance into the current stream.
- ///
- /// The type of the class to write.
- /// The extended instance.
- /// The instance to write into the current stream.
- public static void Save(this BinaryStream self, T value) where T : ISaveable
- {
- value.Save(self.BaseStream);
- }
-
///
/// Writes the given to the given . This is meant to be used
/// in combination with .
diff --git a/src/library/Syroot.Worms/IO/StreamExtensions.cs b/src/library/Syroot.Worms/IO/StreamExtensions.cs
index 9b78eec..46f4cd0 100644
--- a/src/library/Syroot.Worms/IO/StreamExtensions.cs
+++ b/src/library/Syroot.Worms/IO/StreamExtensions.cs
@@ -61,6 +61,29 @@ namespace Syroot.Worms.IO
public static unsafe void WriteStructs(this Stream stream, ReadOnlySpan span) where T : unmanaged
=> stream.Write(MemoryMarshal.Cast(span));
+ // ---- ILoadable / ISaveable ----
+
+ ///
+ /// Reads an instance from the current stream.
+ ///
+ /// The type of the class to instantiate.
+ /// The extended instance.
+ /// The instance.
+ public static T Load(this Stream self) where T : ILoadable, new()
+ {
+ T instance = new T();
+ instance.Load(self);
+ return instance;
+ }
+
+ ///
+ /// Writes the given instance into the current stream.
+ ///
+ /// The type of the class to write.
+ /// The extended instance.
+ /// The instance to write into the current stream.
+ public static void Save(this Stream self, T value) where T : ISaveable => value.Save(self);
+
// ---- Backports ----
#if NETSTANDARD2_0
diff --git a/src/library/Syroot.Worms/Syroot.Worms.csproj b/src/library/Syroot.Worms/Syroot.Worms.csproj
index b960278..28ba016 100644
--- a/src/library/Syroot.Worms/Syroot.Worms.csproj
+++ b/src/library/Syroot.Worms/Syroot.Worms.csproj
@@ -1,19 +1,21 @@
+
+
true
- Syroot.Worms
.NET library for loading and modifying files of Team17 Worms games.
Overhaul implementation and documentation.
4.0.0
+
+
-
-
+
-
+
\ No newline at end of file
diff --git a/src/test.xml b/src/test.xml
index 4538d18..7016847 100644
--- a/src/test.xml
+++ b/src/test.xml
@@ -1,5 +1,6 @@
+
latest
@@ -23,4 +24,5 @@
+
diff --git a/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Files/Libraries/Cache/cached_194940.pxl b/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Files/Libraries/Cache/cached_194940.pxl
deleted file mode 100644
index 01ff4df..0000000
--- a/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Files/Libraries/Cache/cached_194940.pxl
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:35aa8c7cf0d2a6677cae895832d6e1ab2f86a64ed79c14426fed175ae39c5f64
-size 135780
diff --git a/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Files/Libraries/gravler.pxl b/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Files/Libraries/gravler.pxl
deleted file mode 100644
index 01ff4df..0000000
--- a/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Files/Libraries/gravler.pxl
+++ /dev/null
@@ -1,3 +0,0 @@
-version https://git-lfs.github.com/spec/v1
-oid sha256:35aa8c7cf0d2a6677cae895832d6e1ab2f86a64ed79c14426fed175ae39c5f64
-size 135780
diff --git a/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Syroot.Worms.Armageddon.ProjectX.Test.csproj b/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Syroot.Worms.Armageddon.ProjectX.Test.csproj
index 24916f8..bdf3dcd 100644
--- a/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Syroot.Worms.Armageddon.ProjectX.Test.csproj
+++ b/src/test/Syroot.Worms.Armageddon.ProjectX.Test/Syroot.Worms.Armageddon.ProjectX.Test.csproj
@@ -1,7 +1,10 @@
+
+
+
diff --git a/src/test/Syroot.Worms.Armageddon.Test/Syroot.Worms.Armageddon.Test.csproj b/src/test/Syroot.Worms.Armageddon.Test/Syroot.Worms.Armageddon.Test.csproj
index 1d245b8..6cd0d9b 100644
--- a/src/test/Syroot.Worms.Armageddon.Test/Syroot.Worms.Armageddon.Test.csproj
+++ b/src/test/Syroot.Worms.Armageddon.Test/Syroot.Worms.Armageddon.Test.csproj
@@ -1,7 +1,10 @@
+
+
+
diff --git a/src/test/Syroot.Worms.Mgame.Test/Syroot.Worms.Mgame.Test.csproj b/src/test/Syroot.Worms.Mgame.Test/Syroot.Worms.Mgame.Test.csproj
index 6c7ac26..3aa5358 100644
--- a/src/test/Syroot.Worms.Mgame.Test/Syroot.Worms.Mgame.Test.csproj
+++ b/src/test/Syroot.Worms.Mgame.Test/Syroot.Worms.Mgame.Test.csproj
@@ -1,7 +1,10 @@
+
+
+
diff --git a/src/test/Syroot.Worms.Test/Syroot.Worms.Test.csproj b/src/test/Syroot.Worms.Test/Syroot.Worms.Test.csproj
index 9f0ebf6..aeb02c8 100644
--- a/src/test/Syroot.Worms.Test/Syroot.Worms.Test.csproj
+++ b/src/test/Syroot.Worms.Test/Syroot.Worms.Test.csproj
@@ -1,6 +1,9 @@
+
+
+
diff --git a/src/test/Syroot.Worms.WorldParty.Test/Syroot.Worms.WorldParty.Test.csproj b/src/test/Syroot.Worms.WorldParty.Test/Syroot.Worms.WorldParty.Test.csproj
index ebb3788..bfd6405 100644
--- a/src/test/Syroot.Worms.WorldParty.Test/Syroot.Worms.WorldParty.Test.csproj
+++ b/src/test/Syroot.Worms.WorldParty.Test/Syroot.Worms.WorldParty.Test.csproj
@@ -1,7 +1,10 @@
+
+
+
diff --git a/src/test/Syroot.Worms.Worms2.Test/Syroot.Worms.Worms2.Test.csproj b/src/test/Syroot.Worms.Worms2.Test/Syroot.Worms.Worms2.Test.csproj
index ff1d0b2..3fb965a 100644
--- a/src/test/Syroot.Worms.Worms2.Test/Syroot.Worms.Worms2.Test.csproj
+++ b/src/test/Syroot.Worms.Worms2.Test/Syroot.Worms.Worms2.Test.csproj
@@ -1,7 +1,10 @@
+
+
+