//public override ElementBase ReturnParseTreeFromExistingElement(ElementBase ExisitngElement) //{ // //for now I am the top element inthe chain so add it to me and return myself // AddContainedElement(ExisitngElement); // return this; //} internal override MatchResult SubBeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList) { //first lets check the statebag to see if we are in there yet var sbag = GetQuantifierState(tracker); if (!sbag.MatchCount.HasValue) { sbag.MatchCount = new Nullable <int>(0); tracker.SetMyStateBag(this, sbag); } //Pass the event along to the contained element and get its result var subRes = ContainedElement.BeginProcessMatch(tracker, eventenum, sbag.CaptureList); MatchResult tres = IsMatchResult.IsNotMatch; if (QuantifierSymbol == '+') { tres = HandlePlus(sbag.MatchCount, subRes); } if (QuantifierSymbol == '*') { tres = HandleStar(sbag.MatchCount, subRes); } if (QuantifierSymbol == '?') { tres = HandleQuestionMark(sbag.MatchCount, subRes); } //if its the end (either a match or not) , then remove our bag state if (!tres.Is_Continue()) { if (tres.Is_Match()) { //specEventStream.EndApplyAll(); if (CapturedList != null) { CapturedList.AddRange(sbag.CaptureList.Items); } } tracker.RemoveMyStateBag(this); } else { //if its a continue then increment the bagstate sbag.MatchCount = sbag.MatchCount.Value + 1; tracker.SetMyStateBag(this, sbag); } //return to the tracker the result if (subRes.Is_Forward()) { tres = tres | MatchResult.Forward; } return(tres); }
internal override MatchResult BeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList) { tracker.DebugStart(this); //we don't want to capture so send in a null var r = ContainedElement.BeginProcessMatch(tracker, eventenum, null); if (tracker.DebugEnabled) { tracker.SaveDBGResult(this, r); } return(r); }
internal override MatchResult BeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList) { //can't neagte a null - if null event then return no match if (eventenum.Current == null) { return(IsMatchResult.IsNotMatch); } var a = ContainedElement.BeginProcessMatch(tracker, eventenum, null); if (a.Is_Match()) { a = IsMatchResult.IsNotMatch; } else { CapturedList.Add(eventenum.Current); a = IsMatchResult.IsMatch; } return(a); }
internal override MatchResult SubBeginProcessMatch(Tracker tracker, IEventStream eventenum, CaptureList CapturedList) { if (eventenum.Current == null) { return(MatchResult.None); } MatchResult tres = MatchResult.None; var sbag = GetQuantifierState(tracker); if (!sbag.MatchCount.HasValue) { sbag.MatchCount = new Nullable <int>(0); tracker.SetMyStateBag(this, sbag); } var specEventStream = eventenum;//eventenum.CreateSpeculator(); do { MatchResult subRes = MatchResult.None; subRes = ContainedElement.BeginProcessMatch(tracker, eventenum, sbag.CaptureList); if (!subRes.Is_Match()) { //if we matched our minimun we can make a final decisison if it did not match if (sbag.MatchCount.Value >= MinOccours) { tres = MatchResult.Match | MatchResult.Forward; } else//if we have not yet matched our minimun then we just need to continue { tres = MatchResult.Continue | MatchResult.Capture; } } //if we did match if (subRes.Is_Match()) { //if we reached the max then return a match if (sbag.MatchCount.Value + 1 == MaxOccours) { tres = IsMatchResult.IsMatch; } else { //if we matched at least min then mark as match and contineu if (sbag.MatchCount.Value + 1 >= MinOccours) { tres = MatchResult.Match | MatchResult.Continue | MatchResult.Capture; } else { //just continue matching //if the subres has a forward , then don't capture , just relay the forward if (subRes.Is_Forward()) { tres = MatchResult.Continue | MatchResult.Forward; } else { tres = MatchResult.Continue | MatchResult.Capture; } } } } //if its the end (either a match or not) , then remove our bag state if (!tres.Is_Continue()) { tracker.RemoveMyStateBag(this); } else { //if its a continue then increment the bagstate sbag.MatchCount++; tracker.SetMyStateBag(this, sbag); } if (subRes.Is_Forward()) { tres = tres | MatchResult.Forward; } //if this is a match without a continue then grab the commmit the speculator //and add the spculative captures to the tracker captures if (tres.Is_Match() && !tres.Is_Continue()) { //specEventStream.EndApplyAll(); if (CapturedList != null) { CapturedList.AddRange(sbag.CaptureList.Items); } return(tres); } //if this is not a match and not a continue then rollback the speculator and return the result if (!tres.Is_Match() && !tres.Is_Continue()) { //specEventStream.EndDiscardAll(); return(tres); } //its a continue so allow the loop to continue }while ( specEventStream.MoveNextIfNotForward(tres)); //if we are here it means that we ran out of events so we got to deal with that if (tres.Is_Match()) { if (CapturedList != null) { CapturedList.AddRange(sbag.CaptureList.Items); } } //remove the continue if its there if (tres.Is_Continue()) { var mask = ~MatchResult.Continue; tres = tres & mask; } return(tres); }
internal override bool IsPotentialMatch(IChronologicalEvent chronevent) { //just forward to the child return(ContainedElement.IsPotentialMatch(chronevent)); }
internal override MatchResult IsMatch(IChronologicalEvent chronevent, Tracker Tracker, CaptureList CapturedList) { var a = ContainedElement.IsMatch(chronevent, Tracker, CapturedList); return(a); }
public void AddResource(Defs.ResourceTypes target, float max) { GameObject newSpawn = Instantiate(elementObject, elementRoot, false); ContainedElement newElement = new ContainedElement { root = newSpawn.transform, resource = target, fill = newSpawn.transform.GetChild(0).GetChild(0).GetComponent <Image>(), fillReduction = newSpawn.transform.GetChild(0).GetComponent <Image>(), text = newSpawn.transform.GetChild(0).GetChild(0).GetChild(0).GetComponent <TextMeshProUGUI>(), lastTransfer = new Transfer(max, max, 1), throwVal = max, timeout = 0, }; Color color = Color.black; Defs.LayoutSize size = Defs.LayoutSize.Medium; switch (target) { case Defs.ResourceTypes.Health: color = Parameters.i.Health.Color; size = Parameters.i.Health.pHBar; break; case Defs.ResourceTypes.Stamina: color = Parameters.i.Stamina.Color; size = Parameters.i.Stamina.pHBar; break; case Defs.ResourceTypes.Mana: color = Parameters.i.Mana.Color; size = Parameters.i.Mana.pHBar; break; case Defs.ResourceTypes.Bloodlust: color = Parameters.i.Bloodlust.Color; size = Parameters.i.Bloodlust.pHBar; break; case Defs.ResourceTypes.Sunlight: color = Parameters.i.Sunlight.Color; size = Parameters.i.Sunlight.pHBar; break; case Defs.ResourceTypes.Moonlight: color = Parameters.i.Moonlight.Color; size = Parameters.i.Moonlight.pHBar; break; case Defs.ResourceTypes.Curse: color = Parameters.i.Curse.Color; size = Parameters.i.Curse.pHBar; break; case Defs.ResourceTypes.Corruption: color = Parameters.i.Corruption.Color; size = Parameters.i.Corruption.pHBar; break; case Defs.ResourceTypes.Darkness: color = Parameters.i.Darkness.Color; size = Parameters.i.Darkness.pHBar; break; } newElement.fill.color = color; float height = 2; switch (size) { case Defs.LayoutSize.Large: height = 25; break; case Defs.LayoutSize.Medium: height = 18; break; case Defs.LayoutSize.Small: height = 10; newElement.text = null; break; } newElement.root.GetComponent <LayoutElement>().minHeight = height; if (newElement.text != null) { newElement.text.text = max.ToString("F0") + "/<b>" + max.ToString("F0") + "</b>"; } elements.Add(newElement); }
internal override bool IsPotentialMatch(IChronologicalEvent chronevent) { return(!ContainedElement.IsPotentialMatch(chronevent)); }