Shinigami 是面向 Starknet 上 Autonomous Worlds 全链游戏设计的架构,采用分层模块化方式,共 9 层:Types、Elements、Models、Components、Systems、Helpers、Store、Events、Interfaces。其依赖方向为:Systems(Dojo 合约入口)embed 调用 Components(Starknet 组件、编排),Components use 调用 Store(集中数据访问),Store read/write 读写 Models(持久化链上状态);Types(枚举)分发到 Elements(trait 实现);Helpers 为无状态工具,跨层使用;Events 为带工厂 trait 的 Dojo 事件;Interfaces 为外部合约 ABI。
模块结构位于 contracts/src/,包含 lib.cairo、store.cairo、constants.cairo,以及 types、elements、models、components、systems、helpers、events、interfaces 目录。Elements 按类别实现 trait:Powers 8 个、Traps 6 个、Achievements 6 个、Tasks 7 个、Quests 4 个;Models 定义 #[dojo::model] 结构体并提供 GameTrait(38 个方法)、ConfigTrait 等;Components 含 PlayableComponent 等编排逻辑;Systems 如 Play、Setup、Vault 等为薄入口封装;Helpers 含 random、packer、bitmap、deck、heap、verifier、rewarder、power 等。
使用方式上,模型访问应统一通过 Store(如 StoreImpl::new(world)),不要直接调用 world.read_model();元素方法标注 #[inline],Powers/Traps 通过 ref game 修改状态,Achievements/Tasks/Quests 返回元数据;Systems 先定义 #[starknet::interface] trait,用 component!() 嵌入组件并委派逻辑。限制:资料未提供安装命令、收费、价格、平台与效果等信息。