Opened 12 years ago

Closed 12 years ago

#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: Patch:

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.

Change History (3)

comment:1 by historic_bruno, 12 years ago

Relevant discussion here starting around 22:00.

comment:2 by Kieran P, 12 years ago

Milestone: Alpha 11Alpha 12

comment:3 by ben, 12 years ago

Owner: set to ben
Resolution: fixed
Status: newclosed

In 12698:

Adds TechnologyModification message for newly created entities, so they are notified of previously researched techs (this will streamline implementation of certain techs). Fixes #1410

Note: See TracTickets for help on using tickets.