UpdateColor()
{
// warn("UpdateColor");
// let cmpFoundationOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
// let owner = cmpFoundationOwnership.GetOwner();
// if (cmpFoundationOwnership)
// {
// cmpFoundationOwnership.SetOwner(owner);
// }
// warn("Entity : " + this.entity + "Owner : " + owner)
// var owner = Engine.QueryInterface(this.entity, IID_Ownership).GetOwner();
const cmpPlayer = QueryOwnerInterface(this.entity, IID_Player);
let owner = Engine.QueryInterface(this.entity, IID_Ownership).GetOwner();
warn("Entity : " + this.entity + "Owner : " + owner);
let cmpVisual = Engine.QueryInterface(this.entity, IID_Visual);
if (!cmpVisual)
return;
if (cmpPlayer)
{
const color = cmpPlayer.GetColor();
cmpVisual.SetVariable("colorr", color.r);
cmpVisual.SetVariable("colorg", color.g);
cmpVisual.SetVariable("colorb", color.b);
}
// warn("red : "+color.r);
// warn("green : "+color.g);
// warn("blue : "+color.b);
}
I think it doesn't get the good color untli the building is finally constructed, so that's why it applies the gaia color. But how to collect the owner of a building before its construction ?
Something that I don't understand is that I call all the messages during the construction, it should be good but it's not