aboutsummaryrefslogtreecommitdiff
path: root/src/payload
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <silas@exvacuum.dev>2024-12-24 00:54:31 -0500
committerLibravatar Silas Bartha <silas@exvacuum.dev>2024-12-24 00:54:31 -0500
commita1e9304dc31980703446bdb33246e314bafd3b15 (patch)
tree47c9dd32398a6d84050f39fac17d52d0a5d9ad4e /src/payload
parentf3a7c2139cb3f9074d28dd99fa1bbd10d752547e (diff)
Switched to bevy_mod_scripting, bevy 0.15 updatev0.4.0
Diffstat (limited to 'src/payload')
-rw-r--r--src/payload/components/mod.rs20
-rw-r--r--src/payload/mod.rs13
2 files changed, 33 insertions, 0 deletions
diff --git a/src/payload/components/mod.rs b/src/payload/components/mod.rs
index 2a83713..fc24ac1 100644
--- a/src/payload/components/mod.rs
+++ b/src/payload/components/mod.rs
@@ -5,24 +5,36 @@ use bevy::prelude::*;
use serde::{Deserialize, Serialize};
use yarnspinner::core::YarnValue;
+/// Payload component that corresponds to [`bevy::prelude::Transform`]
#[derive(Serialize, Deserialize, Clone, Default, Deref, DerefMut, Debug)]
pub struct Transform(pub bevy::prelude::Transform);
+/// Payload component that represent's an entity's name
#[derive(Serialize, Deserialize, Clone, Default, Deref, DerefMut, Debug)]
pub struct Name(pub String);
+/// Payload component that represents a yarnspinner actor
#[derive(Serialize, Deserialize, Clone, Default, Debug)]
pub struct Actor {
+ /// Actor-local variables
pub local_variables: HashMap<String, YarnValue>,
+ /// Source for the yarnspinner dialog
pub yarn_source: Vec<u8>,
}
+/// Payload component that represents a character's voice. Uses rustysynth to generate random MIDI
+/// tones based on given parameters.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Voice {
+ /// Base MIDI pitch of voice. Defaults to 60
pub pitch: i32,
+ /// MIDI preset to use for voice. Defaults to 0
pub preset: i32,
+ /// MIDI bank to use. Defaults to 0
pub bank: i32,
+ /// Variance in pitch of voice. Defaults to 3
pub variance: u32,
+ /// Speed of voice. Defaults to 1.0
pub speed: f32,
}
@@ -38,22 +50,30 @@ impl Default for Voice {
}
}
+/// Payload component that wraps a [`avian3d::prelude::RigidBody`]
#[derive(Serialize, Deserialize, Clone, Default, Deref, DerefMut, Debug)]
pub struct Rigidbody(pub RigidBody);
+/// Payload component that represents mesh colliders that will be generated for this entity
#[derive(Serialize, Deserialize, Clone, Default, Debug)]
pub struct MeshCollider {
+ /// Whether the generated colliders should be convex hulls
pub convex: bool,
+ /// Whether the generated colliders should be triggers
pub sensor: bool,
}
+/// Payload component representing a lua script that will be attached to an entity
#[derive(Serialize, Deserialize, Clone, Default, Debug)]
pub struct Script {
+ /// Lua script source
pub lua_source: Vec<u8>,
}
+/// Payload component for an arbitrary relationship map, can store 128-bit identifiers indexed by names
#[derive(Serialize, Deserialize, Clone, Default, Deref, DerefMut, Debug)]
pub struct Relationships(pub HashMap<String, [u8; 16]>);
+/// Payload component that indicates that this entity should be able to be picked up
#[derive(Serialize, Deserialize, Clone, Default, Debug)]
pub struct Pickup;
diff --git a/src/payload/mod.rs b/src/payload/mod.rs
index dd064f2..68e23a0 100644
--- a/src/payload/mod.rs
+++ b/src/payload/mod.rs
@@ -1,23 +1,36 @@
use serde::{Deserialize, Serialize};
use uuid::Uuid;
+/// Payload components
pub mod components;
+/// Payload steganographically embedded into asset files
#[derive(Serialize, Deserialize, Default, Clone, Debug)]
pub struct DirworldEntityPayload {
+ /// Unique identifier for this entity, used by conditional system
pub id: Uuid,
+ /// Transform of this entity
pub transform: components::Transform,
+ /// Name for this entity
pub name: Option<components::Name>,
+ /// Actor information for this entity
pub actor: Option<components::Actor>,
+ /// Voice information for this entity
pub voice: Option<components::Voice>,
+ /// Rigidbody for this entity
pub rigidbody: Option<components::Rigidbody>,
+ /// Mesh collider information for this entity
pub mesh_collider: Option<components::MeshCollider>,
+ /// Lua scripts for this entity
pub scripts: Option<Vec<components::Script>>,
+ /// Relationships for this entity
pub relationships: Option<components::Relationships>,
+ /// Pickup information for this entity
pub pickup: Option<components::Pickup>,
}
impl DirworldEntityPayload {
+ /// Create a new default payload with a randomized UUID
pub fn new() -> Self {
Self {
id: Uuid::new_v4(),