public IPartEntity GetPart(IPartEntity old, XElement element) { Type type = PartNames.GetOrThrow(element.Name.ToString()); var part = old != null && old.GetType() == type ? old : (IPartEntity)Activator.CreateInstance(type); part.FromXml(element, this); return(part); }
protected void AssignMaterial() { if (currentWindowName != "Material Builder") { materialID = EditorGUILayout.Popup("Material", materialID, PartNames.ToArray()); for (int i = 0; i < Materials.Count; ++i) { if (Materials[i] == Materials[materialID]) { objectData.BuffValueMaterial = Materials[i].BuffValueMaterial; } } } }
public SubAssembly(HashSet <Component> nodes, TVGLConvexHull combinedCVXHull, double Mass, double Volume, Vertex centerOfMass) { PartNames = nodes.Select(n => n.name).ToList(); Name = Name = "subasm-" + PartNames.Aggregate((i, j) => i + "," + j); this.Mass = Mass; this.Volume = Volume; //volume of sphere = (4/3)*Math.Pi*r*r*r var radius = Math.Pow(0.75 * Volume / Math.PI, 1.0 / 3.0); AvgMomentofInertia = Mass * radius * radius; CVXHull = combinedCVXHull; CenterOfMass = centerOfMass; }
public void Load(System.IO.Stream stream) { _stream = stream; FileInfo.KeepOpen = true; using (var reader = new FileReader(stream, true)) { reader.ByteOrder = Syroot.BinaryData.ByteOrder.LittleEndian; header = reader.ReadStruct <CTR.NCSD.Header>(); for (int i = 0; i < header.Parts.Length; i++) { if (header.Parts[i].Offset != 0) { string name; if (PartNames.ContainsKey(i)) { name = PartNames[i]; } else { name = "Unknown.cfa"; } //Load the cxi if (i == 0) { ncch = new NCCH(); ncch.FileInfo = new File_Info(); ncch.FileInfo.ParentArchive = this; Console.WriteLine("Length NCCH " + reader.BaseStream.Length); ncch.Load(new SubStream(stream, header.Parts[i].Offset * MediaUnitSize, header.Parts[i].Size * MediaUnitSize)); files.AddRange(ncch.files); } } } } }
public bool PatternMatch(IEnumerable <string> names) { IEnumerable <string> subsetOfDefinitionPartNames = PartNames.Take(names.Count()); return(Enumerable.SequenceEqual(subsetOfDefinitionPartNames, names, StringComparer.InvariantCultureIgnoreCase)); }
public PartFilterSpecification BuildSpecification(bool withBelongsTo = true, List <SortingInformation <Part> > orderby = null) { Query.Where(e => (string.IsNullOrEmpty(Id) || e.Id == Id)); Query.Where(e => (string.IsNullOrEmpty(MainRecordId) || e.MainRecordId == MainRecordId)); if (MainRecordIdIsNull) { Query.Where(e => e.MainRecordId == null); } Query.Where(e => (string.IsNullOrEmpty(RecordEditedBy) || e.RecordEditedBy == RecordEditedBy)); Query.Where(e => (!DraftFromUpload.HasValue || e.DraftFromUpload == DraftFromUpload.Value)); #region appgen: generated query if (Ids?.Count > 0) { if (_exact != null && _exact.ContainsKey("id") && _exact["id"] == 1) { Query.Where(e => Ids.Contains(e.Id)); } else { var predicate = PredicateBuilder.False <Part>(); foreach (var item in Ids) { predicate = predicate.Or(p => p.Id.Contains(item)); } Query.Where(predicate); } } if (PartNames?.Count > 0) { if (_exact != null && _exact.ContainsKey("partname") && _exact["partname"] == 1) { Query.Where(e => PartNames.Contains(e.PartName)); } else { var predicate = PredicateBuilder.False <Part>(); foreach (var item in PartNames) { predicate = predicate.Or(p => p.PartName.Contains(item)); } Query.Where(predicate); } } if (Descriptions?.Count > 0) { if (_exact != null && _exact.ContainsKey("description") && _exact["description"] == 1) { Query.Where(e => Descriptions.Contains(e.Description)); } else { var predicate = PredicateBuilder.False <Part>(); foreach (var item in Descriptions) { predicate = predicate.Or(p => p.Description.Contains(item)); } Query.Where(predicate); } } #endregion if (ShowDraftList > BaseEntity.DraftStatus.All) { Query.Where(e => e.IsDraftRecord == (int)ShowDraftList); } if (_skip.HasValue && _take.HasValue) { Query .Skip(_skip.Value) .Take(_take.Value); } if (orderby?.Count > 0) { foreach (var item in orderby) { if (item.SortType == SortingType.Ascending) { Query.OrderBy(item.Predicate); } else { Query.OrderByDescending(item.Predicate); } } } if (withBelongsTo) { #region appgen: belongsToList #endregion } return(this); }