Beispiel #1
0
 public void Execute(List <Entity <IUIPool> > entities)
 {
     foreach (var entity in entities)
     {
         var scope = _uipool.GetScope(entity.Get <Scope>().Id);
         var local = _lua.CreateContext();
         local.Set("self", new ElementTable(entity, _uipool));
         local.Set("scope", new ScopeTable(scope, _uipool));
         entity.SetAttribute <LuaElementContext, ILuaTable>(local);
     }
 }
Beispiel #2
0
        public void Execute(List <Entity <IUIPool> > entities)
        {
            foreach (var scopeEntity in entities)
            {
                ILuaTable props   = null;
                ILuaTable state   = _lua.NewTable();
                ILuaTable context = _lua.CreateContext();

                if (scopeEntity.Has <Parent>())
                {
                    // Child scope (embeded) - requesting props is required!
                    var parent = _uiPool.GetParent(scopeEntity);
                    props = parent.Has <LuaScopeProps>()
                        ? parent.GetAttribute <LuaScopeProps, ILuaTable>()
                        : _lua.NewTable();
                }
                else if (scopeEntity.Has <LuaScopeProps>())
                {
                    props = scopeEntity.GetAttribute <LuaScopeProps, ILuaTable>();
                }
                else
                {
                    // Root scope must create clean props table
                    props = _lua.NewTable();
                }

                props.Set("Test", (Action)(() => Debug.Log("test")));

                context.Set("state", state);
                context.Set("props", props);
                context.Set("scope", new ScopeTable(scopeEntity, _uiPool));

                scopeEntity.SetAttribute <LuaScopeProps, ILuaTable>(props);
                scopeEntity.SetAttribute <LuaScopeState, ILuaTable>(state);
                scopeEntity.SetAttribute <LuaScopeContext, ILuaTable>(context);
            }
        }