Example #1
0
        public static FeatureRecord FromTdfNode(TdfNode n)
        {
            // At least one Cavedog feature has a bad footprintz
            // (CCDATA.CCX/features/Water/CORALS.TDF, Coral20)
            // so we have to cope with them without complaining.
            if (!TdfConvert.TryToInt32(n.Entries.GetOrDefault("footprintx", "0"), out var footprintX))
            {
                footprintX = 1;
            }

            if (!TdfConvert.TryToInt32(n.Entries.GetOrDefault("footprintz", "0"), out var footprintZ))
            {
                footprintZ = 1;
            }

            return(new FeatureRecord
            {
                Name = n.Name,
                World = n.Entries.GetOrDefault("world", string.Empty),
                Category = n.Entries.GetOrDefault("category", string.Empty),
                FootprintX = footprintX,
                FootprintY = footprintZ,
                AnimFileName = n.Entries.GetOrDefault("filename", string.Empty),
                SequenceName = n.Entries.GetOrDefault("seqname", string.Empty),
                ObjectName = n.Entries.GetOrDefault("object", string.Empty)
            });
        }
Example #2
0
        private static TdfNode ToTdfNode(Tdf weapon)
        {
            var n = new TdfNode(weapon.ID);

            n.Entries["ID"]                 = TdfConvert.ToStringInfo(weapon.WeaponId);
            n.Entries["Name"]               = TdfConvert.ToStringInfo(weapon.Name);
            n.Entries["Range"]              = TdfConvert.ToStringInfo(weapon.Range);
            n.Entries["Reloadtime"]         = TdfConvert.ToStringInfo(weapon.Reloadtime);
            n.Entries["Weaponvelocity"]     = TdfConvert.ToStringInfo(weapon.Weaponvelocity);
            n.Entries["Areaofeffect"]       = TdfConvert.ToStringInfo(weapon.Areaofeffect);
            n.Entries["Burst"]              = TdfConvert.ToStringInfo(weapon.Burst);
            n.Entries["BurstRate"]          = TdfConvert.ToStringInfo(weapon.BurstRate);
            n.Entries["EnergyPerShot"]      = TdfConvert.ToStringInfo(weapon.EnergyPerShot);
            n.Entries["Accuracy"]           = TdfConvert.ToStringInfo(weapon.Accuracy);
            n.Entries["StartVelocity"]      = TdfConvert.ToStringInfo(weapon.StartVelocity);
            n.Entries["WeaponAcceleration"] = TdfConvert.ToStringInfo(weapon.WeaponAcceleration);
            n.Entries["WeaponTimer"]        = TdfConvert.ToStringInfo(weapon.WeaponTimer);
            n.Entries["Tolerance"]          = TdfConvert.ToStringInfo(weapon.Tolerance);
            n.Entries["EdgeEffectiveness"]  = TdfConvert.ToStringInfo(weapon.EdgeEffectiveness);
            n.Entries["Color1"]             = TdfConvert.ToStringInfo(weapon.Color);
            n.Entries["Color2"]             = TdfConvert.ToStringInfo(weapon.Color2);
            n.Entries["SprayAngle"]         = TdfConvert.ToStringInfo(weapon.SprayAngle);
            n.Entries["PitchTolerance"]     = TdfConvert.ToStringInfo(weapon.PitchTolerance);
            n.Entries["MinBarrelAngle"]     = TdfConvert.ToStringInfo(weapon.MinBarrelAngle);

            var damage = new TdfNode("DAMAGE");

            damage.Entries["DEFAULT"] = TdfConvert.ToStringInfo(weapon.Default);
            n.Keys["DAMAGE"]          = damage;

            return(n);
        }
Example #3
0
        public MapModel FromTntAndOta(ITntSource tnt, TdfNode ota)
        {
            var attrs = MapAttributes.Load(ota);
            var model = new MapModel(tnt.DataWidth, tnt.DataHeight, attrs);

            this.ReadTnt(tnt, model);

            var schemaData = ota.Keys["GlobalHeader"].Keys["Schema 0"];

            if (schemaData.Keys.ContainsKey("features"))
            {
                var featureData = schemaData.Keys["features"];
                foreach (var data in featureData.Keys)
                {
                    var node = data.Value;
                    var x    = TdfConvert.ToInt32(node.Entries["XPos"]);
                    var y    = TdfConvert.ToInt32(node.Entries["ZPos"]);
                    var name = node.Entries["Featurename"];

                    if (!model.HasFeatureInstanceAt(x, y))
                    {
                        var inst = new FeatureInstance(Guid.NewGuid(), name, x, y);
                        model.AddFeatureInstance(inst);
                    }
                }
            }

            return(model);
        }
Example #4
0
        private static bool isEmptyOrDefault(string s)
        {
            if (string.IsNullOrWhiteSpace(s))
            {
                return(true);
            }

            if (TdfConvert.TryToDouble(s, out var v))
            {
                if (v == 0.0)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #5
0
        private static TdfNode ToTdfNode(Fbi unit)
        {
            var n = new TdfNode("UNITINFO");

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

            return(n);
        }