private NdfObject CopyInstance(NdfObject instToCopy) { NdfObject newInst = instToCopy.Class.Manager.CreateInstanceOf(instToCopy.Class, instToCopy.IsTopObject); _copyInstanceResults.Add(newInst); foreach (var propertyValue in instToCopy.PropertyValues) { if (propertyValue.Type == NdfType.Unset) { continue; } var receiver = newInst.PropertyValues.Single(x => x.Property == propertyValue.Property); receiver.Value = GetCopiedValue(propertyValue); } instToCopy.Class.Instances.Add(newInst); var cls = Classes.SingleOrDefault(x => x.Object == instToCopy.Class); if (cls != null) { cls.Instances.Add(new NdfObjectViewModel(newInst, cls.ParentVm)); } return(newInst); }
/// <summary> /// Reads the object instances. /// </summary> /// <param name="ms"></param> /// <param name="owner"></param> /// <returns></returns> protected List <NdfObject> ReadObjects(Stream ms, NdfBinary owner) { var objects = new List <NdfObject>(); uint instanceCount = ReadChunk(ms, owner); NdfFooterEntry objEntry = owner.Footer.Entries.Single(x => x.Name == "OBJE"); ms.Seek(objEntry.Offset, SeekOrigin.Begin); for (uint i = 0; i < instanceCount; i++) { long objOffset = ms.Position; try { NdfObject obj = ReadObject(ms, i, owner); obj.Offset = objOffset; objects.Add(obj); }catch (Exception e) { throw e; } } return(objects); }
public new bool LoadData(NdfObject dataobject, IrisZoomDataApi.TradManager dictionary, IrisZoomDataApi.TradManager dictionary2, IrisZoomDataApi.EdataManager iconPackage) { NdfSingle ndfFloat32; NdfCollection ndfCollection; // Traerse speed TraverseSpeed = 0; if (dataobject.TryGetValueFromQuery<NdfSingle>(ROTATION_SPEED_PROPERTY, out ndfFloat32)) TraverseSpeed = ndfFloat32.Value; // Weapons if (dataobject.TryGetValueFromQuery<NdfCollection>(WEAPONS_PROPERTY, out ndfCollection)) { List<CollectionItemValueHolder> weaponss = ndfCollection.InnerList.FindAll(x => x.Value is NdfObjectReference); List<NdfObjectReference> weapons = new List<NdfObjectReference>(); foreach (CollectionItemValueHolder w in weaponss) { weapons.Add(w.Value as NdfObjectReference); } AoAWeapon weapon; foreach (NdfObjectReference w in weapons) { weapon = new AoAWeapon(Prefix); if (weapon.LoadData(w.Instance, dictionary, dictionary2, iconPackage)) Weapons.Add(weapon); } } return true; }
protected NdfObject ParseObject(byte[] data, uint index, long objOffset) { var instance = new NdfObject { Id = index, Data = data, Offset = objOffset }; using (var ms = new MemoryStream(data)) { var buffer = new byte[4]; ms.Read(buffer, 0, buffer.Length); int classId = BitConverter.ToInt32(buffer, 0); var cls = instance.Class = Classes.SingleOrDefault(x => x.Id == classId); if (cls == null) { throw new InvalidDataException("Object without class found."); } cls.Instances.Add(instance); _allInstances.Add(instance); NdfPropertyValue prop; bool triggerBreak; // Read properties while (ms.Position < ms.Length) { prop = new NdfPropertyValue(instance); instance.PropertyValues.Add(prop); ms.Read(buffer, 0, buffer.Length); prop.Property = cls.Properties.Single(x => x.Id == BitConverter.ToInt32(buffer, 0)); var res = ReadValue(ms, out triggerBreak, prop); //prop.Type = res.Key; prop.Value = res; if (triggerBreak) { break; } } foreach (var property in instance.Class.Properties) { if (instance.PropertyValues.All(x => x.Property != property)) { instance.PropertyValues.Add(new NdfPropertyValue(instance) { Property = property, Value = new NdfNull(0) }); } } } return(instance); }
public static object GetInstancePropertyValue <DataType>(this NdfObject instance, string propertyName) { var val = instance.PropertyValues.FirstOrDefault(pv => pv.Property.Name == propertyName)?.Value; if (typeof(DataType) == typeof(double)) { return((val == null || val is NdfNull) ? 0 : double.Parse(val.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture)); } if (typeof(DataType) == typeof(bool)) { return((val != null && !(val is NdfNull)) && bool.Parse(val.ToString())); } if (typeof(DataType) == typeof(int)) { return((val == null || val is NdfNull) ? 0 : int.Parse(val.ToString())); } if (typeof(DataType) == typeof(string)) { return((val == null || val is NdfNull) ? "" : val.ToString()); } if (typeof(DataType) == typeof(float)) { return((val == null || val is NdfNull) ? 0 : float.Parse(val.ToString())); } if (typeof(DataType) == typeof(UInt32)) { return((val == null || val is NdfNull) ? 0 : UInt32.Parse(val.ToString())); } if (typeof(DataType) == typeof(int[])) { return (val == null || val is NdfNull) ? new[] { 0 } } : (val as NdfCollection).Select(x => int.Parse(x.Value.ToString())).ToArray(); if (typeof(DataType) == typeof(Dictionary <int, int>)) { var dic = new Dictionary <int, int>(); if (val == null || val is NdfNull) { return(dic); } var maplist = val as NdfMapList; foreach (var item in maplist) { var entry = item.Value as NdfMap; var key = (int)(entry.Key.Value as NdfInt32).Value; var valueHolder = entry.Value as MapValueHolder; var value = (int)(valueHolder.Value as NdfInt32).Value; dic.Add(key, value); } return(dic); } return(null); } }
private string GetCountry(NdfObject unit) { var propertyList = unit.PropertyValues.Where(p => p.Property.Name == "MotherCountry"); if (propertyList.Count() > 0) { return(propertyList.First().Value.ToString()); } return("UNKNOWN"); }
private string GetName(NdfObject unit) { var propertyList = unit.PropertyValues.Where(p => p.Property.Name == "ClassNameForDebug"); if (propertyList.Count() > 0) { return(propertyList.First().Value.ToString()); } return("UNKNOWN"); }
private void AddInstanceExecute(object obj) { MessageBoxResult mb = MessageBox.Show("Do you want the new instance to be top level?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question); NdfObject inst = Object.Manager.CreateInstanceOf(Object, mb == MessageBoxResult.Yes); Object.Instances.Add(inst); Instances.Add(new NdfObjectViewModel(inst, ParentVm)); }
public void LoadInstance() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass(className); NdfObject obj = claass.Instances[0]; Assert.IsTrue(obj.PropertyValues.Count > 0); }
public void ReadCost() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass("TUniteDescriptor"); NdfObject obj = claass.Instances[1]; NdfUInt32 refef; Assert.IsTrue(obj.TryGetValueFromQuery <NdfUInt32>(UNIT_REA_COST, out refef)); }
private bool IsCommander(NdfObject unit) { var modulesProperty = unit.PropertyValues.Where(p => p.Property.Name == "Modules").First(); var modules = (NdfCollection)modulesProperty.Value; var commandMagagerModule = modules.Where(m => ((NdfStringReference)((NdfString)((NdfMap)m.Value).Key.Value).Value).Value == "CommandManager").ToList(); if (commandMagagerModule.Count > 0) { return(true); } return(false); }
public void LoadProperty() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass(className); NdfObject obj = claass.Instances[1]; NdfString uint32; obj.TryGetValueFromQuery <NdfString>(UNIT_ICON, out uint32); }
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); } }
private bool IsPrototype(NdfObject unit) { var isPrototypePropertyList = unit.PropertyValues.Where(p => p.Property.Name == "IsPrototype"); if (isPrototypePropertyList.Count() > 0) { if (isPrototypePropertyList.First().Value.GetType() != typeof(NdfNull)) { return(true); } } return(false); }
public void QueryReference() { EdataManager datamana = new EdataManager(ndffile); datamana.ParseEdataFile(); NdfbinManager ndfbin = datamana.ReadNdfbin(ndfbinfile); NdfClass claass = ndfbin.GetClass("TUniteDescriptor"); NdfObject obj = claass.Instances[1]; NdfObjectReference refef; string query = "Modules.TypeUnit.Default"; Assert.IsTrue(obj.TryGetValueFromQuery <NdfObjectReference>(query, out refef)); }
private List <Specializations> GetAvailableSpecializations(NdfObject unit) { List <Specializations> specs = new List <Specializations>(); var specProperty = unit.PropertyValues.Where(p => p.Property.Name == "UnitTypeTokens").First(); if (specProperty.Value.GetType() == typeof(NdfCollection)) { foreach (var specPropertyValue in (NdfCollection)specProperty.Value) { string hash = ((NdfLocalisationHash)specPropertyValue.Value).ToString(); specs.Add(specializations[hash]); } } return(specs); }
private uint GetUnitPropertyValue(NdfObject unit, string propertyName) { uint value = 0; var propertyList = unit.PropertyValues.Where(p => p.Property.Name == propertyName); if (propertyList.Count() > 0) { var property = propertyList.First(); if (property.Value.GetType() == typeof(NdfUInt32)) { value = (UInt32)((NdfUInt32)property.Value).Value; } else if (property.Value.GetType() == typeof(NdfInt32)) { value = (uint)(Int32)((NdfInt32)property.Value).Value; } } return(value); }
private List <uint> GetAvailableVeterancy(NdfObject unit) { List <uint> veterancy = new List <uint>(); var maxDeployableAmountProperty = unit.PropertyValues.Where(p => p.Property.Name == "MaxDeployableAmount").First(); if (maxDeployableAmountProperty.Value.GetType() == typeof(NdfCollection)) { var deployableAmountList = (NdfCollection)maxDeployableAmountProperty.Value; uint i = 0; foreach (var deployableAmount in deployableAmountList) { int amount = (Int32)((NdfInt32)deployableAmount.Value).Value; if (amount > 0) { veterancy.Add(i); } i++; } } return(veterancy); }
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 }
private List <uint> GetTransportsIds(NdfObject unit) { var modulesProperty = unit.PropertyValues.Where(p => p.Property.Name == "Modules").First(); var modules = (NdfCollection)modulesProperty.Value; var filteredList = modules.Where(m => ((NdfStringReference)((NdfString)((NdfMap)m.Value).Key.Value).Value).Value == "Transportable").ToList(); List <uint> transportIdList = new List <uint>(); if (filteredList.Count > 0) { var transportModule = filteredList[0]; var propertyValues = ((NdfObjectReference)((MapValueHolder)((NdfMap)transportModule.Value).Value).Value).Instance.PropertyValues; var propertyValue = propertyValues.Where(p => p.Property.Name == "TransportListAvailableForSpawn").First(); if (propertyValue.Value.GetType() == typeof(NdfCollection)) { var transportList = (NdfCollection)propertyValue.Value; foreach (var transportReference in transportList) { var transportMovingTypeProperty = ((NdfObjectReference)transportReference.Value).Instance.PropertyValues.Where(p => p.Property.Name == "UnitMovingType").First(); int movingType = (int)((NdfInt32)transportMovingTypeProperty.Value).Value; //if (movingType != 9) { uint transportId = instanceIdToUnitId[(uint)(int)((NdfObjectReference)transportReference.Value).InstanceId]; transportIdList.Add(transportId); List <uint> transportUpgrades = new List <uint>(); while (unitUpgradeTree.ContainsKey(transportId)) { transportUpgrades.Add(unitUpgradeTree[transportId]); transportId = unitUpgradeTree[transportId]; } transportIdList.AddRange(transportUpgrades); //} } } } return(transportIdList); }
public Unit(String country, String name, NdfObject ndfHandle) { _qualifiedName = country + " - " + name; _name = name; _ndfHandle = ndfHandle; // Get which tab the unit is in NdfPropertyValue factory; if (ndfHandle.TryGetProperty("Factory", out factory)) { String factoryString = factory.Value.ToString(); switch (factoryString) { case "3": _factory = "Logistic"; break; case "6": _factory = "Infantry"; break; case "7": _factory = "Plane"; break; case "8": _factory = "Vehicle"; break; case "9": _factory = "Tank"; break; case "10": _factory = "Recon"; break; case "11": _factory = "Helo"; break; case "12": _factory = "Wasted dev time"; break; case "13": _factory = "Support"; break; default: _factory = factoryString; break; } } }
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; } }
private uint GetYear(NdfObject unit) { return(GetUnitPropertyValue(unit, "ProductionYear")); }
private uint GetCategory(NdfObject unit) { return(GetUnitPropertyValue(unit, "Factory")); }
/// <summary> /// Reads one object instance. /// </summary> /// <param name="ms"></param> /// <param name="index"></param> /// <param name="owner"></param> /// <returns></returns> protected NdfObject ReadObject(Stream ms, uint index, NdfBinary owner) { var instance = new NdfObject { Id = index }; if (owner.TopObjects.Contains(index)) { instance.IsTopObject = true; } var buffer = new byte[4]; ms.Read(buffer, 0, buffer.Length); int classId = BitConverter.ToInt32(buffer, 0); if (owner.Classes.Count < classId) { throw new InvalidDataException("Object without class found."); } NdfClass cls = instance.Class = owner.Classes[classId]; cls.Instances.Add(instance); // Read properties for (; ;) { ms.Read(buffer, 0, buffer.Length); uint propertyId = BitConverter.ToUInt32(buffer, 0); if (propertyId == 0xABABABAB) { break; } var propVal = new NdfPropertyValue(instance) { Property = cls.Properties.SingleOrDefault(x => x.Id == propertyId) }; if (propVal.Property == null) { // throw new InvalidDataException("Found a value for a property which doens't exist in this class."); foreach (var c in owner.Classes) { foreach (var p in c.Properties) { if (p.Id == propertyId) { propVal.Property = p; break; } } } } instance.PropertyValues.Add(propVal); NdfValueWrapper res = ReadValue(ms, owner); propVal.Value = res; } owner.AddEmptyProperties(instance); return(instance); }
public new bool LoadData(NdfObject dataobject, TradManager dictionary, TradManager dictionary2, EdataManager iconPackage) { NdfUInt32 ndfuint32; NdfSingle ndfFloat32; NdfInt32 ndfInt32; NdfObject ndfObject; NdfCollection ndfCollection; // HP if (!dataobject.TryGetValueFromQuery<NdfSingle>(DAMMAGE_PATH, out ndfFloat32)) return false; Health = ndfFloat32.Value; // Armor Armor = 0; if (dataobject.TryGetValueFromQuery<NdfUInt32>(ARMOR_PATH, out ndfuint32)) Armor = (int)ndfuint32.Value; //POW if (dataobject.TryGetValueFromQuery<NdfUInt32>(POW_PATH, out ndfuint32)) nbrPOW = (int)ndfuint32.Value; //AutoReveal if (!dataobject.TryGetValueFromQuery<NdfInt32>(AUTOREVEAL_PATH, out ndfInt32)) return false; AutoReveal = ndfInt32.Value == 2; //Transporter if (dataobject.TryGetValueFromQuery<NdfInt32>(TRANSPORT_PATH, out ndfInt32)) { TransportSlot = ndfInt32.Value; } else { TransportSlot = 0; } //Stealth if (!dataobject.TryGetValueFromQuery<NdfSingle>(STEALTH_PATH, out ndfFloat32)) return false; IsStealthy = ndfFloat32.Value >= 50f; // vIEW RANGE if (dataobject.TryGetValueFromQuery<NdfSingle>(VIEW_RANGE_PATH, out ndfFloat32)) { ViewRange = ndfFloat32.Value; } else { ViewRange = 0; } // Slot Taken if(dataobject.TryGetValueFromQuery<NdfInt32>(TRANSPORTABLE_PATH, out ndfInt32)) { SlotTaken = ndfInt32.Value; } else { SlotTaken = 0; } //Turrets if(dataobject.TryGetValueFromQuery<NdfCollection>(TURRET_LIST_PATH, out ndfCollection)) { List<CollectionItemValueHolder> turrs = ndfCollection.InnerList.FindAll(x => x.Value is NdfObjectReference); List<NdfObjectReference> turrets = new List<NdfObjectReference>(); foreach (CollectionItemValueHolder turr in turrs) { turrets.Add(turr.Value as NdfObjectReference); } AoATurret turret; int turrentNum = 1; foreach(NdfObjectReference turr in turrets) { turret = new AoATurret("T" + turrentNum++); if(turret.LoadData(turr.Instance, dictionary, dictionary2, iconPackage)) Turrets.Add(turret); } }// a tester //Vehicle // Speed if(!dataobject.TryGetValueFromQuery<NdfSingle>(SPEED_PATH, out ndfFloat32)) return false; Speed = ndfFloat32.Value; OnRoadSpeed = Speed; if (dataobject.TryGetValueFromQuery<NdfSingle>(ROAD_BONUS, out ndfFloat32)) OnRoadSpeed *= ndfFloat32.Value ; // Upgrades if (dataobject.TryGetValueFromQuery<NdfCollection>(AVAILABLE_RESEARCHES_PATH, out ndfCollection)) { List<CollectionItemValueHolder> ress = ndfCollection.InnerList.FindAll(x => x.Value is NdfObjectReference); List<NdfObjectReference> researches = new List<NdfObjectReference>(); foreach (CollectionItemValueHolder uni in ress) { researches.Add(uni.Value as NdfObjectReference); } AoAResearch aResearch; foreach (NdfObjectReference research in researches) { aResearch = new AoAResearch(); if (aResearch.LoadData(research.Instance, dictionary, dictionary2, iconPackage)) // tech.dic ! { Upgrades.Add(aResearch); } } } // UnitChildren NdfObjectReference ndfref; if (dataobject.TryGetValueFromQuery<NdfObjectReference>(CHILD_PATH, out ndfref)) { AoAGameObject obj = new AoAGameObject(); obj.LoadData(ndfref.Instance, dictionary, dictionary2, iconPackage); AoAUnit unit = new AoAUnit(obj); unit.LoadData(ndfref.Instance, dictionary, dictionary2, iconPackage); Children.Add(unit); } else { // Regarder dans technoregistrar ? } return true; }
private uint GetNumberOfCards(NdfObject unit) { return(GetUnitPropertyValue(unit, "MaxPacks")); }
public bool LoadData(NdfObject dataobject, IrisZoomDataApi.TradManager dictionary, IrisZoomDataApi.TradManager dictionary2, IrisZoomDataApi.EdataManager iconPackage) { throw new NotImplementedException(); }
protected static NdfPropertyValue getProperty(NdfObject obj, string str) { return(obj.PropertyValues.Single(x => x.Property.Name.Equals(str))); }
public new bool LoadData(NdfObject dataobject, TradManager dictionary, TradManager techdic, EdataManager iconPackage) { NdfCollection collection; // UNITS if (dataobject.TryGetValueFromQuery<NdfCollection>(PRODUCABLE_UNITS_PATH, out collection)) { List<CollectionItemValueHolder> unitss = collection.InnerList.FindAll(x => x.Value is NdfObjectReference); List<NdfObjectReference> units = new List<NdfObjectReference>(); foreach (CollectionItemValueHolder uni in unitss) { units.Add(uni.Value as NdfObjectReference); } AoAGameObject obj; foreach (NdfObjectReference unit in units) { obj = new AoAGameObject(); if (obj.LoadData(unit.Instance, dictionary, techdic, iconPackage)) if (obj.Type != ObjectType.Building) { AoAUnit aunit = new AoAUnit(obj); if (aunit.LoadData(unit.Instance, dictionary, techdic, iconPackage)) // !!!!! _BuildableUnits.Add(aunit); } } } //Stealth NdfSingle ndfFloat32; IsStealthy = false; if (dataobject.TryGetValueFromQuery<NdfSingle>(STEALTH_PATH, out ndfFloat32)) IsStealthy = ndfFloat32.Value >= 50f; if (dataobject.TryGetValueFromQuery<NdfSingle>(DAMMAGE_PATH, out ndfFloat32)) Health = ndfFloat32.Value; // Armor NdfUInt32 ndfuint32; Armor = 0; if (dataobject.TryGetValueFromQuery<NdfUInt32>(ARMOR_PATH, out ndfuint32)) Armor = (int)ndfuint32.Value; // vIEW RANGE if (dataobject.TryGetValueFromQuery<NdfSingle>(VIEW_RANGE_PATH, out ndfFloat32)) { ViewRange = ndfFloat32.Value; } else { ViewRange = 0; } //Turrets NdfCollection ndfCollection; if (dataobject.TryGetValueFromQuery<NdfCollection>(TURRET_LIST_PATH, out ndfCollection)) { List<CollectionItemValueHolder> turrs = ndfCollection.InnerList.FindAll(x => x.Value is NdfObjectReference); List<NdfObjectReference> turrets = new List<NdfObjectReference>(); foreach (CollectionItemValueHolder turr in turrs) { turrets.Add(turr.Value as NdfObjectReference); } AoATurret turret; int turretNum = 1; foreach (NdfObjectReference turr in turrets) { turret = new AoATurret("T" + turretNum++); if (turret.LoadData(turr.Instance, dictionary, techdic, iconPackage)) Turrets.Add(turret); } } //RESEARCHES if (dataobject.TryGetValueFromQuery<NdfCollection>(AVAILABLE_RESEARCHES_PATH, out collection)) { List<CollectionItemValueHolder> ress = collection.InnerList.FindAll(x => x.Value is NdfObjectReference); List<NdfObjectReference> researches = new List<NdfObjectReference>(); foreach (CollectionItemValueHolder uni in ress) { researches.Add(uni.Value as NdfObjectReference); } AoAResearch aResearch; foreach (NdfObjectReference research in researches) { aResearch = new AoAResearch(); if (aResearch.LoadData(research.Instance, dictionary, techdic, iconPackage)) // tech.dic ! { Researches.Add(aResearch); } } } return true; }
public new bool LoadData(NdfObject dataobject, IrisZoomDataApi.TradManager dictionary, IrisZoomDataApi.TradManager dictionary2, IrisZoomDataApi.EdataManager iconPackage) { NdfBoolean ndfbool; NdfSingle ndffloat32; NdfUInt32 ndfUint32; NdfLocalisationHash ndfHash; string name; // Name if (dataobject.TryGetValueFromQuery<NdfLocalisationHash>(NAME_PROPERTY, out ndfHash)) { if (dictionary.TryGetString(ndfHash.Value, out name)) Name = string.IsNullOrEmpty(Prefix) ? name : Prefix + ": " + name; } else { Name = string.Empty; } //GroundRange if (dataobject.TryGetValueFromQuery<NdfSingle>(MAX_RANGE_PROPERTY, out ndffloat32)) GroundRange = ndffloat32.Value; //Alpha if (!dataobject.TryGetValueFromQuery<NdfSingle>(DAMAGE_PROPERTY, out ndffloat32)) return false; Alpha = ndffloat32.Value; //TBARange if (dataobject.TryGetValueFromQuery<NdfSingle>(HELICOPTER_MAX_RANGE_PROPERTY, out ndffloat32)) VLARange = ndffloat32.Value; //THARange if (dataobject.TryGetValueFromQuery<NdfSingle>(PLANE_MAX_RANGE_PROPERTY, out ndffloat32)) VHARange = ndffloat32.Value; //Splash if (dataobject.TryGetValueFromQuery<NdfSingle>(SPLASH_DAMAGE_RADIUS_PROPERTY, out ndffloat32)) Splash = ndffloat32.Value; //PowGen if (dataobject.TryGetValueFromQuery<NdfSingle>(POW_PROBABILITY_PROPERTY, out ndffloat32)) PoWGen = ndffloat32.Value; //AmBush if (dataobject.TryGetValueFromQuery<NdfSingle>(AMBUSH_MULTIPLIER_PROPERTY, out ndffloat32)) AmbushMultiplier = ndffloat32.Value; // SimulatenousShots if (!dataobject.TryGetValueFromQuery<NdfUInt32>(SIMULTANEOUS_PROJECTILES_PROPERTY, out ndfUint32)) return false; SimulatenousShots = (int)ndfUint32.Value; // MaxShotsPerSalvo if (!dataobject.TryGetValueFromQuery<NdfUInt32>(SHOTS_PER_SALVO_PROPERTY, out ndfUint32)) return false; MaxShotsPerSalvo = (int)ndfUint32.Value; //TimeBetweenShots if (!dataobject.TryGetValueFromQuery<NdfSingle>(TIME_BETWEEN_SHOTS_PROPERTY, out ndffloat32)) return false; TimeBetweenShots = ndffloat32.Value; //Salvo Reload Time if (!dataobject.TryGetValueFromQuery<NdfSingle>(SALVO_RELOAD_TIME_PROPERTY, out ndffloat32)) return false; SalvoReloadTime = ndffloat32.Value; //Aiming Time AimingTime = 0; if (dataobject.TryGetValueFromQuery<NdfSingle>(AIMING_TIME_PROPERTY, out ndffloat32)) AimingTime = ndffloat32.Value; //Noise IsSilenced = false; if (dataobject.TryGetValueFromQuery<NdfSingle>(NOISE, out ndffloat32)) IsSilenced = ndffloat32.Value < 5; //Supress SupressDamages = 0; if (dataobject.TryGetValueFromQuery<NdfSingle>(SUPRESS_DAMAGES, out ndffloat32)) SupressDamages = ndffloat32.Value; if (dataobject.TryGetValueFromQuery<NdfSingle>(AMBUSH_MULTIPLIER_PROPERTY, out ndffloat32)) AmbushMultiplier = ndffloat32.Value; double oneSalvoCycleTime = TimeBetweenShots * MaxShotsPerSalvo + SalvoReloadTime; // sec float nbshotInOneCycle = SimulatenousShots * MaxShotsPerSalvo; double nbCycleInAMinute = 60 / oneSalvoCycleTime; Sustained = nbshotInOneCycle * nbCycleInAMinute * Alpha; return true; }