Ejemplo n.º 1
0
        public void AddEntity(EntityShotBase entity, out ShotModelData data)
        {
            if (!IsUpdated)
            {
                Update();
            }

            int hash = GetPropertyHashCode(entity.Property, entity.Parent);

            ShotGroup group = null;

            if (ReusableGroupDict.ContainsKey(hash))
            {
                var groupList = ReusableGroupDict[hash];

                group = groupList.FirstOrDefault();

                if (groupList.Count == 1)
                {
                    ReusableGroupDict.Remove(hash);
                }
                else
                {
                    groupList.RemoveAt(0);
                }
            }
            group = group ?? new ShotGroup(entity);

            group.SetEntity(entity);
            data = group.Data;

            GroupList.Add(group);
        }
Ejemplo n.º 2
0
        public void Update()
        {
            GroupList.RemoveWhere(g =>
            {
                if (g.IsReusable)
                {
                    int hash = GetPropertyHashCode(g.Data.Property, g.ParentEntity);

                    if (!ReusableGroupDict.ContainsKey(hash))
                    {
                        ReusableGroupDict[hash] = new List <ShotGroup>();
                    }
                    ReusableGroupDict[hash].Add(g);
                }
                return(g.IsReusable);
            });
            IsUpdated = true;
        }