Skip to content

Commit

Permalink
Bugfixes and other changes
Browse files Browse the repository at this point in the history
- Dreamwood now drops immediately instead of needing to exit and reenter the room
- Add option to disable artifacts in a randomizer
- Disable enable status on top level connections menu
- Fix Debug toggle slots option not enabling overcharging
- Thorned Leaf, Lush Moss, Dung Ball, Honeydrop, and Dreamwood tweaks/fixes
- Fix serialization error and add logging settings
  • Loading branch information
Hoo-Knows committed Oct 16, 2022
1 parent 3612eb8 commit 2198adb
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 44 deletions.
3 changes: 2 additions & 1 deletion LostArtifacts/ArtifactSprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
using UnityEngine;
using System.IO;
using Satchel;
using Newtonsoft.Json;

namespace LostArtifacts
{
public class ArtifactSprite : ISprite
{
public string name;
public Sprite Value => GetArtifactSprite();
[JsonIgnore] public Sprite Value => GetArtifactSprite();

public ArtifactSprite(string name)
{
Expand Down
2 changes: 2 additions & 0 deletions LostArtifacts/LostArtifacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ private void UIManagerStartNewGame(On.UIManager.orig_StartNewGame orig, UIManage
}
return;
}

if(!RandoSettings.Enabled) return;
PlaceArtifacts();
}

Expand Down
4 changes: 2 additions & 2 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.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion>
<AssemblyVersion>1.0.1.0</AssemblyVersion>
<FileVersion>1.0.1.0</FileVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<LangVersion>latest</LangVersion>
</PropertyGroup>
Expand Down
38 changes: 32 additions & 6 deletions LostArtifacts/LostArtifacts/Dreamwood.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,10 @@ public override AbstractLocation Location()
name = InternalName(),
sceneName = nameof(SceneNames.RestingGrounds_05),
Test = new PDBool(nameof(PlayerData.completedRGDreamPlant)),
falseLocation = new CoordinateLocation()
falseLocation = new DreamwoodLocation()
{
name = InternalName(),
sceneName = nameof(SceneNames.RestingGrounds_05),
x = 15.9f,
y = -100f,
elevation = 0f
sceneName = nameof(SceneNames.RestingGrounds_05)
},
trueLocation = new CoordinateLocation()
{
Expand Down Expand Up @@ -91,8 +88,37 @@ public override void Deactivate()
base.Deactivate();

On.EnemyDreamnailReaction.RecieveDreamImpact -= EnemyDreamnailReactionRecieveDreamImpact;
On.HealthManager.Hit += HealthManagerHit;
On.HealthManager.Hit -= HealthManagerHit;
StopAllCoroutines();
}
}

internal class DreamwoodLocation : ContainerLocation
{
protected override void OnLoad()
{
On.DreamPlant.CheckOrbs += DreamPlantCheckOrbs;
}

private IEnumerator DreamPlantCheckOrbs(On.DreamPlant.orig_CheckOrbs orig, DreamPlant self)
{
yield return orig(self);
if(self.gameObject.scene.name == sceneName)
{
GameObject obj;
string containerType;
GetContainer(out obj, out containerType);
Container.GetContainer(containerType).ApplyTargetContext(obj, self.gameObject, 0f);
if(!obj.activeSelf)
{
obj.SetActive(true);
}
}
}

protected override void OnUnload()
{
On.DreamPlant.CheckOrbs -= DreamPlantCheckOrbs;
}
}
}
8 changes: 4 additions & 4 deletions LostArtifacts/LostArtifacts/DungBall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ private IEnumerator SpawnClouds(Vector3 pos)
{
int numToSpawn = 1;
if(level == 2) numToSpawn = 10;
if(level == 3) numToSpawn = 75;
if(level == 4) numToSpawn = 200;
if(level == 3) numToSpawn = 50;
if(level == 4) numToSpawn = 500;

for(int i = 0; i < numToSpawn; i++)
{
Expand All @@ -67,8 +67,8 @@ private IEnumerator SpawnClouds(Vector3 pos)
Destroy(stink.GetComponent<DamageEffectTicker>());

if(level == 2) stink.transform.localScale *= 5f;
if(level == 3) stink.transform.localScale *= 25f;
if(level == 4) stink.transform.localScale *= 50f;
if(level == 3) stink.transform.localScale *= 10f;
if(level == 4) stink.transform.localScale *= 30f;

stink.SetActive(true);

Expand Down
6 changes: 3 additions & 3 deletions LostArtifacts/LostArtifacts/Honeydrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class Honeydrop : Artifact
public override string Name() => "Honeydrop";
public override string Description() => "This honeydrop was made through the bees’ hard work. And you took it without " +
"permission. Unbeelievable.";
public override string LevelInfo() => (50 * (PlayerData.instance.GetInt(nameof(PlayerData.nailDamage)) - 1)) + ", " +
(40 * (PlayerData.instance.GetInt(nameof(PlayerData.nailDamage)) - 1)) + ", " +
(30 * (PlayerData.instance.GetInt(nameof(PlayerData.nailDamage)) - 1)) + " damage";
public override string LevelInfo() => (40 * (PlayerData.instance.GetInt(nameof(PlayerData.nailDamage)) - 1)) + ", " +
(30 * (PlayerData.instance.GetInt(nameof(PlayerData.nailDamage)) - 1)) + ", " +
(20 * (PlayerData.instance.GetInt(nameof(PlayerData.nailDamage)) - 1)) + " damage";
public override string TraitName() => "Honey Coating";
public override string TraitDescription() => "Dealing enough damage gives a honey coating that blocks one instance " +
"of non-hazard damage (cannot stack)";
Expand Down
45 changes: 31 additions & 14 deletions LostArtifacts/LostArtifacts/LumaflyEssence.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,17 @@ public override void Activate()
{
base.Activate();

zapGO = LostArtifacts.Preloads["GG_Uumuu"]["Mega Jellyfish GG"].LocateMyFSM("Mega Jellyfish").
GameObject prefab = LostArtifacts.Preloads["GG_Uumuu"]["Mega Jellyfish GG"].LocateMyFSM("Mega Jellyfish").
GetAction<SpawnObjectFromGlobalPool>("Gen", 2).gameObject.Value;
zapGO = Instantiate(prefab);
zapGO.SetActive(false);
DontDestroyOnLoad(zapGO);

zapGO.name = "LostArtifacts.LumaflyEssenceZap";
zapGO.layer = (int)PhysLayers.HERO_ATTACK;
Destroy(zapGO.GetComponent<DamageHero>());
LumaflyEssenceZap de = zapGO.AddComponent<LumaflyEssenceZap>();

numToSpawn = level;

ModHooks.AttackHook += AttackHook;
Expand Down Expand Up @@ -74,17 +83,6 @@ private IEnumerator ZapControl(Vector3 dir)
for(int i = 1; i <= numToSpawn; i++)
{
GameObject zap = Instantiate(zapGO, pos + i * dir, Quaternion.identity);
zap.SetActive(false);

zap.name = "LostArtifacts.LumaflyEssenceZap";
zap.layer = (int)PhysLayers.HERO_ATTACK;
Destroy(zap.GetComponent<DamageHero>());

DamageEnemies de = zap.AddComponent<DamageEnemies>();
de.damageDealt = PlayerData.instance.GetInt(nameof(PlayerData.nailDamage)) / 2;
de.attackType = AttackTypes.NailBeam;
de.ignoreInvuln = true;

zap.SetActive(true);

yield return new WaitForSeconds(0.1f);
Expand All @@ -97,13 +95,12 @@ private void HealthManagerHit(On.HealthManager.orig_Hit orig, HealthManager self
{
if(hitInstance.Source.name != "LostArtifacts.LumaflyEssenceZap")
{
LostArtifacts.Instance.Log(hitInstance.Source.layer);
orig(self, hitInstance);
return;
}

//Override the iframes on hit so that it doesn't eat nail hits
GameObject.Destroy(hitInstance.Source.GetComponent<DamageEnemies>());
hitInstance.IsExtraDamage = true;
orig(self, hitInstance);
ReflectionHelper.SetField(self, "evasionByHitRemaining", 0f);
}
Expand All @@ -122,4 +119,24 @@ public override void Deactivate()
StopAllCoroutines();
}
}

internal class LumaflyEssenceZap : MonoBehaviour
{

private void OnTriggerEnter2D(Collider2D otherCollider)
{
if(otherCollider == null) return;
if(otherCollider.gameObject.layer != (int)PhysLayers.ENEMIES) return;

HitInstance hit = default(HitInstance);
hit.DamageDealt = PlayerData.instance.GetInt(nameof(PlayerData.nailDamage)) / 2;
hit.AttackType = AttackTypes.NailBeam;
hit.IgnoreInvulnerable = true;
hit.Source = gameObject;
hit.Multiplier = 1f;

HealthManager hm = otherCollider.gameObject.GetComponent<HealthManager>();
hm.Hit(hit);
}
}
}
4 changes: 2 additions & 2 deletions LostArtifacts/LostArtifacts/LushMoss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class LushMoss : Artifact
public override string Name() => "Lush Moss";
public override string Description() => "This piece of moss came from the Massive Moss Charger. It has a mysterious " +
"healing power that allows the moss chargers to recover their moss no matter how many times it is destroyed.";
public override string LevelInfo() => "20, 15, 10 hits to heal";
public override string LevelInfo() => "25, 20, 15 hits to heal";
public override string TraitName() => "Regeneration";
public override string TraitDescription() => "Heal a mask after a certain amount of nail hits";
public override AbstractLocation Location()
Expand Down Expand Up @@ -45,7 +45,7 @@ public override void Activate()
base.Activate();

counter = 0;
hitsNeeded = 25 - level * 5;
hitsNeeded = 30 - level * 5;

On.HealthManager.TakeDamage += HealthManagerTakeDamage;
}
Expand Down
7 changes: 3 additions & 4 deletions LostArtifacts/LostArtifacts/ThornedLeaf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void HealthManagerHit(On.HealthManager.orig_Hit orig, HealthManager self
{
Destroy(self.gameObject.GetComponent<Laceration>());
}
if(!self.IsInvincible) self.gameObject.AddComponent<Laceration>();
self.gameObject.AddComponent<Laceration>();
}
orig(self, hitInstance);

Expand All @@ -72,7 +72,7 @@ public override void Deactivate()
}
}

public class Laceration : MonoBehaviour
internal class Laceration : MonoBehaviour
{
private float damageInterval;

Expand Down Expand Up @@ -103,8 +103,7 @@ private IEnumerator DealDamage()
{
if(gameObject.GetComponent<HealthManager>() != null)
{
if(gameObject.GetComponent<HealthManager>().hp <= 0 ||
gameObject.GetComponent<HealthManager>().IsInvincible) break;
if(gameObject.GetComponent<HealthManager>().hp <= 0) break;

gameObject.GetComponent<HealthManager>().ApplyExtraDamage(1);
gameObject.GetComponent<SpriteFlash>().flashWhiteQuick();
Expand Down
26 changes: 23 additions & 3 deletions LostArtifacts/RandoInterop/ArtifactRando.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
using RandomizerMod.Menu;
using RandomizerMod.RC;
using RandomizerMod.Settings;
using RandomizerMod.Logging;
using System.IO;
using System;
using Newtonsoft.Json;

namespace LostArtifacts.Rando
{
Expand All @@ -15,11 +18,20 @@ public static void HookRando()
RequestBuilder.OnUpdate.Subscribe(-498f, DefineArtifacts);
RequestBuilder.OnUpdate.Subscribe(50f, AddArtifacts);
RandomizerMenuAPI.AddMenuPage(RandoMenu.ConstructMenu, RandoMenu.HandleButton);
SettingsLog.AfterLogSettings += AddSettingsToLog;
}

public static bool IsRandoActive()
{
RandomizerSettings rs = RandomizerMod.RandomizerMod.RS;
if(rs == null) return false;
if(rs.GenerationSettings == null) return false;
return true;
}

private static void DefineLogicItem(GenerationSettings gs, LogicManagerBuilder lmb)
{
if(!LostArtifacts.RandoSettings.RandomizeArtifacts) return;
if(!LostArtifacts.RandoSettings.Enabled || !LostArtifacts.RandoSettings.RandomizeArtifacts) return;

foreach(Artifact artifact in LostArtifacts.Instance.artifacts)
{
Expand All @@ -32,7 +44,7 @@ private static void DefineLogicItem(GenerationSettings gs, LogicManagerBuilder l

private static void DefineArtifacts(RequestBuilder rb)
{
if(!LostArtifacts.RandoSettings.RandomizeArtifacts) return;
if(!LostArtifacts.RandoSettings.Enabled || !LostArtifacts.RandoSettings.RandomizeArtifacts) return;

foreach(Artifact artifact in LostArtifacts.Instance.artifacts)
{
Expand Down Expand Up @@ -81,13 +93,21 @@ bool ResolveGroup(RequestBuilder rb, string item, RequestBuilder.ElementType typ

private static void AddArtifacts(RequestBuilder rb)
{
if(!LostArtifacts.RandoSettings.RandomizeArtifacts) return;
if(!LostArtifacts.RandoSettings.Enabled || !LostArtifacts.RandoSettings.RandomizeArtifacts) return;

foreach(Artifact artifact in LostArtifacts.Instance.artifacts)
{
rb.AddItemByName(artifact.InternalName());
rb.AddLocationByName(artifact.InternalName());
}
}

private static void AddSettingsToLog(LogArguments args, TextWriter tw)
{
tw.WriteLine("Logging LostArtifacts settings:");
using JsonTextWriter jtw = new(tw) { CloseOutput = false, };
RandomizerMod.RandomizerData.JsonUtil._js.Serialize(jtw, LostArtifacts.RandoSettings);
tw.WriteLine();
}
}
}
45 changes: 43 additions & 2 deletions LostArtifacts/RandoInterop/RandoMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@
using MenuChanger.Extensions;
using MenuChanger.MenuElements;
using MenuChanger.MenuPanels;
using System;
using UnityEngine;

namespace LostArtifacts.Rando
{
public static class RandoMenu
{
private static MenuPage SettingsPage;
private static SmallButton pageRootButton;
private static ToggleButton enabledButton;
private static ToggleButton randomizedButton;
private static ToggleButton useMainItemGroupButton;

public static bool HandleButton(MenuPage landingPage, out SmallButton button)
{
button = new(landingPage, LostArtifacts.Instance.GetName());
button.AddHideAndShowEvent(landingPage, SettingsPage);
pageRootButton = new(landingPage, LostArtifacts.Instance.GetName());
pageRootButton.AddHideAndShowEvent(landingPage, SettingsPage);
ChangeTopLevelColor();
button = pageRootButton;
return true;
}

Expand All @@ -24,6 +31,40 @@ public static void ConstructMenu(MenuPage landingPage)
new MenuElementFactory<RandoSettings>(SettingsPage, LostArtifacts.RandoSettings);
IMenuElement[] elements = factory.Elements;
new VerticalItemPanel(SettingsPage, new Vector2(0f, 300f), 75f, true, elements);

enabledButton = (ToggleButton)factory.ElementLookup[nameof(LostArtifacts.RandoSettings.Enabled)];
randomizedButton = (ToggleButton)factory.ElementLookup[nameof(LostArtifacts.RandoSettings.RandomizeArtifacts)];
useMainItemGroupButton = (ToggleButton)factory.ElementLookup[nameof(LostArtifacts.RandoSettings.UseMainItemGroup)];
enabledButton.SelfChanged += EnabledChanged;
randomizedButton.SelfChanged += RandomizedChanged;
useMainItemGroupButton.SelfChanged += UseMainItemGroupChanged;
}

private static void EnabledChanged(IValueElement obj)
{
if(!(bool)obj.Value) randomizedButton.SetValue(false);
}

private static void RandomizedChanged(IValueElement obj)
{
if(!(bool)obj.Value) useMainItemGroupButton.SetValue(false);
else enabledButton.SetValue(true);
ChangeTopLevelColor();
}

private static void UseMainItemGroupChanged(IValueElement obj)
{
if((bool)obj.Value) randomizedButton.SetValue(true);
}

private static void ChangeTopLevelColor()
{
if(pageRootButton != null)
{
pageRootButton.Text.color = Colors.FALSE_COLOR;
if(LostArtifacts.RandoSettings.Enabled) pageRootButton.Text.color = Colors.DEFAULT_COLOR;
if(LostArtifacts.RandoSettings.RandomizeArtifacts) pageRootButton.Text.color = Colors.TRUE_COLOR;
}
}
}
}
1 change: 1 addition & 0 deletions LostArtifacts/RandoInterop/RandoSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public class RandoSettings
{
public bool Enabled { get; set; }
public bool RandomizeArtifacts { get; set; }
public bool UseMainItemGroup { get; set; }
}
Expand Down
2 changes: 1 addition & 1 deletion LostArtifacts/UI/ArtifactManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void OnEnable()
}

//Update Overcharge
canOvercharge = PlayerData.instance.GetInt(nameof(PlayerData.nailSmithUpgrades)) == 4;
canOvercharge = PlayerData.instance.GetInt(nameof(PlayerData.nailSmithUpgrades)) == 4 || LostArtifacts.Settings.unlockedSlots;
if(canOvercharge)
{
if(LostArtifacts.Settings.overchargedSlot == -1) LostArtifacts.Settings.overchargedSlot = 0;
Expand Down
Loading

0 comments on commit 2198adb

Please sign in to comment.