1using System.Collections.Generic;
5using Newtonsoft.Json.Converters;
8[JsonObject(MemberSerialization.OptOut)]
36 [JsonConverter(typeof(StringEnumConverter))]
39 public string id =
"";
41 [JsonConverter(typeof(StringEnumConverter))]
46 public Dictionary<string, int>
mapInt =
new Dictionary<string, int>();
48 public Dictionary<string, string>
mapStr =
new Dictionary<string, string>();
58 [JsonConverter(typeof(StringEnumConverter))]
61 [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
64 public List<string>
sockets =
new List<string>();
66 [JsonConverter(typeof(StringEnumConverter))]
83 for (
int i = 0; i < tag.Length; i++)
89 customThingContent.rarity = r.quality.ToEnum<
Rarity>();
92 if (r.elements.Contains(759))
94 customThingContent.noCopy =
true;
97 case "noRandomSocket":
98 customThingContent.noRandomSocket =
true;
101 customThingContent.restock =
false;
108 customThingContent.
mapInt[array[0]] = array.TryGet(1, returnNull:
true)?.ToInt() ?? 1;
112 if (!array.TryGet(1, returnNull:
true).IsEmpty())
114 customThingContent.
mapStr[array[0]] = array[1];
119 return customThingContent;
124 if (thing.
GetBool(
"custom_content") || thing.
id != base.SourceId)
128 thing.
SetBool(
"custom_content", enable:
true);
129 thing.
SetStr(
"custom_content_id", base.ContentId);
130 thing.
SetStr(
"custom_content_package", base.Owner.id);
132 foreach (KeyValuePair<string, string>
item in mapStr)
134 item.Deconstruct(out var key, out key2);
137 thing.SetStr(text, value);
139 foreach (KeyValuePair<string, int> item2
in mapInt)
141 item2.Deconstruct(out key2, out var value2);
144 thing.SetInt(text2, value3);
146 thing.ChangeRarity(
rarity);
151 thing.elements?.SetBase(759, 10);
160 thing.sockets.Clear();
163 foreach (
string socket
in sockets)
166 if (socket.IsEmpty())
172 ApplyRangedSocket(socket);
175 thing.sockets.RemoveAll((
int s) => s == 0);
176 for (
int i = 0; i <
num; i++)
178 thing.sockets.Add(0);
180 void ApplyRangedSocket(
string socket)
182 int num2 = 3 + Mathf.Min(thing.genLv / 10, 15);
185 ModUtil.LogModError(
"source thing row '" + base.ContentId +
"' has invalid addSocket spec '" + socket +
"'", base.Owner);
189 float num3 = Mathf.Sqrt((
float)(thing.genLv * value4.encFactor) / 100f);
190 float num4 = (float)num2 + num3;
191 int num5 = (value4.mtp +
EClass.
rnd(value4.mtp + (
int)num4)) / value4.mtp;
192 if (value4.encFactor == 0 && num5 > 25)
196 thing.ApplySocket(value4.id, num5);
208 int.TryParse(
id, out var result);
303 thing.
SetBool(101, enable:
true);
314 StringBuilder stringBuilder =
new StringBuilder();
315 stringBuilder.AppendLine(
$"{base.ContentId}/{type}/{base.Owner.id}");
316 stringBuilder.AppendLine(
$" - num({num})/lv({lv})/restock({restock})/noCopy({noCopy})/{material}/{rarity}/{blessedState}/{identifyLevel}");
319 stringBuilder.AppendLine(
$" - sockets({sockets.Count})/noRandomSocket({noRandomSocket})/{string.Join(';', sockets)}");
323 stringBuilder.AppendLine(
" - str/" +
string.Join(
';',
mapStr.Select((KeyValuePair<string, string> kv) => kv.Key +
"=" + kv.Value)));
327 stringBuilder.AppendLine(
" - int/" +
string.Join(
';',
mapInt.Select((KeyValuePair<string, int> kv) =>
$"{kv.Key}={kv.Value}")));
329 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)
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)