Don't set animation for production with UnitAi

Entities with a production queue when queueing or unqueueing items for
will set an appropriate animation which is desired for structures, like
the forge producing smoke, but not so for units as it interferes with
UnitAi animation state.

Units don't have animations for training or researching so the idle
animation will be set in that case instead. If such a unit is in motion
this results in the unit gliding. To avoid this just skip setting an
animation for entities having a UnitAI.

Reported-by: wowgetoffyourcellphone
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser 2025-08-28 09:36:19 +02:00
parent ef007b9e5a
commit 0baafb5375
No known key found for this signature in database
2 changed files with 6 additions and 0 deletions

View file

@ -369,6 +369,11 @@ ProductionQueue.prototype.RemoveItem = function(id)
ProductionQueue.prototype.SetAnimation = function(name)
{
// In case the entity has a UnitAI discard the attempted change of
// animation as it would interfere with animation logic in UnitAI.
if (Engine.QueryInterface(this.entity, IID_UnitAI))
return;
const cmpVisual = Engine.QueryInterface(this.entity, IID_Visual);
if (cmpVisual)
cmpVisual.SelectAnimation(name, false, 1);

View file

@ -3,6 +3,7 @@ Engine.LoadComponentScript("interfaces/ProductionQueue.js");
Engine.LoadComponentScript("interfaces/Researcher.js");
Engine.LoadComponentScript("interfaces/Timer.js");
Engine.LoadComponentScript("interfaces/Trainer.js");
Engine.LoadComponentScript("interfaces/UnitAI.js");
Engine.LoadComponentScript("interfaces/Upgrade.js");
Engine.LoadComponentScript("Timer.js");