A powerful 3D/2.5D game controller plugin for Bevy Engine.
The Devices System provides a unified framework for interactive objects in the game world. It handles everything from simple buttons and doors to complex inspectable items and recharging stations. The system is designed to be highly modular, supporting custom actions, animations, and event-driven logic.
The base component for any interactive entity. It manages the state of usage, player detection, and activation logic.
#[derive(Component)]
pub struct ElectronicDevice {
pub device_can_be_used: bool,
pub using_device: bool,
pub player_inside: bool, // Is player in trigger?
pub use_move_camera_to_device: bool, // Should camera focus on device?
pub use_free_interaction: bool, // Allows moving while using?
}
The player-side component that manages detection and interaction input.
Defines the text and behavior for UI prompts.
#[derive(Component)]
pub struct DeviceStringAction {
pub device_name: String, // e.g., "Safe"
pub device_action: String, // e.g., "Open"
pub secondary_device_action: String, // e.g., "Close"
pub icon_enabled: bool,
}
A comprehensive system for managing doors, gates, and hatches.
Features:
time_to_close seconds.tag_list_to_open).pub struct DoorSystem {
pub movement_type: DoorMovementType,
pub locked: bool,
pub open_speed: f32,
pub auto_close: bool,
// ...
}
Handles buttons, levers, and toggles.
Modes:
Integration:
SimpleSwitchEvent to notify other systems.switch_animation_name on use.Allows the player to pick up and inspect an object in 3D space.
Capabilities:
Refills player attributes (Health or Energy) when used.
UsingDevicesSystem casts a ray or checks for Collider triggers.raycast_distance) and obstacles.DeviceStringAction UI (e.g., “Press E to Open”).ElectronicDevice state is updated.The system relies heavily on Bevy Events for decoupling.
ElectronicDeviceActivationEvent: Fired when a device is successfully used.DoorOpenCloseEvent: Notifies when a door changes state.SimpleSwitchEvent: Generic event for button presses.ExamineObjectEvent: Handles start/stop of inspection.commands.spawn((
// 1. Core Device
ElectronicDevice::default(),
DeviceStringAction {
device_name: "Blast Door".into(),
device_action: "Open".into(),
secondary_device_action: "Close".into(),
..default()
},
// 2. Door Logic
DoorSystem {
movement_type: DoorMovementType::Translate,
open_speed: 2.0,
doors_info: vec![
SingleDoorInfo {
current_target_position: Vec3::new(0.0, 3.0, 0.0), // Slide up
..default()
}
],
..default()
},
// 3. Visuals & Physics
PbrBundle { ... },
Collider::cuboid(1.0, 2.0, 0.1),
));