Esempio n. 1
0
        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.");
            }
        }
Esempio n. 2
0
        public static ScenPart MakeScenPart(ScenPartDef def)
        {
            ScenPart scenPart = (ScenPart)Activator.CreateInstance(def.scenPartClass);

            scenPart.def = def;
            return(scenPart);
        }
Esempio n. 3
0
        private void AddScenPart(ScenPartDef def)
        {
            ScenPart scenPart = ScenarioMaker.MakeScenPart(def);

            scenPart.Randomize();
            this.curScen.parts.Add(scenPart);
        }
Esempio n. 4
0
        public static ScenPart MakeScenPart(ScenPartDef def)
        {
            ScenPart obj = (ScenPart)Activator.CreateInstance(def.scenPartClass);

            obj.def = def;
            return(obj);
        }
Esempio n. 5
0
 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;
        }
Esempio n. 7
0
 private static string <OpenAddScenPartMenu> m__4(ScenPartDef p)
 {
     return(p.LabelCap);
 }
Esempio n. 8
0
 private static string <OpenAddScenPartMenu> m__3(ScenPartDef p)
 {
     return(p.label);
 }
Esempio n. 9
0
 private static bool <OpenAddScenPartMenu> m__2(ScenPartDef p)
 {
     return(p.category != ScenPartCategory.Fixed);
 }