From 3746392f77e88b85bd81831a9f85fe57d066b221 Mon Sep 17 00:00:00 2001 From: SokyranTheDragon Date: Mon, 20 Nov 2023 16:02:50 +0100 Subject: [PATCH] Sync Dialog_BillConfig target item style change The feature is only available with Ideology DLC active while the ideo system is disabled. All of the prefixed methods could be turned into sync methods/delegates, but it would require making a sync worker for Dialog_BillConfig or making an instance/field transformer for it, so it seemed using sync fields would end up simpler. --- Source/Client/Syncing/Game/SyncFields.cs | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Source/Client/Syncing/Game/SyncFields.cs b/Source/Client/Syncing/Game/SyncFields.cs index 3cb25562..799f26bb 100644 --- a/Source/Client/Syncing/Game/SyncFields.cs +++ b/Source/Client/Syncing/Game/SyncFields.cs @@ -52,6 +52,10 @@ public static class SyncFields public static ISyncField SyncBillMechsOnly; public static ISyncField SyncBillNonMechsOnly; + public static ISyncField SyncBillStyle; + public static ISyncField SyncBillGlobalStyle; + public static ISyncField SyncBillGraphicIndexOverride; + public static ISyncField SyncZoneLabel; public static SyncField[] SyncBillProduction; @@ -147,6 +151,10 @@ public static void Init() SyncBillMechsOnly = Sync.Field(typeof(Bill), nameof(Bill.mechsOnly)); SyncBillNonMechsOnly = Sync.Field(typeof(Bill), nameof(Bill.nonMechsOnly)); + SyncBillStyle = Sync.Field(typeof(Bill), nameof(Bill.style)); + SyncBillGlobalStyle = Sync.Field(typeof(Bill), nameof(Bill.globalStyle)); + SyncBillGraphicIndexOverride = Sync.Field(typeof(Bill), nameof(Bill.graphicIndexOverride)); + SyncZoneLabel = Sync.Field(typeof(Zone), "label"); SyncBillProduction = Sync.Fields( @@ -602,6 +610,41 @@ static void WatchMechCarrierMaxToFill(MechCarrierGizmo __instance) SyncMechCarrierGizmoTargetValue.Watch(__instance); SyncMechCarrierMaxToFill.Watch(__instance.carrier); } + + [MpPrefix(typeof(Dialog_BillConfig), nameof(Dialog_BillConfig.DoWindowContents), lambdaOrdinal: 8)] + static void WatchBillStyleGlobal(object __instance) + { + // Sets the graphic to default (global) style + WatchBillStyle(__instance.GetPropertyOrField("<>4__this/bill")); + } + + [MpPrefix(typeof(Dialog_BillConfig), nameof(Dialog_BillConfig.DoWindowContents), lambdaOrdinal: 9)] + static void WatchBillStyleBasic(Dialog_BillConfig __instance) + { + // Sets the graphic to basic style (unstyled) + WatchBillStyle(__instance.bill); + } + + [MpPrefix(typeof(Dialog_BillConfig), nameof(Dialog_BillConfig.DoWindowContents), lambdaOrdinal: 10)] + static void WatchBillStyleSpecific(object __instance) + { + // Sets the graphic to a specific style + WatchBillStyle(__instance.GetPropertyOrField("CS$<>8__locals2/<>4__this/bill")); + } + + [MpPrefix(typeof(Dialog_BillConfig), nameof(Dialog_BillConfig.DoWindowContents), lambdaOrdinal: 11)] + static void WatchBillStyleSpecificIndex(object __instance) + { + // Sets the graphic to a specific style with specific subgraphic index for Graphic_Random + WatchBillStyle(__instance.GetPropertyOrField("CS$<>8__locals3/CS$<>8__locals2/<>4__this/bill")); + } + + static void WatchBillStyle(object bill) + { + SyncBillStyle.Watch(bill); + SyncBillGlobalStyle.Watch(bill); + SyncBillGraphicIndexOverride.Watch(bill); + } } }