Updates to component classes -

Shift from ghosted components to entity-managed for networking
Initial implementation of Systems through the Mesh Component
This commit is contained in:
Areloch 2018-01-28 14:57:02 -06:00
parent ae5a43de70
commit 68efd8e22a
15 changed files with 706 additions and 312 deletions

View file

@ -31,6 +31,7 @@
#include "console/engineAPI.h"
#include "sim/netConnection.h"
#include "console/consoleInternal.h"
#include "T3D/assets/MaterialAsset.h"
#define DECLARE_NATIVE_COMPONENT( ComponentType ) \
Component* staticComponentTemplate = new ComponentType; \
@ -52,7 +53,6 @@ Component::Component()
mNetworked = false;
// [tom, 1/12/2007] We manage the memory for the description since it
// could be loaded from a file and thus massive. This is accomplished with
// protected fields, but since they still call Con::getData() the field
@ -66,7 +66,7 @@ Component::Component()
mOriginatingAssetId = StringTable->EmptyString();
mNetFlags.set(Ghostable);
mIsServerObject = true;
}
Component::~Component()
@ -198,7 +198,6 @@ void Component::onComponentRemove()
{
mOwner->onComponentAdded.remove(this, &Component::componentAddedToOwner);
mOwner->onComponentRemoved.remove(this, &Component::componentRemovedFromOwner);
mOwner->onTransformSet.remove(this, &Component::ownerTransformSet);
}
mOwner = NULL;
@ -212,7 +211,6 @@ void Component::setOwner(Entity* owner)
{
mOwner->onComponentAdded.remove(this, &Component::componentAddedToOwner);
mOwner->onComponentRemoved.remove(this, &Component::componentRemovedFromOwner);
mOwner->onTransformSet.remove(this, &Component::ownerTransformSet);
mOwner->removeComponent(this, false);
}
@ -223,11 +221,18 @@ void Component::setOwner(Entity* owner)
{
mOwner->onComponentAdded.notify(this, &Component::componentAddedToOwner);
mOwner->onComponentRemoved.notify(this, &Component::componentRemovedFromOwner);
mOwner->onTransformSet.notify(this, &Component::ownerTransformSet);
}
if (isServerObject())
{
setMaskBits(OwnerMask);
//if we have any outstanding maskbits, push them along to have the network update happen on the entity
if (mDirtyMaskBits != 0 && mOwner)
{
mOwner->setMaskBits(Entity::ComponentsUpdateMask);
}
}
}
void Component::componentAddedToOwner(Component *comp)
@ -240,16 +245,19 @@ void Component::componentRemovedFromOwner(Component *comp)
return;
}
void Component::ownerTransformSet(MatrixF *mat)
void Component::setMaskBits(U32 orMask)
{
return;
AssertFatal(orMask != 0, "Invalid net mask bits set.");
if (mOwner)
mOwner->setComponentNetMask(this, orMask);
}
U32 Component::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
{
U32 retMask = Parent::packUpdate(con, mask, stream);
U32 retMask = 0;
if (mask & OwnerMask)
/*if (mask & OwnerMask)
{
if (mOwner != NULL)
{
@ -274,7 +282,7 @@ U32 Component::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
}
}
else
stream->writeFlag(false);
stream->writeFlag(false);*/
if (stream->writeFlag(mask & EnableMask))
{
@ -299,9 +307,7 @@ U32 Component::packUpdate(NetConnection *con, U32 mask, BitStream *stream)
void Component::unpackUpdate(NetConnection *con, BitStream *stream)
{
Parent::unpackUpdate(con, stream);
if (stream->readFlag())
/*if (stream->readFlag())
{
if (stream->readFlag())
{
@ -317,7 +323,7 @@ void Component::unpackUpdate(NetConnection *con, BitStream *stream)
//it's being nulled out
setOwner(NULL);
}
}
}*/
if (stream->readFlag())
{
@ -467,7 +473,7 @@ void Component::addComponentField(const char *fieldName, const char *desc, const
else if (fieldType == StringTable->insert("vector"))
fieldTypeMask = TypePoint3F;
else if (fieldType == StringTable->insert("material"))
fieldTypeMask = TypeMaterialName;
fieldTypeMask = TypeMaterialAssetPtr;
else if (fieldType == StringTable->insert("image"))
fieldTypeMask = TypeImageFilename;
else if (fieldType == StringTable->insert("shape"))
@ -488,6 +494,7 @@ void Component::addComponentField(const char *fieldName, const char *desc, const
fieldTypeMask = TypeGameObjectAssetPtr;
else
fieldTypeMask = TypeString;
field.mFieldTypeName = fieldType;
field.mFieldType = fieldTypeMask;