private static IEnumerable <ScenPart> RandomScenPartsOfCategory(Scenario scen, ScenPartCategory cat, int count) { _003CRandomScenPartsOfCategory_003Ec__Iterator0 _003CRandomScenPartsOfCategory_003Ec__Iterator = (_003CRandomScenPartsOfCategory_003Ec__Iterator0) /*Error near IL_0032: stateMachine*/; if (count > 0) { IEnumerable <ScenPartDef> allowedParts = from d in AddableParts(scen) where d.category == cat select d; int numYielded = 0; int numTries = 0; do { if (numYielded >= count || !allowedParts.Any()) { yield break; } ScenPartDef def = allowedParts.RandomElementByWeight((ScenPartDef d) => d.selectionWeight); ScenPart newPart = MakeScenPart(def); if (CanAddPart(scen, newPart)) { yield return(newPart); /*Error: Unable to find new state assignment for yield return*/; } numTries++; }while (numTries <= 100); Log.Error("Could not add ScenPart of category " + cat + " to scenario " + scen + " after 50 tries."); } }
public static ScenPart MakeScenPart(ScenPartDef def) { ScenPart scenPart = (ScenPart)Activator.CreateInstance(def.scenPartClass); scenPart.def = def; return(scenPart); }
private void AddScenPart(ScenPartDef def) { ScenPart scenPart = ScenarioMaker.MakeScenPart(def); scenPart.Randomize(); this.curScen.parts.Add(scenPart); }
public static ScenPart MakeScenPart(ScenPartDef def) { ScenPart obj = (ScenPart)Activator.CreateInstance(def.scenPartClass); obj.def = def; return(obj); }
private Action <OpenAddScenPartMenu> m__5(ScenPartDef p) { return(delegate() { this.AddScenPart(p); }); }
private static IEnumerable <ScenPart> RandomScenPartsOfCategory(Scenario scen, ScenPartCategory cat, int count) { if (count <= 0) { yield break; } IEnumerable <ScenPartDef> allowedParts = from d in ScenarioMaker.AddableParts(scen) where d.category == cat select d; int numYielded = 0; int numTries = 0; while (numYielded < count) { if (!allowedParts.Any <ScenPartDef>()) { yield break; } ScenPartDef def = allowedParts.RandomElementByWeight((ScenPartDef d) => d.selectionWeight); ScenPart newPart = ScenarioMaker.MakeScenPart(def); if (ScenarioMaker.CanAddPart(scen, newPart)) { yield return(newPart); numYielded++; } numTries++; if (numTries > 100) { Log.Error(string.Concat(new object[] { "Could not add ScenPart of category ", cat, " to scenario ", scen, " after 50 tries." }), false); yield break; } } yield break; }
private static string <OpenAddScenPartMenu> m__4(ScenPartDef p) { return(p.LabelCap); }
private static string <OpenAddScenPartMenu> m__3(ScenPartDef p) { return(p.label); }
private static bool <OpenAddScenPartMenu> m__2(ScenPartDef p) { return(p.category != ScenPartCategory.Fixed); }