0.1.6 | Added: StashedBugle

This commit is contained in:
2026-03-07 02:39:14 +01:00
parent 894223dc5c
commit eb212ee599
4 changed files with 79 additions and 2 deletions

View File

@@ -28,3 +28,8 @@
- Added OpenMesaModule and OpenMesaPatch
- OpenMesaPatch makes it so that the Mesa biome is open no matter the seed.
# v0.1.6 | Stashed Bugle
- Added StashedBugleModule
- StashedBugleModule adds a new keybind to toggle give / remove a Bugle.

View File

@@ -13,6 +13,9 @@ public static class ConfigHandler
// Better Airport
public static ConfigEntry<float> ConveyorSpeedModifier { get; private set; } = null!;
// Stashed Bugle settings
public static ConfigEntry<KeyCode> ToggleBugle { get; private set; } = null!;
public static void Initialize(ConfigFile configFile)
{
Config = configFile;
@@ -35,6 +38,14 @@ public static class ConfigHandler
new AcceptableValueRange<float>(0.1f, 100f)
)
);
// Stashed Bugle settings
ToggleBugle = Config.Bind(
"Control",
"ToggleBugle",
KeyCode.V,
new ConfigDescription("Give / destroy Bugle")
);
}
}

View File

@@ -8,7 +8,7 @@
<!-- This is the display name of your mod. Example: BepInEx Template -->
<AssemblyTitle>JordanMod</AssemblyTitle>
<!-- This is the version number of your mod. -->
<Version>0.1.5</Version>
<Version>0.1.6</Version>
</PropertyGroup>
<PropertyGroup>

View File

@@ -0,0 +1,61 @@
using UnityEngine;
using Zorro.Core;
namespace JordanMod.Modules.StashedBugle;
[Module(Enabled = true)]
class StashedBugleModule : Module
{
public override string ModuleName => "Stashed Bugle Module";
private readonly string _bugleItemName = "Bugle";
private readonly string _megaphoneItemName = "Megaphone";
private float? lastPressTime = null;
public override void Update()
{
if (Input.GetKeyDown(ConfigHandler.ToggleBugle.Value)) ToggleBugle();
}
private void ToggleBugle()
{
if (lastPressTime == null || Time.time - lastPressTime > 1f) lastPressTime = Time.time;
else return;
Character localCharacter = Character.localCharacter;
if (localCharacter == null) return;
Item heldItem = localCharacter.data.currentItem;
if (heldItem != null)
{
if (heldItem.UIData.itemName == _bugleItemName)
{
localCharacter.refs.items.DestroyHeldItemRpc();
localCharacter.player.EmptySlot(localCharacter.refs.items.currentSelectedSlot);
localCharacter.player.RPCRemoveItemFromSlot(localCharacter.refs.items.currentSelectedSlot.Value);
localCharacter.refs.items.SpawnItemInHand(_megaphoneItemName);
}
else if (heldItem.UIData.itemName == _megaphoneItemName)
{
localCharacter.refs.items.DestroyHeldItemRpc();
localCharacter.player.EmptySlot(localCharacter.refs.items.currentSelectedSlot);
localCharacter.player.RPCRemoveItemFromSlot(localCharacter.refs.items.currentSelectedSlot.Value);
}
}
else if (heldItem == null)
{
ItemSlot? withBugleSlot = null;
for (int i = 0; i < CharacterItems.MAX_SLOT; i++)
{
ItemSlot itemSlot = localCharacter.player.GetItemSlot((byte)i);
if (itemSlot == null || itemSlot.prefab == null || itemSlot.prefab.UIData == null || itemSlot.prefab.UIData.itemName != _bugleItemName) continue;
withBugleSlot = itemSlot;
break;
}
if (withBugleSlot == null) localCharacter.refs.items.SpawnItemInHand(_bugleItemName);
else localCharacter.refs.items.EquipSlot(Optionable<byte>.Some(withBugleSlot.itemSlotID));
}
}
}