Skip to content

Commit

Permalink
Improved overall UI. Removed KorzUtils hard dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nerthul11 committed Oct 2, 2024
1 parent b5201e1 commit bca108e
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 38 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ jobs:
wget https://github.com/homothetyhk/HollowKnight.ItemChanger/releases/latest/download/ItemChanger.zip -O ItemChanger.zip
unzip -o ItemChanger.zip -d References
- name: Fetch KorzUtils
run: |
wget https://github.com/Korzer420/KorzUtils/releases/latest/download/KorzUtils.zip -O KorzUtils.zip
unzip -o KorzUtils.zip -d References
- name: Fetch MenuChanger
run: |
wget https://github.com/homothetyhk/HollowKnight.MenuChanger/releases/latest/download/MenuChanger.zip -O MenuChanger.zip
Expand Down
2 changes: 1 addition & 1 deletion AccessRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace AccessRandomizer
public class AccessRandomizer : Mod, IGlobalSettings<AccessSettings>
{
new public string GetName() => "AccessRandomizer";
public override string GetVersion() => "1.2.4.0";
public override string GetVersion() => "1.2.4.1";

private static AccessRandomizer _instance;
public AccessRandomizer() : base()
Expand Down
7 changes: 2 additions & 5 deletions AccessRandomizer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<Product>AccessRandomizer</Product>
<Description>A Randomizer add-on for a few miscellaneous access checks.</Description>
<Copyright>Copyright © </Copyright>
<AssemblyVersion>1.2.4.0</AssemblyVersion>
<FileVersion>1.2.4.0</FileVersion>
<AssemblyVersion>1.2.4.1</AssemblyVersion>
<FileVersion>1.2.4.1</FileVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down Expand Up @@ -83,9 +83,6 @@
<Reference Include="ItemChanger">
<HintPath>$(LocalRefs)/Mods/ItemChanger/ItemChanger.dll</HintPath>
</Reference>
<Reference Include="KorzUtils">
<HintPath>$(LocalRefs)/Mods/KorzUtils/KorzUtils.dll</HintPath>
</Reference>
<Reference Include="MenuChanger">
<HintPath>$(LocalRefs)/Mods/MenuChanger/MenuChanger.dll</HintPath>
</Reference>
Expand Down
20 changes: 5 additions & 15 deletions IC/AccessSprite.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ItemChanger;
using KorzUtils.Helper;
using ItemChanger.Internal;
using Newtonsoft.Json;
using System;
using UnityEngine;
Expand All @@ -9,25 +9,15 @@ namespace AccessRandomizer.IC
[Serializable]
public class AccessSprite : ISprite
{
#region Constructors

private static SpriteManager EmbeddedSpriteManager = new(typeof(AccessSprite).Assembly, "AccessRandomizer.Resources.Sprites.");
public string Key { get; set; }
public AccessSprite(string key)
{
if (!string.IsNullOrEmpty(key))
Key = key;
}

#endregion

#region Properties

public string Key { get; set; }

[JsonIgnore]
public Sprite Value => SpriteHelper.CreateSprite<AccessRandomizer>("Sprites." + Key.Replace("/", ".").Replace("\\", "."));

#endregion

public ISprite Clone() => new AccessSprite(Key);
public Sprite Value => EmbeddedSpriteManager.GetSprite(Key);
public ISprite Clone() => (ISprite)MemberwiseClone();
}
}
9 changes: 7 additions & 2 deletions IC/RespectLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using ItemChanger.Locations;
using ItemChanger.Util;
using ItemChanger.Tags;
using KorzUtils.Helper;
using Satchel;
using System.Linq;
using AccessRandomizer.Fsm;
using UnityEngine;

namespace AccessRandomizer.IC
{
Expand Down Expand Up @@ -69,7 +69,12 @@ private void ToggleChallenge(PlayMakerFSM fsm)
fsm.ChangeTransition("Can Talk Bool?", "TRUE", "Idle 2");
// Keep the location disabled but spawn shiny item
if (Placement.Items.All(x => x.WasEverObtained()))
ItemHelper.SpawnShiny(new(30.2f, 7.4f), Placement);
{
Container c = Container.GetContainer(Container.Shiny);
GameObject shiny = c.GetNewContainer(new(c.Name, Placement, flingType));
shiny.transform.position = new(30.2f, 7.4f);
shiny.SetActive(true);
}
}
else
// Force enable if it isn't
Expand Down
1 change: 1 addition & 0 deletions IC/TrapBenchItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class TrapBenchItem : AbstractItem
public override void GiveImmediate(GiveInfo info)
{
AccessModule.Instance.TrapBench = true;
PlayerData.instance.spiderCapture = false;
AccessModule.Instance.CompletedChallenges();
}

Expand Down
49 changes: 45 additions & 4 deletions IC/TrapBenchLocation.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
using System;
using ItemChanger;
using ItemChanger.Locations;
using ItemChanger.Tags;
using ItemChanger.Util;
using Satchel;
using UnityEngine;

namespace AccessRandomizer.IC
{
public class TrapBenchLocation : CoordinateLocation
public class TrapBenchLocation : AutoLocation
{
public TrapBenchLocation()
{
name = "Trap_Bench";
sceneName = SceneNames.Deepnest_Spider_Town;
x = 45.0f;
y = 58.4f;
tags = [TrapBenchLocationTag()];
}

Expand All @@ -29,7 +31,46 @@ private static Tag TrapBenchLocationTag()

protected override void OnLoad()
{
base.OnLoad();
Events.AddFsmEdit(sceneName, new("RestBench Spider", "FSM"), SpawnShiny);
Events.AddFsmEdit(sceneName, new("RestBench Spider", "Bench Control Spider"), GiveItem);
}

protected override void OnUnload()
{
Events.RemoveFsmEdit(sceneName, new("RestBench Spider", "FSM"), SpawnShiny);
Events.RemoveFsmEdit(sceneName, new("RestBench Spider", "Bench Control Spider"), GiveItem);
}

private void SpawnShiny(PlayMakerFSM fsm)
{
fsm.AddState("Spawn Shiny");
fsm.AddCustomAction("Spawn Shiny", () =>
{
if (!Placement.AllObtained())
{
Container c = Container.GetContainer(Container.Shiny);
GameObject shiny = c.GetNewContainer(new(c.Name, Placement, flingType));
shiny.transform.position = new(47.0f, 58.4f);
shiny.SetActive(true);
}
});
fsm.ChangeTransition("Check", "DESTROY", "Spawn Shiny");
fsm.AddTransition("Spawn Shiny", "FINISHED", "Destroy");
}
private void GiveItem(PlayMakerFSM fsm)
{
AccessRandomizer.Instance.Log("This exists");
fsm.AddState("GiveItem");
fsm.AddCustomAction("GiveItem", () => {
ItemUtility.GiveSequentially(Placement.Items, Placement, new GiveInfo()
{
FlingType = FlingType.DirectDeposit,
MessageType = MessageType.Corner,
});
});

fsm.ChangeTransition("Sit Start", "FINISHED", "GiveItem");
fsm.AddTransition("GiveItem", "FINISHED", "Neutral");
}
}
}
14 changes: 8 additions & 6 deletions Modules/AccessModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ public override void Initialize()
}
}

public override void Unload()
{
On.PlayerData.SetBool -= Refresh;
On.GameManager.BeginSceneTransition -= ForceBools;
Events.RemoveLanguageEdit(new LanguageKey("UI", "INV_NAME_TRAM_PASS"), TramName);
Events.RemoveLanguageEdit(new LanguageKey("UI", "INV_DESC_TRAM_PASS"), TramDesc);
}

private void TramName(ref string value)
{
if (UpperTram && LowerTram)
Expand Down Expand Up @@ -96,12 +104,6 @@ private void ElevatorDesc(StringBuilder builder)
builder.AppendLine("You cannot ride large elevators.");
}

public override void Unload()
{
On.PlayerData.SetBool -= Refresh;
On.GameManager.BeginSceneTransition -= ForceBools;
}

private void ForceBools(On.GameManager.orig_BeginSceneTransition orig, GameManager self, GameManager.SceneLoadInfo info)
{
orig(self, info);
Expand Down

0 comments on commit bca108e

Please sign in to comment.