Mutagen-Modding / Mutagen

A .NET library for analyzing, creating, and manipulating Bethesda mods
GNU General Public License v3.0
121 stars 32 forks source link

TryGetContainingCell documentation #521

Open Noggog opened 6 months ago

Noggog commented 6 months ago

Need to document this tooling (I need to remember myself as well)

var linkCache = ...;
var worldspaceCache =
    new WorldspaceCellLocationCache(state.LoadOrder.PriorityOrder.Cell()
        .WinningContextOverrides(state.LinkCache));
foreach (var placedObjectGetter in state.LoadOrder.PriorityOrder.PlacedObject()
             .WinningContextOverrides(state.LinkCache))
{
    if (placedObjectGetter.TryGetContainingCell(worldspaceCache, out var cell))
    {
        // Found the parent cell, whether it was interior, or exterior
    }
}

essentially used to find both interior and exterior setups, as the exteriors are more complex with worldspace coords and all that