public override void LoadTrack() { Keys.ClearEx(); var lookupstruct = Export.GetProperty <StructProperty>("LookupTrack"); if (lookupstruct != null) { var trackKeys = lookupstruct.GetProp <ArrayProperty <StructProperty> >("Points"); //on lookuptrack var posTrack = Export.GetProperty <StructProperty>("PosTrack"); ArrayProperty <StructProperty> points = posTrack?.GetProp <ArrayProperty <StructProperty> >("Points"); if (trackKeys != null) { int keyindex = 0; foreach (var trackKey in trackKeys) { string tooltip = null; if (points != null && points.Count > keyindex) { StructProperty vector = points[keyindex].GetProp <StructProperty>("OutVal"); var point = SharedPathfinding.GetLocationFromVector(vector); tooltip = $"X={point.X},Y={point.Y},Z={point.Z}"; } var time = trackKey.GetProp <FloatProperty>("Time"); Debug.WriteLine(time.Value); Keys.Add(new Key(time, tooltip)); keyindex++; } } } }
public SplinePoint0Node(int idx, float x, float y, IMEPackage p, PathingGraphEditor grapheditor) : base(idx, p, grapheditor) { string s = export.ObjectName; StructProperty splineInfo = export.GetProperty <StructProperty>("SplineInfo"); if (splineInfo != null) { ArrayProperty <StructProperty> pointsProp = splineInfo.GetProp <ArrayProperty <StructProperty> >("Points"); StructProperty point0 = pointsProp[0]; StructProperty point1 = pointsProp[1]; a = PathfindingEditor.GetVector2(point0.GetProp <StructProperty>("OutVal")); tan1 = PathfindingEditor.GetVector2(point0.GetProp <StructProperty>("LeaveTangent")); tan2 = PathfindingEditor.GetVector2(point1.GetProp <StructProperty>("ArriveTangent")); d = PathfindingEditor.GetVector2(point1.GetProp <StructProperty>("OutVal")); // = getType(s); float w = 25; float h = 25; shape = PPath.CreateEllipse(0, 0, w, h); outlinePen = new Pen(color); shape.Pen = outlinePen; shape.Brush = pathfindingNodeBrush; shape.Pickable = false; this.AddChild(shape); this.Bounds = new RectangleF(0, 0, w, h); val = new SText(export.Index + "\nSpline Start"); val.Pickable = false; val.TextAlignment = StringAlignment.Center; val.X = w / 2 - val.Width / 2; val.Y = h / 2 - val.Height / 2; this.AddChild(val); var props = export.GetProperties(); this.TranslateBy(x, y); } }
public void Move(int srcIndex, int destIndex) { if (srcIndex == destIndex) { return; } var sourceExpanded = ArrayProperty.GetArrayElementAtIndex(srcIndex).isExpanded; if (srcIndex < destIndex) { var currentProperty = ArrayProperty.GetArrayElementAtIndex(srcIndex); for (var i = srcIndex + 1; i <= destIndex; i++) { var nextProperty = ArrayProperty.GetArrayElementAtIndex(i); currentProperty.isExpanded = nextProperty.isExpanded; currentProperty = nextProperty; } } else { var currentPropertyExpanded = ArrayProperty.GetArrayElementAtIndex(destIndex).isExpanded; for (var i = destIndex + 1; i <= srcIndex; i++) { var nextProperty = ArrayProperty.GetArrayElementAtIndex(i); var nextPropertyExpanded = nextProperty.isExpanded; nextProperty.isExpanded = currentPropertyExpanded; currentPropertyExpanded = nextPropertyExpanded; } } ArrayProperty.GetArrayElementAtIndex(destIndex).isExpanded = sourceExpanded; ArrayProperty.MoveArrayElement(srcIndex, destIndex); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { var token = JToken.Load(reader); var name = token["NameProperty"].ToString(); PropertyBase prop = null; // by example, it is up to you how you // create an instance of PropertyBase switch (name) { case "string": prop = new StringProperty(); break; case "number": prop = new NumberProperty(); break; case "array": prop = new ArrayProperty(); break; } var ex = new ExampleModel { DifferentProperty = prop }; serializer.Populate(reader, ex); return(ex); }
public void RefreshProperties(SerializedProperty parentProperty, bool includeArraySize) { ArrayProperty = parentProperty.Copy(); var property = ArrayProperty.Copy(); var endProperty = property.GetEndProperty(); property.NextVisible(true); // Expand the first child. properties = new List <SerializedProperty>(); do { if (SerializedProperty.EqualContents(property, endProperty)) { break; } if (property.propertyType == SerializedPropertyType.ArraySize) { ArraySize = property.Copy(); if (includeArraySize) { properties.Add(ArraySize); } } else { properties.Add(property.Copy()); } }while (property.NextVisible(false)); // Never expand children. if (ArraySize == null) { throw new ArgumentException("Can't find array size property!"); } }
public CProperty GetProperty() { // First, read the length and value of the following property name string int propNameLength = GetInt(); string propName = GetString(propNameLength); SkipPadding(); // If this is a "None" ending type property, just return - nothing else will follow this if (propName == "None") { return(null); } // Get the property type string int typeNameLength = GetInt(); string typeName = GetString(typeNameLength); SkipPadding(); // Skip past the size of the following data and its padding GetInt(); SkipPadding(); // Finally, read the data based on the property type CProperty returnProperty; switch (typeName) { case "ArrayProperty": returnProperty = new ArrayProperty(propName, this); break; case "IntProperty": returnProperty = new IntProperty(propName, this); break; case "StrProperty": returnProperty = new StrProperty(propName, this); break; case "NameProperty": returnProperty = new NameProperty(propName, this); break; case "StructProperty": returnProperty = new StructProperty(propName, this, _outputter); break; case "BoolProperty": returnProperty = new BoolProperty(propName, this); break; default: throw new Exception($"Unexpected property type: {typeName}"); } returnProperty.ParseData(); return(returnProperty); }
private bool InventoryEmpty(SaveComponent inventoryComponent) { for (int i = 0; i < inventoryComponent.DataFields.Count; i++) { if (inventoryComponent.DataFields[i].PropertyName == "mInventoryStacks") { ArrayProperty inventoryArray = (ArrayProperty)inventoryComponent.DataFields[i]; for (int j = 0; j < ((ArrayProperty)inventoryComponent.DataFields[i]).Elements.Count; j++) { StructProperty inventoryStruct = (StructProperty)inventoryArray.Elements[j]; DynamicStructData inventoryItem = (DynamicStructData)inventoryStruct.Data; for (int k = 0; k < inventoryItem.Fields.Count; k++) { if (inventoryItem.Fields[k].PropertyName == "NumItems") { IntProperty itemCount = (IntProperty)inventoryItem.Fields[k]; if (itemCount.Value != 0) { return(false); } } } } return(true); } } return(true); }
public static void WriteVectorParameters(ExportEntry export, List <VectorParameter> parameters, string paramName = "VectorParameterValues") { var arr = new ArrayProperty <StructProperty>(paramName); arr.AddRange(parameters.Select(x => x.ToStruct())); export.WriteProperty(arr); }
private Dictionary <uint, Property> FlattenToPropertiesDictionary() { Dictionary <uint, Property> returnDictionary = new Dictionary <uint, Property>(); foreach (PropertyModel prop in displayProperties.OrderBy(p => p.Id).ThenBy(p => p.ArrayIndex)) { if (prop.IsArray) { if (prop.ArrayIndex == 0) { ArrayProperty arrayProp = new ArrayProperty(); arrayProp.PropertyType = prop.Value.GetType(); arrayProp.Values.Add(prop.Value); returnDictionary.Add(prop.Id, arrayProp); } else { ArrayProperty arrayProp = (ArrayProperty)returnDictionary[prop.Id]; arrayProp.Values.Add(prop.Value); } } else { returnDictionary.Add(prop.Id, prop.Value); } } return(returnDictionary); }
public static void BuildStartupPackage() { var weaponAnims = MEPackageHandler.OpenMEPackage(@"C:\Users\mgame\source\repos\ME2Randomizer\ME2Randomizer\staticfiles\binary\WeaponAnims.pcc"); var existingSUF = MEPackageHandler.OpenMEPackage(@"B:\SteamLibrary\steamapps\common\Mass Effect 2\BioGame\DLC\DLC_PRE_General\CookedPC\Startup_PRE_General_int.pcc"); var startupFile = @"C:\Users\mgame\source\repos\ME2Randomizer\ME2Randomizer\staticfiles\binary\Startup_DLC_MOD_ME2Randomizer_INT.pcc"; MEPackageHandler.CreateAndSavePackage(startupFile, MERFileSystem.Game); var startupPackage = MEPackageHandler.OpenMEPackage(startupFile); var objReferencer = existingSUF.FindExport("ObjectReferencer_0"); objReferencer.WriteProperty(new ArrayProperty <ObjectProperty>("ReferencedObjects")); // prevent porting other stuff var sObjRefencer = EntryImporter.ImportExport(startupPackage, objReferencer, 0, true); EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.CloneAllDependencies, weaponAnims.FindExport("WeaponAnimData"), startupPackage, null, true, out _); var referencedObjects = new ArrayProperty <ObjectProperty>("ReferencedObjects"); referencedObjects.AddRange(startupPackage.Exports.Where(x => x.ClassName == "AnimSet").Select(x => new ObjectProperty(x.UIndex))); sObjRefencer.WriteProperty(referencedObjects); startupPackage.Save(compress: true); Debug.WriteLine("Done"); }
void CachePropKeys() { _cacheProperties.Clear(); _cacheInstances.Clear(); _cacheGroups.Clear(); // loads up local cache. double cache is required because it will add values from props later on _cacheInstances = DatabaseManager.Instance.LoadedInstanceIds; // get instance GroupId's from the GroupContainer foreach (uint groupContainer in DatabaseManager.Instance.LoadedGroupIds) { if (!_cacheGroups.Contains(groupContainer)) { _cacheGroups.Add(groupContainer); } } // build up cache for prop files (is a bit more complex due to the value arrays) IEnumerable <DatabaseIndex> propitems = DatabaseManager.Instance.Where(item => item.TypeId == 0xb1b104); foreach (DatabaseIndex item in propitems) { PropertyFile file = new PropertyFile(); byte[] data = item.GetIndexData(true); using (MemoryStream byteStream = new MemoryStream(data)) { file.Read(byteStream); } Dictionary <uint, Property> propertyCollection; propertyCollection = file.Values; foreach (KeyValuePair <uint, Property> prop in propertyCollection) { if (_cacheProperties.Contains(prop.Key) == false) // add Prop key Name { _cacheProperties.Add(prop.Key); } if (prop.Value is ArrayProperty) // add Values from prop array's, these are all instance id's! { ArrayProperty arr = prop.Value as ArrayProperty; try { foreach (KeyProperty subProp in arr.Values) { if (_cacheInstances.Contains(subProp.InstanceId) == false && subProp.InstanceId != 0) { _cacheInstances.Add(subProp.InstanceId); } } } catch { } } } } _cacheReady = true; // set ready flag for threads to continue... }
ConfigProperty ReadConfigArray() { var name = BinaryFile.ReadString(_input); var objects = ReadAnonymousArray(_input); var a = new ArrayProperty(name, objects); return(a); }
private static string GetArrayPropertyType(ArrayProperty ap) { if (ap.ItemType == "Varchar") { return("string[]"); } return(ap.ItemType + "[]"); }
public FingerboardMargin(SILayout layout) : base(layout) { _LastFret = Measure.Empty; _NutMargins = new ArrayProperty <Measure, FingerboardSide>( (s) => s == FingerboardSide.Treble ? _NutTrebleMargin : _NutBassMargin, (s, m) => { if (s == FingerboardSide.Treble) { SetFieldValue(ref _NutTrebleMargin, m, nameof(_NutTrebleMargin)); } else { SetFieldValue(ref _NutBassMargin, m, nameof(_NutBassMargin)); } } ); _BridgeMargins = new ArrayProperty <Measure, FingerboardSide>( (s) => s == FingerboardSide.Treble ? _BridgeTrebleMargin : _BridgeBassMargin, (s, m) => { if (s == FingerboardSide.Treble) { SetFieldValue(ref _BridgeTrebleMargin, m, nameof(_BridgeTrebleMargin)); } else { SetFieldValue(ref _BridgeBassMargin, m, nameof(_BridgeBassMargin)); } } ); _TrebleMargins = new ArrayProperty <Measure, FingerboardEnd>( (s) => s == FingerboardEnd.Nut ? _NutTrebleMargin : _BridgeTrebleMargin, (s, m) => { if (s == FingerboardEnd.Nut) { SetFieldValue(ref _NutTrebleMargin, m, nameof(_NutTrebleMargin)); } else { SetFieldValue(ref _BridgeTrebleMargin, m, nameof(_BridgeTrebleMargin)); } } ); _BassMargins = new ArrayProperty <Measure, FingerboardEnd>( (s) => s == FingerboardEnd.Nut ? _NutBassMargin : _BridgeBassMargin, (s, m) => { if (s == FingerboardEnd.Nut) { SetFieldValue(ref _NutBassMargin, m, nameof(_NutBassMargin)); } else { SetFieldValue(ref _BridgeBassMargin, m, nameof(_BridgeBassMargin)); } } ); }
/// <summary> /// Hack to force power lists to load with only a single check /// </summary> /// <param name="option"></param> /// <returns></returns> public static bool Init(RandomizationOption option) { MERLog.Information(@"Preloading weapon data"); LoadGuns(); WeaponAnimsPackage = MERFileSystem.GetStartupPackage(); WeaponAnimationsArrayProp = WeaponAnimsPackage.FindExport("WeaponAnimData").GetProperty <ArrayProperty <StructProperty> >("WeaponAnimSpecs"); MERLog.Information(@"Installing weapon animations startup package"); MERFileSystem.InstallStartupPackage(); // Contains weapon animations return(true); }
public override Property Copy() { var copy = new ArrayProperty(Info); foreach (var item in this.Value) { copy.Value.Add(item.Copy()); } return(copy); }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { writer.WriteStartObject(); writer.WritePropertyName("ArrayProperty"); ArrayProperty.WriteTo(writer); writer.WritePropertyName("ModelProperty"); ModelProperty.WriteTo(writer); writer.WritePropertyName("ObjectProperty"); ObjectProperty.WriteTo(writer); writer.WriteEndObject(); }
public static void GenerateAOTCollectionFunctions <TProperty, TContainer, TValue>() where TProperty : ICollectionProperty <TContainer, TValue> { TProperty property = default(TProperty); TContainer container = default(TContainer); TValue value = default(TValue); ChangeTracker changeTracker = default(ChangeTracker); var getter = new VisitCollectionElementCallback <TContainer>(); PropertyVisitor propertyVisitor = new PropertyVisitor(); propertyVisitor.TryVisitContainerWithAdapters(property, ref container, ref value, ref changeTracker); propertyVisitor.TryVisitCollectionWithAdapters(property, ref container, ref value, ref changeTracker); propertyVisitor.TryVisitValueWithAdapters(property, ref container, ref value, ref changeTracker); PropertyVisitorAdapterExtensions.TryVisitCollection(null, null, property, ref container, ref value, ref changeTracker); PropertyVisitorAdapterExtensions.TryVisitContainer(null, null, property, ref container, ref value, ref changeTracker); PropertyVisitorAdapterExtensions.TryVisitValue(null, null, property, ref container, ref value, ref changeTracker); var arrayProperty = new ArrayProperty <TContainer, TValue>(); arrayProperty.GetPropertyAtIndex(ref container, 0, ref changeTracker, ref getter); var arrayCollectionElementProperty = new ArrayProperty <TContainer, TValue> .CollectionElementProperty(); arrayCollectionElementProperty.GetValue(ref container); arrayCollectionElementProperty.SetValue(ref container, value); propertyVisitor.VisitProperty <ArrayProperty <TContainer, TValue> .CollectionElementProperty, TContainer, TValue>(arrayCollectionElementProperty, ref container, ref changeTracker); var listProperty = new ListProperty <TContainer, TValue>(); listProperty.GetPropertyAtIndex(ref container, 0, ref changeTracker, ref getter); var listCollectionElementProperty = new ListProperty <TContainer, TValue> .CollectionElementProperty(); listCollectionElementProperty.GetValue(ref container); listCollectionElementProperty.SetValue(ref container, value); propertyVisitor.VisitProperty <ListProperty <TContainer, TValue> .CollectionElementProperty, TContainer, TValue>(listCollectionElementProperty, ref container, ref changeTracker); Actions.GetCollectionCountGetter <TContainer> getCollectionCountGetter = new Actions.GetCollectionCountGetter <TContainer>(); Actions.GetCountFromActualTypeCallback getCountFromActualTypeCallback = new Actions.GetCountFromActualTypeCallback(); getCountFromActualTypeCallback.Invoke <TContainer>(); getCountFromActualTypeCallback.Invoke <TValue>(); Actions.GetCountAtPathGetter <TContainer> getCountAtPathGetter = new Actions.GetCountAtPathGetter <TContainer>(); Actions.VisitAtPathCallback visitAtPathCallback = default; visitAtPathCallback.Invoke <TContainer>(); visitAtPathCallback.Invoke <TValue>(); Actions.SetCountCallback setCountCallback = default; setCountCallback.Invoke <TContainer>(); setCountCallback.Invoke <TValue>(); Actions.TryGetCount(ref container, new PropertyPath(), 0, ref changeTracker, out var count); Actions.TryGetCountImpl(ref container, new PropertyPath(), 0, ref changeTracker, out var otherCount); Actions.GetCount(ref container, new PropertyPath(), 0, ref changeTracker); }
private int MassDismantle(List <SaveObjectModel> objects, ArrayProperty inventory, SaveObjectModel rootItem) { int count = 0; foreach (SaveObjectModel item in objects) { if (item is SaveEntityModel) { if (IsPointInPolygon(((SaveEntityModel)item).Position, polygon) && minZ <= ((SaveEntityModel)item).Position.Z && ((SaveEntityModel)item).Position.Z <= maxZ) { ArrayPropertyViewModel dismantleRefund = ((SaveEntityModel)item).FindField <ArrayPropertyViewModel>("mDismantleRefund"); if (dismantleRefund != null) { foreach (SerializedPropertyViewModel property in dismantleRefund.Elements) { DynamicStructData itemAmountStruct = (DynamicStructData)((StructProperty)property.Model).Data; string itemPath = ((ObjectProperty)itemAmountStruct.Fields[0]).PathName; int itemAmount = ((IntProperty)itemAmountStruct.Fields[1]).Value; byte[] bytes = PrepareForParse(itemPath, itemAmount); using (MemoryStream ms = new MemoryStream(bytes)) using (BinaryReader reader = new BinaryReader(ms)) { SerializedProperty prop = SerializedProperty.Parse(reader); inventory.Elements.Add(prop); } } } if (item.FindField <ObjectPropertyViewModel>("mInventory") != null) { inventory.Elements.AddRange(((ArrayProperty)rootItem.FindChild(item.FindField <ObjectPropertyViewModel>("mInventory").Str2, false).FindField <ArrayPropertyViewModel>("mInventoryStacks").Model).Elements); } if (item.FindField <ObjectPropertyViewModel>("mStorageInventory") != null) { inventory.Elements.AddRange(((ArrayProperty)rootItem.FindChild(item.FindField <ObjectPropertyViewModel>("mStorageInventory").Str2, false).FindField <ArrayPropertyViewModel>("mInventoryStacks").Model).Elements); } if (item.FindField <ObjectPropertyViewModel>("mInputInventory") != null) { inventory.Elements.AddRange(((ArrayProperty)rootItem.FindChild(item.FindField <ObjectPropertyViewModel>("mInputInventory").Str2, false).FindField <ArrayPropertyViewModel>("mInventoryStacks").Model).Elements); } if (item.FindField <ObjectPropertyViewModel>("mOutputInventory") != null) { inventory.Elements.AddRange(((ArrayProperty)rootItem.FindChild(item.FindField <ObjectPropertyViewModel>("mOutputInventory").Str2, false).FindField <ArrayPropertyViewModel>("mInventoryStacks").Model).Elements); } rootItem.Remove(item); count++; } } } return(count); }
private void MenuItem_Click_1(object sender, RoutedEventArgs e) { //Flatten the inheritance of this property file Dictionary <uint, Property> flattenedProperties = new Dictionary <uint, Property>(); flattenedProperties = GetParentProperties(flattenedProperties, FlattenToPropertiesDictionary()); if (flattenedProperties.ContainsKey(0x0A0209B2)) { ArrayProperty excludedProperties = flattenedProperties[0x0A0209B2] as ArrayProperty; if (flattenedProperties.ContainsKey(0x0A0209A2)) { ArrayProperty prop = flattenedProperties[0x0A0209A2] as ArrayProperty; foreach (KeyProperty keyProp in excludedProperties.Values) { prop.Values.RemoveAll(kp => (kp as KeyProperty).InstanceId == keyProp.InstanceId); } } if (flattenedProperties.ContainsKey(0x0A0209A3)) { ArrayProperty prop = flattenedProperties[0x0A0209A3] as ArrayProperty; foreach (KeyProperty keyProp in excludedProperties.Values) { prop.Values.RemoveAll(kp => (kp as KeyProperty).InstanceId == keyProp.InstanceId); } } if (flattenedProperties.ContainsKey(0x0A0209A4)) { ArrayProperty prop = flattenedProperties[0x0A0209A4] as ArrayProperty; foreach (KeyProperty keyProp in excludedProperties.Values) { prop.Values.RemoveAll(kp => (kp as KeyProperty).InstanceId == keyProp.InstanceId); } } if (flattenedProperties.ContainsKey(0x0A0209A5)) { ArrayProperty prop = flattenedProperties[0x0A0209A5] as ArrayProperty; foreach (KeyProperty keyProp in excludedProperties.Values) { prop.Values.RemoveAll(kp => (kp as KeyProperty).InstanceId == keyProp.InstanceId); } } flattenedProperties.Remove(0x0A0209B2); } ReloadDisplayProperties(flattenedProperties); Value_PropertyChanged(this, new EventArgs()); dataGrid1.Items.Refresh(); }
public void RemoveAt(int index) { if (index >= 0 && index < Count) { var currentProperty = ArrayProperty.GetArrayElementAtIndex(index); for (var i = index + 1; i < ArraySize.intValue; i++) { var nextProperty = ArrayProperty.GetArrayElementAtIndex(i); currentProperty.isExpanded = nextProperty.isExpanded; currentProperty = nextProperty; } ArrayProperty.DeleteArrayElementAtIndex(index); } }
public static void AddObjectToSequence(ExportEntry newObject, ExportEntry sequenceExport, bool removeLinks = false) { ArrayProperty <ObjectProperty> seqObjs = sequenceExport.GetProperty <ArrayProperty <ObjectProperty> >("SequenceObjects") ?? new ArrayProperty <ObjectProperty>("SequenceObjects"); seqObjs.Add(new ObjectProperty(newObject)); sequenceExport.WriteProperty(seqObjs); PropertyCollection newObjectProps = newObject.GetProperties(); newObjectProps.AddOrReplaceProp(new ObjectProperty(sequenceExport, "ParentSequence")); newObject.WriteProperties(newObjectProps); if (removeLinks) { RemoveAllLinks(newObject); } newObject.Parent = sequenceExport; }
void ConvertTextureParameters(PropertyReader reader) { ArrayProperty p = reader.GetProperty <ArrayProperty>("TextureParameterValues"); textureParameters = new List <TextureParameterValue>(); foreach (var e in p.props) { StructProperty sp = (StructProperty)e; PropListStruct lp = (PropListStruct)sp.data; PropertyReader lr = new PropertyReader(lp.propsList); textureParameters.Add(new TextureParameterValue { name = lr.GetPropertyStringOrName("ParameterName"), prop = lr.GetProperty <ObjectProperty>("ParameterValue") }); } }
private void btnDebug_Click(object sender, RoutedEventArgs e) { if (this.DataContext.GetType() == typeof(DatabaseIndexData)) { DatabaseIndexData index = (DatabaseIndexData)this.DataContext; //if the text has been changed, create a new modifiedIndex DatabaseIndex originalIndex = DatabaseManager.Instance.Find(i => i.TypeId == index.Index.TypeId && i.GroupContainer == index.Index.GroupContainer && i.InstanceId == index.Index.InstanceId); // originalIndex.IsModified = true; ModifiedPropertyFile propertyFile = new ModifiedPropertyFile(); propertyFile.PropertyFile = new PropertyFile(); propertyFile.PropertyFile.Values = new Dictionary <uint, Property>(); foreach (PropertyModel prop in displayProperties) { if (prop.IsArray) { if (prop.ArrayIndex == 0) { ArrayProperty arrayProp = new ArrayProperty(); arrayProp.PropertyType = prop.Value.GetType(); arrayProp.Values.Add(prop.Value); propertyFile.PropertyFile.Values.Add(prop.Id, arrayProp); } else { ArrayProperty arrayProp = (ArrayProperty)propertyFile.PropertyFile.Values[prop.Id]; arrayProp.Values.Add(prop.Value); } } else { propertyFile.PropertyFile.Values.Add(prop.Id, prop.Value); } } propertyFile.PropertyFile.PropertyCount = (uint)propertyFile.PropertyFile.Values.Count; // // originalIndex.ModifiedData = propertyFile; ViewHexDiff diff = new ViewHexDiff(index.Data, propertyFile.GetData()); diff.ShowDialog(); } }
private void AddProperty(uint id, Property prop) { if (prop is ArrayProperty) { int arrIndex = 0; ArrayProperty arr = prop as ArrayProperty; foreach (Property subProp in arr.Values) { subProp.PropertyChanged += new EventHandler(Value_PropertyChanged); displayProperties.Add(new PropertyModel(id, subProp, true, arrIndex)); arrIndex++; } } else { displayProperties.Add(new PropertyModel(id, prop, false, 0)); } }
private static void SwapRandomBones(int numToSwap, ArrayProperty <NameProperty> trackBoneNames) { if (trackBoneNames.Count < 2) { return; // There is nothing to swap } int i = 0; while (i < numToSwap) { var index1 = trackBoneNames.RandomIndex(); var bn = trackBoneNames[index1]; int numTries = 10; while (numTries > 0 && bonegroupsToNeverRandomize.Any(x => x.Contains(bn.Value, StringComparison.InvariantCultureIgnoreCase))) { index1 = trackBoneNames.RandomIndex(); bn = trackBoneNames[index1]; numTries--; } if (numTries < 0) { return; // Don't try, we could not find a bone to swap to } int index2 = index1; while (numTries > 0 && (index2 == index1 || bonegroupsToNeverRandomize.Any(x => x.Contains(bn.Value, StringComparison.InvariantCultureIgnoreCase)))) { index2 = trackBoneNames.RandomIndex(); bn = trackBoneNames[index2]; numTries--; } if (numTries < 0) { return; // Don't try, we could not find a bone to swap to } // Swap em' var item1 = trackBoneNames[index1]; trackBoneNames[index1] = trackBoneNames[index2]; trackBoneNames[index2] = item1; i++; } }
public bool Apply(SaveObjectModel rootItem) { BuildPolygon(); if (polygon.Length < 2) { MessageBox.Show("At least 2 points needed to mass dismantle", "Could not mass dismantle", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } ArrayProperty inventory = new ArrayProperty("mInventoryStacks") { Type = "StructProperty" }; int countFactory = 0, countBuilding = 0, countCrate = 0; try { countFactory = MassDismantle(rootItem.FindChild("Buildable", true).FindChild("Factory", true).DescendantSelfViewModel, inventory, rootItem); } catch (NullReferenceException) { } try { countBuilding = MassDismantle(rootItem.FindChild("Buildable", true).FindChild("Building", true).DescendantSelfViewModel, inventory, rootItem); } catch (NullReferenceException) { } try { countCrate = MassDismantle(rootItem.FindChild("-Shared", true).FindChild("BP_Crate.BP_Crate_C", true).DescendantSelfViewModel, inventory, rootItem); } catch (NullReferenceException) { } if (countFactory + countBuilding + countCrate == 0) { MessageBox.Show("Nothing was dismantled. Make sure the coordinates are correct and in clockwise order.", "Mass dismantle", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } MessageBoxResult result = MessageBox.Show($"Dismantled {countFactory} factory buildings, {countBuilding} foundations and {countCrate} crates. Drop the items (including items in storages) in a single crate?", "Dismantled", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { CreateCrateEntityFromInventory(rootItem, inventory); } return(true); }
private static void buildPlotElementObject(ArrayProperty <StructProperty> plotStreaming, SquadmateInfoSingle sqm, MEGame game, bool isExplore) { var fName = sqm.HenchPackage; var virtualChunk = $@"BioH_{sqm.HenchName}"; if (game.IsGame3() && isExplore) { fName += @"_Explore"; virtualChunk += @"_Explore"; } var element = plotStreaming.FirstOrDefault(x => x.GetProp <NameProperty>(@"VirtualChunkName").Value == virtualChunk); if (element != null) { var elem = element.GetProp <ArrayProperty <StructProperty> >(@"Elements"); sqm.MemberAppearanceValue = elem.Count; elem.Add(GeneratePlotStreamingElement(fName, sqm.ConditionalIndex)); } }
object[] ReadArray(BitStream stream) { int maxElements = ArrayElements.Value; byte numBits = 1; while ((maxElements >>= 1) != 0) { numBits++; } uint elementCount = stream.ReadUInt(numBits); object[] retVal = new object[elementCount]; for (int i = 0; i < elementCount; i++) { retVal[i] = ArrayProperty.Decode(stream); } return(retVal); }
/// <summary> /// Randomizes the export. Does not check CanRandomize() /// </summary> /// <param name="export"></param> /// <param name="option"></param> private static void RandomizeInternal(ExportEntry export, RandomizationOption option) { var props = export.GetProperties(); ArrayProperty <StructProperty> m_aMorphFeatures = props.GetProp <ArrayProperty <StructProperty> >("m_aMorphFeatures"); if (m_aMorphFeatures != null) { foreach (StructProperty morphFeature in m_aMorphFeatures) { FloatProperty offset = morphFeature.GetProp <FloatProperty>("Offset"); if (offset != null) { //Debug.WriteLine("Randomizing morph face " + Path.GetFilePath(export.FileRef.FilePath) + " " + export.UIndex + " " + export.FullPath + " offset"); offset.Value = offset.Value * ThreadSafeRandom.NextFloat(1 - (option.SliderValue / 3), 1 + (option.SliderValue / 3)); } } } ArrayProperty <StructProperty> m_aFinalSkeleton = props.GetProp <ArrayProperty <StructProperty> >("m_aFinalSkeleton"); if (m_aFinalSkeleton != null) { foreach (StructProperty offsetBonePos in m_aFinalSkeleton) { StructProperty vPos = offsetBonePos.GetProp <StructProperty>("vPos"); if (vPos != null) { //Debug.WriteLine("Randomizing morph face " + Path.GetFilePath(export.FileRef.FilePath) + " " + export.UIndex + " " + export.FullPath + " vPos"); FloatProperty x = vPos.GetProp <FloatProperty>("X"); FloatProperty y = vPos.GetProp <FloatProperty>("Y"); FloatProperty z = vPos.GetProp <FloatProperty>("Z"); x.Value = x.Value * ThreadSafeRandom.NextFloat(1 - option.SliderValue, 1 + option.SliderValue); y.Value = y.Value * ThreadSafeRandom.NextFloat(1 - option.SliderValue, 1 + option.SliderValue); z.Value = z.Value * ThreadSafeRandom.NextFloat(1 - (option.SliderValue / .85), 1 + (option.SliderValue / .85)); } } } export.WriteProperties(props); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Visit configuration array. </summary> /// <remarks> Neil MacMullen, 18/02/2011. </remarks> /// <param name="node"> The node. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// protected override void VisitArrayProperty(ArrayProperty node) { //bool oneLinePerEntry = false; AppendLineIndented(node.Name + "[]="); ExpandNestedArray(node.ToList()); _text.AppendLine(";"); base.VisitArrayProperty(node); }
ConfigProperty ReadConfigArray() { var name = BinaryFile.ReadString(_input); var objects = ReadAnonymousArray(_input); var a = new ArrayProperty(name, objects); return a; }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Visit array property. </summary> /// <param name="node"> The node. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// protected virtual void VisitArrayProperty(ArrayProperty node) { //nothing to be done for array - client is expected to recurse it themselves }
// This is for saying the array length is determined somehow public ArraySizeAttribute(ArrayProperty prop) { this.info = (ArrayInfo)Enum.Parse(typeof(ArrayInfo), prop.ToString()); }