private void PrintActiveItems() { var avatars = Game.Instance?.Simulation?.Avatars; if (avatars == null || avatars.Count <= 0) { Logger.Debug("Unable to find any avatars!"); return; } var items = new List <ItemData>(); InventoryExt.GetItems(avatars[0], items, true); foreach (var item in items) { Logger.Debug($"{item.guid} - {item.Hint} - {item.name}"); } foreach (var slot in Player.Inventory.EquipmentSlots) { var data = (ItemData)slot?.equipment?.Entity?.Data; if (data == null) { Logger.Debug($"{slot.slot} - empty"); } else { Logger.Debug($"{slot.slot} - {data.guid} - {data.Hint} - {data.name}"); } } }
public static void SpawnRelic(this Mod mod) { try { var items = new List <ItemData>(); InventoryExt.GetItems(Game.Instance.Simulation.Avatars[0], items, true); var entities = Game.Instance .Simulation .Entities .Entities .Select(t => t.GetExtension <ItemExt>()) .Where(t => t != null) .Select(t => t.Data?.guid); var relics = mod.GameInstance .Data .RelicCollection .Cast <ItemData>() .Where(t => t.IsDiscovered && t.IsUnlocked && !items.Any(a => a.guid == t.guid) && !entities.Any(a => a == t.guid)) .ToArray(); if (relics == null || relics.Length <= 0) { mod.Logger.Warn("No relics exist to spawn!"); return; } var relic = relics[_rnd.Next(0, relics.Length)]; mod.GameInstance.SpawnRelic(relic); mod.Logger.Debug("Spawned random relic"); } catch (Exception ex) { mod.Logger.Error("Error occurred while spawning relic: " + ex); } }