Ticket #1410 (closed enhancement: fixed)
Improve technology manager event passing
| Reported by: | historic_bruno | Owned by: | ben |
|---|---|---|---|
| Priority: | Must Have | Milestone: | Alpha 12 |
| Component: | UI & Simulation | Keywords: | |
| Cc: |
Description
The current tech manager uses a mix of one-time events and polling. We mostly use polling, which is adequate for some but not all planned techs (see TechnologyManager.ApplyModifications). There is some overhead involved in the polling: an entity component needs to find its owner ID, find the associated player entity, then query the tech manager. So an event might be better for frequently accessed data.
The main problem is components that need complex behavior in response to techs. Health needs to allow increasing the max hitpoints for an entity yet maintain its current health level as a percentage (imagine a unit at 50/100 HP; after a +50 max HP tech, it should become 75/150 HP). But an entity can change ownership, in fact every entity starts without an owner (thus no research), and techs are player-specific. A single event at time of research is inadequate for these cases.
Instead, the tech manager should be modified to send a message not only when a tech is first researched but also when ownership of an entity changes. This will simplify the logic in other components as they will only handle a single message to update their cached state (rather than both polling and handling messages). Some non-trivial redesign of the manager and its caching may be required to achieve this.

Relevant discussion here starting around 22:00.