LlamaLogic.Packages
2.0.0
See the version list below for details.
dotnet add package LlamaLogic.Packages --version 2.0.0
NuGet\Install-Package LlamaLogic.Packages -Version 2.0.0
<PackageReference Include="LlamaLogic.Packages" Version="2.0.0" />
paket add LlamaLogic.Packages --version 2.0.0
#r "nuget: LlamaLogic.Packages, 2.0.0"
// Install LlamaLogic.Packages as a Cake Addin #addin nuget:?package=LlamaLogic.Packages&version=2.0.0 // Install LlamaLogic.Packages as a Cake Tool #tool nuget:?package=LlamaLogic.Packages&version=2.0.0
How to install
Using the .NET CLI
Navigate to your project in a terminal and enter the following command:
dotnet add package LlamaLogic.Packages
Using Visual Studio
Follow these steps:
- right-click on your project under Solution Explorer;
- select Manage NuGet Packages...;
- in the Search textbox, enter
LlamaLogic.Packages
; - press the return key;
- select the LlamaLogic.Packages result; and,
- click the Install button.
Common tasks
Creating a new package
Use the constructor of the Package
class.
using LlamaLogic.Packages;
var brandNewCareerMod = new DataBasePackedFile();
Loading a package
Pass a Stream
object to the LlamaLogic.Packages.DataBasePackedFile
constructor or LlamaLogic.Packages.DataBasePackedFile.FromStreamAsync
to be given a package object to examine and/or alter the contents of a package.
using LlamaLogic.Packages;
using var packageStream = File.OpenRead(@"C:\Users\Jessica\Downloads\SnazzyCouch.package");
using var package = await DataBasePackedFile.FromStreamAsync(packageStream);
Important: In order to conserve memory, DataBasePackedFile
objects do not load resources from streams until they are requested. It is important to create streams only for use by DataBasePackedFile
objects and to let them dispose of those streams when they, themselves, are disposed of by you.
Getting the keys of resources in a package
Call the GetKeys
method of a DataBasePackedFile
object to be given an IEnumerable<LlamaLogic.Packages.ResourceKey>
.
var keys = package.GetKeys();
Console.WriteLine($"This package has {keys.Count:n0} resource(s) consisting of the following types: {string.Join(", ", keys.GroupBy(key => key.Type.ToString()).OrderBy(keysGroupedByType => keysGroupedByType.Key /* the type of which all keys in this group are a part */).Select(keysGroupedByType => $"{keysGroupedByType.Key} ({keysGroupedByType.Count():n0})"))}");
Getting the content of a resource in a package
Call the Get
or GetAsync
method of a DataBasePackedFile
object with a ResourceKey
to be given a ReadOnlyMemory<byte>
consisting of the resource content.
using System.Text;
var loot_Cauldron_Potion_FeelGood_Success_key =
new ResourceKey
(
PackageResourceType.ActionTuning,
0x15,
0x346c3
);
var actionTuningXml =
await package.GetAsync
(loot_Cauldron_Potion_FeelGood_Success_key);
var actionTuningXmlString = Encoding.UTF8.GetString(actionTuningXml.Span);
Console.WriteLine("Potion of Plentiful Needs success override:");
Console.WriteLine(actionTuningXmlString);
Note: Packages may contain content which has been compressed. The library abstracts this detail away by performing any decompression which may be needed when you request the content of a resource. You will always be given usable data that is not compacted or encrypted in any way.
Adding or updating the content of a resource in a package
Call the Set
or SetAsync
method of a DataBasePackedFile
object with a ResourceKey
and a ReadOnlySpan<byte>
representing the content of the resource that you wish to add or update.
using System.Linq;
using System.Xml.Linq;
// Kuttoe says you guys shouldn't be getting your jollies from a potion...
var actionTuningXmlDocument = XDocument.Parse(actionTuningXmlString);
var funHygieneAndSocialMotiveStatisticsLootActionsXPathQuery = "./I[@i = 'action' and @c = 'LootActions' and @m = 'interactions.utils.loot']/L[@n = 'loot_actions']/V[@t = 'statistics']/V[@n = 'statistics' and @t = 'statistic_set_max']/U[@n = 'statistic_set_max']/T[@n = 'stat' and normalize-space(text()) = ('16655', '16657', '16658')]/../../..";
var funHygieneAndSocialMotiveStatisticsLootActions =
actionTuningXmlDocument.XPathSelectElements
(funHygieneAndSocialMotiveStatisticsLootActionsQuery)
.ToList().AsReadOnly();
foreach (var lootAction in funHygieneAndSocialMotiveStatisticsLootActions)
lootAction.Remove();
package.SetResourceContent
(
loot_Cauldron_Potion_FeelGood_Success_key,
Encoding.UTF8.GetBytes(actionTuningXmlDocument.ToString())
);
Saving a package
Call the CopyTo
or CopyToAsync
method with a Stream
object to save current state of the DataBasePackedFile
object to that stream.
using var savePackageStream = File.OpenWrite(@"C:\Users\Jessica\Desktop\SnazzyCouchRevised.package");
await package.SaveToAsync(savePackageStream);
Important: If the DataBasePackedFile
object was originally created from a stream, that stream is still in use. Do not pass the same stream to this method, and do not create a new stream writing to the same file. If you intend to save changes to the original file, have your DataBasePackedFile
object save to an alternate location (such as one provided by System.IO.Path.GetTempFileName
), dispose of your DataBasePackedFile
object (causing it to dispose of its underlying original stream), and then overwrite the original file with the one created in the temporary location.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Nito.AsyncEx (>= 5.1.2)
- SharpZipLib (>= 1.4.2)
- System.Collections.Immutable (>= 8.0.0)
- YamlDotNet (>= 16.0.0)
-
net7.0
- Nito.AsyncEx (>= 5.1.2)
- SharpZipLib (>= 1.4.2)
- System.Collections.Immutable (>= 8.0.0)
- YamlDotNet (>= 16.0.0)
-
net8.0
- Nito.AsyncEx (>= 5.1.2)
- SharpZipLib (>= 1.4.2)
- System.Collections.Immutable (>= 8.0.0)
- YamlDotNet (>= 16.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.15.0 | 77 | 11/19/2024 |
2.14.0 | 72 | 11/12/2024 |
2.13.2 | 89 | 10/27/2024 |
2.13.1 | 83 | 10/25/2024 |
2.13.0 | 95 | 10/25/2024 |
2.12.3 | 95 | 10/23/2024 |
2.12.2 | 91 | 10/23/2024 |
2.12.1 | 114 | 10/20/2024 |
2.12.0 | 141 | 10/18/2024 |
2.11.0 | 94 | 10/14/2024 |
2.10.0 | 73 | 10/14/2024 |
2.9.0 | 80 | 10/14/2024 |
2.8.0 | 84 | 9/29/2024 |
2.7.1 | 87 | 9/28/2024 |
2.7.0 | 78 | 9/27/2024 |
2.6.0 | 82 | 9/25/2024 |
2.5.0 | 80 | 9/25/2024 |
2.4.0 | 95 | 9/22/2024 |
2.3.0 | 104 | 9/18/2024 |
2.1.5 | 124 | 9/15/2024 |
2.1.4 | 103 | 9/11/2024 |
2.1.3 | 94 | 9/10/2024 |
2.1.2 | 92 | 9/9/2024 |
2.1.1 | 97 | 9/9/2024 |
2.1.0 | 99 | 9/8/2024 |
2.0.2 | 90 | 8/29/2024 |
2.0.1 | 110 | 8/26/2024 |
2.0.0 | 122 | 8/24/2024 |
1.3.0 | 58 | 8/3/2024 |
1.2.4 | 90 | 7/24/2024 |
1.2.3 | 92 | 7/22/2024 |
1.2.2 | 80 | 7/22/2024 |
1.2.1 | 77 | 7/22/2024 |
1.2.0 | 76 | 7/22/2024 |
1.1.0 | 83 | 7/22/2024 |
1.0.1 | 86 | 7/21/2024 |
1.0.0 | 83 | 7/21/2024 |
We completely rewrote everything and bumped the major version as this release is hecka breaking.
We added:
* in-memory resource content compression;
* zero-heap-allocation streams for SharpZLib compatibility with minimal footprint and maximum performance;
* thread safety for the DBPF package class;
* async method cancellation;
* forward-only stream copy;
* saving in-place;
* legacy resource decompression;
* legacy header fields;
* recognition of the deleted record marker;
* support for Sim Data and Combined Tuning resources;
* support for String Table resources; and,
* support for Mod Manifest resources.