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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
extern crate oxygengine_animation as anim; extern crate oxygengine_core as core; #[cfg(feature = "script-flow")] extern crate oxygengine_script_flow as flow; pub mod background; pub mod character; pub mod dialogue; pub mod resource; pub mod scene; pub mod script; pub mod story; pub mod system; pub mod vn_story_asset_protocol; #[cfg(test)] mod tests; pub mod prelude { pub use crate::background::*; pub use crate::character::*; pub use crate::dialogue::*; pub use crate::resource::*; pub use crate::scene::*; pub use crate::script::*; pub use crate::story::*; pub use crate::system::*; pub use crate::vn_story_asset_protocol::*; } use crate::system::VnStorySystem; use anim::curve::{Curved, CurvedDistance, CurvedOffset}; use core::{app::AppBuilder, assets::database::AssetsDatabase, Ignite, Scalar}; use serde::{Deserialize, Serialize}; use std::ops::{Add, Mul, Sub}; pub type Scale = Position; #[derive(Ignite, Debug, Default, Copy, Clone, Serialize, Deserialize)] pub struct Position(pub Scalar, pub Scalar); impl Curved for Position { fn zero() -> Self { Self(0.0, 0.0) } fn one() -> Self { Self(1.0, 1.0) } fn negate(&self) -> Self { Self(-self.0, -self.1) } fn get_axis(&self, index: usize) -> Option<Scalar> { match index { 0 => Some(self.0), 1 => Some(self.1), _ => None, } } fn interpolate(&self, other: &Self, factor: Scalar) -> Self { let diff = *other - *self; diff * factor + *self } } impl CurvedDistance for Position { fn curved_distance(&self, other: &Self) -> Scalar { let diff0 = other.0 - self.0; let diff1 = other.1 - self.1; (diff0 * diff0 + diff1 * diff1).sqrt() } } impl CurvedOffset for Position { fn curved_offset(&self, other: &Self) -> Self { *self + *other } } impl Add<Self> for Position { type Output = Self; fn add(self, other: Self) -> Self { Self(self.0 + other.0, self.1 + other.1) } } impl Sub<Self> for Position { type Output = Self; fn sub(self, other: Self) -> Self { Self(self.0 - other.0, self.1 - other.1) } } impl Mul<Scalar> for Position { type Output = Self; fn mul(self, other: Scalar) -> Self { Self(self.0 * other, self.1 * other) } } impl From<(Scalar, Scalar)> for Position { fn from(value: (Scalar, Scalar)) -> Self { Self(value.0, value.1) } } impl From<[Scalar; 2]> for Position { fn from(value: [Scalar; 2]) -> Self { Self(value[0], value[1]) } } #[derive(Ignite, Debug, Default, Copy, Clone, Serialize, Deserialize)] pub struct Color(pub Scalar, pub Scalar, pub Scalar); impl Curved for Color { fn zero() -> Self { Self(0.0, 0.0, 0.0) } fn one() -> Self { Self(1.0, 1.0, 1.0) } fn negate(&self) -> Self { Self(-self.0, -self.1, -self.2) } fn get_axis(&self, index: usize) -> Option<Scalar> { match index { 0 => Some(self.0), 1 => Some(self.1), 2 => Some(self.2), _ => None, } } fn interpolate(&self, other: &Self, factor: Scalar) -> Self { let diff = *other - *self; diff * factor + *self } } impl CurvedDistance for Color { fn curved_distance(&self, other: &Self) -> Scalar { let diff0 = other.0 - self.0; let diff1 = other.1 - self.1; let diff2 = other.2 - self.2; (diff0 * diff0 + diff1 * diff1 + diff2 * diff2).sqrt() } } impl CurvedOffset for Color { fn curved_offset(&self, other: &Self) -> Self { *self + *other } } impl Add<Self> for Color { type Output = Self; fn add(self, other: Self) -> Self { Self(self.0 + other.0, self.1 + other.1, self.2 + other.2) } } impl Sub<Self> for Color { type Output = Self; fn sub(self, other: Self) -> Self { Self(self.0 - other.0, self.1 - other.1, self.2 - other.2) } } impl Mul<Scalar> for Color { type Output = Self; fn mul(self, other: Scalar) -> Self { Self(self.0 * other, self.1 * other, self.2 * other) } } impl From<(Scalar, Scalar, Scalar)> for Color { fn from(value: (Scalar, Scalar, Scalar)) -> Self { Self(value.0, value.1, value.2) } } impl From<[Scalar; 3]> for Color { fn from(value: [Scalar; 3]) -> Self { Self(value[0], value[1], value[2]) } } pub fn bundle_installer<'a, 'b>(builder: &mut AppBuilder<'a, 'b>, _: ()) { builder.install_system(VnStorySystem::default(), "vn-story", &[]); } pub fn protocols_installer(database: &mut AssetsDatabase) { database.register(vn_story_asset_protocol::VnStoryAssetProtocol); }