Elin Decompiled Documentation EA 23.312 Nightly Patch 4
Loading...
Searching...
No Matches
CustomBiographyContent.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Newtonsoft.Json;
5
6[JsonObject(MemberSerialization.OptOut)]
8{
9 private const int FallbackWordKey = -100;
10
11 private static int _lastWordKey;
12
13 public string background;
14
15 public int birthDay;
16
17 public int birthMonth;
18
19 public int birthYear;
20
21 public string birthLocation;
22
23 public string birthPlace;
24
25 public string dad;
26
27 public string mom;
28
29 public string likeThing;
30
31 public string likeHobby;
32
33 public string favCategory;
34
35 public string favFood;
36
37 public static CustomBiographyContent CreateFromId(string biographyId, ModPackage owner = null)
38 {
39 var (fileInfo, eMod) = PackageIterator.GetFilesEx("Data/bio_" + biographyId + ".json").LastOrDefault();
40 if (fileInfo == null)
41 {
42 return null;
43 }
44 if (owner == null)
45 {
46 owner = eMod as ModPackage;
47 }
48 return new CustomBiographyContent
49 {
50 ContentId = "Biography/" + biographyId,
51 Owner = owner,
52 File = fileInfo
53 };
54 }
55
56 public override void OnSetLang(string lang)
57 {
58 CustomBiographyContent customBiographyContent = CreateFromId(base.ContentId.Split('/')[^1]);
59 if (customBiographyContent != null)
60 {
61 base.File = customBiographyContent.File;
62 base.LastModified = DateTime.MinValue;
63 }
64 }
65
66 public void RefreshCharaBio(Chara chara)
67 {
68 Load();
69 Biography bio = chara.bio;
70 bio.birthDay = birthDay;
71 bio.birthMonth = birthMonth;
72 bio.birthYear = birthYear;
73 Dictionary<int, LangWord.Row> langWord = EClass.sources.langWord.map;
74 if (!langWord.ContainsKey(-100))
75 {
76 _lastWordKey = -100;
77 SetTempWord("");
78 }
79 if (!birthPlace.IsEmpty())
80 {
81 bio.idHome = SetTempWord(birthPlace);
82 }
83 if (!birthLocation.IsEmpty())
84 {
85 bio.idLoc = SetTempWord(birthLocation);
86 }
87 if (!dad.IsEmpty())
88 {
89 bio.idAdvDad = -100;
90 bio.idDad = SetTempWord(dad);
91 }
92 if (!mom.IsEmpty())
93 {
94 bio.idAdvMom = -100;
95 bio.idMom = SetTempWord(mom);
96 }
97 if (!likeThing.IsEmpty() && EClass.sources.things.map.ContainsKey(likeThing))
98 {
99 bio.idLike = likeThing;
100 }
101 if (!likeHobby.IsEmpty() && Core.GetElement(likeHobby) != EClass.sources.elements.rows[0].id)
102 {
103 bio.idHobby = -100;
104 }
105 int SetTempWord(string text)
106 {
107 while (langWord.ContainsKey(_lastWordKey))
108 {
109 _lastWordKey--;
110 }
111 Dictionary<int, LangWord.Row> dictionary = langWord;
112 int lastWordKey = _lastWordKey;
113 LangWord.Row obj = new LangWord.Row
114 {
115 id = _lastWordKey
116 };
117 LangWord.Row row = obj;
118 dictionary[lastWordKey] = obj;
119 row.name = (row.name_JP = (row.name_L = text));
120 return _lastWordKey;
121 }
122 }
123
124 protected override void LoadContent()
125 {
126 CustomBiographyContent customBiographyContent = IO.LoadFile<CustomBiographyContent>(base.File.FullName);
127 background = customBiographyContent.background;
128 birthDay = customBiographyContent.birthDay;
129 birthMonth = customBiographyContent.birthMonth;
130 birthYear = customBiographyContent.birthYear;
131 birthLocation = customBiographyContent.birthLocation;
132 birthPlace = customBiographyContent.birthPlace;
133 dad = customBiographyContent.dad;
134 mom = customBiographyContent.mom;
135 likeThing = customBiographyContent.likeThing;
136 likeHobby = customBiographyContent.likeHobby;
137 favCategory = customBiographyContent.favCategory;
138 favFood = customBiographyContent.favFood;
139 }
140}
Biography bio
Definition: Card.cs:45
Definition: Chara.cs:10
Definition: Core.cs:14
static int GetElement(string id)
Definition: Core.cs:743
void RefreshCharaBio(Chara chara)
static CustomBiographyContent CreateFromId(string biographyId, ModPackage owner=null)
override void OnSetLang(string lang)
string ContentId
Definition: CustomContent.cs:6
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:43
SourceThing things
LangWord langWord
SourceElement elements