Git Product home page Git Product logo

libadvflight's Introduction

LibAdvFlight

A simple library to track events related to the advanced flying system. Requires LibStub (included in packaged releases).

Usage

Add LibAdvFlight-1.0 to your addon by either specifying it in your .pkgmeta file, or by downloading a packaged version from this repo, and loading the lib.xml file.

local LibAdvFlight = LibStub:GetLibrary("LibAdvFlight-1.0");
local Events = LibAdvFlight.Events;

local function OnAdvFlyStart()
    print("Player has taken off!");
end

--- Using the provided API function
LibAdvFlight.RegisterCallback(Events.ADV_FLYING_START, OnAdvFlyStart);

-- Using the global EventRegistry
EventRegistry:RegisterCallback(Events.ADV_FLYING_START, OnAdvFlyStart);

API

Events

All events can be found in LibAdvFlight.Events. Event args will be listed beneath any events that include them.

Advanced Flying Enable State

Whether or not the player is able to advanced fly. i.e. player is mounted on an advanced flying mount.

  • ADV_FLYING_ENABLED: Advanced flying has been enabled. This fires when the player mounts up on an advanced flyable mount, or when using Soar as a Dracthyr.
  • ADV_FLYING_DISABLED: Advanced flying has been disabled. Occurs when the player dismounts, or if the zone is not advanced flyable.
  • ADV_FLYING_ENABLE_STATE_CHANGED: Advanced flying enable state has changed. This acts as a 'toggle', useful if you would rather register one event instead of both ADV_FLYING_{ENABLED | DISABLED}.
    • isAdvFlyEnabled - boolean: Indicates the new advanced flying enable state.
Advanced Flying State

Whether the player is actively using advanced flight or not (flying or grounded, essentially).

  • ADV_FLYING_START: Player has taken off and begun flying using advanced flight.
  • ADV_FLYING_END: Player has either landed or dismounted and is no longer flying.
  • ADV_FLYING_STATE_CHANGED: Advanced flying state has changed, as with ADV_FLYING_ENABLE_STATE_CHANGED, this is acts as a 'toggle' event.
    • isAdvFlying - boolean: Indicates the new 'flying' state of the player.
Vigor State

Player's current vigor/energy state

  • VIGOR_MAX_CHANGED: Player's maximum vigor value has changed. This event may fire multiple times upon first mounting up due to Blizzard's nonsense.
    • vigorMax - number: Player's maximum vigor value.
  • VIGOR_CHANGED: Player's current vigor value has changed. This event may also have unexpected behavior upon first mounting up (like values above 6??).
    • vigorCurrent - number: Player's current vigor value.

Functions

Events are great and all, but useless without a way to listen for them. Here, you can choose to use the API function below, or you can just register a callback with the global EventRegistry if you prefer.

LibAdvFlight.RegisterCallback(event, callback, owner?)

Registers a callback for the given event.

  • event - string: Event name. Names can be found in LibAdvFlight.Events.
  • callback - function: Callback function called when the given event is fired and will be passed the event's arguments.
  • owner? - table: Object passed to callback as the first argument to the callback function, same as the base CallbackRegistry, though if it's not provided, passes just the event arguments.

Returns a callback handle - a table containing an Unregister function to unregister the callback.

LibAdvFlight.IsAdvFlyEnabled()

Returns whether or not advanced flying is currently enabled. See the Events section above for more details.

LibAdvFlight.IsAdvFlying()

Returns whether or not the player is currently flying using advanced flight. See the Events section above for more details.

LibAdvFlight.GetMaxVigor()

Returns the player's maximum vigor level. Returns 0 if not mounted on an advanced flight mount.

LibAdvFlight.GetCurrentVigor()

Returns the player's current vigor level. Returns 0 if not mounted on an advanced flight mount.

LibAdvFlight.GetForwardSpeed()

Returns the current forwardSpeed of the player. Returns 0 if not mounted on an advanced flight mount.

LibAdvFlight.GetForwardSpeedRounded()

Returns the current forwardSpeed, rounded to the nearest whole number. Returns 0 if not mounted on an advanced flight mount.

LibAdvFlight.GetHeading()

Returns the player's current heading (direction) in degrees. Returns nil inside instances.

LibAdvFlight.GetHeadingRounded()

Returns the player's current heading in degrees, rounded to the nearest whole number. Returns nil inside instances.

LibAdvFlight.GetHeadingRadians()

Returns the player's current heading in radians. Returns nil inside instances.

libadvflight's People

Contributors

ghostopheles avatar

Stargazers

David C. Uhrig avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.