Skip to main content

Crate rakata_generics

Crate rakata_generics 

Source
Expand description

Typed views over the game’s blueprint and template resources.

KotOR stores most of its non-asset content in GFF, a generic labelled-tree container. The files in this crate are the formats built on it: creatures, doors, items, placeables, triggers, waypoints, sounds, merchants, areas, dialogue, factions and module info. A typed view reads one of those trees and presents its contents as named Rust fields, so a caller works with creature.hp rather than looking up the label HitPoints and unwrapping a GffValue.

§A typed view is a projection, not a copy

A typed view models a field only where the engine reads it at that path. Fields the engine never looks at are deliberately absent, even when vanilla files carry them. The consequence is the thing to know before choosing between this crate and the raw container:

from_gff followed by to_gff does not round-trip byte for byte. Anything the view does not model is dropped, because the view has nowhere to keep it. Carrying unmodelled data along silently would make the view a worse answer to the question it exists for.

So pick by what the job needs. Reading or editing engine-meaningful fields, which is validation, inspection and most editing, is what these types are for. Preserving a file exactly, which is byte-faithful round-tripping and diffing against an original, means holding the Gff tree and editing that.

§author_, not write_

Every other format in the tree pairs read_x_from_bytes with write_x_to_vec, and that pair reads as a promise: what came out goes back in. These functions cannot keep it, for the reason above. So they are spelled author_ and the shape is otherwise unchanged, <W: Write> sibling included.

§Clone discipline in to_gff() methods

Serialization methods take &self and hand owned data to GffValue variants, which store an owned String, GffLocalizedString or Vec<_>. &self cannot move fields out, so the clone is unavoidable. Uniform across every typed view here, and not flagged per-clone.

Re-exports§

pub use are::author_are;
pub use are::author_are_to_vec;
pub use are::read_are;
pub use are::read_are_from_bytes;
pub use are::Are;
pub use are::AreError;
pub use are::AreMap;
pub use are::AreMiniGame;
pub use are::AreMiniGameBullet;
pub use are::AreMiniGameEnemy;
pub use are::AreMiniGameGunBank;
pub use are::AreMiniGameModel;
pub use are::AreMiniGameMouse;
pub use are::AreMiniGameObjectScripts;
pub use are::AreMiniGameObstacle;
pub use are::AreMiniGamePlayer;
pub use are::AreMiniGameSounds;
pub use are::AreMiniGameTargeting;
pub use are::AreMiniGameVehicle;
pub use are::AreMiniGameVehicleScripts;
pub use are::AreRoom;
pub use are::BANK_ID_NONE;
pub use dlg::author_dlg;
pub use dlg::author_dlg_to_vec;
pub use dlg::read_dlg;
pub use dlg::read_dlg_from_bytes;
pub use dlg::Dlg;
pub use dlg::DlgAnimation;
pub use dlg::DlgError;
pub use dlg::DlgNode;
pub use dlg::DlgStunt;
pub use fac::author_fac;
pub use fac::author_fac_to_vec;
pub use fac::read_fac;
pub use fac::read_fac_from_bytes;
pub use fac::Fac;
pub use fac::FacError;
pub use fac::FacFaction;
pub use fac::FacReaction;
pub use fac::FacReputation;
pub use git::author_git;
pub use git::author_git_to_vec;
pub use git::blocks::LockState;
pub use git::blocks::Placement;
pub use git::blocks::SavingThrows;
pub use git::blocks::DoorPortraitLabels;
pub use git::blocks::SavedPortrait;
pub use git::blocks::SavedPortraitLabels;
pub use git::creature::SavedClass;
pub use git::creature::SavedCreature;
pub use git::door::SavedDoor;
pub use git::item::SavedItem;
pub use git::placeable::SavedPlaceable;
pub use git::read_git;
pub use git::read_git_from_bytes;
pub use git::sound::SavedSound;
pub use git::store::SavedStore;
pub use git::trigger::SavedTrigger;
pub use git::Git;
pub use git::GitAreaEffect;
pub use git::GitAreaEffectShape;
pub use git::GitAreaProperties;
pub use git::GitCamera;
pub use git::GitCreature;
pub use git::GitCreatures;
pub use git::GitDoor;
pub use git::GitEncounter;
pub use git::GitEncounterPoint;
pub use git::GitError;
pub use git::GitItem;
pub use git::GitMapNote;
pub use git::GitObjects;
pub use git::GitPlaceable;
pub use git::GitSound;
pub use git::GitSpawnPoint;
pub use git::GitStore;
pub use git::GitTrigger;
pub use git::GitWaypoint;
pub use ifo::author_ifo;
pub use ifo::author_ifo_to_vec;
pub use ifo::read_ifo;
pub use ifo::read_ifo_from_bytes;
pub use ifo::Ifo;
pub use ifo::IfoArea;
pub use ifo::IfoCutScene;
pub use ifo::IfoError;
pub use ifo::IfoExpansion;
pub use ifo::IfoPlayer;
pub use ifo::IfoToken;
pub use shared::ObjectId;
pub use utc::author_utc;
pub use utc::author_utc_to_vec;
pub use utc::read_utc;
pub use utc::read_utc_from_bytes;
pub use utc::Utc;
pub use utc::UtcClass;
pub use utc::UtcError;
pub use utc::UtcSkills;
pub use utd::author_utd;
pub use utd::author_utd_to_vec;
pub use utd::read_utd;
pub use utd::read_utd_from_bytes;
pub use utd::Utd;
pub use utd::UtdError;
pub use ute::author_ute;
pub use ute::author_ute_to_vec;
pub use ute::read_ute;
pub use ute::read_ute_from_bytes;
pub use ute::Ute;
pub use ute::UteAreaEntry;
pub use ute::UteCreature;
pub use ute::UteError;
pub use ute::UteGeometryVertex;
pub use ute::UteSpawnEntry;
pub use ute::UteSpawnPoint;
pub use uti::author_uti;
pub use uti::author_uti_to_vec;
pub use uti::read_uti;
pub use uti::read_uti_from_bytes;
pub use uti::Uti;
pub use uti::UtiError;
pub use uti::UtiProperty;
pub use utm::author_utm;
pub use utm::author_utm_to_vec;
pub use utm::read_utm;
pub use utm::read_utm_from_bytes;
pub use utm::Utm;
pub use utm::UtmError;
pub use utm::UtmInventoryItem;
pub use utp::author_utp;
pub use utp::author_utp_to_vec;
pub use utp::read_utp;
pub use utp::read_utp_from_bytes;
pub use utp::Utp;
pub use utp::UtpError;
pub use utp::UtpInventoryItem;
pub use uts::author_uts;
pub use uts::author_uts_to_vec;
pub use uts::read_uts;
pub use uts::read_uts_from_bytes;
pub use uts::Uts;
pub use uts::UtsError;
pub use uts::UtsSound;
pub use utt::author_utt;
pub use utt::author_utt_to_vec;
pub use utt::read_utt;
pub use utt::read_utt_from_bytes;
pub use utt::Utt;
pub use utt::UttError;
pub use utw::author_utw;
pub use utw::author_utw_to_vec;
pub use utw::read_utw;
pub use utw::read_utw_from_bytes;
pub use utw::Utw;
pub use utw::UtwError;

Modules§

are
Typed ARE (.are) area environment and conversion helpers. ARE (.are) typed generic wrapper.
dlg
Typed DLG (.dlg) dialogue tree and conversion helpers. DLG (.dlg) typed generic wrapper.
fac
Typed FAC (.fac) faction table and conversion helpers. FAC (.fac) typed generic wrapper.
git
Typed GIT (.git) area instance layout and conversion helpers. GIT (.git) typed generic wrapper.
ifo
Typed IFO (.ifo) module info and conversion helpers. IFO (.ifo) typed generic wrapper.
shared
Shared typed components reused across generic wrappers. Types and engine sentinels more than one view needs.
utc
Typed UTC (.utc) creature blueprint and conversion helpers. UTC (.utc) typed generic wrapper.
utd
Typed UTD (.utd) door blueprint and conversion helpers. UTD (.utd) typed generic wrapper.
ute
Typed UTE (.ute) encounter blueprint and conversion helpers. UTE (.ute) typed generic wrapper.
uti
Typed UTI (.uti) item blueprint and conversion helpers. UTI (.uti) typed generic wrapper.
utm
Typed UTM (.utm) merchant blueprint and conversion helpers. UTM (.utm) typed generic wrapper.
utp
Typed UTP (.utp) placeable blueprint and conversion helpers. UTP (.utp) typed generic wrapper.
uts
Typed UTS (.uts) sound emitter blueprint and conversion helpers. UTS (.uts) typed generic wrapper.
utt
Typed UTT (.utt) trigger blueprint and conversion helpers. UTT (.utt) typed generic wrapper.
utw
Typed UTW (.utw) waypoint blueprint and conversion helpers. UTW (.utw) typed generic wrapper.

Functions§

schema_for
The schema of the view modelling a container, found by its magic. The schema of the view modelling file_type, in parts, or None.