示例#1
0
        public Entity Update(Spread <EntityComponent> components)
        {
            // Quick change check
            if (components != this.components)
            {
                this.components = components;
            }
            else
            {
                return(entity);
            }

            // Synchronize our entity links
            var @array = components._array;

            for (int i = 0; i < array.Length; i++)
            {
                var link = links.ElementAtOrDefault(i);
                if (link == null)
                {
                    link = new ComponentLink(entity);
                    links.Add(link);
                }
                link.Component = array[i];
            }
            for (int i = links.Count - 1; i >= array.Length; i--)
            {
                var link = links[i];
                link.Dispose();
                links.RemoveAt(i);
            }

            return(entity);
        }