From 5367c899a63a161f9fdb3c781ba2ade3a99bacce Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 02:49:22 +0200 Subject: [PATCH] auto-guns: copy the plain gun's fields Co-Authored-By: Claude Sonnet 5.5 --- tools/AetherDb/AutoGunsCatalog.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/AetherDb/AutoGunsCatalog.cs b/tools/AetherDb/AutoGunsCatalog.cs index 4292d745b..d62206681 100644 --- a/tools/AetherDb/AutoGunsCatalog.cs +++ b/tools/AetherDb/AutoGunsCatalog.cs @@ -2,7 +2,7 @@ using System; using System.IO; using System.Linq; using GameCult.Caching; -using MessagePack; +using System.Reflection; // Makes the named plain guns fully automatic (ruling fire-mode-is-the-design): each one's InstantWeaponData becomes an // AutoWeaponData carrying every authored stat unchanged, so cadence and damage do not move. A gun that is already an @@ -21,8 +21,12 @@ public static class AutoGunsCatalog var index = gear.Behaviors.FindIndex(b => b.GetType() == typeof(InstantWeaponData)); if (index < 0) { output.WriteLine($"{name}: no plain gun, kept"); continue; } var plain = (InstantWeaponData) gear.Behaviors[index]; - var bytes = MessagePackSerializer.Serialize(typeof(InstantWeaponData), plain); - gear.Behaviors[index] = MessagePackSerializer.Deserialize(bytes); + var auto = new AutoWeaponData(); + // AutoWeaponData adds no member of its own: every field of the plain gun, from every base, carries over. + for (var type = typeof(InstantWeaponData); type != null; type = type.BaseType) + foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly)) + field.SetValue(auto, field.GetValue(plain)); + gear.Behaviors[index] = auto; output.WriteLine($"{name}: InstantWeaponData -> AutoWeaponData (cooldown {plain.Cooldown.Max:0.###} s)"); changed.Add(gear); }