protected void DiscoverEverything(IServerPlayer plr) { JournalAsset[] journalAssets = sapi.World.AssetManager.GetMany <JournalAsset>(sapi.World.Logger, "config/lore/").Values.ToArray(); Journal journal; if (!journalsByPlayerUid.TryGetValue(plr.PlayerUID, out journal)) { journalsByPlayerUid[plr.PlayerUID] = journal = new Journal(); } journal.Entries.Clear(); foreach (var val in journalAssets) { JournalEntry entry = null; journal.Entries.Add(entry = new JournalEntry() { Editable = false, Title = val.Title, LoreCode = val.Code, EntryId = journal.Entries.Count }); serverChannel.SendPacket(entry, plr); foreach (var part in val.Pieces) { JournalChapter piece = new JournalChapter() { Text = part, EntryId = entry.EntryId }; entry.Chapters.Add(piece); serverChannel.SendPacket(piece, plr); } } }
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); }
private void OnJournalPieceReceived(JournalChapter entryPiece) { ownJournal.Entries[entryPiece.EntryId].Chapters.Add(entryPiece); }