Skip to content

Commit

Permalink
fix(package): add for_playables to entity
Browse files Browse the repository at this point in the history
  • Loading branch information
philpax committed Sep 15, 2023
1 parent 9d577c5 commit 4494506
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 36 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 68 additions & 1 deletion crates/ecs/src/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ mod raw {
};
use glam::{Mat4, Quat, UVec2, UVec3, UVec4, Vec2, Vec3, Vec4};
use std::time::Duration;
components ! ("package" , { # [doc = "**Is Package**: Whether or not this entity is a package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Is Package"] , Description ["Whether or not this entity is a package."]] is_package : () , # [doc = "**Enabled**: Whether or not this package is enabled.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Enabled"] , Description ["Whether or not this package is enabled."]] enabled : bool , # [doc = "**ID**: The ID of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["ID"] , Description ["The ID of the package."]] id : String , # [doc = "**Name**: The name of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Name"] , Description ["The name of the package."]] name : String , # [doc = "**Version**: The version of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Version"] , Description ["The version of the package."]] version : String , # [doc = "**Authors**: The authors of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Authors"] , Description ["The authors of the package."]] authors : Vec :: < String > , # [doc = "**Description**: The description of the package. If not attached, the package does not have a description.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Description"] , Description ["The description of the package. If not attached, the package does not have a description."]] description : String , # [doc = "**Repository**: The repository of the package. If not attached, the package does not have a repository.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Repository"] , Description ["The repository of the package. If not attached, the package does not have a repository."]] repository : String , # [doc = "**Asset URL**: The asset URL (i.e. where the built assets are) of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Asset URL"] , Description ["The asset URL (i.e. where the built assets are) of the package."]] asset_url : String , # [doc = "**Client Modules**: The clientside WASM modules spawned by this package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Client Modules"] , Description ["The clientside WASM modules spawned by this package."]] client_modules : Vec :: < EntityId > , # [doc = "**Server Modules**: The serverside WASM modules spawned by this package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Server Modules"] , Description ["The serverside WASM modules spawned by this package."]] server_modules : Vec :: < EntityId > , });
components ! ("package" , { # [doc = "**Is Package**: Whether or not this entity is a package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Is Package"] , Description ["Whether or not this entity is a package."]] is_package : () , # [doc = "**Enabled**: Whether or not this package is enabled.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Enabled"] , Description ["Whether or not this package is enabled."]] enabled : bool , # [doc = "**ID**: The ID of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["ID"] , Description ["The ID of the package."]] id : String , # [doc = "**Name**: The name of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Name"] , Description ["The name of the package."]] name : String , # [doc = "**Version**: The version of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Version"] , Description ["The version of the package."]] version : String , # [doc = "**Authors**: The authors of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Authors"] , Description ["The authors of the package."]] authors : Vec :: < String > , # [doc = "**Description**: The description of the package. If not attached, the package does not have a description.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Description"] , Description ["The description of the package. If not attached, the package does not have a description."]] description : String , # [doc = "**Repository**: The repository of the package. If not attached, the package does not have a repository.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Repository"] , Description ["The repository of the package. If not attached, the package does not have a repository."]] repository : String , # [doc = "**For Playables**: The playable IDs that this package is for. This package must be a `Mod`.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["For Playables"] , Description ["The playable IDs that this package is for. This package must be a `Mod`."]] for_playables : Vec :: < String > , # [doc = "**Asset URL**: The asset URL (i.e. where the built assets are) of the package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Asset URL"] , Description ["The asset URL (i.e. where the built assets are) of the package."]] asset_url : String , # [doc = "**Client Modules**: The clientside WASM modules spawned by this package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Client Modules"] , Description ["The clientside WASM modules spawned by this package."]] client_modules : Vec :: < EntityId > , # [doc = "**Server Modules**: The serverside WASM modules spawned by this package.\n\n*Attributes*: Debuggable, Networked"] @ [Debuggable , Networked , Name ["Server Modules"] , Description ["The serverside WASM modules spawned by this package."]] server_modules : Vec :: < EntityId > , });
}
#[doc = r" Auto-generated message definitions. Messages are used to communicate with the runtime, the other side of the network,"]
#[doc = r" and with other modules."]
Expand Down Expand Up @@ -660,6 +660,73 @@ mod raw {
}
impl RuntimeMessage for PackageLoadFailure {}
}
#[doc = r" Auto-generated type definitions."]
pub mod types {
use ambient_package_rt::message_serde::*;
use serde;
#[derive(
Copy,
Clone,
Debug,
PartialEq,
Eq,
serde :: Serialize,
serde :: Deserialize,
Default,
)]
#[serde(crate = "self::serde")]
#[doc = "**PackageContent**: The content type of the package."]
pub enum PackageContent {
#[default]
#[doc = "A playable experience."]
Playable,
#[doc = "An asset."]
Asset,
#[doc = "A tool."]
Tool,
#[doc = "A mod."]
Mod,
}
impl crate::EnumComponent for PackageContent {
fn to_u32(&self) -> u32 {
match self {
Self::Playable => PackageContent::Playable as u32,
Self::Asset => PackageContent::Asset as u32,
Self::Tool => PackageContent::Tool as u32,
Self::Mod => PackageContent::Mod as u32,
}
}
fn from_u32(value: u32) -> Option<Self> {
if value == PackageContent::Playable as u32 {
return Some(Self::Playable);
}
if value == PackageContent::Asset as u32 {
return Some(Self::Asset);
}
if value == PackageContent::Tool as u32 {
return Some(Self::Tool);
}
if value == PackageContent::Mod as u32 {
return Some(Self::Mod);
}
None
}
}
impl MessageSerde for PackageContent {
fn serialize_message_part(
&self,
output: &mut Vec<u8>,
) -> Result<(), MessageSerdeError> {
crate::EnumComponent::to_u32(self).serialize_message_part(output)
}
fn deserialize_message_part(
input: &mut dyn std::io::Read,
) -> Result<Self, MessageSerdeError> {
crate::EnumComponent::from_u32(u32::deserialize_message_part(input)?)
.ok_or(MessageSerdeError::InvalidValue)
}
}
}
}
pub mod physics {
#[doc = r" Auto-generated component definitions."]
Expand Down
1 change: 1 addition & 0 deletions crates/package_semantic_native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ambient_core = { path = "../core", version = "0.3.0-dev" }

ambient_cb = { path = "../../libs/cb", version = "0.3.0-dev" }

ambient_package = { path = "../../shared_crates/package", version = "0.3.0-dev" }
ambient_package_semantic = { path = "../../shared_crates/package_semantic", version = "0.3.0-dev" }
ambient_shared_types = { path = "../../shared_crates/shared_types", version = "0.3.0-dev" }

Expand Down
4 changes: 4 additions & 0 deletions crates/package_semantic_native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use ambient_ecs::{
};
use ambient_native_std::asset_url::AbsAssetUrl;
use ambient_network::ServerWorldExt;
use ambient_package::PackageContent;
use ambient_package_semantic::{
Item, ItemId, ItemSource, LocalOrRemote, Package, PrimitiveType, RetrievableFile, Semantic,
TypeInner,
Expand Down Expand Up @@ -235,6 +236,9 @@ fn sync_semantic_to_world(
if let Some(repository) = &manifest.package.repository {
entity.set(self::repository(), repository.clone());
}
if let PackageContent::Mod { for_playables } = &manifest.package.content {
entity.set(self::for_playables(), for_playables.clone());
}
let entity = entity.spawn(world);
world
.synced_resource_mut(package_id_to_package_entity())
Expand Down
107 changes: 106 additions & 1 deletion guest/rust/api_core/src/internal/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2644,6 +2644,12 @@ mod raw {
pub fn repository() -> Component<String> {
*REPOSITORY
}
static FOR_PLAYABLES: Lazy<Component<Vec<String>>> =
Lazy::new(|| __internal_get_component("ambient_core::package::for_playables"));
#[doc = "**For Playables**: The playable IDs that this package is for. This package must be a `Mod`.\n\n*Attributes*: Debuggable, Networked"]
pub fn for_playables() -> Component<Vec<String>> {
*FOR_PLAYABLES
}
static ASSET_URL: Lazy<Component<String>> =
Lazy::new(|| __internal_get_component("ambient_core::package::asset_url"));
#[doc = "**Asset URL**: The asset URL (i.e. where the built assets are) of the package.\n\n*Attributes*: Debuggable, Networked"]
Expand Down Expand Up @@ -2699,6 +2705,8 @@ mod raw {
pub description: Option<String>,
#[doc = "**Component**: `ambient_core::package::repository`\n\n**Component description**: The repository of the package. If not attached, the package does not have a repository.\n\n"]
pub repository: Option<String>,
#[doc = "**Component**: `ambient_core::package::for_playables`\n\n**Component description**: The playable IDs that this package is for. This package must be a `Mod`.\n\n"]
pub for_playables: Option<Vec<String>>,
}
impl Concept for Package {
fn make(self) -> Entity {
Expand Down Expand Up @@ -2745,6 +2753,12 @@ mod raw {
repository,
);
}
if let Some(for_playables) = self.optional.for_playables {
entity.set(
crate::ambient_core::package::components::for_playables(),
for_playables,
);
}
entity
}
fn get_spawned(id: EntityId) -> Option<Self> {
Expand Down Expand Up @@ -2794,6 +2808,10 @@ mod raw {
id,
crate::ambient_core::package::components::repository(),
),
for_playables: entity::get_component(
id,
crate::ambient_core::package::components::for_playables(),
),
},
})
}
Expand All @@ -2820,6 +2838,8 @@ mod raw {
.get(crate::ambient_core::package::components::description()),
repository: entity
.get(crate::ambient_core::package::components::repository()),
for_playables: entity
.get(crate::ambient_core::package::components::for_playables()),
},
})
}
Expand Down Expand Up @@ -2865,7 +2885,7 @@ mod raw {
Component<Vec<EntityId>>,
Component<Vec<EntityId>>,
);
type Optional = (Component<String>, Component<String>);
type Optional = (Component<String>, Component<String>, Component<Vec<String>>);
fn required() -> Self::Required {
(
crate::ambient_core::package::components::is_package(),
Expand All @@ -2883,6 +2903,7 @@ mod raw {
(
crate::ambient_core::package::components::description(),
crate::ambient_core::package::components::repository(),
crate::ambient_core::package::components::for_playables(),
)
}
fn from_required_data(
Expand Down Expand Up @@ -2979,6 +3000,90 @@ mod raw {
}
impl RuntimeMessage for PackageLoadFailure {}
}
#[doc = r" Auto-generated type definitions."]
pub mod types {
use crate::{global::serde, message::*};
#[derive(
Copy,
Clone,
Debug,
PartialEq,
Eq,
serde :: Serialize,
serde :: Deserialize,
Default,
)]
#[serde(crate = "self::serde")]
#[doc = "**PackageContent**: The content type of the package."]
pub enum PackageContent {
#[default]
#[doc = "A playable experience."]
Playable,
#[doc = "An asset."]
Asset,
#[doc = "A tool."]
Tool,
#[doc = "A mod."]
Mod,
}
impl crate::ecs::EnumComponent for PackageContent {
fn to_u32(&self) -> u32 {
match self {
Self::Playable => PackageContent::Playable as u32,
Self::Asset => PackageContent::Asset as u32,
Self::Tool => PackageContent::Tool as u32,
Self::Mod => PackageContent::Mod as u32,
}
}
fn from_u32(value: u32) -> Option<Self> {
if value == PackageContent::Playable as u32 {
return Some(Self::Playable);
}
if value == PackageContent::Asset as u32 {
return Some(Self::Asset);
}
if value == PackageContent::Tool as u32 {
return Some(Self::Tool);
}
if value == PackageContent::Mod as u32 {
return Some(Self::Mod);
}
None
}
}
impl crate::ecs::SupportedValue for PackageContent {
fn from_result(result: crate::ecs::WitComponentValue) -> Option<Self> {
use crate::ecs::EnumComponent;
u32::from_result(result).and_then(Self::from_u32)
}
fn into_result(self) -> crate::ecs::WitComponentValue {
use crate::ecs::EnumComponent;
self.to_u32().into_result()
}
fn from_value(value: crate::ecs::ComponentValue) -> Option<Self> {
use crate::ecs::EnumComponent;
u32::from_value(value).and_then(Self::from_u32)
}
fn into_value(self) -> crate::ecs::ComponentValue {
use crate::ecs::EnumComponent;
self.to_u32().into_value()
}
}
impl MessageSerde for PackageContent {
fn serialize_message_part(
&self,
output: &mut Vec<u8>,
) -> Result<(), MessageSerdeError> {
crate::ecs::EnumComponent::to_u32(self).serialize_message_part(output)
}
fn deserialize_message_part(
input: &mut dyn std::io::Read,
) -> Result<Self, MessageSerdeError> {
crate::ecs::EnumComponent::from_u32(u32::deserialize_message_part(input)?)
.ok_or(MessageSerdeError::InvalidValue)
}
}
}
}
pub mod physics {
#[doc = r" Auto-generated component definitions."]
Expand Down
Loading

0 comments on commit 4494506

Please sign in to comment.