Module ambient_api::prelude

source ·

Modules

  • Element is a React-inspired virtual tree library for the Ambient runtime.
  • Retrieval of assets and where to find them.
  • [Client-only] Audio functionality, including loading sounds and playback.
  • Helper functions for the camera.
  • Manipulation, creation, removal, search and more for entities.
  • glam
  • [Server-only] HTTP-related functionality, including sending requests and receiving responses.
  • [Client-only] Input retrieval and manipulation.
  • Messaging to other packages and to the other side of the network boundary.
  • [Server-only] Physics-related functionality, including applying forces, changing physical properties, and more.
  • Player-specific functionality.
  • Serde

Macros

  • Construct an ad-hoc error from a string or existing non-anyhow error value.
  • Shorthand for let x = x.to_owned();

Structs

  • A 2D affine transform, which can represent translation, rotation, scaling and shear.
  • A 3D affine transform, which can represent translation, rotation, scaling and shear.
  • A full-screen alert dialog that the user must acknowledge.
  • An editor for a fixed-size array.
  • An entry in a Bookcase.
  • A bookcase layout is a min-max layout; it should be a list of BookFiles, where each BookFile has a container and a book. The book’s determine the size of the entire Bookcase, but their sizes are not manipulated. The containers are resized to fit the bookcase though, to align them.
  • A button UI element.
  • A Centered is a Flow that is oriented vertically and is centered.
  • A checkbox.
  • An area that tracks mouse events.
  • A component (piece of entity data). See entity::get_component and entity::set_component.
  • Helper that lets you pass in concepts where component tuples are expected.
  • An editor for a value that can be parsed from a string, but with custom parsing and stringification.
  • Contains a single element with a background color and click area.
  • A docking layout, where each child specifies which side of the parent it should be docked to. It is top-down: it starts with a given area (say the screen) and then divides it into smaller pieces with each new element added to it.
  • A dropdown element: shows the dropdown when show is specified.
  • A dropdown select element. Presents a button next to content that, when clicked, shows a dropdown with the items in items.
  • A Duration type to represent a span of time, typically used for system timeouts.
  • An editor for EditableDuration.
  • A duration that can be edited.
  • Legacy newtype for FlowColumn.
  • Options for the Editor type.
  • A full-screen prompt dialog to edit a value.
  • A row with a title and an element, used as part of larger editors.
  • A rendered ElementComponent instance.
  • A tree of instantiated Elements.
  • An Entity is a collection of components and associated values.
  • An identifier for an entity in the world.
  • A FixedGrid is a grid of elements with a fixed stride.
  • A flow layout. It is bottom-up: it auto-resizes itself to fit its constituent components.
  • A FlowColumn is a Flow that is oriented vertically.
  • A FlowRow is a Flow that is oriented horizontally.
  • A FontAwesome icon.
  • Wrap multiple Elements in a flat hierarchy.
  • Hooks are a way to hook into the state and lifecycle of an Element.
  • An element that will invoke a callback when a hotkey is pressed.
  • A 2-dimensional vector.
  • A 3-dimensional vector.
  • A 4-dimensional vector.
  • An editor for a IndexMap. The key and value types must implement Editor.
  • A slider for an integer value.
  • An editor for a HashMap. The key and value types must implement Editor.
  • Sets the translation of inner to offset its size in the selected axes. Note that you will have to use another mechanism to move the inner element as a result.
  • A simple UI line. Use components like line_from, line_to, line_width, background_color, border_color, border_radius and border_thickness to control its appearance.
  • An editor for a list of items that implement Editor; each item can be edited, moved up or down, or deleted.
  • A DropdownSelect that shows the current item for you automatically.
  • A 2x2 column major matrix.
  • A 3x3 column major matrix.
  • A 3x3 column major matrix.
  • A 4x4 column major matrix.
  • Measures the absolute position of its inner element and calls the callback when it changes.
  • Measures the size of its inner element and calls the callback when it changes.
  • Memoize the ElementComponent, such that it is only re-rendered if the component changes.
  • A MinimalListEditorWithItemEditor that uses the default editor for the items.
  • A single item in a list editor
  • A configurable list editor that allows you to specify the editor for the items, and to provide other preset options.
  • Represents the current state of the keyboard modifiers
  • Delegates a type editor to edit in a new screen.
  • Contains several elements with a background color and click area.
  • An editor for a value that can be parsed from a string.
  • Procedural storage handle type
  • Procedural storage handle type
  • Procedural storage handle type
  • Procedural storage handle type
  • A full-screen prompt dialog that the user must acknowledge.
  • A quaternion representing an orientation.
  • Ray represented by an origin and a direction
  • A simple UI rect. Use components like width, height, background_color, border_color, border_radius and border_thickness to control its appearance.
  • Contains an element with a background color and click area.
  • A scroll area that can be used to scroll its child.
  • A simple separator, similar to <hr> in HTML.
  • A slider for a floating-point value.
  • A wrapper for Arc<RwLock<T>> to simplify passing complex state around callbacks.
  • The standard RNG. The PRNG algorithm in StdRng is chosen to be efficient on the current platform, to be statistically strong and unpredictable (meaning a cryptographically secure PRNG).
  • An editor for SystemTime.
  • A header bar of tabs. Does not contain the tab content.
  • A set of tabs. Contains a TabBar and the content of the selected tab.
  • A text element. Use the text, font_size, font_family and color components to set its state.
  • A text element that renders in the main scene in 3D.
  • A text editor.
  • A reference to the thread-local generator
  • Shows an animated progress bar to indicate that progress is being made and has not frozen.
  • A tooltip element: shows the tooltip when the inner is hovered.
  • A base element for all UI elements. It contains all the components needed for a UI element to work.
  • This only exists so that we can implement From<String> for Text, and then use it in for instance Button.
  • A 2-dimensional vector.
  • A 3-dimensional vector.
  • A 4-dimensional vector.
  • A Ulid is a unique 128-bit lexicographically sortable identifier
  • A 2-dimensional vector.
  • A 3-dimensional vector.
  • A 3-dimensional vector.
  • A 4-dimensional vector.
  • A window with a title bar and a child element. Can be moved around.
  • A Dock that is always the size of the window.
  • A chance to style the window
  • Wraps the inner Element. This is useful for introducing an intermediate component node in a tree.

Enums

Constants

Traits

  • Provides the context method for Result.
  • A trait that abstracts over return types so that you can return an ResultEmpty or nothing.
  • A tuple of Components.
  • Concepts are defined in the package manifest, and are used to define a collection of components that correspond to some concept in the game world.
  • Provides component tuples for this concept.
  • Provides a helper method to get an instance of this concept with all of the fields filled in with suggested values.
  • A marker trait used to indicate that an RngCore or BlockRngCore implementation is supposed to be cryptographically secure.
  • Types (distributions) that can be used to create a random instance of T.
  • A trait for types that can be edited in the UI.
  • The base trait for all element components. These are similar to React components.
  • A convenience trait for converting an ElementComponent into an Element.
  • A future represents an asynchronous computation obtained by use of async.
  • An extension trait for Futures that provides a variety of convenient adapters.
  • Extension trait on iterators, providing random sampling methods.
  • Implemented on all types that can be de/serialized from/to a Vec<u8>.
  • Implemented by all messages that can be sent between modules.
  • An automatically-implemented extension trait on RngCore providing high-level generic methods for sampling values and other convenience methods.
  • The core of a random number generator.
  • Implemented by all messages sent from the runtime.
  • A random number generator that can be explicitly seeded.
  • Extension trait on slices, providing random mutation and sampling methods.
  • A trait that adds some default styles to elements.
  • A trait that provides helper methods for UI elements.

Functions

  • Align horizontal: Layout alignment: horizontal.
  • Align vertical: Layout alignment: vertical.
  • The color used for the background of the app.
  • Stops execution of this function until the provided condition is true. Useful for waiting for something to happen in the game world.
  • Helper for constructing a Cb.
  • Creates a new ChangeQuery that will find entities that have the specified components that will call its bound function when components marked by ChangeQuery::track_change change.
  • A color slightly darker than app_background_color.
  • Helper function that returns the Default for the type T. Most useful with struct update syntax, or with initializing components.
  • The length of the previous frame, in seconds.
  • Creates a new EventQuery that will find entities that have the specified components that will call its bound function when an entity with those components are despawned / seen for the last time by this query.
  • Docking: Layout docking.
  • The time, relative to Jan 1, 1970. Not guaranteed to be monotonic. Use game_time for most applications.
  • The error color.
  • Fit horizontal: Layout fit: horizontal.
  • Fit vertical: Layout fit: vertical.
  • Runs callback at most every dt. The actual time taken is passed to callback.
  • The time, relative to the start of the game. Guaranteed to be monotonic.
  • GPU UI size: Upload the width and height of this UI element to the GPU.
  • Height: The height of a UI element.
  • Is book file: This is a file in a layout_bookcase.
  • Is screen: This entity will be treated as a screen. Used by the Screen ui component.
  • Creates a 2-dimensional vector.
  • Creates a 3-dimensional vector.
  • Creates a 4-dimensional vector.
  • Layout: Layout.
  • Lerp (linear-interpolate) between any two values that support addition and multiplication.
  • Margin: Layout margin: [top, right, bottom, left].
  • Creates a 2x2 matrix from two column vectors.
  • Creates a 3x3 matrix from three column vectors.
  • Creates a 3x3 matrix from three column vectors.
  • Creates a 4x4 matrix from four column vectors.
  • Maximum height: The maximum height of a UI element.
  • Maximum width: The maximum width of a UI element.
  • Mesh to local from size: Update the mesh_to_local based on the width and height of this entity.
  • Minimum height: The minimum height of a UI element.
  • Minimum width: The minimum width of a UI element.
  • Orientation: Layout orientation.
  • Padding: Layout padding: [top, right, bottom, left].
  • The primary color.
  • Creates a quaternion from x, y, z and w values.
  • Creates a new GeneralQueryBuilder that will find entities that have the specified components and can be built to create a GeneralQuery.
  • randomstd and std_rng
    Generates a random value using the thread-local random number generator.
  • Runs the given async block (future). This lets your module set up behaviour to run concurrently, like a long-running task. It can return either a ResultEmpty or nothing.
  • The secondary color.
  • Stops execution of this function until seconds has passed.
  • Space between items: Space between items in a layout.
  • Creates a new EventQuery that will find entities that have the specified components that will call its bound function when an entity with those components are spawned / seen for the first time by this query.
  • Retrieve the lazily-initialized thread-local random number generator, seeded by the system. Intended to be used in method chaining style, e.g. thread_rng().gen::<i32>(), or cached locally, e.g. let mut rng = thread_rng();. Invoked by the Default trait, making ThreadRng::default() equivalent.
  • The color used for tooltip backgrounds.
  • Creates a 2-dimensional vector.
  • Creates a 3-dimensional vector.
  • Creates a 4-dimensional vector.
  • Creates a 2-dimensional vector.
  • Creates a 3-dimensional vector.
  • Creates a 3-dimensional vector.
  • Creates a 4-dimensional vector.
  • Stops execution of this function until one of the given RuntimeMessagesare received. The is_relevant functions are used to filter out messages that are not relevant.
  • Stops execution of this function until the given RuntimeMessage is received. The is_relevant function is used to filter out messages that are not relevant.
  • Width: The width of a UI element.
  • Converts the given element into a rect.

Type Aliases

Attribute Macros

  • Helper macro to implement a ElementComponent with a pure free function.
  • Makes your main() function accessible to the WASM host, and generates a packages module that contain all packages visible to your package, including itself.

Derive Macros