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>();
61 [JsonConverter(typeof(StringEnumConverter))]
67 public List<string>
sockets =
new List<string>();
69 [JsonConverter(typeof(StringEnumConverter))]
86 for (
int i = 0; i < tag.Length; i++)
92 customThingContent.forceRarity =
true;
93 customThingContent.rarity = r.quality.ToEnum<
Rarity>();
96 if (r.elements.Contains(759))
98 customThingContent.noCopy =
true;
101 case "noRandomSocket":
102 customThingContent.noRandomSocket =
true;
105 customThingContent.restock =
false;
112 customThingContent.
mapInt[array[0]] = array.TryGet(1, returnNull:
true)?.ToInt() ?? 1;
116 if (!array.TryGet(1, returnNull:
true).IsEmpty())
118 customThingContent.
mapStr[array[0]] = array[1];
123 return customThingContent;
128 if (thing.
GetBool(
"custom_content") || thing.
id != base.SourceId)
132 thing.
SetBool(
"custom_content", enable:
true);
133 thing.
SetStr(
"custom_content_id", base.ContentId);
134 thing.
SetStr(
"custom_content_package", base.Owner.id);
136 foreach (KeyValuePair<string, string>
item in mapStr)
138 item.Deconstruct(out var key, out key2);
141 thing.SetStr(text, value);
143 foreach (KeyValuePair<string, int> item2
in mapInt)
145 item2.Deconstruct(out key2, out var value2);
148 thing.SetInt(text2, value3);
152 thing.ChangeRarity(
rarity);
158 thing.elements?.SetBase(759, 10);
167 thing.sockets.Clear();
170 foreach (
string socket
in sockets)
173 if (socket.IsEmpty())
179 ApplyRangedSocket(socket);
182 thing.sockets.RemoveAll((
int s) => s == 0);
183 for (
int num2 = 0; num2 <
num; num2++)
185 thing.sockets.Add(0);
187 void ApplyRangedSocket(
string socket)
189 int num3 = 3 + Mathf.Min(thing.genLv / 10, 15);
192 ModUtil.LogModError(
"source thing row '" + base.ContentId +
"' has invalid addSocket spec '" + socket +
"'", base.Owner);
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)
204 thing.ApplySocket(value4.id, num7);
216 int.TryParse(
id, out var result);
311 thing.
SetBool(101, enable:
true);
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}");
328 stringBuilder.AppendLine(
$" - sockets({sockets.Count})/noRandomSocket({noRandomSocket})/{string.Join(';', sockets)}");
332 stringBuilder.AppendLine(
" - str/" +
string.Join(
';',
mapStr.Select((KeyValuePair<string, string> kv) => kv.Key +
"=" + kv.Value)));
336 stringBuilder.AppendLine(
" - int/" +
string.Join(
';',
mapInt.Select((KeyValuePair<string, int> kv) =>
$"{kv.Key}={kv.Value}")));
338 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)