Elin Decompiled Documentation EA 23.312 Nightly Patch 4
Loading...
Searching...
No Matches
CustomMerchantStock.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using Newtonsoft.Json;
5using UnityEngine;
6
7[JsonObject(MemberSerialization.OptOut)]
9{
10 public List<CustomThingContent> items = new List<CustomThingContent>();
11
12 public List<Thing> Generate(Card owner)
13 {
14 Load();
15 List<Thing> list = new List<Thing>();
16 int createLv = owner?.trait?.ShopLv ?? (-1);
17 foreach (CustomThingContent item2 in items)
18 {
19 try
20 {
21 Thing item = item2.Create(createLv);
22 list.Add(item);
23 }
24 catch (Exception ex)
25 {
26 ModUtil.LogModError("can't create stock item '" + item2.ContentId + "'\n" + ex.Message, base.Owner);
27 Debug.LogError(ex);
28 }
29 }
30 return list;
31 }
32
33 public static CustomMerchantStock CreateFromId(string stockId, ModPackage owner)
34 {
35 var (fileInfo, eMod) = PackageIterator.GetFilesEx("Data/stock_" + stockId + ".json").LastOrDefault();
36 if (fileInfo == null)
37 {
38 return null;
39 }
40 if (owner == null)
41 {
42 owner = eMod as ModPackage;
43 }
44 return new CustomMerchantStock
45 {
46 ContentId = "MerchantStock/" + stockId,
47 Owner = owner,
48 File = fileInfo
49 };
50 }
51
52 protected override void LoadContent()
53 {
54 CustomMerchantStock customMerchantStock = IO.LoadFile<CustomMerchantStock>(base.File.FullName);
55 items = customMerchantStock.items;
56 }
57
58 public override string ToString()
59 {
60 return $"{base.ContentId}/items({items.Count})";
61 }
62}
$
Definition: ModManager.cs:76
Definition: Card.cs:11
Trait trait
Definition: Card.cs:54
Thing Add(string id, int num=1, int lv=1)
Definition: Card.cs:3221
string ContentId
Definition: CustomContent.cs:6
override string ToString()
List< Thing > Generate(Card owner)
static CustomMerchantStock CreateFromId(string stockId, ModPackage owner)
override void LoadContent()
List< CustomThingContent > items
Thing Create(int createLv=-1)
Definition: Thing.cs:8
virtual int ShopLv
Definition: Trait.cs:525