Exemple #1
0
        /// <summary>
        ///     Allocates an entity and loads components but does not do initialization.
        /// </summary>
        private protected Entity CreateEntity(string prototypeName, EntityUid?uid = null)
        {
            if (prototypeName == null)
            {
                return(AllocEntity(uid));
            }

            var entity = AllocEntity(prototypeName, uid);

            EntityPrototype.LoadEntity(entity.Prototype, entity, ComponentFactory, null);
            return(entity);
        }
Exemple #2
0
        /// <summary>
        ///     Allocates an entity and loads components but does not do initialization.
        /// </summary>
        private protected Entity CreateEntity(string prototypeName, EntityUid?uid = null)
        {
            if (prototypeName == null)
            {
                return(AllocEntity(uid));
            }

            var entity = AllocEntity(prototypeName, uid);

            try
            {
                EntityPrototype.LoadEntity(entity.Prototype, entity, ComponentFactory, null);
                return(entity);
            }
            catch (Exception e)
            {
                // Exception during entity loading.
                // Need to delete the entity to avoid corrupt state causing crashes later.
                DeleteEntity(entity);
                throw new EntityCreationException("Exception inside CreateEntity", e);
            }
        }
Exemple #3
0
 private protected void LoadEntity(Entity entity, IEntityLoadContext context)
 {
     EntityPrototype.LoadEntity(entity.Prototype, entity, ComponentFactory, context);
 }