LlamaLogic.Packages 1.2.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package LlamaLogic.Packages --version 1.2.2                
NuGet\Install-Package LlamaLogic.Packages -Version 1.2.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LlamaLogic.Packages" Version="1.2.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LlamaLogic.Packages --version 1.2.2                
#r "nuget: LlamaLogic.Packages, 1.2.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LlamaLogic.Packages as a Cake Addin
#addin nuget:?package=LlamaLogic.Packages&version=1.2.2

// Install LlamaLogic.Packages as a Cake Tool
#tool nuget:?package=LlamaLogic.Packages&version=1.2.2                

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:

  1. right-click on your project under Solution Explorer;
  2. select Manage NuGet Packages...;
  3. in the Search textbox, enter LlamaLogic.Packages;
  4. press the return key;
  5. select the LlamaLogic.Packages result; and,
  6. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 87 11/19/2024
2.14.0 74 11/12/2024
2.13.2 90 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 95 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 corrected a potential duplicate key exception in resource name indexing.