Пример #1
0
        private static Tdf ToTdf(string file, TdfNode weaponInfo)
        {
            var tdf = new Tdf();

            tdf.File = file;

            tdf.ID                 = weaponInfo.Name;
            tdf.WeaponId           = weaponInfo.GetStringOrDefault("ID");
            tdf.Name               = weaponInfo.GetStringOrDefault("Name");
            tdf.Range              = weaponInfo.GetDoubleOrDefault("Range");
            tdf.Reloadtime         = weaponInfo.GetDoubleOrDefault("Reloadtime");
            tdf.Weaponvelocity     = weaponInfo.GetDoubleOrDefault("Weaponvelocity");
            tdf.Areaofeffect       = weaponInfo.GetDoubleOrDefault("Areaofeffect");
            tdf.Burst              = weaponInfo.GetDoubleOrDefault("Burst");
            tdf.BurstRate          = weaponInfo.GetDoubleOrDefault("BurstRate");
            tdf.EnergyPerShot      = weaponInfo.GetDoubleOrDefault("EnergyPerShot");
            tdf.Accuracy           = weaponInfo.GetDoubleOrDefault("Accuracy");
            tdf.StartVelocity      = weaponInfo.GetDoubleOrDefault("StartVelocity");
            tdf.WeaponAcceleration = weaponInfo.GetDoubleOrDefault("WeaponAcceleration");
            tdf.WeaponTimer        = weaponInfo.GetDoubleOrDefault("WeaponTimer");
            tdf.Tolerance          = weaponInfo.GetDoubleOrDefault("Tolerance");
            tdf.EdgeEffectiveness  = weaponInfo.GetDoubleOrDefault("EdgeEffectiveness");
            tdf.Color              = weaponInfo.GetStringOrDefault("Color");
            tdf.Color2             = weaponInfo.GetStringOrDefault("Color2");
            tdf.SprayAngle         = weaponInfo.GetDoubleOrDefault("SprayAngle");
            tdf.PitchTolerance     = weaponInfo.GetDoubleOrDefault("PitchTolerance");
            tdf.MinBarrelAngle     = weaponInfo.GetDoubleOrDefault("MinBarrelAngle");

            if (weaponInfo.Keys.TryGetValue("DAMAGE", out var damageInfo))
            {
                tdf.Default = damageInfo.GetDoubleOrDefault("DEFAULT");
            }

            tdf.Changed = false;
            return(tdf);
        }
Пример #2
0
        private static Fbi ToFbi(string file, TdfNode unitInfo)
        {
            var unit = new Fbi();

            unit.File = file;

            unit.ID                     = unitInfo.GetStringOrDefault("UnitName");
            unit.Side                   = unitInfo.GetStringOrDefault("Side");
            unit.Name                   = unitInfo.GetStringOrDefault("Name");
            unit.Description            = unitInfo.GetStringOrDefault("Description");
            unit.Category               = unitInfo.GetStringOrDefault("Category");
            unit.BuildCostEnergy        = unitInfo.GetDoubleOrDefault("BuildCostEnergy");
            unit.BuildCostMetal         = unitInfo.GetDoubleOrDefault("BuildCostMetal");
            unit.MaxDamage              = unitInfo.GetDoubleOrDefault("MaxDamage");
            unit.DamageModifier         = unitInfo.GetDoubleOrDefault("DamageModifier");
            unit.EnergyUse              = unitInfo.GetDoubleOrDefault("EnergyUse");
            unit.BuildTime              = unitInfo.GetDoubleOrDefault("BuildTime");
            unit.WorkerTime             = unitInfo.GetDoubleOrDefault("WorkerTime");
            unit.BuildDistance          = unitInfo.GetDoubleOrDefault("BuildDistance");
            unit.SightDistance          = unitInfo.GetDoubleOrDefault("SightDistance");
            unit.RadarDistance          = unitInfo.GetDoubleOrDefault("RadarDistance");
            unit.SonarDistance          = unitInfo.GetDoubleOrDefault("SonarDistance");
            unit.RadarDistanceJam       = unitInfo.GetDoubleOrDefault("RadarDistanceJam");
            unit.SonarDistanceJam       = unitInfo.GetDoubleOrDefault("SonarDistanceJam");
            unit.Stealth                = unitInfo.GetDoubleOrDefault("Stealth");
            unit.CloakCost              = unitInfo.GetDoubleOrDefault("CloakCost");
            unit.CloakCostMoving        = unitInfo.GetDoubleOrDefault("CloakCostMoving");
            unit.MinCloakDistance       = unitInfo.GetDoubleOrDefault("MinCloakDistance");
            unit.EnergyStorage          = unitInfo.GetDoubleOrDefault("EnergyStorage");
            unit.MetalStorage           = unitInfo.GetDoubleOrDefault("MetalStorage");
            unit.MetalMake              = unitInfo.GetDoubleOrDefault("MetalMake");
            unit.MakesMetal             = unitInfo.GetDoubleOrDefault("MakesMetal");
            unit.EnergyMake             = unitInfo.GetDoubleOrDefault("EnergyMake");
            unit.WindGenerator          = unitInfo.GetDoubleOrDefault("WindGenerator");
            unit.MaxVelocity            = unitInfo.GetDoubleOrDefault("MaxVelocity");
            unit.BrakeRate              = unitInfo.GetDoubleOrDefault("BrakeRate");
            unit.Acceleration           = unitInfo.GetDoubleOrDefault("Acceleration");
            unit.TurnRate               = unitInfo.GetDoubleOrDefault("TurnRate");
            unit.CanMove                = unitInfo.GetDoubleOrDefault("CanMove");
            unit.CanAttack              = unitInfo.GetDoubleOrDefault("CanAttack");
            unit.CanCapture             = unitInfo.GetDoubleOrDefault("CanCapture");
            unit.CanDgun                = unitInfo.GetDoubleOrDefault("CanDgun");
            unit.CanGuard               = unitInfo.GetDoubleOrDefault("CanGuard");
            unit.CanPatrol              = unitInfo.GetDoubleOrDefault("CanPatrol");
            unit.CanReclamate           = unitInfo.GetDoubleOrDefault("CanReclamate");
            unit.CanStop                = unitInfo.GetDoubleOrDefault("CanStop");
            unit.CanLoad                = unitInfo.GetDoubleOrDefault("CanLoad");
            unit.CantBeTransported      = unitInfo.GetDoubleOrDefault("CantBeTransported");
            unit.TransportCapacity      = unitInfo.GetDoubleOrDefault("TransportCapacity");
            unit.Corpse                 = unitInfo.GetStringOrDefault("Corpse");
            unit.HealTime               = unitInfo.GetDoubleOrDefault("HealTime");
            unit.TransportSize          = unitInfo.GetDoubleOrDefault("TransportSize");
            unit.OnOffable              = unitInfo.GetDoubleOrDefault("OnOffable");
            unit.ShootMe                = unitInfo.GetDoubleOrDefault("ShootMe");
            unit.NoAutoFire             = unitInfo.GetDoubleOrDefault("NoAutoFire");
            unit.FireStandOrders        = unitInfo.GetDoubleOrDefault("FireStandOrders");
            unit.StandingFireOrder      = unitInfo.GetDoubleOrDefault("StandingFireOrder");
            unit.MobileStandOrders      = unitInfo.GetDoubleOrDefault("MobileStandOrders");
            unit.StandingMoveOrder      = unitInfo.GetDoubleOrDefault("StandingMoveOrder");
            unit.MaxWaterDepth          = unitInfo.GetDoubleOrDefault("MaxWaterDepth");
            unit.MinWaterDepth          = unitInfo.GetDoubleOrDefault("MinWaterDepth");
            unit.Floater                = unitInfo.GetDoubleOrDefault("Floater");
            unit.Upright                = unitInfo.GetDoubleOrDefault("Upright");
            unit.MoveRate1              = unitInfo.GetDoubleOrDefault("MoveRate1");
            unit.MoveRate2              = unitInfo.GetDoubleOrDefault("MoveRate2");
            unit.FootPrintX             = unitInfo.GetDoubleOrDefault("FootPrintX");
            unit.FootPrintZ             = unitInfo.GetDoubleOrDefault("FootPrintZ");
            unit.MaxSlope               = unitInfo.GetDoubleOrDefault("MaxSlope");
            unit.CanFly                 = unitInfo.GetDoubleOrDefault("CanFly");
            unit.HoverAttack            = unitInfo.GetDoubleOrDefault("HoverAttack");
            unit.Amphibious             = unitInfo.GetDoubleOrDefault("Amphibious");
            unit.WaterLine              = unitInfo.GetDoubleOrDefault("WaterLine");
            unit.ImmuneToParalyzer      = unitInfo.GetDoubleOrDefault("ImmuneToParalyzer");
            unit.Cruisealt              = unitInfo.GetDoubleOrDefault("Cruisealt");
            unit.BankScale              = unitInfo.GetDoubleOrDefault("BankScale");
            unit.PitchScale             = unitInfo.GetDoubleOrDefault("PitchScale");
            unit.SoundCategory          = unitInfo.GetStringOrDefault("SoundCategory");
            unit.NoChaseCategory        = unitInfo.GetStringOrDefault("NoChaseCategory");
            unit.wpri_badtargetcategory = unitInfo.GetStringOrDefault("wpri_badtargetcategory");
            unit.wsec_badtargetcategory = unitInfo.GetStringOrDefault("wsec_badtargetcategory");
            unit.wspe_badtargetcategory = unitInfo.GetStringOrDefault("wspe_badtargetcategory");
            unit.MovementClass          = unitInfo.GetStringOrDefault("MovementClass");
            unit.ExplodeAs              = unitInfo.GetStringOrDefault("ExplodeAs");
            unit.SelfDestructAs         = unitInfo.GetStringOrDefault("SelfDestructAs");
            unit.DefaultMissionType     = unitInfo.GetStringOrDefault("DefaultMissionType");

            if (unit.Category != null)
            {
                if (unit.Category.Contains("LEVEL1"))
                {
                    unit.Level = "L1";
                }
                else if (unit.Category.Contains("LEVEL2"))
                {
                    unit.Level = "L2";
                }
                else if (unit.Category.Contains("LEVEL3"))
                {
                    unit.Level = "L3";
                }
                else if (unit.Category.Contains("LEVEL4"))
                {
                    unit.Level = "L4";
                }
                else if (unit.Category.Contains("LEVEL5"))
                {
                    unit.Level = "L5";
                }
            }

            var tedClass = unitInfo.GetStringOrDefault("TEDCLASS") ?? "";

            unit.Vehcl    = tedClass.Contains("TANK");
            unit.KBot     = tedClass.Contains("KBOT") || tedClass.Contains("COMMANDER");
            unit.Building = new[] { "ENERGY", "METAL", "PLANT", "FORT", "SPECIAL" }.Any(x => tedClass.Contains(x));
            unit.Ship     = tedClass.Contains("SHIP") || tedClass.Contains("WATER");
            unit.Cnstr    = tedClass.Contains("CNSTR") || (unit.Category != null && unit.Category.Contains("CNSTR"));
            unit.Air      = tedClass.Contains("VTOL");

            unit.Weapons = new List <string>();
            for (var i = 1; i <= 5; ++i)
            {
                var weapon = unitInfo.GetStringOrDefault($"WEAPON{i}");
                if (weapon != null)
                {
                    unit.Weapons.Add(weapon.ToUpper());
                }
            }

            var explodeAs = unitInfo.GetStringOrDefault("EXPLODEAS");

            if (explodeAs != null)
            {
                unit.Weapons.Add(explodeAs.ToUpper());
            }

            var selfDestruct = unitInfo.GetStringOrDefault("SELFDESTRUCT");

            if (selfDestruct != null)
            {
                unit.Weapons.Add(selfDestruct.ToUpper());
            }

            unit.Changed = false;
            return(unit);
        }