Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 public bool ContainsData(DataAccessor accessor)
 {
     return(_defaultDataInstances.ContainsKey(accessor.Id));
 }
Ejemplo n.º 4
0
 public bool ContainsData(DataAccessor accessor)
 {
     return(_data.ContainsKey(accessor.Id));
 }
Ejemplo n.º 5
0
 public bool WasRemoved(DataAccessor accessor)
 {
     return(_removedLastFrame.ContainsKey(accessor.Id));
 }
Ejemplo n.º 6
0
 public bool WasAdded(DataAccessor accessor)
 {
     return(_addedLastFrame.ContainsKey(accessor.Id));
 }
Ejemplo n.º 7
0
 public bool WasModified(DataAccessor accessor)
 {
     return(_modifiedLastFrame.ContainsKey(accessor.Id));
 }