Beispiel #1
0
        public void Load(string iplfile)
        {
            Name = Path.GetFileNameWithoutExtension(iplfile).ToLowerInvariant();

            var  lines  = File.ReadAllLines(iplfile);
            bool ininst = false;
            bool incars = false;

            foreach (var line in lines)
            {
                string tline = line.Trim();
                if (string.IsNullOrEmpty(tline))
                {
                    continue;                              //blank line
                }
                if (tline.StartsWith("#"))
                {
                    continue;                        //commented out
                }
                //if (tline.StartsWith("version")) continue;
                if (tline.StartsWith("inst"))
                {
                    ininst = true; continue;
                }                                                          //start of instances
                if (tline.StartsWith("cars"))
                {
                    incars = true; continue;
                }                                                          //start of car gens
                if (tline.StartsWith("end") && (ininst || incars))
                {
                    ininst = false;
                    incars = false;
                    continue;
                }
                if (ininst)
                {
                    Entity ent = new Entity(tline);
                    AllEntities.Add(ent);
                    if (ent.Name.StartsWith("slod"))
                    {
                        SlodEntities.Add(ent);
                    }
                    else if (ent.Name.StartsWith("lod"))
                    {
                        LodEntities.Add(ent);
                    }
                    else
                    {
                        if (ent.ParentIndex < 0)
                        {
                            OEntities.Add(ent);
                        }
                        else
                        {
                            HdEntities.Add(ent);
                        }
                    }
                }
                if (incars)
                {
                    CarGen cgen = new CarGen(tline);
                    CarGenerators.Add(cgen);
                }
            }

            AllLodEntities.Clear();
            AllLodEntities.AddRange(SlodEntities);
            AllLodEntities.AddRange(LodEntities);

            AllHdEntities.Clear();
            AllHdEntities.AddRange(HdEntities);
            AllHdEntities.AddRange(OEntities);


            for (int i = 0; i < AllLodEntities.Count; i++)
            {
                AllLodEntities[i].NewIndex = i;
            }
            for (int i = 0; i < AllHdEntities.Count; i++)
            {
                AllHdEntities[i].NewIndex = i;
            }
        }
Beispiel #2
0
        public void ProcessEntities()
        {
            foreach (var ent in AllEntities)
            {
                var depth = ent.ChildDepth;

                if (depth == 2)
                {
                    SlodEntities.Add(ent);
                }
                else if (depth == 1)
                {
                    LodEntities.Add(ent);
                }
                else if (depth == 0)
                {
                    if (ent.InteriorInfo != null)
                    {
                        InteriorEntities.Add(ent);
                    }
                    else if (ent.Parent != null)
                    {
                        HdEntities.Add(ent);
                    }
                    else
                    {
                        OEntities.Add(ent);
                    }
                }
                else
                {
                    SlodEntities.Add(ent);//not really correct here, but what else to do? slod2/3?
                }



                //if (ent.Name.StartsWith("slod"))
                //{
                //    SlodEntities.Add(ent);
                //}
                //else if (ent.Name.StartsWith("lod"))
                //{
                //    LodEntities.Add(ent);
                //}
                //else
                //{
                //    if (ent.ParentIndex < 0)
                //    {
                //        OEntities.Add(ent);
                //    }
                //    else
                //    {
                //        HdEntities.Add(ent);
                //    }
                //}
            }


            AllLodEntities.Clear();
            AllLodEntities.AddRange(SlodEntities);
            AllLodEntities.AddRange(LodEntities);

            AllHdEntities.Clear();
            AllHdEntities.AddRange(HdEntities);
            AllHdEntities.AddRange(OEntities);


            for (int i = 0; i < AllLodEntities.Count; i++)
            {
                AllLodEntities[i].NewIndex = i;
            }
            for (int i = 0; i < AllHdEntities.Count; i++)
            {
                AllHdEntities[i].NewIndex = i;
            }
        }