Skip to content

Commit

Permalink
RSM Interop and logic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoo-Knows committed May 16, 2024
1 parent 9a9f70c commit 034042b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 11 deletions.
4 changes: 4 additions & 0 deletions LostArtifacts/LostArtifacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ public override void Initialize(Dictionary<string, Dictionary<string, GameObject
{
ArtifactDebug.AddToDebug();
}
if(ModHooks.GetMod("RandoSettingsManager") is Mod)
{
RSMInterop.Hook();
}

On.HeroController.Start += HeroControllerStart;
On.HeroController.OnDisable += HeroControllerOnDisable;
Expand Down
17 changes: 10 additions & 7 deletions LostArtifacts/LostArtifacts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<Product>LostArtifacts</Product>
<Description>A Hollow Knight Mod</Description>
<Copyright>Copyright © 2022</Copyright>
<AssemblyVersion>1.1.1.0</AssemblyVersion>
<FileVersion>1.1.1.0</FileVersion>
<AssemblyVersion>1.1.1.1</AssemblyVersion>
<FileVersion>1.1.1.1</FileVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down Expand Up @@ -59,7 +59,7 @@
<HintPath>$(HollowKnightRefs)/Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="DebugMod">
<HintPath>..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\DebugMod\DebugMod.dll</HintPath>
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\DebugMod\DebugMod.dll</HintPath>
</Reference>
<Reference Include="GalaxyCSharp">
<HintPath>$(HollowKnightRefs)/GalaxyCSharp.dll</HintPath>
Expand All @@ -68,7 +68,7 @@
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\ItemChanger\ItemChanger.dll</HintPath>
</Reference>
<Reference Include="MenuChanger">
<HintPath>..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\MenuChanger\MenuChanger.dll</HintPath>
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\MenuChanger\MenuChanger.dll</HintPath>
</Reference>
<Reference Include="MMHOOK_Assembly-CSharp">
<HintPath>$(HollowKnightRefs)/MMHOOK_Assembly-CSharp.dll</HintPath>
Expand Down Expand Up @@ -98,13 +98,16 @@
<HintPath>$(HollowKnightRefs)/PlayMaker.dll</HintPath>
</Reference>
<Reference Include="RandomizerCore">
<HintPath>..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\RandomizerCore\RandomizerCore.dll</HintPath>
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\RandomizerCore\RandomizerCore.dll</HintPath>
</Reference>
<Reference Include="RandomizerCore.Json">
<HintPath>..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\RandomizerCore.Json\RandomizerCore.Json.dll</HintPath>
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\RandomizerCore.Json\RandomizerCore.Json.dll</HintPath>
</Reference>
<Reference Include="RandomizerMod">
<HintPath>..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\Randomizer 4\RandomizerMod.dll</HintPath>
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\Randomizer 4\RandomizerMod.dll</HintPath>
</Reference>
<Reference Include="RandoSettingsManager">
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\Hollow Knight\hollow_knight_Data\Managed\Mods\RandoSettingsManager\RandoSettingsManager.dll</HintPath>
</Reference>
<Reference Include="Satchel">
<HintPath>$(HollowKnightRefs)\Mods\Satchel\Satchel.dll</HintPath>
Expand Down
40 changes: 40 additions & 0 deletions LostArtifacts/RandoInterop/RSMInterop.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using RandoSettingsManager;
using RandoSettingsManager.SettingsManagement;
using RandoSettingsManager.SettingsManagement.Versioning;

namespace LostArtifacts.Rando
{
internal static class RSMInterop
{
public static void Hook()
{
RandoSettingsManagerMod.Instance.RegisterConnection(new ArtifactRandoSettings());
}
}

internal class ArtifactRandoSettings : RandoSettingsProxy<RandoSettings, string>
{
public override string ModKey => LostArtifacts.Instance.GetName();

public override VersioningPolicy<string> VersioningPolicy { get; }
= new EqualityVersioningPolicy<string>(LostArtifacts.Instance.GetVersion());

public override void ReceiveSettings(RandoSettings settings)
{
if(settings != null)
{
RandoMenu.Apply(settings);
}
else
{
RandoMenu.Disable();
}
}

public override bool TryProvideSettings(out RandoSettings settings)
{
settings = LostArtifacts.RandoSettings;
return settings.EnableArtifacts;
}
}
}
24 changes: 21 additions & 3 deletions LostArtifacts/RandoInterop/RandoMenu.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MenuChanger;
using ItemChanger;
using MenuChanger;
using MenuChanger.Extensions;
using MenuChanger.MenuElements;
using MenuChanger.MenuPanels;
Expand Down Expand Up @@ -33,12 +34,12 @@ public static void ConstructMenu(MenuPage landingPage)

enableArtifactsToggle = (ToggleButton)factory.ElementLookup[nameof(LostArtifacts.RandoSettings.EnableArtifacts)];
randomizeArtifactsToggle = (ToggleButton)factory.ElementLookup[nameof(LostArtifacts.RandoSettings.RandomizeArtifacts)];
artifactGroupField = (NumericEntryField<int>)factory.ElementLookup[nameof(LostArtifacts.RandoSettings.ArtifactGroup)];
useCustomLocations = (ToggleButton)factory.ElementLookup[nameof(LostArtifacts.RandoSettings.UseCustomLocations)];
artifactGroupField = (NumericEntryField<int>)factory.ElementLookup[nameof(LostArtifacts.RandoSettings.ArtifactGroup)];
enableArtifactsToggle.SelfChanged += EnableArtifactsChanged;
randomizeArtifactsToggle.SelfChanged += RandomizeArtifactsChanged;
artifactGroupField.SelfChanged += ArtifactGroupChanged;
useCustomLocations.SelfChanged += UseCustomLocationsChanged;
artifactGroupField.SelfChanged += ArtifactGroupChanged;

if(!LostArtifacts.RandoSettings.RandomizeArtifacts)
{
Expand Down Expand Up @@ -104,5 +105,22 @@ private static void ChangeTopLevelColor()
if(LostArtifacts.RandoSettings.RandomizeArtifacts) pageRootButton.Text.color = Colors.TRUE_COLOR;
}
}

// RSM Interop
public static void Apply(RandoSettings settings)
{
enableArtifactsToggle.SetValue(settings.EnableArtifacts);
randomizeArtifactsToggle.SetValue(settings.RandomizeArtifacts);
useCustomLocations.SetValue(settings.UseCustomLocations);
artifactGroupField.SetValue(settings.ArtifactGroup);
}

public static void Disable()
{
enableArtifactsToggle.SetValue(false);
randomizeArtifactsToggle.SetValue(false);
useCustomLocations.SetValue(false);
artifactGroupField.SetValue(-1);
}
}
}
2 changes: 1 addition & 1 deletion LostArtifacts/Resources/logic.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
},
{
"name": "AttunedJewel",
"logic": "GG_Workshop + GG_Atrium + *Boss_Geo-Vengefly_King + Defeated_Gruz_Mother + Defeated_False_Knight + *Boss_Geo-Massive_Moss_Charger + Defeated_Hornet_1 + Defeated_Gorb + Defeated_Elegant_Warrior + Defeated_Brooding_Mawlek + Defeated_Xero + Defeated_Colosseum_2 + Defeated_Mantis_Lords + Defeated_Marmu + Defeated_Flukemarm + Defeated_Galien + Defeated_Hive_Knight + Defeated_Elder_Hu + Defeated_Collector + Defeated_Grimm + Defeated_Watcher_Knights + Defeated_Uumuu + Defeated_Nosk + Defeated_Hornet_2 + Defeated_Enraged_Guardian + Defeated_Lost_Kin + Defeated_No_Eyes + Defeated_Traitor_Lord + Defeated_White_Defender + Defeated_Soul_Tyrant + Defeated_Markoth + Defeated_Failed_Champion"
"logic": "GG_Atrium + WINGS + LEFTCLAW + VOIDHEART + *Boss_Geo-Vengefly_King + Defeated_Gruz_Mother + Defeated_False_Knight + *Boss_Geo-Massive_Moss_Charger + Defeated_Hornet_1 + Defeated_Gorb + Defeated_Elegant_Warrior + Defeated_Brooding_Mawlek + Defeated_Xero + Defeated_Colosseum_2 + Defeated_Mantis_Lords + Defeated_Marmu + Defeated_Flukemarm + Defeated_Galien + Defeated_Hive_Knight + Defeated_Elder_Hu + Defeated_Collector + Defeated_Grimm + Defeated_Watcher_Knights + Defeated_Uumuu + Defeated_Nosk + Defeated_Hornet_2 + Defeated_Enraged_Guardian + Defeated_Lost_Kin + Defeated_No_Eyes + Defeated_Traitor_Lord + Defeated_White_Defender + Defeated_Soul_Tyrant + Defeated_Markoth + Defeated_Failed_Champion + Defeated_Grey_Prince_Zote"
},
{
"name": "HiddenMemento",
Expand Down

0 comments on commit 034042b

Please sign in to comment.