16个不稳定版本 (5个破坏性更新)
使用旧的Rust 2015
0.6.0 | 2020年2月12日 |
---|---|
0.5.1 | 2019年7月23日 |
0.4.0 | 2019年7月9日 |
0.3.0 | 2018年11月6日 |
0.2.0 | 2018年7月11日 |
666 在 数据结构 中
3,371 每月下载量
在 67 个crate中使用 (6个直接使用)
29KB
509 行
specs-hierarchy
用于specs
的场景图类型层次抽象。
通过查询用户提供的Parent
组件来构建一个Hierarchy
资源。需要组件被Tracked
。
将在内部的EventChannel
上发送修改事件。请注意,Removed
事件并不意味着Parent
组件已被从组件存储中移除,只是表示实体不再被视为Hierarchy
的一部分。这是因为用户可能只想移除组件、完整的Entity
或完全不同的内容。当一个父实体被从层次结构中移除时,它下面的完整子树也将从层次结构中移除。
用法
# Cargo.toml
[dependencies]
specs-hierarchy = "0.5.1"
示例
use specs::prelude::{Component, DenseVecStorage, Entity, FlaggedStorage};
use specs_hierarchy::{Hierarchy, Parent as HParent};
/// Component for defining a parent entity.
///
/// The entity with this component *has* a parent, rather than *is* a parent.
#[derive(Debug, Clone, Eq, Ord, PartialEq, PartialOrd)]
pub struct Parent {
/// The parent entity
pub entity: Entity,
}
impl Component for Parent {
type Storage = FlaggedStorage<Self, DenseVecStorage<Self>>;
}
impl HParent for Parent {
fn parent_entity(&self) -> Entity {
self.entity
}
}
许可证
根据您的选择许可
- Apache License,版本2.0,(LICENSE-APACHE 或 https://apache.ac.cn/licenses/LICENSE-2.0)
- MIT许可证 (LICENSE-MIT 或 http://opensource.org/licenses/MIT)
。
贡献
我们是一个欢迎任何人贡献的社区项目。如果您有兴趣帮忙,您可以通过GitHub或gitter
联系我们。
除非您明确表示,否则根据Apache-2.0许可证定义的任何有意提交以包含在作品中的贡献,都应如上所述双重许可,不附加任何额外条款或条件。
依赖关系
~4.5MB
~92K SLoC