Elin Decompiled Documentation EA 23.329 Nightly
Loading...
Searching...
No Matches
CustomThingContent Class Reference
Inheritance diagram for CustomThingContent:
CustomSourceContent CustomContent EClass

Public Types

enum  SpawnType {
  Item , Block , Cassette , Currency ,
  Category , Filter , Tag , Letter ,
  Map , Perfume , Plan , Potion ,
  Recipe , RedBook , Rod , Rune ,
  RuneFree , Scroll , Skill , Spell ,
  Usuihon
}
 

Public Member Functions

void OnThingCreated (Thing thing)
 
Thing Create (int createLv=-1)
 
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 CustomThingContent CreateFromRow (SourceThing.Row r, ModPackage mod=null)
 
- 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

BlessedState blessedState
 
string id = ""
 
IDTLevel identifyLevel
 
int lv = -1
 
Dictionary< string, int > mapInt = new Dictionary<string, int>()
 
Dictionary< string, string > mapStr = new Dictionary<string, string>()
 
string material = ""
 
bool noCopy
 
bool noRandomSocket
 
int num = 1
 
Rarity rarity
 
bool restock = true
 
List< string > sockets = new List<string>()
 
SpawnType type
 
string priceCalc = ""
 

Properties

override string SourceType [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]
 

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 10 of file CustomThingContent.cs.

Member Enumeration Documentation

◆ SpawnType

Member Function Documentation

◆ Create()

Thing CustomThingContent.Create ( int  createLv = -1)
inline

Definition at line 205 of file CustomThingContent.cs.

206 {
207 if (lv != -1)
208 {
209 createLv = lv;
210 }
212 int.TryParse(id, out var result);
213 if (EClass.sources.elements.fuzzyAlias.TryGetValue(id, out var value))
214 {
215 result = EClass.sources.elements.alias[value].id;
216 }
217 Thing thing = null;
218 int idMat = EClass.sources.materials.alias.TryGetValue(material)?.id ?? (-1);
219 switch (type)
220 {
221 case SpawnType.Item:
222 thing = ThingGen.Create(id, idMat, createLv).SetNum(num);
223 break;
224 case SpawnType.Block:
225 {
226 SourceBlock.Row row = EClass.sources.blocks.alias.TryGetValue(id);
227 if (row != null)
228 {
229 thing = ThingGen.CreateBlock(row.id, idMat).SetNum(num);
230 }
231 break;
232 }
233 case SpawnType.Cassette:
234 if (!EClass.core.refs.dictBGM.ContainsKey(result))
235 {
236 result = EClass.core.refs.dictBGM.RandomItem().id;
237 }
238 thing = ThingGen.CreateCassette(result);
239 break;
240 case SpawnType.Currency:
241 thing = ThingGen.CreateCurrency(num, id);
242 break;
243 case SpawnType.Category:
244 thing = ThingGen.CreateFromCategory(id, createLv).SetNum(num);
245 break;
246 case SpawnType.Filter:
247 thing = ThingGen.CreateFromFilter(id, createLv).SetNum(num);
248 break;
249 case SpawnType.Tag:
250 thing = ThingGen.CreateFromTag(id, createLv).SetNum(num);
251 break;
252 case SpawnType.Letter:
253 thing = ThingGen.CreateLetter(id);
254 break;
255 case SpawnType.Map:
256 thing = ThingGen.CreateMap(id, createLv);
257 break;
258 case SpawnType.Perfume:
259 thing = ThingGen.CreatePerfume(result, createLv).SetNum(num);
260 break;
261 case SpawnType.Plan:
262 thing = ThingGen.CreatePlan(result);
263 break;
264 case SpawnType.Potion:
265 thing = ThingGen.CreatePotion(result, num);
266 break;
267 case SpawnType.Recipe:
268 thing = ThingGen.CreateRecipe(id);
269 break;
270 case SpawnType.RedBook:
271 thing = ThingGen.CreateRedBook(id);
272 break;
273 case SpawnType.Rod:
274 thing = ThingGen.CreateRod(result, num);
275 break;
276 case SpawnType.Rune:
277 thing = ThingGen.CreateRune(result, num);
278 break;
279 case SpawnType.RuneFree:
280 thing = ThingGen.CreateRune(result, num, free: true);
281 break;
282 case SpawnType.Scroll:
283 thing = ThingGen.CreateScroll(result, num);
284 break;
285 case SpawnType.Skill:
286 thing = ThingGen.CreateSkillbook(result, num);
287 break;
288 case SpawnType.Spell:
289 thing = ThingGen.CreateSpellbook(result, 1, num);
290 break;
291 case SpawnType.Usuihon:
292 thing = ThingGen.Create("1084");
293 thing.c_idRefName = EClass.game.religions.dictAll.TryGetValue(id)?.id;
294 break;
295 default:
296 thing = ThingGen.Create(id);
297 break;
298 }
299 if (thing == null)
300 {
301 return null;
302 }
303 thing.c_IDTState = (int)identifyLevel;
305 if (!restock)
306 {
307 thing.SetBool(101, enable: true);
308 }
309 if (!priceCalc.IsEmpty())
310 {
311 thing.SetStr("price_calc_override", priceCalc);
312 }
313 thing.ChangeRarity(rarity);
314 return thing;
315 }
static void SetRarity(Rarity q=Rarity.Normal)
Thing SetNum(int a)
Definition: Card.cs:3669
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:4069
void SetStr(string id, string value=null)
Definition: Card.cs:2600
void SetBool(string id, bool enable)
Definition: Card.cs:2562
virtual void ChangeRarity(Rarity q)
Definition: Card.cs:4094
Dictionary< int, BGMData > dictBGM
Definition: CoreRef.cs:386
CoreRef refs
Definition: Core.cs:51
BlessedState blessedState
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Core core
Definition: EClass.cs:7
static SourceManager sources
Definition: EClass.cs:43
ReligionManager religions
Definition: Game.cs:159
Dictionary< string, Religion > dictAll
Dictionary< string, string > fuzzyAlias
SourceMaterial materials
SourceBlock blocks
SourceElement elements
static Thing CreateRune(int ele, int v, bool free=false)
Definition: ThingGen.cs:209
static Thing CreatePotion(int ele, int num=1)
Definition: ThingGen.cs:224
static Thing CreateFromFilter(string id, int lv=-1)
Definition: ThingGen.cs:63
static Thing CreateMap(string idSource=null, int lv=-1)
Definition: ThingGen.cs:132
static Thing CreatePerfume(int ele, int num=1)
Definition: ThingGen.cs:231
static Thing CreateBlock(int id, int idMat)
Definition: ThingGen.cs:101
static Thing CreateRedBook(string id, int num=1)
Definition: ThingGen.cs:175
static Thing CreateCassette(int id)
Definition: ThingGen.cs:238
static Thing CreateSpellbook(string alias, int num=1)
Definition: ThingGen.cs:159
static Thing CreatePlan(int ele)
Definition: ThingGen.cs:145
static Thing CreateFromTag(string idTag, int lv=-1)
Definition: ThingGen.cs:80
static Thing CreateRecipe(string id)
Definition: ThingGen.cs:152
static Thing CreateSkillbook(int ele, int num=1)
Definition: ThingGen.cs:183
static Thing CreateFromCategory(string idCat, int lv=-1)
Definition: ThingGen.cs:75
static Thing CreateLetter(string idLetter)
Definition: ThingGen.cs:245
static Thing CreateScroll(int ele, int num=1)
Definition: ThingGen.cs:190
static Thing CreateCurrency(int a, string id="money")
Definition: ThingGen.cs:37
static Thing CreateRod(int ele, int charge=-1)
Definition: ThingGen.cs:217
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
int id
Definition: TileRow.cs:8

References blessedState, SourceManager.blocks, Card.ChangeRarity(), EClass.core, ThingGen.Create(), ThingGen.CreateBlock(), ThingGen.CreateCassette(), ThingGen.CreateCurrency(), ThingGen.CreateFromCategory(), ThingGen.CreateFromFilter(), ThingGen.CreateFromTag(), ThingGen.CreateLetter(), ThingGen.CreateMap(), ThingGen.CreatePerfume(), ThingGen.CreatePlan(), ThingGen.CreatePotion(), ThingGen.CreateRecipe(), ThingGen.CreateRedBook(), ThingGen.CreateRod(), ThingGen.CreateRune(), ThingGen.CreateScroll(), ThingGen.CreateSkillbook(), ThingGen.CreateSpellbook(), ReligionManager.dictAll, CoreRef.dictBGM, SourceManager.elements, SourceElement.fuzzyAlias, EClass.game, TileRow.id, identifyLevel, lv, material, SourceManager.materials, num, priceCalc, rarity, Core.refs, Game.religions, restock, Card.SetBlessedState(), Card.SetBool(), Card.SetNum(), CardBlueprint.SetRarity(), Card.SetStr(), EClass.sources, and type.

Referenced by CustomMerchantStock.Generate().

◆ CreateFromRow()

static CustomThingContent CustomThingContent.CreateFromRow ( SourceThing::Row  r,
ModPackage  mod = null 
)
inlinestatic

Definition at line 74 of file CustomThingContent.cs.

75 {
76 CustomThingContent customThingContent = new CustomThingContent
77 {
78 ContentId = "Thing/" + r.id,
79 SourceId = r.id,
80 Owner = mod,
81 id = r.id
82 };
83 string[] tag = r.tag;
84 for (int i = 0; i < tag.Length; i++)
85 {
86 var (text, item, array) = CustomSourceContent.GetParams(tag[i]);
87 switch (text)
88 {
89 case "forceRarity":
90 customThingContent.rarity = r.quality.ToEnum<Rarity>();
91 break;
92 case "noCopy":
93 if (r.elements.Contains(759))
94 {
95 customThingContent.noCopy = true;
96 }
97 break;
98 case "noRandomSocket":
99 customThingContent.noRandomSocket = true;
100 break;
101 case "noRestock":
102 customThingContent.restock = false;
103 break;
104 case "addSocket":
105 customThingContent.sockets.Add(item);
106 break;
107 case "addFlag":
108 case "addInt":
109 customThingContent.mapInt[array[0]] = array.TryGet(1, returnNull: true)?.ToInt() ?? 1;
110 break;
111 case "addFlagValue":
112 case "addStr":
113 if (!array.TryGet(1, returnNull: true).IsEmpty())
114 {
115 customThingContent.mapStr[array[0]] = array[1];
116 }
117 break;
118 }
119 }
120 return customThingContent;
121 }
Rarity
Definition: Rarity.cs:2
int quality
Definition: CardRow.cs:19
int[] elements
Definition: CardRow.cs:21
string id
Definition: CardRow.cs:7
string ContentId
Definition: CustomContent.cs:6
static string string string[] kv GetParams(string tag)
List< string > sockets
Dictionary< string, int > mapInt
Dictionary< string, string > mapStr
string[] tag
Definition: RenderRow.cs:58

References CustomContent.ContentId, CustomSourceContent.GetParams(), item, mapInt, mapStr, CustomContent.Owner, sockets, and CustomSourceContent.SourceId.

Referenced by ModPackage.GenerateCustomContentProfiles().

◆ OnThingCreated()

void CustomThingContent.OnThingCreated ( Thing  thing)
inline

Definition at line 123 of file CustomThingContent.cs.

124 {
125 if (thing.GetBool("custom_content") || thing.id != base.SourceId)
126 {
127 return;
128 }
129 thing.SetBool("custom_content", enable: true);
130 thing.SetStr("custom_content_id", base.ContentId);
131 thing.SetStr("custom_content_package", base.Owner.id);
132 string key2;
133 foreach (KeyValuePair<string, string> item in mapStr)
134 {
135 item.Deconstruct(out var key, out key2);
136 string text = key;
137 string value = key2;
138 thing.SetStr(text, value);
139 }
140 foreach (KeyValuePair<string, int> item2 in mapInt)
141 {
142 item2.Deconstruct(out key2, out var value2);
143 string text2 = key2;
144 int value3 = value2;
145 thing.SetInt(text2, value3);
146 }
147 if (thing.source.ContainsTag("forceRarity"))
148 {
149 thing.ChangeRarity(rarity);
150 }
151 if (noCopy)
152 {
153 EClass.core.actionsNextFrame.Add(delegate
154 {
155 thing.elements?.SetBase(759, 10);
156 });
157 }
158 if (sockets.Count <= 0)
159 {
160 return;
161 }
162 if (noRandomSocket)
163 {
164 thing.sockets.Clear();
165 }
166 int num = 0;
167 foreach (string socket in sockets)
168 {
169 thing.AddSocket();
170 if (socket.IsEmpty())
171 {
172 num++;
173 }
174 else
175 {
176 ApplyRangedSocket(socket);
177 }
178 }
179 thing.sockets.RemoveAll((int s) => s == 0);
180 for (int i = 0; i < num; i++)
181 {
182 thing.sockets.Add(0);
183 }
184 void ApplyRangedSocket(string socket)
185 {
186 int num2 = 3 + Mathf.Min(thing.genLv / 10, 15);
187 if (!EClass.sources.elements.alias.TryGetValue(socket, out var value4))
188 {
189 ModUtil.LogModError("source thing row '" + base.ContentId + "' has invalid addSocket spec '" + socket + "'", base.Owner);
190 }
191 else
192 {
193 float num3 = Mathf.Sqrt((float)(thing.genLv * value4.encFactor) / 100f);
194 float num4 = (float)num2 + num3;
195 int num5 = (value4.mtp + EClass.rnd(value4.mtp + (int)num4)) / value4.mtp;
196 if (value4.encFactor == 0 && num5 > 25)
197 {
198 num5 = 25;
199 }
200 thing.ApplySocket(value4.id, num5);
201 }
202 }
203 }
List< Action > actionsNextFrame
Definition: BaseCore.cs:31
void AddSocket()
Definition: Card.cs:3715
ElementContainerCard elements
Definition: Card.cs:42
string id
Definition: Card.cs:36
void SetInt(string id, int value=0)
Definition: Card.cs:2586
void ApplySocket(Thing t)
Definition: Card.cs:3724
bool GetBool(string id)
Definition: Card.cs:2557
int genLv
Definition: Card.cs:197
List< int > sockets
Definition: Card.cs:48
static int rnd(long a)
Definition: EClass.cs:59
Element SetBase(string alias, int v, int potential=0)
SourceThing.Row source
Definition: Thing.cs:11

References BaseCore.actionsNextFrame, EClass.core, SourceManager.elements, Card.GetBool(), Card.id, item, mapInt, mapStr, noCopy, noRandomSocket, num, rarity, EClass.rnd(), Card.SetBool(), Card.SetStr(), sockets, and EClass.sources.

◆ ToString()

override string CustomThingContent.ToString ( )
inline

Definition at line 317 of file CustomThingContent.cs.

318 {
319 StringBuilder stringBuilder = new StringBuilder();
320 stringBuilder.AppendLine($"{base.ContentId}/{type}/{base.Owner.id}");
321 stringBuilder.AppendLine($" - num({num})/lv({lv})/restock({restock})/noCopy({noCopy})/{material}/{rarity}/{blessedState}/{identifyLevel}");
322 if (sockets.Count > 0)
323 {
324 stringBuilder.AppendLine($" - sockets({sockets.Count})/noRandomSocket({noRandomSocket})/{string.Join(';', sockets)}");
325 }
326 if (mapStr.Count > 0)
327 {
328 stringBuilder.AppendLine(" - str/" + string.Join(';', mapStr.Select((KeyValuePair<string, string> kv) => kv.Key + "=" + kv.Value)));
329 }
330 if (mapInt.Count > 0)
331 {
332 stringBuilder.AppendLine(" - int/" + string.Join(';', mapInt.Select((KeyValuePair<string, int> kv) => $"{kv.Key}={kv.Value}")));
333 }
334 return stringBuilder.ToString();
335 }

References $, mapInt, mapStr, and sockets.

Member Data Documentation

◆ blessedState

BlessedState CustomThingContent.blessedState

Definition at line 38 of file CustomThingContent.cs.

Referenced by Create().

◆ id

string CustomThingContent.id = ""

Definition at line 40 of file CustomThingContent.cs.

◆ identifyLevel

IDTLevel CustomThingContent.identifyLevel

Definition at line 43 of file CustomThingContent.cs.

Referenced by Create().

◆ lv

int CustomThingContent.lv = -1

Definition at line 45 of file CustomThingContent.cs.

Referenced by Create().

◆ mapInt

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

Definition at line 47 of file CustomThingContent.cs.

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

◆ mapStr

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

Definition at line 49 of file CustomThingContent.cs.

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

◆ material

string CustomThingContent.material = ""

Definition at line 51 of file CustomThingContent.cs.

Referenced by Create().

◆ noCopy

bool CustomThingContent.noCopy

Definition at line 53 of file CustomThingContent.cs.

Referenced by OnThingCreated().

◆ noRandomSocket

bool CustomThingContent.noRandomSocket

Definition at line 55 of file CustomThingContent.cs.

Referenced by OnThingCreated().

◆ num

int CustomThingContent.num = 1

Definition at line 57 of file CustomThingContent.cs.

Referenced by Create(), and OnThingCreated().

◆ priceCalc

string CustomThingContent.priceCalc = ""

Definition at line 70 of file CustomThingContent.cs.

Referenced by Create().

◆ rarity

Rarity CustomThingContent.rarity

Definition at line 60 of file CustomThingContent.cs.

Referenced by Create(), and OnThingCreated().

◆ restock

bool CustomThingContent.restock = true

Definition at line 63 of file CustomThingContent.cs.

Referenced by Create().

◆ sockets

List<string> CustomThingContent.sockets = new List<string>()

Definition at line 65 of file CustomThingContent.cs.

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

◆ type

SpawnType CustomThingContent.type

Definition at line 68 of file CustomThingContent.cs.

Referenced by Create().

Property Documentation

◆ SourceType

override string CustomThingContent.SourceType
get

Definition at line 72 of file CustomThingContent.cs.


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