You are viewing a potentially older version of this package. View all versions.
Amorously-AmorLib-1.1.1 icon

AmorLib

My cool library mod for plugin developers

Date uploaded 2 days ago
Version 1.1.1
Download link Amorously-AmorLib-1.1.1.zip
Downloads 468
Dependency string Amorously-AmorLib-1.1.1

This mod requires the following mods to function

BepInEx-BepInExPack_GTFO-3.2.2 icon
BepInEx-BepInExPack_GTFO

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

Preferred version: 3.2.2

README

AmorLib

Adds an API for plugin developers to modify lights without conflicting with other mods. Decouples StateReplicators from FloLib and SyncedEvents from EEC for convenient host-client syncing. With safe dependency wrappers for InjectLib and PartialData reflection and JsonSerializerOptions. And various other consolidated fixes and utilities.

Basically, a common library so that I don't have to copy paste the same code for each plugin.

Documentation is still a work in progress. Please refer to the GitHub repo or ask in my plugin feedback thread for how to use.

Terminals

Contains the following vanilla bug fixes:

  • FlowGeos modded reactor terminal instantiation.
  • Hidden terminal commands are fully hidden (not able to be tabbed).
  • Reactor terminals are appended to their zone's TerminalsSpawnedInZone.

API

Currently exposes LightAPI. Major thanks to Dinorush for the help with putting this together.

(Expand)

First, you need to pull LightWorker(s) of the lights you want to change. (LightAPI has several helper methods to get certain LightWorkers in a zone or within range of a position.) Then, to add a modifier, call AddModifier on the LightWorker. For example, if you are applying the same modifier to multiple lights:

IEnumerable<LightWorker> workersInZone = LightAPI.GetLightWorkersInZone((0, 0, 0));
GetLightWorkersInZone<ILightModifier> lightMod = workersInZone.AddLightModifiers("red", 1.0f, true, LightPriority.Normal);

This will instantly enable all lights in the elevator zone, set intensity to 1, and change the color to red.

If you want to lerp light settings for individual lights, create a modifier with the current light settings as to not immediately apply new settings:

LightWorker worker = MyCoolWorkers[i]; // example list of LightWorkers
LG_Light light = worker.Light;
ILightModifier mod = worker.AddModifier(light.m_color, light.m_intensity, light.enabled);
// Go to MyCoolCoroutine...
while (time <= duration)
{
    time += Time.deltaTime;
    progress = Mathf.Clamp01(time / duration);
    mod.Color = Color.Lerp(startColor, endColor, progress);
    mod.Intensity = Mathf.Lerp(startIntensity, endIntensity, progress);
    yield return null;
}

All AddModifier methods return the created ILightModifier object(s), which provide methods to update or remove itself.

public interface ILightModifier
{
    // The color of this modifier.
    public Color Color { get; set; }

    // The intensity of this modifier.
    public float Intensity { get; set; }

    // The (light) enabled/disabled state of this modifer.
    public bool Enabled { get; set; }

    // The priority of the modifier. Highest priority takes affect; FIFO.
    public int Priority { get; }

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

    // Sets a new light color, intensity, and enabled state for the modifier, if Active
    public void Set(Color color, float intensity, bool enabled) { }

    // Adds the full modifier back to the top of the stack.
    public bool Register(); 

    // Disables the modifier and removes it from the light.
    public void Remove();
}

Note: LightWorkers do not persist between levels.

Other Features

  • Dependencies
    • InjectLib wrapper
    • PData wrapper
  • Events
    • Additional level-related events
    • SNetEvents-related events
  • Networking
    • StateReplicators
    • SyncedEvents
  • Utils
    • Json-related
      • BoolBase
      • ValueBase
      • LocaleText
    • CourseNodeUtil
    • GlobalBase & GlobalIndexUtil
    • JsonSerializerUtil

CHANGELOG

Changelog

v1.1.1

  • Made the Prefix string in SyncedEvents virtual.

v1.1.0

  • Updated Thunderstore README.
  • Fixed a logic issue with LightWorkers where modifiers were not fully reset or removed.
  • Added new DataBlockUtil.
  • Added IStateReplicatorHolder interface.

v1.0.5

  • Fixed a null reference exception in CourseNodeUtil when a course node is null.

v1.0.4

  • Fixed an issue with the InjectLib and PartialData wrappers throwing an exception if either were not present in the profile.

v1.0.3

  • Hotfix for CourseNodeUtil mistakenly running on each factory batch instead of after the last AIGraph batch.

v1.0.2

  • Added new GameObject extension method ClonePrefabSpawners.

v1.0.1

  • Fixed an issue with CourseNodeUtil failing on consecutive drops.