Revision as of 10:51, 5 October 2024 by Librae (talk | contribs) (Created page with "If something needs a unit (like distance, speed, resource amount), take a smallest amount that can be considered useful in gameplay, and make it 1 unit. If unit is produced from other units, make it relative to 1 other units. Resulting unit should still be divisible to microunits (1e-6). When using Units struct, this is how a unit works by default. Maximum possible amount of a unit stored in a variable then is ~9 trillion (i64 max being 9e18, 1e6 for microunits, 9e12 le...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Development:Unit

From librae wiki

If something needs a unit (like distance, speed, resource amount), take a smallest amount that can be considered useful in gameplay, and make it 1 unit. If unit is produced from other units, make it relative to 1 other units.

Resulting unit should still be divisible to microunits (1e-6). When using Units struct, this is how a unit works by default. Maximum possible amount of a unit stored in a variable then is ~9 trillion (i64 max being 9e18, 1e6 for microunits, 9e12 left).

The amounts should be stored in special template type rustorion::units::Unit.

Various relations between units (e.g. EC produced by 1 mil humans) should be stored as Ratio (rational 128bit number) until calculated down to final amount of units, which should be stored.