Swordfish
Swordfish is a Data-Oriented Design (DOD) Logic Layer for large scale social based simulations / games. It's designed for fast query / discrete graphs processing performance and the ease of use.
Features
- Macro-driven Table Creation: Define your data tables with a simple macro.
- Efficient Data Storage: Data is stored in parallel vectors, allowing for cache-friendly iteration and operations.
- Fast Insertions: Reuses IDs from deleted entries to minimize memory reallocations and maintain contiguous data.
- Easily Querying: Iterate over your table data easily with
query!andquery_mut!macros, providing direct access to fields.
Installation
Add the following to your Cargo.toml file:
[]
= "0.9.0" # Or the latest version
Usage
Use the create_table! macro to define your archetype.
use ;
create_table!;
This will generate a struct named EntityTable with fields for position_x, position_y, and health, along with management methods.
Creating a Table Instance
use ;
create_table!;
Inserting Data
Use the insert method to add new entries to your table. It returns the id of the newly inserted entry.
use ;
create_table!;
Querying Data
The query! macro allows you to iterate over your table's data, providing immutable references to the fields.
query!;
Mutating Data
The query_mut! macro is similar to query!, but it provides mutable references to the fields, allowing you to modify them within the loop.
query_mut!;
Deleting Data
You can mark entries for deletion using delete_by_id. Work safe ONLY in query_mut (or query) statement.
query_mut!;