Ejemplo n.º 1
0
    private void OnEntrySelected(UIButton buttonScript)
    {
        //display entry
        CodexEntry item = codexEntries.Find(x => x.title == buttonScript.gameObject.name);

        entryDisplay.Populate(item);
    }
Ejemplo n.º 2
0
    static void UpdateCodex(Codex codex)
    {
        List <DNA>        DNAPool = codex.DNAPool;
        List <CodexEntry> Codex   = codex.CodexEntries;

        //remove empty
        List <CodexEntry> RemovedCodex = Codex.FindAll(c => c.MotherDNA == null || c.FatherDNA == null);

        RemovedCodex.ForEach(c => Codex.Remove(c));

        for (int fatherID = 0; fatherID < DNAPool.Count; fatherID++)
        {
            for (int motherID = 0; motherID < DNAPool.Count; motherID++)
            {
                DNA fatherDNA = DNAPool[fatherID];
                DNA motherDNA = DNAPool[motherID];
                if (fatherDNA == null || motherDNA == null)
                {
                    continue;
                }

                CodexEntry c = Codex.Find(entry => entry.FatherDNA == fatherDNA && entry.MotherDNA == motherDNA);
                if (c != null)
                {
                    continue;
                }

                c           = new CodexEntry();
                c.FatherDNA = fatherDNA;
                c.MotherDNA = motherDNA;
                Codex.Add(c);
            }
        }
    }
 internal CodexEntryEvent InvokeEvent(CodexEntryEvent arg)
 {
     if (_api.ValidateEvent(arg))
     {
         CodexEntry?.Invoke(_api, arg);
     }
     return(arg);
 }
Ejemplo n.º 4
0
        private static void Action(Tag speciesTag, string name, Dictionary <string, CodexEntry> results)
        {
            List <GameObject> brains = Assets.GetPrefabsWithComponent <CreatureBrain>();
            CodexEntry        entry  = new CodexEntry("CREATURES", new List <ContentContainer>()
            {
                new ContentContainer(new List <ICodexWidget>()
                {
                    new CodexSpacer(),
                    new CodexSpacer()
                }, ContentContainer.ContentLayout.Vertical)
            }, name);

            entry.parentId = "CREATURES";
            CodexCache.AddEntry(speciesTag.ToString(), entry, null);
            results.Add(speciesTag.ToString(), entry);
            foreach (GameObject gameObject in brains)
            {
                if (gameObject.GetDef <BabyMonitor.Def>() == null)
                {
                    Sprite     sprite = null;
                    GameObject prefab = Assets.TryGetPrefab((gameObject.PrefabID().ToString() + "Baby"));
                    if (prefab != null)
                    {
                        sprite = Def.GetUISprite(prefab, "ui", false).first;
                    }
                    CreatureBrain component = gameObject.GetComponent <CreatureBrain>();
                    if (component.species == speciesTag)
                    {
                        List <ContentContainer> contentContainerList = new List <ContentContainer>();
                        string symbolPrefix = component.symbolPrefix;
                        Sprite first        = Def.GetUISprite(gameObject, symbolPrefix + "ui", false).first;
                        if ((bool)((UnityEngine.Object)sprite))
                        {
                            Traverse.Create(typeof(CodexEntryGenerator)).Method("GenerateImageContainers", new[] { typeof(Sprite[]), typeof(List <ContentContainer>), typeof(ContentContainer.ContentLayout) })
                            .GetValue(new Sprite[2]
                            {
                                first,
                                sprite
                            }, contentContainerList, ContentContainer.ContentLayout.Horizontal);
                        }
                        else
                        {
                            contentContainerList.Add(new ContentContainer(new List <ICodexWidget>()
                            {
                                new CodexImage(128, 128, first)
                            }, ContentContainer.ContentLayout.Vertical));
                        }

                        Traverse.Create(typeof(CodexEntryGenerator)).Method("GenerateCreatureDescriptionContainers", new[] { typeof(GameObject), typeof(List <ContentContainer>) }).GetValue(gameObject, contentContainerList);
                        entry.subEntries.Add(new SubEntry(component.PrefabID().ToString(), speciesTag.ToString(), contentContainerList, component.GetProperName())
                        {
                            icon      = first,
                            iconColor = UnityEngine.Color.white
                        });
                    }
                }
            }
        }
Ejemplo n.º 5
0
    Creature CreateCreature(DNA father, DNA mother)
    {
        CodexEntry entry = Codex.CodexEntries.Find(ce => ce.FatherDNA == father && ce.MotherDNA == mother);

        if (entry != null)
        {
            return(entry.Creature);
        }
        else
        {
            Debug.Log("error");
            return(null);
        }
    }
Ejemplo n.º 6
0
 public void Populate(CodexEntry codexEntry)
 {
     title.text   = codexEntry.title;
     content.text = codexEntry.content;
     if (codexEntry.icon != null)
     {
         this.icon.gameObject.SetActive(true);
         this.icon.sprite = Resources.Load <Sprite>(codexEntry.icon);
     }
     else
     {
         this.icon.gameObject.SetActive(false);
     }
 }
Ejemplo n.º 7
0
        public static void UnlockEntry <type>(Player player)
        {
            CodexHandler mp    = player.GetModPlayer <CodexHandler>();
            CodexEntry   entry = mp.Entries.FirstOrDefault(n => n is type);

            if (entry.RequiresUpgradedBook && mp.CodexState != 2)
            {
                return;                                                   //dont give the player void entries if they dont have the void book
            }
            entry.Locked = false;
            entry.New    = true;
            if (mp.CodexState != 0)
            {
                StarlightRiver.Instance.codexpopup.TripEntry(entry.Title);
            }
            Main.PlaySound(SoundID.Item30);
        }
Ejemplo n.º 8
0
 public static CodexEntry GetTemplate(string templatePath)
 {
     if (!entries.ContainsKey(templatePath))
     {
         entries.Add(templatePath, null);
     }
     if (entries[templatePath] == null)
     {
         string     text       = Path.Combine(baseEntryPath, templatePath);
         CodexEntry codexEntry = YamlIO.LoadFile <CodexEntry>(text + ".yaml", null, widgetTagMappings);
         if (codexEntry == null)
         {
             Debug.LogWarning("Missing template [" + text + ".yaml]");
         }
         entries[templatePath] = codexEntry;
     }
     return(entries[templatePath]);
 }
Ejemplo n.º 9
0
    public static List <CodexEntry> CollectEntries(string folder)
    {
        List <CodexEntry> list = new List <CodexEntry>();
        string            path = (!(folder == string.Empty)) ? Path.Combine(baseEntryPath, folder) : baseEntryPath;

        string[] array = new string[0];
        try
        {
            array = Directory.GetFiles(path, "*.yaml");
        }
        catch (UnauthorizedAccessException obj)
        {
            Debug.LogWarning(obj);
        }
        string category = folder.ToUpper();

        string[] array2 = array;
        foreach (string text in array2)
        {
            try
            {
                CodexEntry codexEntry = YamlIO.LoadFile <CodexEntry>(text, YamlParseErrorCB, widgetTagMappings);
                if (codexEntry != null)
                {
                    codexEntry.category = category;
                    list.Add(codexEntry);
                }
            }
            catch (Exception ex)
            {
                DebugUtil.DevLogErrorFormat("CodexCache.CollectEntries failed to load [{0}]: {1}", text, ex.ToString());
            }
        }
        foreach (CodexEntry item in list)
        {
            if (string.IsNullOrEmpty(item.sortString))
            {
                item.sortString = Strings.Get(item.title);
            }
        }
        list.Sort((CodexEntry x, CodexEntry y) => x.sortString.CompareTo(y.sortString));
        return(list);
    }
Ejemplo n.º 10
0
        public static void UnlockEntry <type>(Player player)
        {
            CodexHandler mp    = player.GetModPlayer <CodexHandler>();
            CodexEntry   entry = mp.Entries.FirstOrDefault(n => n is type);

            if (entry is null || (entry.RequiresUpgradedBook && mp.CodexState != 2))
            {
                return; //dont give the player void entries if they dont have the void book
            }
            if (entry.Locked)
            {
                entry.Locked = false;
                entry.New    = true;

                if (mp.CodexState != 0)
                {
                    UILoader.GetUIState <CodexPopup>().TripEntry(entry.Title, entry.Icon);
                    Main.PlaySound(StarlightRiver.Instance.GetLegacySoundSlot(SoundType.Custom, "Sounds/CodexUnlock"));
                }
            }
        }
Ejemplo n.º 11
0
 public static void AddEntry(string id, CodexEntry entry, List <CategoryEntry> categoryEntries = null)
 {
     id = FormatLinkID(id);
     if (entries.ContainsKey(id))
     {
         Debug.LogError("Tried to add " + id + " to the Codex screen multiple times");
     }
     entries.Add(id, entry);
     entry.id = id;
     if (entry.name == null)
     {
         entry.name = Strings.Get(entry.title);
     }
     if (!string.IsNullOrEmpty(entry.iconPrefabID))
     {
         try
         {
             entry.icon = Def.GetUISpriteFromMultiObjectAnim(Assets.GetPrefab(entry.iconPrefabID).GetComponent <KBatchedAnimController>().AnimFiles[0], "ui", false, string.Empty);
         }
         catch
         {
             Debug.LogWarningFormat("Unable to get icon for prefabID {0}", entry.iconPrefabID);
         }
     }
     if (categoryEntries != null)
     {
         CodexEntry codexEntry = categoryEntries.Find((CategoryEntry group) => group.id == entry.parentId);
         if (codexEntry != null)
         {
             (codexEntry as CategoryEntry).entriesInCategory.Add(entry);
         }
     }
     foreach (ContentContainer contentContainer in entry.contentContainers)
     {
         if (contentContainer.lockID != null)
         {
             AddLockLookup(contentContainer.lockID, entry.id);
         }
     }
 }
Ejemplo n.º 12
0
    public static void MergeEntry(string id, CodexEntry entry)
    {
        id       = FormatLinkID(entry.id);
        entry.id = id;
        CodexEntry codexEntry = entries[id];

        codexEntry.customContentLength = entry.contentContainers.Count;
        for (int num = entry.contentContainers.Count - 1; num >= 0; num--)
        {
            codexEntry.contentContainers.Insert(0, entry.contentContainers[num]);
        }
        if (entry.disabled)
        {
            codexEntry.disabled = entry.disabled;
        }
        foreach (ContentContainer contentContainer in entry.contentContainers)
        {
            if (contentContainer.lockID != null)
            {
                AddLockLookup(contentContainer.lockID, entry.id);
            }
        }
    }
Ejemplo n.º 13
0
 public EntryButton(CodexEntry entry)
 {
     Entry = entry;
 }