summaryrefslogtreecommitdiffhomepage
path: root/game/study_player/components.rb
blob: 0bb717a825f820f7f7d23f8cdb88c2c9e6725c53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Study Player — Flecs component declarations.
#
# Components are real C structs declared at runtime via the flecs meta/reflection
# addon. Values are serialized as Ruby Hashes between C memory and Ruby.
#
# See: notes/study-player-rewrite-plan.md §3 (flecs component/state model)

module StudyPlayer
  # Declare components on a Flecs::World. Returns a Hash of component handles.
  def self.declare_components(world)
    {
      audio_file:     world.struct("AudioFile",     "{string path; float duration;}"),
      playback_state: world.struct("PlaybackState", "{bool loaded; bool playing; float current_time; int skip_auto_update; bool seek_pending; float seek_target;}"),
      study_state:    world.struct("StudyState",    "{bool study_mode; bool was_in_silence; int last_silence_idx; bool smart_play_held;}"),
      layout_dirty:   world.struct("LayoutDirty",   "{bool value;}"),
      needs_load:     world.tag("NeedsLoad"),
    }
  end
end