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); }
public static bool TryParseDeepest(IWatchContext ctxFirst, string path, ref RangeInt cursor, out IWatchContext ctxResult) { var c = cursor; IWatchContext curCtx = ctxFirst; while (c.length > 0) { var nextCursor = c; if (ParserUtils.TryExtractPathPart(path, ref nextCursor, out var partRange)) { if (curCtx.TryParse(path, ref partRange, out var nextCtx)) { c = nextCursor; curCtx = nextCtx; continue; } } break; } cursor = c; ctxResult = curCtx; return(true); }
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); }