private void OnLoreDiscovery(string eventName, ref EnumHandling handling, IAttribute data) { TreeAttribute tree = data as TreeAttribute; string playerUid = tree.GetString("playeruid"); string category = tree.GetString("category"); IServerPlayer plr = sapi.World.PlayerByUid(playerUid) as IServerPlayer; LoreDiscovery discovery = TryGetRandomLoreDiscovery(sapi.World, plr, category); if (discovery == null) { plr.SendMessage(GlobalConstants.GeneralChatGroup, Lang.Get("Nothing new in these pages"), EnumChatType.Notification); return; } ItemSlot itemslot = plr.InventoryManager.ActiveHotbarSlot; itemslot.TakeOut(1); itemslot.MarkDirty(); plr.Entity.World.PlaySoundAt(new AssetLocation("sounds/effect/writing"), plr.Entity); handling = EnumHandling.PreventDefault; DiscoverLore(discovery, plr); }
/// <summary> Get the currently selected metal for the entity with this behavior </summary> public string GetSelectedMetal() { return(allomancyTree.GetString("selectedMetal")); }
private void OnLoreDiscovery(string eventName, ref EnumHandling handling, IAttribute data) { TreeAttribute tree = data as TreeAttribute; string playerUid = tree.GetString("playeruid"); string category = tree.GetString("category"); IServerPlayer plr = sapi.World.PlayerByUid(playerUid) as IServerPlayer; LoreDiscovery discovery = TryGetRandomLoreDiscovery(sapi.World, plr, category); if (discovery == null) { plr.SendMessage(GlobalConstants.GeneralChatGroup, Lang.Get("Nothing of significance in these pages"), EnumChatType.Notification); return; } handling = EnumHandling.PreventDefault; Journal journal = null; if (!journalsByPlayerUid.TryGetValue(playerUid, out journal)) { journalsByPlayerUid[playerUid] = journal = new Journal(); } JournalEntry entry = null; JournalAsset asset = journalAssetsByCode[discovery.Code]; for (int i = 0; i < journal.Entries.Count; i++) { if (journal.Entries[i].LoreCode == discovery.Code) { entry = journal.Entries[i]; break; } } bool isNew = false; if (entry == null) { journal.Entries.Add(entry = new JournalEntry() { Editable = false, Title = asset.Title, LoreCode = discovery.Code, EntryId = journal.Entries.Count }); isNew = true; } for (int i = 0; i < discovery.PieceIds.Count; i++) { JournalPiecce piece = new JournalPiecce() { Text = asset.Pieces[discovery.PieceIds[i]], EntryId = entry.EntryId }; entry.Chapters.Add(piece); if (!isNew) { serverChannel.SendPacket(piece, plr); } } if (isNew) { serverChannel.SendPacket(entry, plr); } plr.SendMessage(GlobalConstants.GeneralChatGroup, Lang.Get("lorediscovery", entry.Title), EnumChatType.Notification); }