internal static void FixAllCustomDataItems(ExtraContainerChanges.Data inventory) { if (inventory != null) { var objects = inventory.Objects; if (objects != null) { foreach (var o in objects) { var els = o.ExtraData; if (els != null) { foreach (var edata in els) { uint ex = 0; if (edata != null && (ex = edata.GetCustomData()) != 0 && (ex & 0x80000000) == 0) { edata.SetCustomData(0); } } } } } } }
private bool ProcessInventory(ExtraContainerChanges.Data inventory, TESObjectREFR instance, TESForm item, TESForm owner, int count, uint?cdata = null) { if (inventory == null || item == null) { return(false); } // Special case for references, it might already be handled before. Containers have this check elsewhere. if (instance != null && instance.ExtraDataList.IsStolenForever()) { return(false); } ExtraContainerChanges.ItemEntry entry = null; BSExtraDataList best = null; int bestCount = 0; foreach (var o in inventory.Objects) { var template = o.Template; if (template == null) { continue; } if (!item.Equals(template)) { continue; } entry = o; o.ForeachEntry((data, icount) => { // Already not stolen. var iowner = data != null ? data.GetOwner() : null; if (iowner == null) { return; } if (cdata.HasValue && cdata.Value != data.GetCustomData()) { return; } if (data.IsStolenForever()) { return; } if (!CheckConditions(o, data, item)) { return; } if (best == null || Math.Abs(count - bestCount) > Math.Abs(count - icount)) { best = data; bestCount = icount; } }); break; } if (best == null) { return(false); } this.ApplyResult(entry, best, this.WasDetected); return(true); }