Beispiel #1
0
        /// <summary>
        /// This operation deletes all the entities that were created by means of the "create" operations on the <see cref="Publisher" />. That is, it deletes
        /// all contained <see cref="DataWriter" /> objects.
        /// </summary>
        /// <remarks>
        /// <para>The operation will return <see cref="ReturnCode.PreconditionNotMet" /> if the any of the contained entities is in a state where it cannot be deleted.</para>
        /// <para>Once DeleteContainedEntities returns successfully, the application may delete the <see cref="Publisher" /> knowing that it has no
        /// contained <see cref="DataWriter" /> objects.</para>
        /// </remarks>
        /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
        public ReturnCode DeleteContainedEntities()
        {
            ReturnCode ret = UnsafeNativeMethods.DeleteContainedEntities(_native);

            if (ret == ReturnCode.Ok)
            {
                foreach (Entity e in ContainedEntities)
                {
                    EntityManager.Instance.Remove(e.ToNative());
                }

                ContainedEntities.Clear();
            }

            return(ret);
        }
Beispiel #2
0
        private void UnpackListing(IncomingEntityComponentMessage msg)
        {
            MaxSlots = (int)msg.MessageParameters[1];

            ContainedEntities.Clear();

            for (int i = 0; i < (int)msg.MessageParameters[2]; i++)
            {
                int    msgPos = 3 + i;
                Entity entity = Owner.EntityManager.GetEntity((int)msg.MessageParameters[msgPos]);
                if (entity != null)
                {
                    ContainedEntities.Add(entity);
                }
            }

            if (Changed != null)
            {
                Changed(this, MaxSlots, ContainedEntities);
            }
        }