Elin Decompiled Documentation EA 23.312 Nightly Patch 4
Loading...
Searching...
No Matches
CustomCharaContent Class Reference
Inheritance diagram for CustomCharaContent:
CustomSourceContent CustomContent EClass

Public Types

enum  SpawnType { Common , Adventurer , Merchant , Unique }
 

Public Member Functions

void OnCharaCreated (Chara chara)
 
override void OnGameLoad (GameIOContext context)
 
override string ToString ()
 
- Public Member Functions inherited from CustomContent
virtual void OnGameLoad (GameIOContext context)
 
virtual void OnGameSave (GameIOContext context)
 
override string ToString ()
 

Static Public Member Functions

static CustomCharaContent CreateFromRow (SourceChara.Row r, ModPackage owner=null)
 
static SpawnType GetSpawnTypeFromTrait (string trait)
 
- Static Public Member Functions inherited from CustomSourceContent
static string string string[] kv GetParams (string tag)
 
- Static Public Member Functions inherited from EClass
static int rndSeed (int a, int seed)
 
static int rnd (long a)
 
static int rnd (int a)
 
static int curve (long _a, int start, int step, int rate=75)
 
static int sqrt (int a)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 

Public Attributes

List< string > equipments = new List<string>()
 
Dictionary< string, int > mapInt = new Dictionary<string, int>()
 
Dictionary< string, string > mapStr = new Dictionary<string, string>()
 
SpawnType spawnType
 
List< string > spawnZones = new List<string>()
 
List< string > stocks = new List<string>()
 
List< string > things = new List<string>()
 

Properties

override string SourceType [get]
 
bool IsAdventurer [get]
 
- Properties inherited from CustomSourceContent
virtual string SourceType [get]
 
string SourceId [get, set]
 
- Properties inherited from CustomContent
string ContentId [get, protected set]
 
EMod Owner [get, protected set]
 
- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Static Private Attributes

static readonly Dictionary< string, SpawnType_cachedSpawnTypes = new Dictionary<string, SpawnType>()
 

Additional Inherited Members

- Static Public Attributes inherited from CustomSourceContent
static string action
 
static string string spec
 
- Static Public Attributes inherited from EClass
static Core core
 

Detailed Description

Definition at line 9 of file CustomCharaContent.cs.

Member Enumeration Documentation

◆ SpawnType

Enumerator
Common 
Adventurer 
Merchant 
Unique 

Definition at line 11 of file CustomCharaContent.cs.

Member Function Documentation

◆ CreateFromRow()

static CustomCharaContent CustomCharaContent.CreateFromRow ( SourceChara::Row  r,
ModPackage  owner = null 
)
inlinestatic

Definition at line 39 of file CustomCharaContent.cs.

40 {
41 string trait = r.trait.TryGet(0, returnNull: true) ?? "Chara";
42 if (owner == null)
43 {
44 owner = ModUtil.FindSourceRowPackage(r);
45 }
46 CustomCharaContent customCharaContent = new CustomCharaContent
47 {
48 ContentId = "Chara/" + r.id,
49 SourceId = r.id,
51 Owner = owner
52 };
53 string[] tag = r.tag;
54 for (int i = 0; i < tag.Length; i++)
55 {
56 var (text, text2, array) = CustomSourceContent.GetParams(tag[i]);
57 switch (text)
58 {
59 case "addZone":
60 case "addAdvZone":
61 if (!text2.IsEmpty())
62 {
63 customCharaContent.spawnZones.Add(text2);
64 }
65 break;
66 case "addEq":
67 case "addAdvEq":
68 case "addEquipment":
69 if (!text2.IsEmpty())
70 {
71 customCharaContent.equipments.Add(text2);
72 }
73 break;
74 case "addThing":
75 if (!text2.IsEmpty())
76 {
77 customCharaContent.things.Add(text2);
78 }
79 break;
80 case "addStock":
81 {
82 string text3 = text2.IsEmpty(r.id);
83 if (!ModUtil.HasContent("MerchantStock/" + text3))
84 {
85 CustomMerchantStock customMerchantStock = CustomMerchantStock.CreateFromId(text3, owner);
86 if (customMerchantStock == null)
87 {
88 break;
89 }
90 ModUtil.AddContent(customMerchantStock);
91 }
92 if (!customCharaContent.stocks.Contains(text3))
93 {
94 customCharaContent.stocks.Add(text3);
95 customCharaContent.mapStr["merchant_override"] = string.Join('|', customCharaContent.stocks);
96 }
97 break;
98 }
99 case "addDrama":
100 if (!text2.IsEmpty())
101 {
102 customCharaContent.mapStr["drama_override"] = text2;
103 }
104 break;
105 case "addBio":
106 case "addBiography":
107 {
108 string text4 = text2.IsEmpty(r.id);
109 customCharaContent.mapStr["biography_override"] = text4;
110 if (!ModUtil.HasContent("Biography/" + text4))
111 {
112 CustomBiographyContent customBiographyContent = CustomBiographyContent.CreateFromId(text4, owner);
113 if (customBiographyContent != null)
114 {
115 ModUtil.AddContent(customBiographyContent);
116 }
117 }
118 break;
119 }
120 case "addFlag":
121 case "addInt":
122 customCharaContent.mapInt[array[0]] = array.TryGet(1, returnNull: true)?.ToInt() ?? 1;
123 break;
124 case "addFlagValue":
125 case "addStr":
126 if (!array.TryGet(1, returnNull: true).IsEmpty())
127 {
128 customCharaContent.mapStr[array[0]] = array[1];
129 }
130 break;
131 }
132 }
133 return customCharaContent;
134 }
string[] trait
Definition: CardRow.cs:33
string id
Definition: CardRow.cs:7
static CustomBiographyContent CreateFromId(string biographyId, ModPackage owner=null)
Dictionary< string, string > mapStr
Dictionary< string, int > mapInt
static SpawnType GetSpawnTypeFromTrait(string trait)
List< string > things
List< string > spawnZones
List< string > equipments
List< string > stocks
string ContentId
Definition: CustomContent.cs:6
static CustomMerchantStock CreateFromId(string stockId, ModPackage owner)
static string string string[] kv GetParams(string tag)
string[] tag
Definition: RenderRow.cs:58

References CustomContent.ContentId, CustomBiographyContent.CreateFromId(), CustomMerchantStock.CreateFromId(), equipments, CustomSourceContent.GetParams(), GetSpawnTypeFromTrait(), mapInt, mapStr, CustomContent.Owner, CustomSourceContent.SourceId, spawnType, spawnZones, stocks, and things.

Referenced by ModPackage.GenerateCustomContentProfiles().

◆ GetSpawnTypeFromTrait()

static SpawnType CustomCharaContent.GetSpawnTypeFromTrait ( string  trait)
inlinestatic

Definition at line 136 of file CustomCharaContent.cs.

137 {
138 if (_cachedSpawnTypes.TryGetValue(trait, out var value))
139 {
140 return value;
141 }
142 Trait trait2 = ClassCache.Create<Trait>("Trait" + trait, "Elin");
143 if (!(trait2 is TraitChara traitChara))
144 {
145 goto IL_005f;
146 }
148 if (traitChara.AdvType == TraitChara.Adv_Type.None)
149 {
150 if (!(trait2 is TraitMerchant))
151 {
152 if (!(trait2 is TraitUniqueChara))
153 {
154 goto IL_005f;
155 }
156 spawnType = SpawnType.Unique;
157 }
158 else
159 {
160 spawnType = SpawnType.Merchant;
161 }
162 }
163 else
164 {
165 spawnType = SpawnType.Adventurer;
166 }
167 goto IL_0061;
168 IL_0061:
169 return _cachedSpawnTypes[trait] = spawnType;
170 IL_005f:
171 spawnType = SpawnType.Common;
172 goto IL_0061;
173 }
static readonly Dictionary< string, SpawnType > _cachedSpawnTypes
Definition: Trait.cs:7

References _cachedSpawnTypes, and spawnType.

Referenced by CreateFromRow().

◆ OnCharaCreated()

void CustomCharaContent.OnCharaCreated ( Chara  chara)
inline

Definition at line 175 of file CustomCharaContent.cs.

176 {
177 if (chara.GetBool("custom_content") || chara.GetBool("cwl_tags_applied") || chara.id != base.SourceId)
178 {
179 return;
180 }
181 chara.SetBool("custom_content", enable: true);
182 chara.SetStr("custom_content_id", base.ContentId);
183 chara.SetStr("custom_content_package", base.Owner.id);
184 string key2;
185 foreach (KeyValuePair<string, string> item in mapStr)
186 {
187 item.Deconstruct(out var key, out key2);
188 string id2 = key;
189 string value = key2;
190 chara.SetStr(id2, value);
191 }
192 foreach (KeyValuePair<string, int> item2 in mapInt)
193 {
194 item2.Deconstruct(out key2, out var value2);
195 string id3 = key2;
196 int value3 = value2;
197 chara.SetInt(id3, value3);
198 }
199 if (things.Count > 0 || equipments.Count > 0)
200 {
201 chara.RemoveThings();
202 }
203 foreach (string[] item3 in equipments.Select((string t) => t.Split('#')))
204 {
205 if (!Enum.TryParse<Rarity>(item3.TryGet(1, returnNull: true), out var result))
206 {
207 result = Rarity.Random;
208 }
209 if (HasValidContentId(item3[0]))
210 {
211 chara.EQ_ID(item3[0], -1, result);
212 }
213 }
214 foreach (string[] item4 in things.Select((string t) => t.Split('#')))
215 {
216 if (!int.TryParse(item4.TryGet(1, returnNull: true), out var result2))
217 {
218 result2 = 1;
219 }
220 if (HasValidContentId(item4[0]))
221 {
222 chara.AddThing(item4[0]).SetNum(result2);
223 }
224 }
225 bool HasValidContentId(string id)
226 {
227 if (EClass.sources.cards.map.ContainsKey(id))
228 {
229 return true;
230 }
231 ModUtil.LogModError("source chara row '" + base.ContentId + "' has invalid addEq/addThing spec '" + id + "'", base.Owner);
232 return false;
233 }
234 }
Rarity
Definition: Rarity.cs:2
string id
Definition: Card.cs:36
void SetInt(string id, int value=0)
Definition: Card.cs:2561
Thing AddThing(string id, int lv=-1)
Definition: Card.cs:3244
Thing SetNum(int a)
Definition: Card.cs:3640
void SetStr(string id, string value=null)
Definition: Card.cs:2571
bool GetBool(string id)
Definition: Card.cs:2541
void SetBool(string id, bool enable)
Definition: Card.cs:2546
void RemoveThings()
Definition: Card.cs:3455
Thing EQ_ID(string s, int mat=-1, Rarity r=Rarity.Random)
Definition: Chara.cs:5209
Definition: EClass.cs:6
static SourceManager sources
Definition: EClass.cs:43
Dictionary< string, CardRow > map
Definition: SourceCard.cs:9
SourceCard cards

References SourceManager.cards, equipments, Card.GetBool(), Card.id, item, SourceCard.map, mapInt, mapStr, Card.SetBool(), Card.SetStr(), EClass.sources, and things.

◆ OnGameLoad()

override void CustomCharaContent.OnGameLoad ( GameIOContext  context)
inlinevirtual

Reimplemented from CustomContent.

Definition at line 236 of file CustomCharaContent.cs.

237 {
238 if (spawnZones.Count == 0)
239 {
240 return;
241 }
242 Debug.Log($"#mod-content loading {this}");
243 ILookup<string, Chara> lookup = EClass.game.cards.globalCharas.Values.ToLookup((Chara c) => c.id);
244 List<Zone> list = new List<Zone>();
245 foreach (string spawnZone in spawnZones)
246 {
247 Zone zone = ModUtil.FindZoneByFullName(spawnZone);
248 if (zone != null)
249 {
250 list.Add(zone);
251 continue;
252 }
253 ModUtil.LogModError("source chara row '" + base.SourceId + "' has invalid addZone spec '" + spawnZone + "'", base.Owner);
254 }
255 List<Chara> list2 = lookup[base.SourceId].ToList();
256 int count = list2.Count;
257 if (list.Count == 0 && count == 0)
258 {
259 ModUtil.LogModError("source chara row '" + base.SourceId + "' has invalid addZone spec", base.Owner);
260 return;
261 }
262 int num = Math.Max(0, list.Count - count);
263 int num2 = count;
264 if (num2 <= 1)
265 {
266 if (num2 != 1)
267 {
268 goto IL_01d5;
269 }
270 if (IsAdventurer)
271 {
272 goto IL_017e;
273 }
274 }
275 else if (IsAdventurer)
276 {
277 ModUtil.LogModError("adventurer '" + base.SourceId + "' has spawned more than once", base.Owner);
278 return;
279 }
280 if (num == 0)
281 {
282 goto IL_017e;
283 }
284 goto IL_01d5;
285 IL_017e:
286 Debug.Log("#mod-content skipping existing character '" + base.SourceId + "', " + $"{count} at {string.Join('/', list2.Select((Chara c) => c.currentZone.ZoneFullName))}");
287 return;
288 IL_01d5:
289 for (int i = 0; i < num; i++)
290 {
291 Zone z2 = list[i];
292 Chara chara = SpawnToZone(z2);
293 if (chara == null)
294 {
295 ModUtil.LogModError("can't spawn character '" + base.SourceId + "'", base.Owner);
296 break;
297 }
298 if (IsAdventurer)
299 {
300 EClass.game.cards.listAdv.Add(chara);
301 break;
302 }
303 }
304 Chara SpawnToZone(Zone z)
305 {
306 Chara chara2 = CharaGen.Create(base.SourceId);
307 if (chara2.id == "chicken")
308 {
309 return null;
310 }
311 chara2.SetHomeZone(z);
312 chara2.MoveZone(z, ZoneTransition.EnterState.RandomVisit);
313 Debug.Log("#mod-content spawned character '" + base.SourceId + "' to " + z.ZoneFullName);
314 return chara2;
315 }
316 }
$
Definition: ModManager.cs:76
List< Chara > listAdv
Definition: CardManager.cs:64
GlobalCharaList globalCharas
Definition: CardManager.cs:46
static Chara Create(string id, int lv=-1)
Definition: CharaGen.cs:17
Definition: Chara.cs:10
Chara SetHomeZone(Zone zone)
Definition: Chara.cs:1474
void MoveZone(string alias)
Definition: Chara.cs:3412
static Game game
Definition: EClass.cs:9
CardManager cards
Definition: Game.cs:156
Definition: Zone.cs:12
string ZoneFullName
Definition: Zone.cs:85

References $, Game.cards, CharaGen.Create(), Debug, EClass.game, CardManager.globalCharas, Card.id, IsAdventurer, CardManager.listAdv, Chara.MoveZone(), Chara.SetHomeZone(), spawnZones, and Zone.ZoneFullName.

◆ ToString()

override string CustomCharaContent.ToString ( )
inline

Definition at line 318 of file CustomCharaContent.cs.

319 {
320 StringBuilder stringBuilder = new StringBuilder();
321 stringBuilder.AppendLine($"{base.ContentId}/{spawnType}/{base.Owner.id}");
322 stringBuilder.AppendLine($" - zones({spawnZones.Count})/{string.Join(';', spawnZones)}");
323 if (things.Count > 0)
324 {
325 stringBuilder.AppendLine($" - things({things.Count})/{string.Join(';', things)}");
326 }
327 if (equipments.Count > 0)
328 {
329 stringBuilder.AppendLine($" - equipments({equipments.Count})/{string.Join(';', equipments)}");
330 }
331 if (stocks.Count > 0)
332 {
333 stringBuilder.AppendLine(" - stocks/" + string.Join(';', stocks));
334 }
335 if (mapStr.Count > 0)
336 {
337 stringBuilder.AppendLine(" - str/" + string.Join(';', mapStr.Select((KeyValuePair<string, string> kv) => kv.Key + "=" + kv.Value)));
338 }
339 if (mapInt.Count > 0)
340 {
341 stringBuilder.AppendLine(" - int/" + string.Join(';', mapInt.Select((KeyValuePair<string, int> kv) => $"{kv.Key}={kv.Value}")));
342 }
343 return stringBuilder.ToString();
344 }

References $, equipments, mapInt, mapStr, stocks, and things.

Member Data Documentation

◆ _cachedSpawnTypes

readonly Dictionary<string, SpawnType> CustomCharaContent._cachedSpawnTypes = new Dictionary<string, SpawnType>()
staticprivate

Definition at line 19 of file CustomCharaContent.cs.

Referenced by GetSpawnTypeFromTrait().

◆ equipments

List<string> CustomCharaContent.equipments = new List<string>()

Definition at line 21 of file CustomCharaContent.cs.

Referenced by CreateFromRow(), OnCharaCreated(), and ToString().

◆ mapInt

Dictionary<string, int> CustomCharaContent.mapInt = new Dictionary<string, int>()

Definition at line 23 of file CustomCharaContent.cs.

Referenced by CreateFromRow(), OnCharaCreated(), and ToString().

◆ mapStr

Dictionary<string, string> CustomCharaContent.mapStr = new Dictionary<string, string>()

Definition at line 25 of file CustomCharaContent.cs.

Referenced by CreateFromRow(), OnCharaCreated(), and ToString().

◆ spawnType

SpawnType CustomCharaContent.spawnType

Definition at line 27 of file CustomCharaContent.cs.

Referenced by CreateFromRow(), and GetSpawnTypeFromTrait().

◆ spawnZones

List<string> CustomCharaContent.spawnZones = new List<string>()

Definition at line 29 of file CustomCharaContent.cs.

Referenced by CreateFromRow(), and OnGameLoad().

◆ stocks

List<string> CustomCharaContent.stocks = new List<string>()

Definition at line 31 of file CustomCharaContent.cs.

Referenced by CreateFromRow(), and ToString().

◆ things

List<string> CustomCharaContent.things = new List<string>()

Definition at line 33 of file CustomCharaContent.cs.

Referenced by CreateFromRow(), OnCharaCreated(), and ToString().

Property Documentation

◆ IsAdventurer

bool CustomCharaContent.IsAdventurer
get

Definition at line 37 of file CustomCharaContent.cs.

Referenced by OnGameLoad().

◆ SourceType

override string CustomCharaContent.SourceType
get

Definition at line 35 of file CustomCharaContent.cs.


The documentation for this class was generated from the following file: