1
0
forked from 0ad/0ad

Fix foundation and corpses phenotypes being different than the source entity.

Reported by: @wowgetoffyourcellphone
This was SVN commit r25832.
This commit is contained in:
Stan 2021-07-20 22:04:19 +00:00
parent c6a9e7188e
commit 2bda444435
3 changed files with 34 additions and 0 deletions

View File

@ -343,6 +343,19 @@ Foundation.prototype.Build = function(builderEnt, work)
if (cmpVisual && cmpBuildingVisual)
cmpBuildingVisual.SetActorSeed(cmpVisual.GetActorSeed());
const cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity);
const cmpBuildingIdentity = Engine.QueryInterface(building, IID_Identity);
if (cmpIdentity && cmpBuildingIdentity)
{
const oldPhenotype = cmpIdentity.GetPhenotype();
if (cmpBuildingIdentity.GetPhenotype() !== oldPhenotype)
{
cmpBuildingIdentity.SetPhenotype(oldPhenotype);
if (cmpVisualCorpse)
cmpVisualCorpse.RecomputeActorName();
}
}
if (cmpPlayerStatisticsTracker)
cmpPlayerStatisticsTracker.IncreaseConstructedBuildingsCounter(building);

View File

@ -378,6 +378,22 @@ Health.prototype.CreateCorpse = function()
cmpVisualCorpse.SelectAnimation("death", true, 1);
}
const cmpIdentityCorpse = Engine.QueryInterface(entCorpse, IID_Identity);
if (cmpIdentityCorpse)
{
const cmpIdentity = Engine.QueryInterface(this.entity, IID_Identity);
if (cmpIdentity)
{
const oldPhenotype = cmpIdentity.GetPhenotype();
if (cmpIdentityCorpse.GetPhenotype() !== oldPhenotype)
{
cmpIdentityCorpse.SetPhenotype(oldPhenotype);
if (cmpVisualCorpse)
cmpVisualCorpse.RecomputeActorName();
}
}
}
if (resource)
Engine.PostMessage(this.entity, MT_EntityRenamed, {
"entity": this.entity,

View File

@ -201,6 +201,11 @@ Identity.prototype.SetControllable = function(controllability)
this.controllable = controllability;
};
Identity.prototype.SetPhenotype = function(phenotype)
{
this.phenotype = phenotype;
};
function IdentityMirage() {}
IdentityMirage.prototype.Init = function(cmpIdentity)
{