game.environment.villager_happiness
Manages the happiness level of the villagers.
Classes
Calculates and tracks the average happiness of island villagers. |
Module Contents
- class game.environment.villager_happiness.VillagerHappinessSystem(isometric_map, entity_manager, degradation_system)[source]
Calculates and tracks the average happiness of island villagers.
Happiness is composed of three parts:
Food happiness — rises with pig count up to an ideal range, then falls off as the population grows too large.
Environment happiness — average of ecosystem health (inverse of overall degradation) and current forest coverage.
Feast bonus — a temporary boost granted when an emergency feast reduces an over-populated pig herd; decays smoothly over time.
The two base components are recalculated once per second to avoid per-frame overhead. The feast bonus is updated every frame for smooth visual decay.
- register_feast(pigs_slaughtered)[source]
Register that an emergency feast has taken place.
If the pig count before the feast exceeded
HAPPINESS_IDEAL_PIG_MAX(i.e. the feast actually relieved overpopulation pressure), a one-offfeast_happiness_bonusof 0.5 is granted. The bonus then decays each frame viaupdate().- Parameters:
pigs_slaughtered (int) – Number of pigs removed by the feast. Added back to the current count to reconstruct the pre-feast population for the threshold check.