LlamaLogic.Packages
1.2.0
See the version list below for details.
dotnet add package LlamaLogic.Packages --version 1.2.0
NuGet\Install-Package LlamaLogic.Packages -Version 1.2.0
<PackageReference Include="LlamaLogic.Packages" Version="1.2.0" />
paket add LlamaLogic.Packages --version 1.2.0
#r "nuget: LlamaLogic.Packages, 1.2.0"
// Install LlamaLogic.Packages as a Cake Addin #addin nuget:?package=LlamaLogic.Packages&version=1.2.0 // Install LlamaLogic.Packages as a Cake Tool #tool nuget:?package=LlamaLogic.Packages&version=1.2.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 Package();
Loading a package
Pass a Stream
object to LlamaLogic.Packages.Package.FromStream
or LlamaLogic.Packages.Package.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 Package.FromStreamAsync(packageStream);
Important: In order to conserve memory, Package
objects do not load resources from streams until they are requested. It is important to create streams only for use by Package
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 GetResourceKeys
method of a Package
object to be given an IEnumerable<LlamaLogic.Packages.PackageResourceKey>
.
var keys = package.GetResourceKeys();
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 GetResourceContent
or GetResourceContentAsync
method of a Package
object with a PackageResourceKey
to be given a ReadOnlyMemory<byte>
consisting of the resource content.
using System.Text;
var loot_Cauldron_Potion_FeelGood_Success_key =
new PackageResourceKey
(
PackageResourceType.ActionTuning,
0x15,
0x346c3
);
var actionTuningXml =
await package.GetResourceContentAsync
(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 SetResourceContent
method of a Package
object with a PackageResourceKey
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 SaveTo
or SaveToAsync
method with a Stream
object to save current state of the Package
object to that stream.
using var savePackageStream = File.OpenWrite(@"C:\Users\Jessica\Desktop\SnazzyCouchRevised.package");
await package.SaveToAsync(savePackageStream);
Important: If the Package
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 Package
object save to an alternate location (such as one provided by System.IO.Path.GetTempFileName
), dispose of your Package
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 | net5.0 was computed. net5.0-windows was computed. 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. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- SharpZipLib (>= 1.4.2)
- System.Collections.Immutable (>= 8.0.0)
-
net6.0
- SharpZipLib (>= 1.4.2)
- System.Collections.Immutable (>= 8.0.0)
-
net7.0
- SharpZipLib (>= 1.4.2)
- System.Collections.Immutable (>= 8.0.0)
-
net8.0
- SharpZipLib (>= 1.4.2)
- System.Collections.Immutable (>= 8.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.17.0 | 43 | 12/24/2024 |
2.16.0 | 80 | 12/20/2024 |
2.15.2 | 95 | 12/4/2024 |
2.15.1 | 92 | 12/4/2024 |
2.15.0 | 100 | 11/19/2024 |
2.14.0 | 89 | 11/12/2024 |
2.13.2 | 100 | 10/27/2024 |
2.13.1 | 94 | 10/25/2024 |
2.13.0 | 108 | 10/25/2024 |
2.12.3 | 106 | 10/23/2024 |
2.12.2 | 100 | 10/23/2024 |
2.12.1 | 123 | 10/20/2024 |
2.12.0 | 149 | 10/18/2024 |
2.11.0 | 105 | 10/14/2024 |
2.10.0 | 83 | 10/14/2024 |
2.9.0 | 90 | 10/14/2024 |
2.8.0 | 94 | 9/29/2024 |
2.7.1 | 95 | 9/28/2024 |
2.7.0 | 94 | 9/27/2024 |
2.6.0 | 92 | 9/25/2024 |
2.5.0 | 89 | 9/25/2024 |
2.4.0 | 103 | 9/22/2024 |
2.3.0 | 114 | 9/18/2024 |
2.1.5 | 135 | 9/15/2024 |
2.1.4 | 114 | 9/11/2024 |
2.1.3 | 103 | 9/10/2024 |
2.1.2 | 101 | 9/9/2024 |
2.1.1 | 105 | 9/9/2024 |
2.1.0 | 107 | 9/8/2024 |
2.0.2 | 100 | 8/29/2024 |
2.0.1 | 118 | 8/26/2024 |
2.0.0 | 131 | 8/24/2024 |
1.3.0 | 67 | 8/3/2024 |
1.2.4 | 98 | 7/24/2024 |
1.2.3 | 101 | 7/22/2024 |
1.2.2 | 92 | 7/22/2024 |
1.2.1 | 85 | 7/22/2024 |
1.2.0 | 84 | 7/22/2024 |
1.1.0 | 93 | 7/22/2024 |
1.0.1 | 94 | 7/21/2024 |
1.0.0 | 91 | 7/21/2024 |
We added methods to retrieve the complete list of resource names.