PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
audio_source_component.h
1#pragma once
2
3#include "pixelbullet/audio/audio_spatial_settings.h"
4#include "pixelbullet/filesystem/virtual_path.h"
5#include "pixelbullet/filesystem/virtual_path_serialization.h"
6#include "pixelbullet/serialization/node.h"
7
8namespace pixelbullet
9{
11{
12 bool enabled = true;
13 VirtualPath clip;
14 bool autoplay = true;
15 bool loop = false;
16 float volume = 1.0f;
17 bool spatial = false;
18 float min_distance = 1.0f;
19 float max_distance = 20.0f;
20
21 bool operator==(const AudioSourceComponent& other) const noexcept
22 {
23 return enabled == other.enabled && clip.LogicalPath() == other.clip.LogicalPath() && autoplay == other.autoplay &&
24 loop == other.loop && volume == other.volume && spatial == other.spatial && min_distance == other.min_distance &&
25 max_distance == other.max_distance;
26 }
27};
28
29inline Node& operator<<(Node& node, const AudioSourceComponent& component)
30{
31 node["enabled"] << component.enabled;
32 node["clip"] << component.clip;
33 node["autoplay"] << component.autoplay;
34 node["loop"] << component.loop;
35 node["volume"] << component.volume;
36 node["spatial"] << component.spatial;
37 node["minDistance"] << component.min_distance;
38 node["maxDistance"] << component.max_distance;
39 return node;
40}
41
42inline const Node& operator>>(const Node& node, AudioSourceComponent& component)
43{
44 if (node.HasProperty("enabled"))
45 {
46 node["enabled"] >> component.enabled;
47 }
48 if (node.HasProperty("clip"))
49 {
50 node["clip"] >> component.clip;
51 }
52 if (node.HasProperty("autoplay"))
53 {
54 node["autoplay"] >> component.autoplay;
55 }
56 if (node.HasProperty("loop"))
57 {
58 node["loop"] >> component.loop;
59 }
60 if (node.HasProperty("volume"))
61 {
62 node["volume"] >> component.volume;
63 }
64 if (node.HasProperty("spatial"))
65 {
66 node["spatial"] >> component.spatial;
67 }
68 if (node.HasProperty("minDistance"))
69 {
70 node["minDistance"] >> component.min_distance;
71 }
72 if (node.HasProperty("maxDistance"))
73 {
74 node["maxDistance"] >> component.max_distance;
75 }
76 return node;
77}
78} // namespace pixelbullet
Represents a hierarchical node capable of storing various data types and supporting YAML serializatio...
Definition node.h:45
Definition virtual_path.h:10
Definition audio_source_component.h:11