1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Optional, statically typed extensions composed by a game.
//!
//! A plugin is an ordinary Cargo dependency. The game owns its instances and
//! chooses when to call each hook, passing the same public contexts it receives
//! from [`crate::Game`]. There is no registry, scheduler, implicit dispatch, or
//! dependency from the engine to plugin crates. See [`crate::guides::plugins`].
use crate::;
/// Opt-in lifecycle hooks over explicitly shared, game-owned state.
///
/// `State` can be a scene, a game-defined struct, a borrowed view, or `()` for an
/// independent plugin. Hooks have defaults so a plugin implements only what it
/// needs. Games may also call plugin-specific methods directly, for example to
/// draw several plugins inside one world pass or supply routed input.
///
/// The engine does **not** invoke these hooks. Call them from your [`crate::Game`]
/// implementation in the desired order. Propagate initialization errors with
/// `?`; the engine then drops the game before assets and the graphics context.
/// Partial initialization is not automatically rolled back when a game catches
/// the error and continues. Each plugin must document that recovery policy.
///
/// CPU data and jobs can live in plugin fields. Keep SDK contexts borrowed for
/// the duration of the call; native GPU work belongs to init/draw/unload on the
/// owning thread. Asset IDs borrow ownership from the run's asset collection:
/// dropping an ID does not unload its resource. Do not unload shared resources
/// without an explicit ownership agreement.