Beispiel #1
0
        public Weapon(TradManager dictionary, NdfObject weapon, int turretIndex, int weaponIndex)
        {
            weaponHandle     = weapon;
            this.turretIndex = turretIndex;
            this.weaponIndex = weaponIndex;

            NdfLocalisationHash hash;

            if (weapon.TryGetValueFromQuery <NdfLocalisationHash>("Name", out hash))
            {
                dictionary.TryGetString(hash.Value, out name);
            }
        }
Beispiel #2
0
        public void ReadDictionaryEntry()
        {
            EdataManager datamana = new EdataManager(ndffile);

            datamana.ParseEdataFile();
            NdfbinManager       ndfbin = datamana.ReadNdfbin(ndfbinfile);
            NdfClass            claass = ndfbin.GetClass("TUniteDescriptor");
            NdfObject           obj    = claass.Instances[1];
            NdfLocalisationHash refef;
            string query = "Modules.TypeUnit.Default.DescriptionHintToken";

            Assert.IsTrue(obj.TryGetValueFromQuery <NdfLocalisationHash>(query, out refef));

            EdataManager dic = new EdataManager(trans);

            dic.ParseEdataFile();
            TradManager trad   = dic.ReadDictionary(transFile);
            string      output = string.Empty;

            Assert.IsTrue(trad.TryGetString(refef.Value, out output)); // get LOSAT's description
        }
Beispiel #3
0
        public bool LoadData(NdfObject dataobject, TradManager dictionary, TradManager dictionary2, EdataManager iconPackage)
        {
            InstanceIndex = dataobject.Id;

            NdfString debugstring;
            if (dataobject.TryGetValueFromQuery<NdfString>(DEBUG_NAME, out debugstring))
            {
                DebugName = debugstring.ToString();
                if (DEBUG_NAME_USELESS.Any(x => DebugName.Contains(x))) // verify if unit isn't a useless data
                    return false;

                //Finish loading data
                NdfLocalisationHash localisation;
                string aString;

                //NAME
                if (!dataobject.TryGetValueFromQuery<NdfLocalisationHash>(UNIT_NAME_HASH, out localisation))
                    if (!dataobject.TryGetValueFromQuery<NdfLocalisationHash>(UNIT_NAME_HASH_ALT, out localisation))
                        return false;
                if (!dictionary.TryGetString(localisation.Value, out aString))
                    return false;
                Name = aString;

                //Description
                if (!dataobject.TryGetValueFromQuery<NdfLocalisationHash>(UNIT_DESCRIPTION_HASH, out localisation))
                    if (!dataobject.TryGetValueFromQuery<NdfLocalisationHash>(UNIT_DESCRIPTION_HASH_ALT, out localisation))
                        return false;
                if (!dictionary.TryGetString(localisation.Value, out aString))
                    return false;
                Description = aString;

                //Icon
                string iconPath;
                NdfString ndfstring = null;
                Bitmap bitmap;
                if (!dataobject.TryGetValueFromQuery<NdfString>(UNIT_ICON, out ndfstring))
                    dataobject.TryGetValueFromQuery<NdfString>(UNIT_ICON_ALT, out ndfstring);
                if (ndfstring != null)
                {
                    string iconpath = ndfstring.ToString().Replace(@"/", @"\").Replace(@"GameData:\", @"pc\texture\").Replace("png", "tgv").ToLower();
                    if (iconPackage.TryToLoadTgv(iconpath, out bitmap)) // must modify icon path first
                        Icon = new Bitmap(bitmap);
                }

                //Faction
                NdfString str;
                if (!dataobject.TryGetValueFromQuery<NdfString>(UNIT_FACTION, out str))
                    return false;

                if (str != null)
                {
                    Faction = FromString2FactionEnum(str.ToString());
                }
                else
                {
                    Faction = FactionEnum.Other;
                }

                //Type
                NdfInt32 ndfint32;
                if (!dataobject.TryGetValueFromQuery<NdfInt32>(UNIT_TYPE, out ndfint32))
                    if (!dataobject.TryGetValueFromQuery<NdfInt32>(UNIT_TYPE_ALT, out ndfint32))
                        return false;
                Type = (ObjectType)ndfint32.Value;

                //COSTS
                NdfUInt32 ndfuint32;
                if (dataobject.TryGetValueFromQuery<NdfUInt32>(UNIT_CASH_COST, out ndfuint32))
                    CashCost = (int)ndfuint32.Value;
                if (dataobject.TryGetValueFromQuery<NdfUInt32>(UNIT_ALU_COST, out ndfuint32))
                    AluminiumCost = (int)ndfuint32.Value;
                if (dataobject.TryGetValueFromQuery<NdfUInt32>(UNIT_ELEC_COST, out ndfuint32))
                    ElectricityCost = (int)ndfuint32.Value;
                if (dataobject.TryGetValueFromQuery<NdfUInt32>(UNIT_REA_COST, out ndfuint32))
                    RareEarthCost = (int)ndfuint32.Value;

                return true;
            }
            else
            {
                return false;
            }
        }