Exemple #1
0
        /// <summary>
        /// Attempts to create a new DataRenderer instance for the given type.
        /// </summary>
        public static bool TryGetRenderer(DataAccessor dataType, out DataRenderer renderer)
        {
            int id = dataType.Id;

            if (_renderers.ContainsKey(id))
            {
                Type rendererType = _renderers[id];
                renderer = (DataRenderer)Activator.CreateInstance(rendererType);
                return(true);
            }

            renderer = null;
            return(false);
        }
        /// <summary>
        /// Returns an entity instance for the given entity UniqueId. If an instance for the given
        /// id already exists, then it is returned. Otherwise, either a RuntimeEntity or
        /// ContentEntity is created.
        /// </summary>
        /// <param name="entityId">The id of the entity to get an instance for.</param>
        /// <param name="context">The GameEngineContext, used to determine if we should create a
        /// ContentTemplate or RuntimeTemplate instance.</param>
        public IEntity GetEntityInstance(int entityId, GameEngineContext context)
        {
            if (CreatedEntities.ContainsKey(entityId))
            {
                return(CreatedEntities[entityId]);
            }

            IEntity entity;

            if (context.GameEngine.IsEmpty)
            {
                entity = new ContentEntity();
            }
            else
            {
                entity = new RuntimeEntity();
            }

            CreatedEntities[entityId] = entity;
            return(entity);
        }
Exemple #3
0
 public bool ContainsData(DataAccessor accessor)
 {
     return(_defaultDataInstances.ContainsKey(accessor.Id));
 }
Exemple #4
0
 public bool ContainsData(DataAccessor accessor)
 {
     return(_data.ContainsKey(accessor.Id));
 }
Exemple #5
0
 public bool WasRemoved(DataAccessor accessor)
 {
     return(_removedLastFrame.ContainsKey(accessor.Id));
 }
Exemple #6
0
 public bool WasAdded(DataAccessor accessor)
 {
     return(_addedLastFrame.ContainsKey(accessor.Id));
 }
Exemple #7
0
 public bool WasModified(DataAccessor accessor)
 {
     return(_modifiedLastFrame.ContainsKey(accessor.Id));
 }