public ScenarioResult Run(ScenarioResult lastResult, ScenarioFrame frame) { if (Satisfies(lastResult)) { return(mScenario.Run(frame)); } else { return(ScenarioResult.End); } }
public void Add(ScenarioFrame frame, Scenario scenario, ScenarioResult result) { if (frame == null) { StoryProgression.Main.Scenarios.Post(scenario); } else { if (frame.Count == 0) { result = ScenarioResult.Start; } frame.Add(Manager, scenario, result); } }
public void Add(ScenarioFrame frame, Scenario scenario, int chance) { if (frame == null) { if (RandomUtil.RandomChance(chance)) { StoryProgression.Main.Scenarios.Post(scenario); } } else { if (frame.Count == 0) { Add(frame, scenario, ScenarioResult.Start); } else { frame.Add(Manager, scenario, chance); } } }
protected override bool PrivateUpdate(ScenarioFrame frame) { return(false); }
protected ScenarioFrame(ScenarioFrame parent, Scenario.ScenarioRun root) { mRoot = root; mParent = parent; }
public List <ScenarioFrame> Run() { if (StoryProgression.Main == null) { return(null); } using (Common.TestSpan span = new Common.TestSpan(StoryProgression.Main.Scenarios, "ScenarioFrameRun", Common.DebugLevel.Stats)) { if (mCountdown > 0) { return(null); } if (mChildren.Count > 0) { return(null); } ScenarioResult lastResult = LastResult; List <ScenarioFrame> frames = new List <ScenarioFrame>(); while (Count > 0) { Scenario.ScenarioRun run = this[0]; string test = UnlocalizedName; if ((frames.Count > 0) && ((!run.IsInstant) || (!ChildOfRoot))) { break; } RemoveAt(0); ScenarioFrame frame = new ScenarioFrame(this, run); ScenarioResult prevResult = lastResult; //lastResult = Scenario.ScenarioRun.RunTask.Wait(run, lastResult, frame); lastResult = run.Run(lastResult, frame); if (frame.Count > 0) { if ((StoryProgression.Main != null) && (StoryProgression.Main.Scenarios.TrackingID == ID)) { StoryProgression.Main.Scenarios.Track("Before: " + prevResult + Common.NewLine + "After: Nested" + Common.NewLine + run.ToString() + Common.NewLine + ToString()); } frame.ID = run.ID; frames.Add(frame); } else { if ((StoryProgression.Main != null) && (StoryProgression.Main.Scenarios.TrackingID == ID)) { StoryProgression.Main.Scenarios.Track("Before: " + prevResult + Common.NewLine + "After: " + lastResult + Common.NewLine + run.ToString() + Common.NewLine + ToString()); } LastResult = lastResult; } } if (Count == 0) { RemoveFromParent(this); } if (frames.Count > 0) { AddChildren(frames); } return(frames); } }
protected override bool PrivateUpdate(ScenarioFrame frame) { GetData(Sim).InvalidateCache(); return(true); }
protected ScenarioResult Run(ScenarioFrame frame) { try { if (Scenarios == null) { return(ScenarioResult.Failure); } string name = "Duration " + UnlocalizedName; if (!Main.SecondCycle) { name = "First " + name; } using (Common.TestSpan span = new Common.TestSpan(Scenarios, name)) { AddTry(); if (!Test()) { AllowFailCleanup(); return(ScenarioResult.Failure); } AddAllowed(); List <Scenario> list = new List <Scenario>(); int continueChance = ContinueChance; int maximum = 0; bool random = true; GatherResult result = GatherResult.Failure; string gatherName = "Gather " + UnlocalizedName; if (!Main.SecondCycle) { gatherName = "First " + gatherName; } using (Common.TestSpan gatherSpan = new Common.TestSpan(Scenarios, gatherName)) { result = Gather(list, ref continueChance, ref maximum, ref random); } switch (result) { case GatherResult.Update: return(Update(frame)); case GatherResult.Failure: IncStat("Gathering Failure"); return(ScenarioResult.Failure); } // Stops the PushAndPrint() routine from firing mPushed = true; AddStat("Gathered", list.Count); if (list.Count == 0) { return(ScenarioResult.Failure); } if (maximum <= 0) { maximum = list.Count; } if (continueChance != 100) { AddStat("Chance", continueChance); } bool first = true; int count = 0; if (random) { while (list.Count > 0) { int index = RandomUtil.GetInt(list.Count - 1); Scenario item = list[index]; list.RemoveAt(index); item.mFirst = first; first = false; Add(frame, item, continueChance); count++; if (count > maximum) { AddStat("Maximum", count); break; } } } else { foreach (Scenario item in list) { item.mFirst = first; first = false; Add(frame, item, continueChance); count++; if (count > maximum) { AddStat("Maximum", count); break; } } } return(ScenarioResult.Success); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(ToString(), e); return(ScenarioResult.Failure); } }
protected abstract bool PrivateUpdate(ScenarioFrame frame);