Ejemplo n.º 1
0
 private void OnJournalItemsReceived(Journal fullJournal)
 {
     ownJournal = fullJournal;
 }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public void DiscoverLore(LoreDiscovery discovery, IServerPlayer plr)
        {
            string playerUid = plr.PlayerUID;

            Journal journal;

            if (!journalsByPlayerUid.TryGetValue(playerUid, out journal))
            {
                journalsByPlayerUid[playerUid] = journal = new Journal();
            }

            JournalEntry entry = null;

            ensureJournalAssetsLoaded();
            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;
            }

            int partnum   = 0;
            int partcount = asset.Pieces.Length;

            for (int i = 0; i < discovery.ChapterIds.Count; i++)
            {
                JournalChapter chapter = new JournalChapter()
                {
                    Text = asset.Pieces[discovery.ChapterIds[i]], EntryId = entry.EntryId, ChapterId = discovery.ChapterIds[i]
                };
                entry.Chapters.Add(chapter);
                if (!isNew)
                {
                    serverChannel.SendPacket(chapter, plr);
                }

                partnum = discovery.ChapterIds[i];
            }

            if (isNew)
            {
                serverChannel.SendPacket(entry, plr);
            }


            sapi.SendIngameDiscovery(plr, "lore-" + discovery.Code, null, partnum + 1, partcount);
            sapi.World.PlaySoundAt(new AssetLocation("sounds/effect/deepbell"), plr.Entity, null, false, 32, 0.5f);
        }