public void Execute(List <Entity <IUIPool> > entities) { foreach (var entity in entities) { var id = entity.Get <Element>().Id; var methods = entity.Get <LuaLooperMethods>(); var collection = _lua.ToTable(methods.GetCollection()); var keys = collection.GetKeys <int>(); var count = keys.Count(); var item = entity.GetAttribute <LoopItem, string>(); var children = _uipool.GetChildren(id); var childCount = children.Count; if (childCount < count) { for (var i = 0; i < count - childCount; i++) { var child = _uipool.CreateChild(id); child.Add <XmlElement>(xml => { xml.Name = item; xml.Attributes = new Dictionary <string, string>(); xml.Content = string.Empty; }) .Add <Scope>(s => s.Id = child.Get <Element>().Id); } } entity.Toggle <LuaScopeStateUpdate>(false); entity.SetAttribute <LooperCollection, ILuaTable>(collection); } }
public void Execute(List <Entity <IUIPool> > entities) { foreach (var entity in entities) { Debug.Log("Inject looper"); var id = entity.Get <Element>().Id; var children = _uipool.GetChildren(id).ToArray(); var collection = entity.GetAttribute <LooperCollection, ILuaTable>(); var keys = collection.GetKeys <int>().ToArray(); var collectionCount = keys.Length; var injection = entity.Get <LuaLooperMethods>().GetItterationProperties; var index = 0; foreach (var child in children) { if (index < collectionCount) { var props = injection(new ElementTable(child, _uipool), keys[index++]); child.SetAttribute <LuaScopeProps, ILuaTable>(_lua.ToTable(props)); //child.Toggle<LuaScopeStateUpdate>(true); } else { child.Toggle <Destroy>(true); } } } }
private void InjectFrom(Entity <IUIPool> embed) { var cycle = embed.Get <LuaLifeCycle>(); var props = cycle.PropertyInjection(); var table = _lua.ToTable(props); embed.SetAttribute <LuaScopeProps, ILuaTable>(table); embed.Toggle <LuaScopeStateUpdate>(false); }