youvsvirus / youvsvirus-unity

Unity version of the you vs virus game.
GNU General Public License v3.0
1 stars 1 forks source link

Sandbox sometimes ends early #128

Closed holke closed 4 years ago

holke commented 4 years ago

The sandbox mode sometimes ends early bc the endlevelcontroler does not see any infected humans at the beginning.

holke commented 4 years ago

I think this is the reason:

Sometimes the Start() Routine of HumanBase is called before the Start() routine of HumanInstants. This is due to the fact, that the order in which the Start() routines are called is undefined.

When an NPC starts as infected, this is set by SetInitialCondition in HumanInstants::CreateHumans which is called during Start.

This initial infected NPC is only passed on to the EndLevelController in the NPCs Start() routine at

SetCondition(_initialCondition);

but, if the NPCs Start() routine was already executed before its InitialCondition was set by the HumanBase start, then this Info does not get passed on to the EndLevelController. And thus, the ELC thinks that there are 0 infected NPCs and hence wants to finish the game.

This also causes the ELC to think that there are less infected humans then actually are.

maccxs commented 4 years ago

I made a quick fix in commit 123c8ace248e25ab9aeaeb24482bf28b7d7f413c. This is not the cleanest way but it seems to work for me. Please try.

holke commented 4 years ago

I could not recreate the bug so I think you resolved it.