Elin Decompiled Documentation EA 23.342.1 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 forceRarity
 
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 209 of file CustomThingContent.cs.

210 {
211 if (lv != -1)
212 {
213 createLv = lv;
214 }
216 int.TryParse(id, out var result);
217 if (EClass.sources.elements.fuzzyAlias.TryGetValue(id, out var value))
218 {
219 result = EClass.sources.elements.alias[value].id;
220 }
221 Thing thing = null;
222 int idMat = EClass.sources.materials.alias.TryGetValue(material)?.id ?? (-1);
223 switch (type)
224 {
225 case SpawnType.Item:
226 thing = ThingGen.Create(id, idMat, createLv).SetNum(num);
227 break;
228 case SpawnType.Block:
229 {
230 SourceBlock.Row row = EClass.sources.blocks.alias.TryGetValue(id);
231 if (row != null)
232 {
233 thing = ThingGen.CreateBlock(row.id, idMat).SetNum(num);
234 }
235 break;
236 }
237 case SpawnType.Cassette:
238 if (!EClass.core.refs.dictBGM.ContainsKey(result))
239 {
240 result = EClass.core.refs.dictBGM.RandomItem().id;
241 }
242 thing = ThingGen.CreateCassette(result);
243 break;
244 case SpawnType.Currency:
245 thing = ThingGen.CreateCurrency(num, id);
246 break;
247 case SpawnType.Category:
248 thing = ThingGen.CreateFromCategory(id, createLv).SetNum(num);
249 break;
250 case SpawnType.Filter:
251 thing = ThingGen.CreateFromFilter(id, createLv).SetNum(num);
252 break;
253 case SpawnType.Tag:
254 thing = ThingGen.CreateFromTag(id, createLv).SetNum(num);
255 break;
256 case SpawnType.Letter:
257 thing = ThingGen.CreateLetter(id);
258 break;
259 case SpawnType.Map:
260 thing = ThingGen.CreateMap(id, createLv);
261 break;
262 case SpawnType.Perfume:
263 thing = ThingGen.CreatePerfume(result, createLv).SetNum(num);
264 break;
265 case SpawnType.Plan:
266 thing = ThingGen.CreatePlan(result);
267 break;
268 case SpawnType.Potion:
269 thing = ThingGen.CreatePotion(result, num);
270 break;
271 case SpawnType.Recipe:
272 thing = ThingGen.CreateRecipe(id);
273 break;
274 case SpawnType.RedBook:
275 thing = ThingGen.CreateRedBook(id);
276 break;
277 case SpawnType.Rod:
278 thing = ThingGen.CreateRod(result, num);
279 break;
280 case SpawnType.Rune:
281 thing = ThingGen.CreateRune(result, num);
282 break;
283 case SpawnType.RuneFree:
284 thing = ThingGen.CreateRune(result, num, free: true);
285 break;
286 case SpawnType.Scroll:
287 thing = ThingGen.CreateScroll(result, num);
288 break;
289 case SpawnType.Skill:
290 thing = ThingGen.CreateSkillbook(result, num);
291 break;
292 case SpawnType.Spell:
293 thing = ThingGen.CreateSpellbook(result, 1, num);
294 break;
295 case SpawnType.Usuihon:
296 thing = ThingGen.Create("1084");
297 thing.c_idRefName = EClass.game.religions.dictAll.TryGetValue(id)?.id;
298 break;
299 default:
300 thing = ThingGen.Create(id);
301 break;
302 }
303 if (thing == null)
304 {
305 return null;
306 }
307 thing.c_IDTState = (int)identifyLevel;
309 if (!restock)
310 {
311 thing.SetBool(101, enable: true);
312 }
313 if (!priceCalc.IsEmpty())
314 {
315 thing.SetStr("price_calc_override", priceCalc);
316 }
317 thing.ChangeRarity(rarity);
318 return thing;
319 }
static void SetRarity(Rarity q=Rarity.Normal)
Thing SetNum(int a)
Definition: Card.cs:3676
virtual void SetBlessedState(BlessedState s)
Definition: Card.cs:4076
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:4101
Dictionary< int, BGMData > dictBGM
Definition: CoreRef.cs:388
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.

◆ CreateFromRow()

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

Definition at line 76 of file CustomThingContent.cs.

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

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

References BaseCore.actionsNextFrame, EClass.core, SourceManager.elements, forceRarity, 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 321 of file CustomThingContent.cs.

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

References $, mapInt, mapStr, and sockets.

Member Data Documentation

◆ blessedState

BlessedState CustomThingContent.blessedState

Definition at line 38 of file CustomThingContent.cs.

Referenced by Create().

◆ forceRarity

bool CustomThingContent.forceRarity

Definition at line 53 of file CustomThingContent.cs.

Referenced by OnThingCreated().

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

Referenced by OnThingCreated().

◆ noRandomSocket

bool CustomThingContent.noRandomSocket

Definition at line 57 of file CustomThingContent.cs.

Referenced by OnThingCreated().

◆ num

int CustomThingContent.num = 1

Definition at line 59 of file CustomThingContent.cs.

Referenced by Create(), and OnThingCreated().

◆ priceCalc

string CustomThingContent.priceCalc = ""

Definition at line 72 of file CustomThingContent.cs.

Referenced by Create().

◆ rarity

Rarity CustomThingContent.rarity

Definition at line 62 of file CustomThingContent.cs.

Referenced by Create(), and OnThingCreated().

◆ restock

bool CustomThingContent.restock = true

Definition at line 65 of file CustomThingContent.cs.

Referenced by Create().

◆ sockets

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

Definition at line 67 of file CustomThingContent.cs.

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

◆ type

SpawnType CustomThingContent.type

Definition at line 70 of file CustomThingContent.cs.

Referenced by Create().

Property Documentation

◆ SourceType

override string CustomThingContent.SourceType
get

Definition at line 74 of file CustomThingContent.cs.


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