Exemplo n.º 1
0
        // Update variable timestep logic
        void HandleSceneUpdate(SceneUpdateEvent e)
        {            
            // Handle Start
            if (cscomponentStart.Count > 0)
            {
                var started = new List<CSComponent>();

                foreach (var csc in cscomponentStart.ToList())
                {
                    if (!csc.IsEnabled())
                    {
                        continue;
                    }

                    // mark as started whether or not a Start method exists
                    csc.started = true;
                    started.Add(csc);

                    CSComponentInfo info;
                    if (CSComponentCore.csinfoLookup.TryGetValue(csc.GetType(), out info))
                    {
                        if (info.StartMethod != null)
                        {
                            info.StartMethod.Invoke(csc, null);
                        }
                    }

                }

                foreach (var csc in started)
                {
                    cscomponentStart.Remove(csc);
                }
            }

            // Handle Scene Update

            Object[] args = new Object[1] { e.TimeStep };

            foreach (var item in cscomponents.ToList())
            {
                var info = item.Key;

                var UpdateMethod = info.UpdateMethod;

                if (UpdateMethod == null)
                    continue;

                foreach (var csc in item.Value.ToList())
                {
                    if (!csc.Started || !csc.IsEnabled())
                        continue;

                    UpdateMethod.Invoke(csc, args);
                }
                
            }

        }
Exemplo n.º 2
0
        // Update variable timestep logic
        void HandleSceneUpdate(SceneUpdateEvent e)
        {
            // Handle Start
            if (cscomponentStart.Count > 0)
            {
                var started = new List <CSComponent>();

                foreach (var csc in cscomponentStart.ToList())
                {
                    if (!csc.IsEnabled())
                    {
                        continue;
                    }

                    // mark as started whether or not a Start method exists
                    csc.started = true;
                    started.Add(csc);

                    CSComponentInfo info;
                    if (CSComponentCore.csinfoLookup.TryGetValue(csc.GetType(), out info))
                    {
                        if (info.StartMethod != null)
                        {
                            info.StartMethod.Invoke(csc, null);
                        }
                    }
                }

                foreach (var csc in started)
                {
                    cscomponentStart.Remove(csc);
                }
            }

            // Handle Scene Update

            Object[] args = new Object[1] {
                e.TimeStep
            };

            foreach (var item in cscomponents.ToList())
            {
                var info = item.Key;

                var UpdateMethod = info.UpdateMethod;

                if (UpdateMethod == null)
                {
                    continue;
                }

                foreach (var csc in item.Value.ToList())
                {
                    if (!csc.Started || !csc.IsEnabled())
                    {
                        continue;
                    }

                    UpdateMethod.Invoke(csc, args);
                }
            }
        }