Пример #1
0
 public WorldDictionary(IWatchContext parent, string relativePath, ContextFieldInfo fieldInfo)
     : base(parent
            , relativePath
            , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(WorldDictionary)))
            )
 {
 }
Пример #2
0
 public VisitStatus VisitCollectionProperty <TProperty2, TContainer2, TValue2>(TProperty2 property, ref TContainer2 container, ref ChangeTracker changeTracker)
     where TProperty2 : ICollectionProperty <TContainer2, TValue2>
 {
     if (Result)
     {
         int count = property.GetCount(ref container);
         for (int i = 0; i != count && Result; ++i)
         {
             var getter = new MemberInfoGetter <TContainer2>();
             property.GetPropertyAtIndex(ref container, i, ref changeTracker, ref getter);
             ContextMemberInfo info;
             if (getter.Found)
             {
                 info = new ContextMemberInfo(
                     ContextFieldInfo.MakeOperator("[" + i + "]")
                     , getter.Result
                     );
             }
             else
             {
                 // Unknown type
                 info = new ContextMemberInfo(
                     ContextFieldInfo.MakeOperator("[" + i + "]")
                     , new ContextTypeInfo()
                     );
             }
             Result = Visitor(info);
         }
     }
     return(VisitStatus.Handled);
 }
Пример #3
0
 public override bool VisitAllMembers(Func <ContextMemberInfo, bool> visitor)
 {
     foreach (var e in World.EntityManager.GetAllEntities())
     {
         var info = new ContextMemberInfo(ContextFieldInfo.MakeOperator($"[{e.Index}]"), ContextTypeInfo.Make(typeof(PropertyPathContext <EntityContainer, EntityContainer>)));
         if (!visitor(info))
         {
             return(false);
         }
     }
     return(true);
 }
Пример #4
0
 VisitStatus IPropertyVisitor.VisitProperty <TProperty2, TContainer2, TValue2>(TProperty2 property, ref TContainer2 container, ref ChangeTracker changeTracker)
 {
     if (Result)
     {
         var info = new ContextMemberInfo(
             ContextFieldInfo.Make(property.GetName()),
             ContextTypeInfo.MakeProperty(property)
             );
         Result = Visitor(info);
     }
     return(VisitStatus.Handled);
 }
Пример #5
0
 public override bool TryParseIndex(string path, RangeInt cursor, out IWatchContext ctx)
 {
     if (ParserUtils.TryParseScopeSequenceRange(path, ref cursor, ParserUtils.DelemiterQuote, out var worldNameRangeIn, out var worldNameRangeOut))
     {
         string worldName = path.Substring(worldNameRangeIn);
         foreach (var w in Entities.World.All)
         {
             if (w.Name == worldName)
             {
                 ctx = new WorldContext(this, $"[\"{worldName}\"]", w, ContextFieldInfo.MakeOperator($"[\"{worldName}\"]"));
                 return(true);
             }
         }
     }
     ctx = default;
     return(false);
 }
Пример #6
0
        public override bool VisitAllMembers(Func <ContextMemberInfo, bool> visitor)
        {
            var comps = GO.GetComponents <Component>();

            for (int i = 0; i != comps.Length; ++i)
            {
                var info = new ContextMemberInfo(
                    ContextFieldInfo.MakeOperator($"[{i}]"),
                    ContextTypeInfo.Make(comps[i].GetType())
                    );
                if (!visitor(info))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #7
0
 public override bool TryParseIndex(string path, RangeInt cursor, out IWatchContext ctx)
 {
     if (ParserUtils.TryParseScopeSequenceRange(path, ref cursor, ParserUtils.DelemiterQuote, out var nameRangeIn, out var nameRangeOut))
     {
         string name = path.Substring(nameRangeIn);
         for (int i = 0; i != UnityEngine.SceneManagement.SceneManager.sceneCount; ++i)
         {
             var s = UnityEngine.SceneManagement.SceneManager.GetSceneAt(i);
             if (s.name == name)
             {
                 ctx = new SceneContext(this, $"[\"{name}\"]", s, ContextFieldInfo.MakeOperator($"[\"{name}\"]"));
                 return(true);
             }
         }
     }
     ctx = default;
     return(false);
 }
Пример #8
0
 public override bool TryParseIndex(string path, RangeInt cursor, out IWatchContext ctx)
 {
     if (ParserUtils.TryParseScopeSequenceRange(path, ref cursor, ParserUtils.DelemiterQuote, out var nameRangeIn, out var nameRangeOut))
     {
         string name = path.Substring(nameRangeIn);
         foreach (var go in Scene.GetRootGameObjects())
         {
             if (go.name == name)
             {
                 GameObject go2 = go;
                 ctx = new GameObjectContext(this, $"[\"{name}\"]", go, ContextFieldInfo.MakeOperator($"[\"{name}\"]"));
                 //ctx = new PropertyPathContext<GameObject, GameObject>(this, this, $"[\"{name}\"]", ref go2, null, ContextFieldInfo.MakeOperator($"[\"{name}\"]"));
                 //ctx = new PropertyBagContext<GameObject>(this, $"[\"{name}\"]", ref go2, ContextFieldInfo.MakeOperator($"[\"{name}\"]"));
                 return(true);
             }
         }
     }
     ctx = default;
     return(false);
 }
Пример #9
0
 protected ContextMemberInfo MakeMemberInfo <TMemberType>(string index)
 {
     return(new ContextMemberInfo(ContextFieldInfo.MakeOperator($"[{index}]"), ContextTypeInfo.Make(typeof(TMemberType))));
 }
Пример #10
0
        public override bool TryParseIndex(string path, RangeInt cursor, out IWatchContext ctx)
        {
            if (ParserUtils.TryParseIntAt(path, ref cursor, out var index))
            {
                var       comps = GO.GetComponents <Component>();
                Component comp  = comps[index];

                //Type PropertyBagContextType = typeof(PropertyBagContext<>);
                //Type[] typeParams = new Type[] { comp.GetType() };
                //Type PropertyBagContextTypeGen = PropertyBagContextType.MakeGenericType(typeParams);
                //
                //ctx = (IWatchContext)Activator.CreateInstance(PropertyBagContextTypeGen, this, $"[{index}]", comp, ContextFieldInfo.MakeOperator($"[{index}]"));


                Type   PropertyPathContextType = typeof(PropertyPathContext <,>);
                Type[] typeParams = new Type[] { comp.GetType(), comp.GetType() };
                Type   PropertyBagContextTypeGen = PropertyPathContextType.MakeGenericType(typeParams);

                //public PropertyPathContext(IWatchContext parent, IWatchContext rootPathContext, string relativePath, ref TContainer container, PropertyPath propPath, ContextFieldInfo fieldInfo)
                ctx = (IWatchContext)Activator.CreateInstance(PropertyBagContextTypeGen, this, this, $"[{index}]", comp, null, ContextFieldInfo.MakeOperator($"[{index}]"));

                if (ctx != null)
                {
                    return(ctx != null);
                }
            }
            ctx = default;
            return(false);
        }
Пример #11
0
 public GameObjectComponentDictionary(IWatchContext parent, string relativePath, GameObject go, ContextFieldInfo fieldInfo)
     : base(parent
            , relativePath
            , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(GameObjectContext)))
            )
 {
     GO = go;
 }
Пример #12
0
 public GameObjectContext(IWatchContext parent, string relativePath, GameObject go, ContextFieldInfo fieldInfo)
     : base(parent
            , relativePath
            , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(GameObjectContext)))
            )
 {
     GO = go;
     this.Variables.Add("Components", new GameObjectComponentDictionary(this, ".Components", go, ContextFieldInfo.Make("Components")));
 }
Пример #13
0
 public SceneContext(IWatchContext parent, string relativePath, UnityEngine.SceneManagement.Scene scene, ContextFieldInfo fieldInfo)
     : base(parent
            , relativePath
            , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(SceneContext)))
            )
 {
     Scene = scene;
     Variables.Add("GameObject", new GameObjectDictionary(this, ParserUtils.MakePathRelative("GameObject"), Scene, ContextFieldInfo.Make("GameObject")));
 }
Пример #14
0
 public GameObjectDictionary(IWatchContext parent, string relativePath, UnityEngine.SceneManagement.Scene scene, ContextFieldInfo fieldInfo)
     : base(parent
            , relativePath
            , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(GameObjectDictionary)))
            )
 {
     Scene = scene;
 }
Пример #15
0
            VisitStatus IPropertyVisitor.VisitCollectionProperty <TProperty2, TContainer2, TValue2>(TProperty2 property, ref TContainer2 container, ref ChangeTracker changeTracker)
            {
                var propName = property.GetName();

                if (propName != PropertyIdentifier)
                {
                    return(VisitStatus.Handled);
                }
                if (Result != null)
                {
                    return(VisitStatus.Handled);
                }
                Result = new PropertyPathContext <TContainer, TValue2>(Parent, Root, ParserUtils.MakePathRelative(PropertyPart), Container, RootPath.AppendedIndexer(PropertyPart), ContextFieldInfo.MakeOperator(PropertyPart));
                return(VisitStatus.Handled);
            }
Пример #16
0
        public override bool TryParse(string path, ref RangeInt cursor, out IWatchContext ctx)
        {
            var c = cursor;

            if (ParserUtils.TryParseScopeSequenceRange(path, ref c, ParserUtils.DelemiterSquareBracket, out var seqIn, out var seqOut))
            {
                if (ParserUtils.TryParseIntAt(path, ref seqIn, out var index))
                {
                    var es = World.EntityManager.GetAllEntities();
                    for (int i = 0; i != es.Length; ++i)
                    {
                        if (es[i].Index == index)
                        {
                            cursor = c;
                            var ctnr = new EntityContainer(World.EntityManager, es[i]);
                            ctx = new PropertyPathContext <EntityContainer, EntityContainer>(this, this, $"[{es[i].Index}]", ctnr, null, ContextFieldInfo.MakeOperator($"[{es[i].Index}]"));
                            return(true);
                        }
                    }
                }
            }
            ctx = null;
            return(false);
        }
Пример #17
0
 // propPath
 public PropertyPathContext(IWatchContext parent, IWatchContext rootPathContext, string relativePath, TContainer container, PropertyPath propPath, ContextFieldInfo fieldInfo)
     : base(parent
            , relativePath
            , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(TPropertyType)))
            )
 {
     Container       = container;
     PropPath        = propPath;
     RootPathContext = rootPathContext;
 }
Пример #18
0
 public EntityContext(IWatchContext parent, string relativePath, Entity entity, ContextFieldInfo fieldInfo)
     : base(parent
            , relativePath
            , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(WorldContext)))
            )
 {
     this.entity = entity;
     //Variables.Add("Components", new EntityDictionary(this, ".Entity", World, ContextFieldInfo.Make("Entity")));
 }
Пример #19
0
 public EntityDictionary(IWatchContext parent, string relativePath, Entities.World world, ContextFieldInfo fieldInfo)
     : base(parent
            , relativePath
            , new ContextMemberInfo(fieldInfo, ContextTypeInfo.Make(typeof(EntityDictionary)))
            )
 {
     World = world;
 }