public static DataPreviewViewModel Create(int offset, TagViewModel tag, IH2Map map) { var vm = new DataPreviewViewModel(offset, tag); // TODO: interned strings isn't prebuilt anymore //if(map.InternedStrings.TryGetValue(vm.Short, out var str)) //{ // vm.InternedString = str; //} if (map.TryGetTag(vm.UInt, out BaseTag t)) { vm.TagName = t.Name; } var secondaryOffset = map.GetSecondaryOffset(tag.OriginalTag.DataFile, vm.Int); vm.FileOffset = tag.OriginalTag.DataFile switch { DataFile.Local => secondaryOffset.Value.ToString(), DataFile.MainMenu => "MM-" + secondaryOffset.Value, DataFile.Shared => "MS-" + secondaryOffset.Value, DataFile.SinglePlayerShared => "SS-" + secondaryOffset.Value, }; return(vm); }
public TagPatcher(IH2Map originalMap, Stream mapToPatch) { this.originalMap = originalMap; this.mapToPatch = mapToPatch; this.DataWriters.Add(typeof(ITagRef), WriteTagRef); this.DataWriters.Add(typeof(TagRef), WriteTagRef); this.DataWriters.Add(typeof(TagRef <>), WriteTagRef); this.DataWriters.Add(typeof(Vector3), WriteVec3); }
public static BaseTag CreateTag(uint id, string name, TagIndexEntry index, IH2Map map, MapStream reader) { var tagType = GetTypeForTag(index.Tag); BaseTag tag; if (tagType == null) { tag = new UnknownTag(id, index.Tag.ToString()) { Name = name, Length = (uint)index.DataSize, Offset = (uint)index.Offset.Value, InternalSecondaryMagic = map.SecondaryMagic + index.Offset.Value }; } else { BaseTag instance; // PERF: check ctor existence ahead of time try { //var ctor = tagType.GetConstructor(new[] { typeof(uint) }); //instance = (BaseTag)ctor.Invoke(new object[] { id }); instance = Activator.CreateInstance(tagType, new object[] { id }) as BaseTag; } catch { instance = (BaseTag)FormatterServices.GetUninitializedObject(tagType); } tag = (BaseTag)BlamSerializer.DeserializeInto(instance, tagType, reader.GetStream(map.OriginFile), index.Offset.Value, map.SecondaryMagic, map); } tag.Name = name; tag.TagIndexEntry = index; tag.DataFile = map.OriginFile; tag.PopulateExternalData(reader); return(tag); }
public PrimaryOffset(IH2Map scene, int offsetValue) { this.scene = scene; this.offset = offsetValue; }
public ExplorationTagTreeProcessor(IH2Map scene) { this.scene = scene; }
public static PrimaryOffset PrimaryOffset(this IH2Map scene, int value) { return(new PrimaryOffset(scene, value)); }