Struct collider::Collider [] [src]

pub struct Collider<P: HbProfile> { /* fields omitted */ }

A structure that tracks hitboxes and returns collide/separate events.

Collider manages events using a "simulation time" that the user updates as necessary. This time starts at 0.0.

Methods

impl<P: HbProfile> Collider<P>
[src]

[src]

Constructs a new Collider instance.

[src]

Returns the current simulation time.

[src]

Returns the time at which self.next() needs to be called again.

Even if self.next_time() == self.time(), there is a chance that calling self.next() will return None, having processed an internal event. Regardless, after self.next() has been called repeatedly until it returns None, then self.next_time() will be greater than self.time() again.

This is a fast constant-time operation. The result may be infinity.

[src]

Advances the simulation time to the given value.

The positions of all hitboxes will be updated based on the velocities of the hitboxes. Will panic if time exceeds self.next_time(). Will also panic if time is less than self.time() (i.e. cannot rewind time).

The hitboxes are updated implicitly, and this is actually a fast constant-time operation.

[src]

Processes and returns the next Collide or Separate event, or returns None if there are no more events that occured at the given time (although an internal event might have been processed if None is returned). Will always return None if self.next_time() > self.time().

The returned value is a tuple, denoting the type of event (Collide or Separate) and the two hitbox profiles involved, in increasing order by HbId.

[src]

Returns the current state of the hitbox with the given id.

[src]

Adds a new hitbox to the collider.

The profile is used to track the hitbox over time; Collider will return this profile in certain methods, and the ID in this profile can be used to make updates to the hitbox. This method will panic if there is an ID clash. hitbox is the initial state of the hitbox.

Returns a vector of all hitbox profiles that this new hitbox collided with as it was added. Note that separate collision events will not be generated for these collisions.

[src]

Updates the velocity information of the hitbox with the given id.

[src]

Removes the hitbox with the given id from all tracking.

Returns a vector of all hitbox profiles that this hitbox separated from as it was removed. No further events will be generated for this hitbox.

[src]

Returns the profiles of all currently tracked overlaps on the hitbox with the given id.

[src]

Returns true if there is a currently tracked overlap between the hitboxes with id_1 and id_2.

[src]

Returns the profiles of all hitboxes that overlap the given shape and interact with the given profile.

Trait Implementations

Auto Trait Implementations

impl<P> Send for Collider<P> where
    P: Send

impl<P> Sync for Collider<P> where
    P: Sync