1using System.Collections.Generic;
2using System.ComponentModel;
6using Newtonsoft.Json.Converters;
9[JsonObject(MemberSerialization.OptOut)]
37 [JsonConverter(typeof(StringEnumConverter))]
40 public string id =
"";
42 [JsonConverter(typeof(StringEnumConverter))]
47 public Dictionary<string, int>
mapInt =
new Dictionary<string, int>();
49 public Dictionary<string, string>
mapStr =
new Dictionary<string, string>();
59 [JsonConverter(typeof(StringEnumConverter))]
65 public List<string>
sockets =
new List<string>();
67 [JsonConverter(typeof(StringEnumConverter))]
84 for (
int i = 0; i < tag.Length; i++)
90 customThingContent.rarity = r.quality.ToEnum<
Rarity>();
93 if (r.elements.Contains(759))
95 customThingContent.noCopy =
true;
98 case "noRandomSocket":
99 customThingContent.noRandomSocket =
true;
102 customThingContent.restock =
false;
109 customThingContent.
mapInt[array[0]] = array.TryGet(1, returnNull:
true)?.ToInt() ?? 1;
113 if (!array.TryGet(1, returnNull:
true).IsEmpty())
115 customThingContent.
mapStr[array[0]] = array[1];
120 return customThingContent;
125 if (thing.
GetBool(
"custom_content") || thing.
id != base.SourceId)
129 thing.
SetBool(
"custom_content", enable:
true);
130 thing.
SetStr(
"custom_content_id", base.ContentId);
131 thing.
SetStr(
"custom_content_package", base.Owner.id);
133 foreach (KeyValuePair<string, string>
item in mapStr)
135 item.Deconstruct(out var key, out key2);
138 thing.SetStr(text, value);
140 foreach (KeyValuePair<string, int> item2
in mapInt)
142 item2.Deconstruct(out key2, out var value2);
145 thing.SetInt(text2, value3);
147 if (thing.source.ContainsTag(
"forceRarity"))
149 thing.ChangeRarity(
rarity);
155 thing.elements?.SetBase(759, 10);
164 thing.sockets.Clear();
167 foreach (
string socket
in sockets)
170 if (socket.IsEmpty())
176 ApplyRangedSocket(socket);
179 thing.sockets.RemoveAll((
int s) => s == 0);
180 for (
int i = 0; i <
num; i++)
182 thing.sockets.Add(0);
184 void ApplyRangedSocket(
string socket)
186 int num2 = 3 + Mathf.Min(thing.genLv / 10, 15);
189 ModUtil.LogModError(
"source thing row '" + base.ContentId +
"' has invalid addSocket spec '" + socket +
"'", base.Owner);
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)
200 thing.ApplySocket(value4.id, num5);
212 int.TryParse(
id, out var result);
307 thing.
SetBool(101, enable:
true);
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}");
324 stringBuilder.AppendLine(
$" - sockets({sockets.Count})/noRandomSocket({noRandomSocket})/{string.Join(';', sockets)}");
328 stringBuilder.AppendLine(
" - str/" +
string.Join(
';',
mapStr.Select((KeyValuePair<string, string> kv) => kv.Key +
"=" + kv.Value)));
332 stringBuilder.AppendLine(
" - int/" +
string.Join(
';',
mapInt.Select((KeyValuePair<string, int> kv) =>
$"{kv.Key}={kv.Value}")));
334 return stringBuilder.ToString();
List< Action > actionsNextFrame
static void SetRarity(Rarity q=Rarity.Normal)
virtual void SetBlessedState(BlessedState s)
void SetStr(string id, string value=null)
void SetBool(string id, bool enable)
virtual void ChangeRarity(Rarity q)
Dictionary< int, BGMData > dictBGM
static string string string[] kv GetParams(string tag)
override string SourceType
BlessedState blessedState
override string ToString()
Dictionary< string, int > mapInt
static CustomThingContent CreateFromRow(SourceThing.Row r, ModPackage mod=null)
Thing Create(int createLv=-1)
Dictionary< string, string > mapStr
void OnThingCreated(Thing thing)
static SourceManager sources
ReligionManager religions
Dictionary< string, Religion > dictAll
Dictionary< string, string > fuzzyAlias
static Thing CreateRune(int ele, int v, bool free=false)
static Thing CreatePotion(int ele, int num=1)
static Thing CreateFromFilter(string id, int lv=-1)
static Thing CreateMap(string idSource=null, int lv=-1)
static Thing CreatePerfume(int ele, int num=1)
static Thing CreateBlock(int id, int idMat)
static Thing CreateRedBook(string id, int num=1)
static Thing CreateCassette(int id)
static Thing CreateSpellbook(string alias, int num=1)
static Thing CreatePlan(int ele)
static Thing CreateFromTag(string idTag, int lv=-1)
static Thing CreateRecipe(string id)
static Thing CreateSkillbook(int ele, int num=1)
static Thing CreateFromCategory(string idCat, int lv=-1)
static Thing CreateLetter(string idLetter)
static Thing CreateScroll(int ele, int num=1)
static Thing CreateCurrency(int a, string id="money")
static Thing CreateRod(int ele, int charge=-1)
static Thing Create(string id, int idMat=-1, int lv=-1)