Exemple #1
0
        internal void InternalInitialize()
        {
            Current = this;

            Id = 1;
            this.SetIEntity(NativeEntityMethods.GetEntity(Id));
        }
Exemple #2
0
        /// <summary>
        /// Removes the entity with the specified id.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="forceRemoveNow"></param>
        public static void Remove(EntityId id, bool forceRemoveNow = false)
        {
#if !(RELEASE && RELEASE_DISABLE_CHECKS)
            if (id == 0)
            {
                throw new ArgumentException("entityId cannot be 0!");
            }
#endif
            if (!NativeEntityMethods.GetFlags(NativeEntityMethods.GetEntity(id)).HasFlag(EntityFlags.NoSave))
            {
                throw new EntityRemovalException("Attempted to remove an entity placed via Editor");
            }

            NativeEntityMethods.RemoveEntity(id, forceRemoveNow);
        }
Exemple #3
0
        /// <summary>
        /// Get an entity by its unique ID.
        /// </summary>
        /// <param name="entityId">The ID as an unsigned integer.</param>
        /// <returns>A reference to the entity.</returns>
        /// <remarks>If the entity does not exist in the managed space, this function will attempt to find
        /// a C++ entity with the specified ID></remarks>
        public static EntityBase Get(EntityId entityId)
        {
#if !(RELEASE && RELEASE_DISABLE_CHECKS)
            if (entityId == 0)
            {
                throw new ArgumentException("entityId cannot be 0!");
            }
#endif

            var ent = Get <EntityBase>(entityId);
            if (ent != null)
            {
                return(ent);
            }

            // Couldn't find a CryMono entity, check if a non-managed one exists.
            var entPointer = NativeEntityMethods.GetEntity(entityId);
            if (entPointer != IntPtr.Zero)
            {
                return(CreateNativeEntity(entityId, entPointer));
            }

            return(null);
        }