Exemplo n.º 1
0
            public override void Save()
            {
                Patch.Files.Add(HzdCore.EnsureExt(Source));

                Paths.CheckDirectory(Path.GetDirectoryName(FilePath));
                Binary.ToFile(FilePath);
            }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
 public HzdCorePatch(HzdCore core)
 {
     Source = core.Source;
     Binary = core.Binary;
 }