diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2b34221..e830f45 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -65,6 +65,7 @@ jobs: BepInEx-BepInExPack-5.4.2100 Evaisa-LethalLib-1.1.1 WhiteSpike-Interactive_Terminal_API-1.3.0 + Sigurd-CSync-5.0.1 website: ${{ steps.get-properties.outputs.WEBSITE }} files: | ./src/ShipInventoryUpdated/bin/Release/ShipInventoryUpdated.dll diff --git a/src/ShipInventoryUpdated/Configurations/ChuteConfig.cs b/src/ShipInventoryUpdated/Configurations/ChuteConfig.cs index 90717ef..f4b5d46 100644 --- a/src/ShipInventoryUpdated/Configurations/ChuteConfig.cs +++ b/src/ShipInventoryUpdated/Configurations/ChuteConfig.cs @@ -1,4 +1,6 @@ using BepInEx.Configuration; +using CSync.Extensions; +using CSync.Lib; using ShipInventoryUpdated.Helpers; namespace ShipInventoryUpdated.Configurations; @@ -6,16 +8,17 @@ namespace ShipInventoryUpdated.Configurations; /// /// Class that holds the configurations related to the chute itself /// -internal class ChuteConfig +internal class ChuteConfig : SyncedConfig2 { + private const string GUID_ = MyPluginInfo.PLUGIN_GUID + "." + nameof(ChuteConfig); private const string SECTION = "Chute"; - public readonly ConfigEntry Blacklist; + [SyncedEntryField] public readonly SyncedEntry Blacklist; public readonly ConfigEntry StoreSpeed; - public ChuteConfig(ConfigFile cfg) + public ChuteConfig(ConfigFile cfg) : base(GUID_) { - Blacklist = cfg.Bind( + Blacklist = cfg.BindSyncedEntry( new ConfigDefinition(SECTION, "ChuteBlacklist"), "", new ConfigDescription(Localization.Get("configuration.chute.blacklist.description")) @@ -26,5 +29,7 @@ public ChuteConfig(ConfigFile cfg) 0.5f, new ConfigDescription(Localization.Get("configuration.chute.storeSpeed.description")) ); + + ConfigManager.Register(this); } } \ No newline at end of file diff --git a/src/ShipInventoryUpdated/Configurations/InventoryConfig.cs b/src/ShipInventoryUpdated/Configurations/InventoryConfig.cs index 72fde48..bdb117b 100644 --- a/src/ShipInventoryUpdated/Configurations/InventoryConfig.cs +++ b/src/ShipInventoryUpdated/Configurations/InventoryConfig.cs @@ -1,4 +1,6 @@ using BepInEx.Configuration; +using CSync.Extensions; +using CSync.Lib; using ShipInventoryUpdated.Helpers; namespace ShipInventoryUpdated.Configurations; @@ -6,23 +8,24 @@ namespace ShipInventoryUpdated.Configurations; /// /// Class that holds the configurations related to the inventory itself /// -internal class InventoryConfig +internal class InventoryConfig : SyncedConfig2 { + private const string GUID_ = MyPluginInfo.PLUGIN_GUID + "." + nameof(InventoryConfig); private const string SECTION = "Inventory"; - public readonly ConfigEntry MaxItemCount; - public readonly ConfigEntry ClearOnWipe; + [SyncedEntryField] public readonly SyncedEntry MaxItemCount; + [SyncedEntryField] public readonly SyncedEntry ClearOnWipe; public readonly ConfigEntry RetrieveSpeed; - public InventoryConfig(ConfigFile cfg) + public InventoryConfig(ConfigFile cfg) : base(GUID_) { - MaxItemCount = cfg.Bind( + MaxItemCount = cfg.BindSyncedEntry( new ConfigDefinition(SECTION, "MaxItemCount"), 5_000, new ConfigDescription(Localization.Get("configuration.inventory.maxItemCount.description")) ); - ClearOnWipe = cfg.Bind( + ClearOnWipe = cfg.BindSyncedEntry( new ConfigDefinition(SECTION, "ClearOnWipe"), true, new ConfigDescription(Localization.Get("configuration.inventory.clearOnWipe.description")) @@ -33,5 +36,7 @@ public InventoryConfig(ConfigFile cfg) 0.5f, new ConfigDescription(Localization.Get("configuration.inventory.retrieveSpeed.description")) ); + + ConfigManager.Register(this); } } \ No newline at end of file diff --git a/src/ShipInventoryUpdated/Configurations/UnlockConfig.cs b/src/ShipInventoryUpdated/Configurations/UnlockConfig.cs index b2313d8..df9ea70 100644 --- a/src/ShipInventoryUpdated/Configurations/UnlockConfig.cs +++ b/src/ShipInventoryUpdated/Configurations/UnlockConfig.cs @@ -1,4 +1,6 @@ using BepInEx.Configuration; +using CSync.Extensions; +using CSync.Lib; using ShipInventoryUpdated.Helpers; namespace ShipInventoryUpdated.Configurations; @@ -6,15 +8,16 @@ namespace ShipInventoryUpdated.Configurations; /// /// Class that holds the configurations related to the unlocking of the inventory /// -internal class UnlockConfig +internal class UnlockConfig : SyncedConfig2 { + private const string GUID_ = MyPluginInfo.PLUGIN_GUID + "." + nameof(UnlockConfig); private const string SECTION = "Unlock"; public readonly ConfigEntry UnlockName; - public readonly ConfigEntry UnlockCost; - public readonly ConfigEntry IsChuteUnlocked; + [SyncedEntryField] public readonly SyncedEntry UnlockCost; + [SyncedEntryField] public readonly SyncedEntry IsChuteUnlocked; - public UnlockConfig(ConfigFile cfg) + public UnlockConfig(ConfigFile cfg) : base(GUID_) { UnlockName = cfg.Bind( new ConfigDefinition(SECTION, "ChuteUnlockName"), @@ -22,19 +25,21 @@ public UnlockConfig(ConfigFile cfg) new ConfigDescription(Localization.Get("configuration.unlock.unlockName.description")) ); - UnlockCost = cfg.Bind( + UnlockCost = cfg.BindSyncedEntry( new ConfigDefinition(SECTION, "ChuteUnlockCost"), 60, new ConfigDescription(Localization.Get("configuration.unlock.unlockCost.description")) ); - IsChuteUnlocked = cfg.Bind( + IsChuteUnlocked = cfg.BindSyncedEntry( new ConfigDefinition(SECTION, "ChuteIsUnlock"), false, new ConfigDescription(Localization.Get("configuration.unlock.isUnlockable.description")) ); UnlockName.SettingChanged += (_, _) => Patches.Terminal_Patches.AssignNewCommand(UnlockName.Value); - UnlockCost.SettingChanged += (_, _) => Patches.Terminal_Patches.AssignNewCost(UnlockCost.Value); + UnlockCost.Changed += (_, _) => Patches.Terminal_Patches.AssignNewCost(UnlockCost.Value); + + ConfigManager.Register(this); } } \ No newline at end of file diff --git a/src/ShipInventoryUpdated/Dependencies/LethalConfig/Dependency.cs b/src/ShipInventoryUpdated/Dependencies/LethalConfig/Dependency.cs index 88129ca..5cbf750 100644 --- a/src/ShipInventoryUpdated/Dependencies/LethalConfig/Dependency.cs +++ b/src/ShipInventoryUpdated/Dependencies/LethalConfig/Dependency.cs @@ -72,7 +72,7 @@ private static void ApplyInformation() private static void ApplyChuteConfiguration(ChuteConfig config) { LethalConfigManager.AddConfigItem(new TextInputFieldConfigItem( - config.Blacklist, + config.Blacklist.Entry, new TextInputFieldOptions { Name = Localization.Get("configuration.chute.blacklist.name"), @@ -100,7 +100,7 @@ private static void ApplyChuteConfiguration(ChuteConfig config) private static void ApplyInventoryConfiguration(InventoryConfig config) { LethalConfigManager.AddConfigItem(new IntInputFieldConfigItem( - config.MaxItemCount, + config.MaxItemCount.Entry, new IntInputFieldOptions { Name = Localization.Get("configuration.inventory.maxItemCount.name"), @@ -111,7 +111,7 @@ private static void ApplyInventoryConfiguration(InventoryConfig config) )); LethalConfigManager.AddConfigItem(new BoolCheckBoxConfigItem( - config.ClearOnWipe, + config.ClearOnWipe.Entry, new BoolCheckBoxOptions { Name = Localization.Get("configuration.inventory.clearOnWipe.name"), @@ -167,7 +167,7 @@ private static void ApplyUnlockConfiguration(UnlockConfig config) )); LethalConfigManager.AddConfigItem(new IntInputFieldConfigItem( - config.UnlockCost, + config.UnlockCost.Entry, new IntInputFieldOptions { Name = Localization.Get("configuration.unlock.unlockCost.name"), @@ -178,7 +178,7 @@ private static void ApplyUnlockConfiguration(UnlockConfig config) )); LethalConfigManager.AddConfigItem(new BoolCheckBoxConfigItem( - config.IsChuteUnlocked, + config.IsChuteUnlocked.Entry, new BoolCheckBoxOptions { Name = Localization.Get("configuration.unlock.isUnlockable.name"), diff --git a/src/ShipInventoryUpdated/ShipInventoryUpdated.cs b/src/ShipInventoryUpdated/ShipInventoryUpdated.cs index 6048503..92e33f5 100644 --- a/src/ShipInventoryUpdated/ShipInventoryUpdated.cs +++ b/src/ShipInventoryUpdated/ShipInventoryUpdated.cs @@ -11,6 +11,7 @@ namespace ShipInventoryUpdated; // Hard [BepInDependency("WhiteSpike.InteractiveTerminalAPI", "1.3.0")] [BepInDependency(LethalLib.Plugin.ModGUID)] +[BepInDependency("com.sigurd.csync", "5.0.1")] // Soft [BepInDependency(LethalConfig.PluginInfo.Guid, BepInDependency.DependencyFlags.SoftDependency)] public class ShipInventoryUpdated : BaseUnityPlugin diff --git a/src/ShipInventoryUpdated/ShipInventoryUpdated.csproj b/src/ShipInventoryUpdated/ShipInventoryUpdated.csproj index c1923bc..1199ce6 100644 --- a/src/ShipInventoryUpdated/ShipInventoryUpdated.csproj +++ b/src/ShipInventoryUpdated/ShipInventoryUpdated.csproj @@ -22,6 +22,7 @@ PrivateAssets="all" /> +