Skip to content

Toggling The Boss Rush Event

Tien edited this page Aug 16, 2024 · 3 revisions

Toggling the Boss Rush Event

This page will show you how to toggle the Boss Rush Event on and off.

Introduction

The way that the Boss Rush Event is turned on is through a simple method. That's it. However, the mod might need more compatibilities instead of just toggling the event on and off. One side effect to this is being able to toggle a Boss Rush Event from one mod and being able to cancel it out from another through toggling off. Having a universal method for this feels a bit off.

Code to Toggle the Event

BossRushAPI.BossRushSystem.I.ToggleBossRushEvent();

If the Boss Rush Event is off, then the code will toggle it on; if the event is on, then the code will toggle it off. You can use existing checks from Boss Rush System to prevent your mod from accidentally turning off the Boss Rush Events of other mods.

using BRS = BossRushAPI.BossRushSystem;

// ...

if (BRS.I.IsBossRushActive)
{
    Main.NewText("You cannot run away from your fate!");
}
else if (BRS.I.IsBossRushOff)
{
    BRS.I.ToggleBossRushEvent();
}
else
{
    throw new("Something went wrong.");
}

You may also use BossRushSystem.State property to check the current state of the Boss Rush Event.

using BRS = BossRushAPI.BossRushSystem;

// ...

if (BRS.I.State == BRS.States.Run || BRS.I.State == BRS.States.Prepare)
{
    Main.NewText("You cannot run away from your fate!");
}
else if (BRS.I.State == BRS.States.Off)
{
    BRS.I.ToggleBossRushEvent();
}
else
{
    throw new("Something went wrong.");
}

When to Toggle the Event

You can toggle it freely. Of course, the world should be loaded already when toggling takes place. An item that toggles the event, an NPC interaction, meeting certain conditions, you name it!

Clone this wiki locally