Example #1
0
        internal Entity(Guid id, [NotNull] EntityManager manager, Guid factionOwner, IEnumerable <BaseDataBlob> dataBlobs = null)
        {
            Manager      = manager;
            Guid         = id;
            FactionOwner = factionOwner;
            //This is problematic, currently, if a datablob references it's own entity (ie namedb in faction entity) the entity will get a new guid.
            //and (presumably) the db will point to an empty entity.
            //TODO: should we throw an exception instead of just replacing the guid with a new one? I'm leaning towards yes.
            while (Guid == Guid.Empty || manager.EntityExistsGlobaly(Guid)) //using a while here removes the infintisimal chance of creating a guid that already exsists.
            {
                Guid = Guid.NewGuid();
            }

            Manager.SetupEntity(this, dataBlobs);

            /* Moved this to Manager.SetupEntity
             * _protectedDataBlobMask_ = Manager.EntityMasks[ID];
             *
             *
             * if (dataBlobs == null)
             * {
             *  return;
             * }
             *
             * foreach (BaseDataBlob dataBlob in dataBlobs)
             * {
             *  if (dataBlob != null)
             *  {
             *      SetDataBlob(dataBlob);
             *  }
             * }
             */
        }