pmotschmann / Evolve

An incremental game about evolving a civilization
Mozilla Public License 2.0
824 stars 354 forks source link

Add setting to auto-power all new structs #1010

Closed yarukishi closed 6 months ago

yarukishi commented 9 months ago

Currently, new structures are powered on when there is spare electricity or support to enable them without disturbing other structures. This change adds a new option to always power on new structures. The default value is disabled, matching previous behavior. When the switch is enabled, new structures will always be powered on, and they will always perform associated side effects, such as reallocating workers. The subsequent fast tick of the game loop should resolve any power grid rebalancing issues and other incomplete side effects of new structures.

In order to enable this change, powerOnNewStruct() now handles both electricity and support requirements for all new structs. It is permissible for a struct to require both electricity and support. The type of support is provided by a new "s_type" property on each struct that requires support. The return value of this function has been corrected: it now returns "true" only when the new structure has been powered on.

As a matter of bookkeeping, the return value of powered() on a structure has been set to "0" for cases where electrical power is not consumed. It is possible that these occurrences of powered() could instead be replaced with switchable(), which has a more obvious side effect.