
Pegasus Lib
Pegasus Lib: A Foundation for tModLoader Modding Excellence
For the dedicated tModLoader modder, efficiency and robust functionality are paramount. Pegasus Lib emerges as an indispensable toolkit, designed by Moonlight Glint to streamline the development process and empower creators with a suite of powerful, reusable code components. This library mod acts as a bedrock, offering solutions to common challenges faced when building complex modifications for tModLoader.
Core Features for Mod Developers
Pegasus Lib consolidates a range of essential functionalities, meticulously crafted to enhance the capabilities of other tModLoader mods. Its primary purpose is to reduce repetitive coding tasks for modders and provide reliable implementations for advanced features.
Key Components of Pegasus Lib:
- ShaderLayerTargetHandler: A sophisticated system for applying shaders to elements drawn in multiple segments, or for layering multiple shader effects onto a single visual component.
- Strikethrough Font: Introduces a custom font style that mirrors the character spacing of the default MouseText font, allowing for visually consistent strikethrough text.
- Fast Field Access: Offers faster alternatives to traditional reflection for accessing fields, with `FastFieldInfo` and `FastStaticFieldInfo` reducing overhead.
- Automatic Asset Loading: Simplifies the management of game assets through `AutoLoadingAsset`, ensuring resources are loaded efficiently.
- Custom Item Drawing: Enables unique visual representations for items when they are being used or held with the `ICustomDrawItem` interface.
- Enhanced Collision Methods: Provides a collection of extended collision detection utilities through `CollisionExt`, aiding in more precise in-game interactions.
Integrating Pegasus Lib into Your Mods
For players, the experience is seamless: simply install and enable Pegasus Lib alongside any mod that requires it. Modders will find the integration straightforward. After setting up Pegasus Lib as a library mod, use `PegasusLib.PegasusLib.Require()` during your mod’s loading phase, specifying the `PegasusLib.LibFeatures` your mod depends on. This proactive approach ensures that features relying on specific library components do not fail silently if those components are unavailable or encounter issues due to tModLoader updates or mod incompatibilities. Furthermore, developers can leverage `PegasusLib.PegasusLib.IsFeatureErrored` or `PegasusLib.PegasusLib.OnFeatureError` for custom error handling, ensuring a more resilient and player-friendly modding experience.
