PDA

View Full Version : Entities not recognizing name changed



BigBMan
10-23-2011, 02:04 AM
Heya Seth,

I noticed that of you explicitly set the "name" variant of an Entity, it doesn't change the cached variable (m_name).

This will fix the problem.



void Entity::OneTimeInit()
{
m_pPosVarCache = NULL;
m_pAlignment = NULL;
m_pSizeCache = NULL;
m_recursiveFilterReferences = 0;
m_bTaggedForDeletion = false;
m_pParent = NULL;

GetVar("name")->GetSigOnChanged()->connect(boost::bind(&Entity::OnNameChanged, this, _1));


GetFunction("OnDelete")->sig_function.connect(1, boost::bind(&Entity::OnDelete, this, _1));
}

void Entity::OnNameChanged(Variant* v)
{
m_name = v->GetString();
}

Seth
10-23-2011, 03:10 AM
This is by design - m_name is not a variant, just a standard string settable with SetName(). If someone uses a DB variant of "name", they can safely assume it is for their own use and not connected to an entity name or anything else.

That said, I guess it could make sense to have it be a variant instead, to make it easy to schedule name changes. I've never had a need to do that before though. Would that help with something you are doing?

BigBMan
10-23-2011, 08:03 AM
Ahhh, makes sense.

I'm working on a set of functions that will allow you to load your Entity/Component layouts via XML (to be shared soon!). Using a Variant makes my parsing functions a little cleaner, but it's really not that big of a deal either way.