예제 #1
0
        public static void ClassInit()
        {
            // initialize galaxy
            new Galaxy();
            Mod.Load(null);

            // initialize empires
            empire      = new Empire();
            empire.Name = "Engi";
            race        = new Race();
            race.Name   = "Engi";
            race.Aptitudes["Construction"] = 100;

            // initialize components
            sy = Mod.Current.FacilityTemplates.FindByName("Space Yard Facility I");
        }
예제 #2
0
        public override IEnumerable <IModObject> Load(Mod mod)
        {
            foreach (var rec in DataFile.Records)
            {
                var f = new FacilityTemplate();
                f.TemplateParameters = rec.Parameters;
                mod.FacilityTemplates.Add(f);

                int index = -1;

                f.ModID        = rec.Get <string>("ID", f);
                f.Name         = rec.Get <string>("Name", f);
                f.Description  = rec.Get <string>("Description", f);
                f.Group        = rec.Get <string>("Facility Group", f);
                f.Family       = rec.Get <string>("Facility Family", f);
                f.RomanNumeral = rec.Get <int>("Roman Numeral", f);
                var picfield = rec.FindField("Pic", ref index, false, 0, true);
                if (picfield != null)
                {
                    f.PictureName = picfield.Value;
                }
                else
                {
                    f.PictureName = "Facil_" + rec.Get <int>("Pic Num", f).Value.ToString("000");                    // for compatibility with SE4
                }
                foreach (var costfield in rec.Fields.Where(cf => cf.Name.StartsWith("Cost ")))
                {
                    f.Cost[Resource.Find(costfield.Name.Substring("Cost ".Length))] = costfield.CreateFormula <int>(f);
                }

                foreach (var tr in RequirementLoader.LoadEmpireRequirements(rec, f, RequirementType.Unlock))
                {
                    f.UnlockRequirements.Add(tr);
                }

                // TODO - build and use requirements

                foreach (var abil in AbilityLoader.Load(Filename, rec, f).ToArray())
                {
                    f.Abilities.Add(abil);
                }

                yield return(f);
            }
        }
예제 #3
0
        public void CorrectAbilities()
        {
            Mod.Load(null);
            var ft1 = new FacilityTemplate();

            ft1.Name = "Mineral Miner Test";
            ft1.Abilities.Add(new Ability(ft1, Mod.Current.AbilityRules.FindByName("Resource Generation - Minerals"), null, 800));
            var ft2 = new FacilityTemplate();

            ft2.Name = "Organics Farm Test";
            ft2.Abilities.Add(new Ability(ft1, Mod.Current.AbilityRules.FindByName("Resource Generation - Organics"), null, 800));
            var fts = new List <FacilityTemplate> {
                ft1, ft2
            };
            var serdata = Serializer.SerializeToString(fts);
            var deser   = Serializer.Deserialize <List <FacilityTemplate> >(serdata);

            Assert.AreEqual(800, deser.First().GetAbilityValue("Resource Generation - Minerals").ToInt());
            Assert.AreEqual(0, deser.First().GetAbilityValue("Resource Generation - Organics").ToInt());
            Assert.AreEqual(0, deser.Last().GetAbilityValue("Resource Generation - Minerals").ToInt());
            Assert.AreEqual(800, deser.Last().GetAbilityValue("Resource Generation - Organics").ToInt());
        }
예제 #4
0
 public void Bind(FacilityTemplate data)
 {
     isUpgrading = false;
     Bind(new Facility(data));
 }
예제 #5
0
 public FacilityReport(FacilityTemplate ft)
 {
     InitializeComponent();
     Bind(ft);
 }