pub struct ArenaPhysicsManager {
pub world: PhysicsWorld,
pub rooms: Vec<ArenaRoom>,
pub trap_systems: HashMap<u32, TrapSystem>,
pub treasure_rooms: HashMap<u32, TreasureRoom>,
pub chaos_rifts: HashMap<u32, ChaosRiftRoom>,
pub damage_events: Vec<DamageEvent>,
pub collision_callbacks: Vec<CollisionCallback>,
pub floor_y: f32,
}Expand description
Top-level manager that owns the PhysicsWorld, trap systems, and room state.
Fields§
§world: PhysicsWorld§rooms: Vec<ArenaRoom>§trap_systems: HashMap<u32, TrapSystem>§treasure_rooms: HashMap<u32, TreasureRoom>§chaos_rifts: HashMap<u32, ChaosRiftRoom>§damage_events: Vec<DamageEvent>§collision_callbacks: Vec<CollisionCallback>§floor_y: f32Implementations§
Source§impl ArenaPhysicsManager
impl ArenaPhysicsManager
pub fn new() -> Self
Sourcepub fn register_trap_system(&mut self, room_id: u32, system: TrapSystem)
pub fn register_trap_system(&mut self, room_id: u32, system: TrapSystem)
Register a trap system for a room.
Sourcepub fn register_treasure_room(&mut self, room_id: u32, treasure: TreasureRoom)
pub fn register_treasure_room(&mut self, room_id: u32, treasure: TreasureRoom)
Register a treasure room.
Sourcepub fn register_chaos_rift(&mut self, room_id: u32, rift: ChaosRiftRoom)
pub fn register_chaos_rift(&mut self, room_id: u32, rift: ChaosRiftRoom)
Register a chaos rift room.
Sourcepub fn on_collision(&mut self, callback: CollisionCallback)
pub fn on_collision(&mut self, callback: CollisionCallback)
Register a collision callback.
Sourcepub fn step(&mut self, dt: f32) -> Vec<DamageEvent>
pub fn step(&mut self, dt: f32) -> Vec<DamageEvent>
Step the entire arena physics forward.
Sourcepub fn check_entity_damage(
&self,
entity_pos: Vec2,
entity_id: ObjectId,
) -> Vec<DamageEvent>
pub fn check_entity_damage( &self, entity_pos: Vec2, entity_id: ObjectId, ) -> Vec<DamageEvent>
Check trap damage for an entity.
Sourcepub fn notify_entity_position(&mut self, entity_pos: Vec2)
pub fn notify_entity_position(&mut self, entity_pos: Vec2)
Notify traps that an entity is at a position (for trigger zones).
Sourcepub fn raycast(&self, origin: Vec2, dir: Vec2, max_dist: f32) -> Option<RayHit>
pub fn raycast(&self, origin: Vec2, dir: Vec2, max_dist: f32) -> Option<RayHit>
Raycast through the arena.
Sourcepub fn overlap_test(&self, shape: &CollisionShape, pos: Vec2) -> Vec<ObjectId>
pub fn overlap_test(&self, shape: &CollisionShape, pos: Vec2) -> Vec<ObjectId>
Overlap test in the arena.
Sourcepub fn total_objects(&self) -> usize
pub fn total_objects(&self) -> usize
Get total active physics objects.
Auto Trait Implementations§
impl Freeze for ArenaPhysicsManager
impl RefUnwindSafe for ArenaPhysicsManager
impl Send for ArenaPhysicsManager
impl Sync for ArenaPhysicsManager
impl Unpin for ArenaPhysicsManager
impl UnsafeUnpin for ArenaPhysicsManager
impl UnwindSafe for ArenaPhysicsManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.