예제 #1
0
        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);
        }
예제 #2
0
 private void OnJournalPieceReceived(JournalPiecce entryPiece)
 {
     ownJournal.Entries[entryPiece.EntryId].Chapters.Add(entryPiece);
 }