Example #1
0
        /// <summary>
        /// Registeres a game object.
        /// </summary>
        public GameHandle <T> Register <T>(RegistrationContext <T> context) where T : IBufferedState <T>
        {
            Logger logger = GameEngine.TryQueryComponent <Logger>();

            if (context == null)
            {
                logger?.PostMessage(
                    string.Format("An atempt to register 'null' on target {0} has been made.", this.GetType().FullName),
                    LogMessageKind.Error, LogMessagePriority.Engine);
                throw new ArgumentNullException(nameof(context));
            }

            RenderContainer renderable;
            var             node = Updateables.Add(new UpdateContainer <T>(context, BufferCount, out renderable));

            if (renderable != null)
            {
                Renderables.Add(renderable);
                renderable.DepthPositionChanged += (sender, e) => sortAtNextCall = true;
                sortAtNextCall = true;
            }

            logger?.PostMessage(
                string.Format("Game handle {0} has been registered in context {1} on target {2}.",
                              typeof(GameHandle <T>).FullName, context.GetType().FullName, this.GetType().FullName),
                LogMessageKind.Information, LogMessagePriority.Engine);

            return(new GameHandle <T>(this, node, renderable));
        }
Example #2
0
        /// <summary>
        /// Registeres a resource.
        /// </summary>
        public static ResourceHandle RegisterResource(IResource resource)
        {
            string tagString = resource.Tag?.ToString() ?? string.Empty;

            PostGlobalLogMessage(string.Format("Resource {0}{1} loaded.", resource.GetType().FullName, string.IsNullOrEmpty(tagString) ? string.Empty : " with tag " + tagString),
                                 LogMessageKind.Information, LogMessagePriority.Engine);

            return(new ResourceHandle(Resources, Resources.Add(resource)));
        }