1#![allow(clippy::too_many_arguments, clippy::type_complexity)]
2#![warn(missing_docs)]
3#![doc = include_str!("../readme.md")]
4
5use avian3d::prelude::*;
6use bevy_app::prelude::*;
7use bevy_ecs::prelude::*;
8
9pub mod actor;
10mod cooldown;
11pub mod input;
12mod interaction;
13mod math;
14pub mod output;
15pub mod prop;
16mod rng;
17mod verb;
18pub use verb::Holding;
19
20pub use rng::*;
21pub mod prelude {
23 pub(crate) use super::{
24 HandleVerbSystem,
25 cooldown::prelude::*,
26 prop::{NonPickupMass, prelude::*},
27 };
28 pub use crate::{
29 AvianPickupPlugin, AvianPickupSystem, actor::prelude::*, input::prelude::*,
30 output::prelude::*,
31 };
32 pub(crate) use avian3d::prelude::*;
33 pub(crate) use bevy_app::prelude::*;
34 pub(crate) use bevy_ecs::prelude::*;
35 pub(crate) use bevy_log::prelude::*;
36 pub(crate) use bevy_math::prelude::*;
37 pub(crate) use bevy_reflect::prelude::*;
38 pub(crate) use bevy_transform::prelude::*;
39 pub(crate) use bevy_utils::prelude::*;
40}
41
42#[derive(Default)]
59#[non_exhaustive]
60pub struct AvianPickupPlugin;
61
62impl Plugin for AvianPickupPlugin {
63 fn build(&self, app: &mut App) {
64 let physics_schedule = app.get_schedule(PhysicsSchedule);
65 if physics_schedule.is_none() {
66 panic!(
67 "Failed to build `AvianPickupPlugin`:\
68 Avian's `PhysicsSchedule` was not found. Make sure to add Avian's plugins *before* `AvianPickupPlugin`.\
69 This usually done by adding `PhysicsPlugins` to your `App`."
70 )
71 }
72
73 app.configure_sets(
74 PhysicsSchedule,
75 (
76 AvianPickupSystem::First,
77 AvianPickupSystem::HandleVerb,
78 AvianPickupSystem::ResetIdle,
79 AvianPickupSystem::TickTimers,
80 AvianPickupSystem::Last,
81 )
82 .chain()
83 .before(PhysicsStepSystems::First),
84 )
85 .configure_sets(
86 PhysicsSchedule,
87 (
88 HandleVerbSystem::Pull,
89 HandleVerbSystem::Hold,
90 HandleVerbSystem::Drop,
91 HandleVerbSystem::Throw,
92 )
93 .chain()
94 .in_set(AvianPickupSystem::HandleVerb),
95 );
96
97 app.add_plugins((
98 input::plugin,
99 output::plugin,
100 actor::plugin,
101 interaction::plugin,
102 cooldown::plugin,
103 prop::plugin,
104 verb::plugin,
105 rng::plugin,
106 ));
107 }
108}
109
110#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
114pub enum AvianPickupSystem {
115 First,
117 HandleVerb,
122 ResetIdle,
127 TickTimers,
129 Last,
131}
132
133#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
134pub(crate) enum HandleVerbSystem {
135 Pull,
136 Hold,
137 Drop,
138 Throw,
139}