Module entity_generic

Module entity_generic 

Source
Expand description

§Guide

The entity command manipulates the lists of game objects that live inside an epoch.
An epoch is a snapshot of the game state that can be written to disk or rolled back to an earlier one.
Every entity type (character, town, event, …) has the same set of operations:

§Summary

Sub‑commandUsageWhat it changes
add<entity> add [OPTIONS] [IDENTIFIER]Creates a new <entity>, pushes it to the epoch’s list, and writes the epoch.
del<entity> del <IDENTIFIER>Removes the matching <entity> from the list and writes the epoch.
edit<entity> edit <IDENTIFIER> [OPTIONS]Modifies the stats/position/duration/effect/bounds of the chosen <entity> and writes the epoch.
find<entity> find <IDENTIFIER>Prints full details of a single <entity>.
show<entity> show [<IDENTIFIER>]Lists all entities on one line, or shows one <entity> in full detail.
diff<entity> diff <IDENTIFIER>Prints the difference between the current and previous epoch for that <entity>.

IDENTIFIER is either a name or a @tag (@1234).
If omitted, a random name is generated for the type you are working on.

§Options

FlagDescription
-d, --deltaApply a delta to the supplied stats (add or subtract) instead of overwriting them.
-v, --verbose…Increase output verbosity.
--rng <RNG>How to fill unspecified stats.
Possible values: zero, low, med, high, legendary, mixed, flawed. Default: zero.
--pos-exact <POS> / --pos <POS>Place the new entity at a specific x,y coordinate (the epoch must be in a map context).
--duration <DURATION>Lifespan of the entity (e.g. Permanent, Temporary, Duration(1) for a one‑turn event).
--bounds <BOUNDS>Effect limits, given as min,max (e.g. 10,80).
--effect <EFFECT>How the effect is applied:
recurring, when-present, permanent-effect-to-apply, permanent-effect-applied.
-s, --stats <STATS>One or more key:value pairs, e.g. fod,10 military:8.

§Usage

All the following example use chr as a choice of entity but can be safely substitued to any entity: event, town, blocker etc…

# Create a character named “Aria”
chr add Aria \
  --stats fod:10 mil:8 \
  --rng mixed

# Edit that character: bump military, shorten duration
chr edit Aria \
  --stats mil:5 \
  --duration Duration:5

# Show all characters
chr show

# Show one character in detail
chr show Aria

# Delete a character
chr del Aria

# Diff a character between two epochs
chr diff Aria

Tip<entity> diff automatically loads the current epoch and the previous one, so you don’t need to specify epoch numbers.

All changes are persisted immediately to the epoch file after the command finishes.

Structs§

EntityArgs
Arguments required for any entity operation.

Enums§

EntitySubCommands
Commands that operate on an entity.

Functions§

find_by_args 🔒
Helper function finding by name, note that a lot more helpers could be done to find by other criterias
find_by_id 🔒
Find an entity matching a tag
find_by_name 🔒
Find an entity matching a name
find_entity 🔒
Looks up an entity inside the given epoch_info according to the supplied arguments.
handle_create_entity 🔒
Function handler for the create subcommand
handle_delete_entity 🔒
Function handler for the delete subcommand
handle_diff_entity 🔒
Function handler for the diff subcommand
handle_edit_entity 🔒
Function handler for the edit subcommand
handle_entity_commands
Handles an entity subcommand.
handle_find_entity 🔒
Function handler for the find subcommand
handle_show_entity 🔒
Function handler for the show subcommand
update_defaults 🔒
Update the default values of the entity with sensible defaults
update_stats 🔒
Update the given stats with the given argumenbts Note that this function will not change name & id due to the usage variance between caller
vec_entities 🔒
Returns a slice over the entities of the requested type from the given EpochInfo.
vec_entities_mut 🔒
Returns a mutable slice over the entities of the requested type from the given EpochInfo.