pub trait CollisionProvider<T: TilesetTrait> {
// Required methods
fn is_tile_passable(&self, tileset: T, tile_id: u8) -> bool;
fn check_tile_pair_collision(
&self,
tileset: T,
standing_tile: u8,
target_tile: u8,
on_water: bool,
) -> bool;
fn check_ledge_jump(
&self,
tileset: T,
sprite_facing: u8,
standing_tile: u8,
target_tile: u8,
held_input: u8,
) -> bool;
fn is_counter_tile(&self, tileset: T, tile_id: u8) -> bool;
fn get_tile_at_position(
&self,
tileset: T,
blocks: &[u8],
map_width: u8,
x: u16,
y: u16,
) -> u8;
fn is_door_tile(&self, tileset: T, tile_id: u8) -> bool;
fn is_warp_tile(&self, tileset: T, tile_id: u8) -> bool;
fn is_warp_carpet_tile_in_front(
&self,
tileset: T,
facing_idx: u8,
tile_id: u8,
) -> bool;
fn uses_warp_tile_in_front_check(&self, tileset: T) -> bool;
fn check_extra_warp_special(
&self,
tileset: T,
tile_in_front: u8,
) -> Option<bool>;
// Provided methods
fn is_water_tile(&self, _tileset: T, _tile_id: u8) -> bool { ... }
fn get_connection_edge_tile(
&self,
_tileset: T,
_map_width_blocks: u8,
_map_height_blocks: u8,
_x: u16,
_y: u16,
_direction: Direction,
) -> Option<u8> { ... }
}Expand description
Provides game-specific collision data to the engine.
Implementations supply tile passability, ledge jump rules, tile-pair collision data, and warp-support metadata for a given tileset type.
Required Methods§
Sourcefn is_tile_passable(&self, tileset: T, tile_id: u8) -> bool
fn is_tile_passable(&self, tileset: T, tile_id: u8) -> bool
Returns true if tile_id is passable (walkable) in the given tileset.
Sourcefn check_tile_pair_collision(
&self,
tileset: T,
standing_tile: u8,
target_tile: u8,
on_water: bool,
) -> bool
fn check_tile_pair_collision( &self, tileset: T, standing_tile: u8, target_tile: u8, on_water: bool, ) -> bool
Returns true if movement between standing_tile and target_tile
is blocked by a tile-pair collision (elevation difference).
Sourcefn check_ledge_jump(
&self,
tileset: T,
sprite_facing: u8,
standing_tile: u8,
target_tile: u8,
held_input: u8,
) -> bool
fn check_ledge_jump( &self, tileset: T, sprite_facing: u8, standing_tile: u8, target_tile: u8, held_input: u8, ) -> bool
Returns true if the player should jump a ledge.
sprite_facing is one of SPRITE_FACING_DOWN, etc.
held_input is a bitmask of pressed d-pad buttons.
Sourcefn is_counter_tile(&self, tileset: T, tile_id: u8) -> bool
fn is_counter_tile(&self, tileset: T, tile_id: u8) -> bool
Returns true if tile_id is a counter tile (can interact across but not walk onto).
Sourcefn get_tile_at_position(
&self,
tileset: T,
blocks: &[u8],
map_width: u8,
x: u16,
y: u16,
) -> u8
fn get_tile_at_position( &self, tileset: T, blocks: &[u8], map_width: u8, x: u16, y: u16, ) -> u8
Resolve the tile ID at a given map position from block data.
Sourcefn is_door_tile(&self, tileset: T, tile_id: u8) -> bool
fn is_door_tile(&self, tileset: T, tile_id: u8) -> bool
Returns true if tile_id is a door tile (for auto-step-out logic).
Sourcefn is_warp_tile(&self, tileset: T, tile_id: u8) -> bool
fn is_warp_tile(&self, tileset: T, tile_id: u8) -> bool
Returns true if tile_id is a warp tile (immediate warp trigger).
Sourcefn is_warp_carpet_tile_in_front(
&self,
tileset: T,
facing_idx: u8,
tile_id: u8,
) -> bool
fn is_warp_carpet_tile_in_front( &self, tileset: T, facing_idx: u8, tile_id: u8, ) -> bool
Returns true if the tile-in-front with the given facing_idx (0=Down, 1=Up, 2=Left, 3=Right)
is a warp-carpet tile for ExtraWarpCheck function 2.
Sourcefn uses_warp_tile_in_front_check(&self, tileset: T) -> bool
fn uses_warp_tile_in_front_check(&self, tileset: T) -> bool
Returns true if the tileset should use warp-tile-in-front checking
(ExtraWarpCheck function 2) instead of facing-map-edge (function 1).
Sourcefn check_extra_warp_special(
&self,
tileset: T,
tile_in_front: u8,
) -> Option<bool>
fn check_extra_warp_special( &self, tileset: T, tile_in_front: u8, ) -> Option<bool>
Handle map-specific extra-warp special cases (e.g. SS_ANNE_BOW tile 0x15).
Returns Some(true) if warp should fire, Some(false) if not,
or None to fall through to normal logic.
Provided Methods§
Sourcefn is_water_tile(&self, _tileset: T, _tile_id: u8) -> bool
fn is_water_tile(&self, _tileset: T, _tile_id: u8) -> bool
Returns true if tile_id is a water tile in the given tileset —
a tile a surfer can move onto while staying on the water
(CollisionCheckOnWater). Default: no water tiles.
Sourcefn get_connection_edge_tile(
&self,
_tileset: T,
_map_width_blocks: u8,
_map_height_blocks: u8,
_x: u16,
_y: u16,
_direction: Direction,
) -> Option<u8>
fn get_connection_edge_tile( &self, _tileset: T, _map_width_blocks: u8, _map_height_blocks: u8, _x: u16, _y: u16, _direction: Direction, ) -> Option<u8>
Resolve the tile the player would step onto when crossing a map
boundary in direction — the connected map’s edge tile. The original
reads this tile from the connection strip drawn in the tilemap
(LoadTileBlockMap / GetTileAndCoordsInFrontOfPlayer) and applies the
normal passability rules to it before the player may cross
(CollisionCheckOnLand / CollisionCheckOnWater → CheckTilePassable).
Returns None when the map has no connection in direction (or the
connected map has no tile at the arrival position) — the engine then
falls back to the plain map-edge behavior.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".