public override void Save() { Patch.Files.Add(HzdCore.EnsureExt(Source)); Paths.CheckDirectory(Path.GetDirectoryName(FilePath)); Binary.ToFile(FilePath); }
private async Task <List <Outfit> > GetOutfits(HzdCore core, Dictionary <BaseGGUUID, string> variantFiles) { var items = core.GetTypes <InventoryEntityResource>(); var itemComponents = core.GetTypesById <InventoryItemComponentResource>(); var componentResources = core.GetTypesById <NodeGraphComponentResource>(); var overrides = core.GetTypesById <OverrideGraphProgramResource>(); var mappings = core.GetTypesById <NodeGraphHumanoidBodyVariantUUIDRefVariableOverride>(); var outfits = new List <Outfit>(); foreach (var item in items) { var outfit = new Outfit() { Name = item.Name.ToString().Replace("InventoryEntityResource", "") }; foreach (var component in item.EntityComponentResources) { if (itemComponents.TryGetValue(component.GUID, out var invItem)) { outfit.LocalName = await IoC.Localization.GetString( invItem.LocalizedItemName.ExternalFile?.ToString(), invItem.LocalizedItemName.GUID); } if (componentResources.TryGetValue(component.GUID, out var compRes)) { var overrideRef = compRes.OverrideGraphProgramResource; if (overrideRef?.GUID == null || !overrides.TryGetValue(overrideRef.GUID, out var rOverride)) { continue; } foreach (var mapRef in rOverride.VariableOverrides) { if (mappings.TryGetValue(mapRef.GUID, out var mapItem)) { outfit.ModelId = mapItem.Object.GUID; outfit.RefId = mapItem.ObjectUUID; if (variantFiles.TryGetValue(outfit.ModelId, out var modelFile)) { outfit.ModelFile = modelFile; } break; } } } } outfits.Add(outfit); } return(outfits); }
public static List <StreamingRef <HumanoidBodyVariant> > GetPlayerModels(HzdCore core) { var resource = core.GetTypes <BodyVariantComponentResource>().FirstOrDefault(); if (resource == null) { throw new HzdException("Unable to find PlayerBodyVariants"); } return(resource.Variants); }
private ProgramParameter GetMenuMusicParam(HzdCore core) { var node = core.GetType <NodeConstantsResource>(); var param = node?.Parameters.FirstOrDefault(); if (param == null) { throw new HzdException($"Unable to find menu music program parameter"); } return(param); }
private MenuAnimationResource GetIntroMenu(HzdCore core) { var menuName = IoC.Get <MiscConfig>().IntroMenuName; var menu = core.GetTypes <MenuAnimationResource>().FirstOrDefault(x => x.Name == menuName); if (menu == null) { throw new HzdException($"Unable to find intro menu with name: {menuName}"); } return(menu); }
public static async Task <HzdCore> GetRefCoreAsync(HzdCore core, BaseRef reference) { if (reference != null) { if (reference.Type == BaseRef.Types.LocalCoreUUID || reference.Type == BaseRef.Types.UUIDRef) { return(core); } if (reference.Type == BaseRef.Types.ExternalCoreUUID || reference.Type == BaseRef.Types.StreamingRef) { return(await IoC.Archiver.LoadGameFileAsync(reference.ExternalFile)); } } return(await Task.FromResult <HzdCore>(null)); }
public static HzdCore GetRefCore(HzdCore core, BaseRef reference) { if (reference != null) { if (reference.Type == BaseRef.Types.LocalCoreUUID || reference.Type == BaseRef.Types.UUIDRef) { return(core); } if (reference.Type == BaseRef.Types.ExternalCoreUUID || reference.Type == BaseRef.Types.StreamingRef) { return(IoC.Archiver.LoadGameFile(reference.ExternalFile)); } } return(null); }
public HzdCore AddFile(string file) { var subPath = NormalizeSubPath(HzdCore.EnsureExt(file)); var path = Path.Combine(WorkingDir, subPath); var core = Files.Contains(subPath) ? HzdCore.FromFile(path, subPath) : IoC.Archiver.LoadGameFile(subPath); var patchCore = new HzdCorePatch(core) { Patch = this, FilePath = path }; return(patchCore); }
private bool UpdateLinks(int[][] fileLinks, string filepath, string name) { var fileCore = HzdCore.FromFile(filepath, name); // Regenerate links for this specific file (don't forget to remove duplicates (Distinct()!!!)) var newLinks = fileCore.Binary.GetAllReferences() .Where(x => x.Type == BaseRef.Types.ExternalCoreUUID) .Select(x => Files[x.ExternalFile.Value]) .Distinct() .ToArray(); var oldLinks = fileLinks[Files[name]].ToHashSet(); if (!oldLinks.SetEquals(newLinks)) { fileLinks[Files[name]] = newLinks; return(true); } return(false); }
public bool Rebuild(Patch patch) { var sizeChanged = false; var linksChanged = false; var links = GetLinks(); foreach (var file in patch.Files) { //only operate on .core files var fileName = HzdCore.NormalizeSource(file); if (Files.TryGetValue(fileName, out int idx)) { var filePath = Path.Combine(patch.WorkingDir, HzdCore.EnsureExt(file)); var length = (int)new FileInfo(filePath).Length; if (Data.Sizes[idx] != length) { sizeChanged = true; Data.Sizes[idx] = length; } if (UpdateLinks(links, filePath, fileName)) { linksChanged = true; } } } if (linksChanged) { RebuildLinks(links); } return(sizeChanged || linksChanged); }
public HzdCorePatch(HzdCore core) { Source = core.Source; Binary = core.Binary; }