You are viewing a potentially older version of this package. View all versions.
Dinorush-ModifierAPI-1.2.0 icon

ModifierAPI

API for plugin developers to modify certain values without conflicts.

Date uploaded 3 days ago
Version 1.2.0
Download link Dinorush-ModifierAPI-1.2.0.zip
Downloads 491
Dependency string Dinorush-ModifierAPI-1.2.0

This mod requires the following mods to function

BepInEx-BepInExPack_GTFO-3.2.1 icon
BepInEx-BepInExPack_GTFO

BepInEx pack for GTFO. Preconfigured and includes Unity Base DLLs.

Preferred version: 3.2.1

README

ModifierAPI

Adds an API for plugin developers to modify certain values without conflicting with other mods.

Currently supports:

  • Movement Speed
  • Melee Attack Speed
    • Can specify Light, Charged, Push, or All

API

Currently exposes 2 APIs:

  • MovementSpeedAPI
  • MeleeAttackSpeedAPI

To add a modifier, call an AddModifier function from an API, e.g.:

IStatModifier MoveSpeedAPI.AddModifier(float mod, StackLayer layer = StackLayer.Multiply, string groupName = "Default");

Where the parameters are:

  • mod: The value of the modifier to apply.
  • layer: Which layer the modifier is added to. Determines how it stacks with other modifiers.
    • Options: Multiply, Add, Max, Min, Override
  • groupName: Which group to put the modifier in. Layers only apply within each group; separate groups are multiplied.

All AddModifier functions return the created IStatModifier object. The modifier provides methods to update its value or remove itself:

public interface IStatModifier
{
  // The value of the modifier. Updates when modified if active.
  public float Mod { get; set; }

  // The layer the modifier is on.
  public StackLayer Layer { get; }

  // Whether the modifier is active.
  public bool Active { get; }

  // Enables the modifier if it is inactive.
  public void Enable();

  // Sets Mod to the value and enables the modifier if it is inactive.
  public void Enable(float mod);

  // Disables/removes the modifier.
  public void Disable();
}

Note: Speed modifiers are disabled on level cleanup. If you wish to use the same speed modifier across drops, make sure to Enable it.

Examples

Simple Timed Buff

public void AddSpeedBuff(float mod, float duration) {
  CoroutineManager.StartCoroutine(RunSpeedBuff(mod, duration).WrapToIl2Cpp());
}

private IEnumerator RunSpeedBuff(float mod, float duration) {
  var modifier = MoveSpeedAPI.AddModifier(mod);
  yield new WaitForSeconds(duration);
  modifier.Disable();
}

Simple Persistent Buff

IStatModifier? _activeModifier = null;

public void SetAttackSpeedBuff(float mod) {
  if (_activeModifier == null)
  {
    _activeModifier = MeleeAttackSpeedAPI.AddModifier(mod);
  }
  else
  {
    _activeModifier.Enable(mod);
  }
}

CHANGELOG

v1.2.1

  • Fix melee modifiers not always applying on drop.

v1.2.0

  • Renamed from MovementSpeedAPI to fit the expanded scope.
  • Added an API to support melee attack speed.

v1.1.2

  • Fixed checkpoints making movement speed modifiers permanent.

v1.1.1

  • Fixed MTFO Hot Reload breaking the plugin.

v1.1.0

  • Added groups to allow mods to keep layer behavior local to themselves.

v1.0.0

  • Initial Release