private void UpdateBlueprint(ItemBlueprint bp, JSONObject o) { bp.rarity = GetRarity(o); if (!_craftingController) { bp.time = o.GetFloat("time", 0); } bp.amountToCreate = o.GetInt("amountToCreate", 1); //bp.UnlockPrice = o.GetInt("UnlockPrice", 0); //bp.UnlockLevel = o.GetInt("UnlockLevel", 10); bp.blueprintStackSize = o.GetInt("blueprintStackSize"); //bp.userCraftable = o.GetBoolean("userCraftable", true); bp.isResearchable = o.GetBoolean("isResearchable", true); bp.NeedsSteamItem = o.GetBoolean("NeedsSteamItem", false); var ingredients = o.GetArray("ingredients"); bp.ingredients.Clear(); foreach (var ingredient in ingredients) { var itemDef = GetItem(ingredient.Obj, "shortname"); if (itemDef == null) { continue; } bp.ingredients.Add(new ItemAmount(itemDef, ingredient.Obj.GetFloat("amount", 0))); } }
private static bool GetTypeArray(JSON.Object o, Type type, string key, ref object value) { JSON.Array result = default(JSON.Array); if (!o.Get(key, ref result)) { return(false); } int count = result.Count; Array array = Array.CreateInstance(type, count); for (int i = 0; i < count; ++i) { JSON.Object tmp1 = default(JSON.Object); if (!o.Get(key, ref tmp1)) { return(false); } JSON.Readable tmp2; try { tmp2 = (JSON.Readable)Activator.CreateInstance(type); } catch (Exception) { return(false); } if (!tmp2.Read(tmp1)) { return(false); } array.SetValue(tmp2, i); } value = array; return(true); }
private static bool GetEnumNullable(JSON.Object o, Type type, string key, ref object value) { string result = default(string); if (!o.Get(key, ref result)) { return(false); } if (string.IsNullOrEmpty(result)) { value = Activator.CreateInstance(typeof(Nullable <>).MakeGenericType(type)); return(true); } object tmp; try { tmp = Enum.Parse(type, result); } catch (Exception) { return(false); } value = Activator.CreateInstance(typeof(Nullable <>).MakeGenericType(type), tmp); return(true); }
private static bool GetTypeNullable(JSON.Object o, Type type, string key, ref object value) { JSON.Object result = default(JSON.Object); if (!o.Get(key, ref result)) { return(false); } if (result == null) { value = Activator.CreateInstance(typeof(Nullable <>).MakeGenericType(type)); return(true); } JSON.Readable tmp; try { tmp = (JSON.Readable)Activator.CreateInstance(type); } catch (Exception) { return(false); } if (!tmp.Read(result)) { return(false); } value = Activator.CreateInstance(typeof(Nullable <>).MakeGenericType(type), tmp); return(true); }
private static bool GetEnumArray(JSON.Object o, Type type, string key, ref object value) { JSON.Array result = default(JSON.Array); if (!o.Get(key, ref result)) { return(false); } int count = result.Count; Array array = Array.CreateInstance(type, count); for (int i = 0; i < count; ++i) { string tmp1 = default(string); if (!o.Get(key, ref tmp1)) { return(false); } object tmp2; try { tmp2 = Enum.Parse(type, tmp1); } catch (Exception) { return(false); } array.SetValue(tmp2, i); } value = array; return(true); }
private Rarity GetRarity(JSONObject item) { var rarity = "None"; if (item.ContainsKey("rarity")) { rarity = item["rarity"].Type == JSONValueType.String ? item.GetString("rarity", "None") : item.GetInt("rarity", 0).ToString(); } return((Rarity)Enum.Parse(typeof(Rarity), rarity)); }
public static bool Read(JSON.Object o, ref T value) { for (int i = 0, j = readers.Count; i < j; ++i) { if (!readers[i](o, ref value)) { return(false); } } return(true); }
public Value(JSON.Object obj) { if (obj == null) { this.Type = JSON.ValueType.Null; } else { this.Type = JSON.ValueType.Object; this.Obj = obj; } }
private static void StripObject(JSONObject obj) { if (obj == null) { return; } var keys = obj.Select(entry => entry.Key).ToList(); foreach (var key in keys) { if (!key.Equals("shortname") && !key.Equals("itemid")) { obj.Remove(key); } } }
private JSONValue ObjectToJsonObject(object obj) { if (obj == null) { return(new JSONValue(JSONValueType.Null)); } if (obj is string) { return(new JSONValue((string)obj)); } if (obj is double) { return(new JSONValue((double)obj)); } if (obj is int) { return(new JSONValue((int)obj)); } if (obj is bool) { return(new JSONValue((bool)obj)); } var dict = obj as Dictionary <string, object>; if (dict != null) { var newObj = new JSONObject(); foreach (var prop in dict) { newObj.Add(prop.Key, ObjectToJsonObject(prop.Value)); } return(newObj); } var list = obj as List <object>; if (list != null) { var arr = new JSONArray(); foreach (var o in list) { arr.Add(ObjectToJsonObject(o)); } return(arr); } Puts("Unknown: " + obj.GetType().FullName + " Value: " + obj); return(new JSONValue(JSONValueType.Null)); }
private void UpdateLootSpawn(LootSpawn lootSpawn, JSONObject obj, string path) { var value = obj.GetValue(path); if (value != null && value.Type == JSONValueType.Array && value.Array.Length > 0) { lootSpawn.items = new ItemAmount[0]; lootSpawn.blueprints = new ItemAmount[0]; lootSpawn.subSpawn = new LootSpawn.Entry[value.Array.Length]; for (var i = 0; i < lootSpawn.subSpawn.Length; i++) { lootSpawn.subSpawn[i] = new LootSpawn.Entry { category = ScriptableObject.CreateInstance <LootSpawn>(), weight = value.Array[i].Obj.GetInt("weight", 0) }; UpdateLootSpawn(lootSpawn.subSpawn[i].category, value.Array[i].Obj, "category"); } return; } var itemsValue = obj.GetValue("items"); if (itemsValue != null && itemsValue.Type == JSONValueType.Array && itemsValue.Array.Length > 0) { var items = itemsValue.Array; lootSpawn.items = new ItemAmount[items.Length]; for (var i = 0; i < items.Length; i++) { var def = ItemManager.FindItemDefinition(items[i].Obj.GetString("item", "unnamed")); //TODO null check lootSpawn.items[i] = new ItemAmount(def, items[i].Obj.GetFloat("amount", 0)); } } var blueprintsValue = obj.GetValue("blueprints"); if (blueprintsValue != null && blueprintsValue.Type == JSONValueType.Array && blueprintsValue.Array.Length > 0) { var blueprints = blueprintsValue.Array; lootSpawn.blueprints = new ItemAmount[blueprints.Length]; for (var i = 0; i < blueprints.Length; i++) { var def = ItemManager.FindItemDefinition(blueprints[i].Obj.GetString("item", "unnamed")); //TODO null check lootSpawn.blueprints[i] = new ItemAmount(def, blueprints[i].Obj.GetFloat("amount", 0)); } } }
private static void UpdateBlueprint(ItemBlueprint bp, JSONObject o) { bp.rarity = (Rarity)Enum.Parse(typeof(Rarity), o.GetString("rarity", "None")); bp.time = o.GetInt("time", 0); bp.amountToCreate = o.GetInt("amountToCreate", 1); bp.userCraftable = o.GetBoolean("userCraftable", true); bp.defaultBlueprint = o.GetBoolean("defaultBlueprint", false); var ingredients = o.GetArray("ingredients"); var manager = SingletonComponent <ItemManager> .Instance; bp.ingredients.Clear(); foreach (var ingredient in ingredients) { var itemid = ingredient.Obj.GetInt("itemid", 0); var definition = manager.itemList.Find(x => x.itemid == itemid); bp.ingredients.Add(new ItemAmount(definition, ingredient.Obj.GetFloat("amount", 0))); } }
private static bool GetEnum(JSON.Object o, Type type, string key, ref object value) { string result = default(string); if (!o.Get(key, ref result)) { return(false); } try { value = Enum.Parse(type, result); } catch (Exception) { return(false); } return(true); }
private void StripLoot(JSONObject obj, JSONObject parent = null, string path = null) { var value = obj.GetValue("subSpawn"); if (value != null && value.Type == JSONValueType.Array && value.Array.Length > 0) { if (parent != null) { parent[path] = obj.GetArray("subSpawn"); } obj.Remove("items"); obj.Remove("blueprints"); StripSubCategoryLoot(obj.GetArray("subSpawn")); return; } obj.Remove("subSpawn"); var items = obj.GetValue("items"); if (items != null && items.Type == JSONValueType.Array) { foreach (var item in items.Array) { StripEntry(item.Obj); } } var bps = obj.GetValue("blueprints"); if (bps != null && bps.Type == JSONValueType.Array) { foreach (var bp in bps.Array) { StripEntry(bp.Obj); } } if (parent != null && path != null && path.Equals("category")) { parent["items"] = items; parent["blueprints"] = bps; parent.Remove("category"); } }
private static bool GetType(JSON.Object o, Type type, string key, ref object value) { JSON.Object result = default(JSON.Object); if (!o.Get(key, ref result)) { return(false); } JSON.Readable tmp; try { tmp = (JSON.Readable)Activator.CreateInstance(type); } catch (Exception) { return(false); } if (!tmp.Read(result)) { return(false); } value = tmp; return(true); }
private async Task <VersionNumber> GetLatestExtensionVersion() { string json = await WebClient.DownloadStringTaskAsync(OxideRustReleaseListUrl); if (string.IsNullOrWhiteSpace(json)) { throw new Exception("Could not retrieve latest Oxide.Rust version from GitHub API"); } JSON.Array releaseArray = JSON.Array.Parse(json); JSON.Object latest = releaseArray[0].Obj; string tag = latest.GetString("tag_name"); if (string.IsNullOrWhiteSpace(tag)) { throw new Exception("Tag name is undefined"); } VersionNumber tagVersion = ParseVersionNumber(tag); return(tagVersion); }
public Object(JSON.Object other) { this.values = new Dictionary <string, Value>(); this.values = new Dictionary <string, Value>(); if (other != null) { IEnumerator <KeyValuePair <string, Value> > enumerator = other.values.GetEnumerator(); try { while (enumerator.MoveNext()) { KeyValuePair <string, Value> current = enumerator.Current; this.values[current.Key] = new Value(current.Value); } } finally { if (enumerator == null) { } enumerator.Dispose(); } } }
/*private static void StripObject(JSONObject obj) * { * if (obj == null) return; * var keys = obj.Select(entry => entry.Key).ToList(); * foreach (var key in keys) * { * if (!key.Equals("shortname") && !key.Equals("itemid")) * obj.Remove(key); * } * } * * private static void StripArray(JSONArray arr, string key) * { * if (arr == null) return; * foreach (var obj in arr) * { * StripObject(obj.Obj[key].Obj); * } * }*/ private bool CreateDefaultConfig() { Config.Clear(); Config["Version"] = Protocol.network; Config["VersionConfig"] = VersionConfig; var gameObjectArray = FileSystem.Load <ObjectList>("Assets/items.asset").objects.Cast <GameObject>().ToArray(); var itemList = gameObjectArray.Select(x => x.GetComponent <ItemDefinition>()).Where(x => x != null).ToArray(); var bpList = gameObjectArray.Select(x => x.GetComponent <ItemBlueprint>()).Where(x => x != null).ToArray(); var items = new JSONArray(); foreach (var definition in itemList) { //Puts("Item: {0}", definition.displayName.english); var obj = ToJsonObject(definition); obj.Remove("itemid"); obj.Remove("hidden"); obj.Remove("isWearable"); obj["Parent"] = definition.Parent?.shortname; obj["displayName"] = definition.displayName.english; obj["displayDescription"] = definition.displayDescription.english; var mods = definition.GetComponentsInChildren <ItemMod>(true); var modArray = new JSONArray(); foreach (var itemMod in mods) { if (itemMod.GetType() == typeof(ItemModMenuOption) || itemMod.GetType() == typeof(ItemModConditionHasFlag) || itemMod.GetType() == typeof(ItemModConditionContainerFlag) || itemMod.GetType() == typeof(ItemModSwitchFlag) || itemMod.GetType() == typeof(ItemModCycle) || itemMod.GetType() == typeof(ItemModConditionHasContents) || itemMod.GetType() == typeof(ItemModUseContent) || itemMod.GetType() == typeof(ItemModEntity) || itemMod.GetType() == typeof(ItemModUnwrap)) { continue; } //Puts("ItemMod: {0}", itemMod.GetType()); var mod = ToJsonObject(itemMod); if (itemMod.GetType() == typeof(ItemModBurnable)) { mod["byproductItem"] = mod.GetObject("byproductItem")?.GetString("shortname", "unnamed"); } else if (itemMod.GetType() == typeof(ItemModCookable)) { mod["becomeOnCooked"] = mod.GetObject("becomeOnCooked")?.GetString("shortname", "unnamed"); } else if (itemMod.GetType() == typeof(ItemModContainer)) { var defaultContents = mod["defaultContents"].Array; foreach (var entry in defaultContents) { entry.Obj["shortname"] = entry.Obj.GetObject("itemDef").GetString("shortname", "unnamed"); entry.Obj.Remove("itemDef"); entry.Obj.Remove("itemid"); } mod["onlyAllowedItemType"] = mod.GetObject("onlyAllowedItemType")?.GetString("shortname", "unnamed"); } else if (itemMod.GetType() == typeof(ItemModConsume)) { mod["effects"] = ToJsonArray(itemMod.GetComponent <ItemModConsumable>().effects); } else if (itemMod.GetType() == typeof(ItemModReveal)) { mod["revealedItemOverride"] = mod.GetObject("revealedItemOverride")?.GetString("shortname", "unnamed"); } else if (itemMod.GetType() == typeof(ItemModRecycleInto)) { mod["recycleIntoItem"] = mod.GetObject("recycleIntoItem")?.GetString("shortname", "unnamed"); } else if (itemMod.GetType() == typeof(ItemModUpgrade)) { mod["upgradedItem"] = mod.GetObject("upgradedItem")?.GetString("shortname", "unnamed"); } else if (itemMod.GetType() == typeof(ItemModSwap)) { var becomeItems = mod["becomeItem"].Array; foreach (var entry in becomeItems) { entry.Obj["shortname"] = entry.Obj.GetObject("itemDef").GetString("shortname", "unnamed"); entry.Obj.Remove("itemDef"); entry.Obj.Remove("itemid"); } } else if (itemMod.GetType() == typeof(ItemModWearable)) { var itemModWearable = itemMod.GetComponent <ItemModWearable>(); if (itemModWearable.protectionProperties != null) { var protectionObj = new JSONObject { ["density"] = itemModWearable.protectionProperties.density }; var amounts = new JSONObject(); for (var i = 0; i < itemModWearable.protectionProperties.amounts.Length; i++) { amounts[((DamageType)i).ToString()] = itemModWearable.protectionProperties.amounts[i]; } protectionObj["amounts"] = amounts; mod["protection"] = protectionObj; } if (itemModWearable.armorProperties != null) { mod["armor"] = FromJsonString <string>(ToJsonString((HitAreaUnity)itemModWearable.armorProperties.area)); } var targetWearable = mod.GetObject("targetWearable"); targetWearable.Remove("showCensorshipCube"); targetWearable.Remove("showCensorshipCubeBreasts"); targetWearable.Remove("followBone"); targetWearable["occupationOver"] = FromJsonString <string>(ToJsonString((OccupationSlotsUnity)itemModWearable.targetWearable.occupationOver)); targetWearable["occupationUnder"] = FromJsonString <string>(ToJsonString((OccupationSlotsUnity)itemModWearable.targetWearable.occupationUnder)); } if (!mod.Any()) { continue; } mod["type"] = itemMod.GetType().FullName; modArray.Add(mod); } var modEntity = definition.GetComponent <ItemModEntity>(); if (modEntity != null) { var prefab = modEntity.entityPrefab?.Get(); var timedExplosive = prefab?.GetComponent <ThrownWeapon>()?.prefabToThrow?.Get()?.GetComponent <TimedExplosive>(); if (timedExplosive != null) { var mod = ToJsonObject(timedExplosive); mod["type"] = modEntity.GetType().FullName + timedExplosive.GetType().FullName; if (timedExplosive is DudTimedExplosive) { mod.Remove("itemToGive"); } modArray.Add(mod); } var modMelee = prefab?.GetComponent <BaseMelee>(); if (modMelee != null) { var mod = ToJsonObject(modMelee); mod["type"] = modEntity.GetType().FullName + typeof(BaseMelee).FullName; mod.Remove("strikeEffect"); modArray.Add(mod); } var baseProjectile = prefab?.GetComponent <BaseProjectile>(); if (baseProjectile != null) { var mod = new JSONObject { ["ammoType"] = baseProjectile.primaryMagazine.ammoType.shortname, //["ammoTypes"] = ToJsonString(baseProjectile.primaryMagazine.definition.ammoTypes), ["builtInSize"] = baseProjectile.primaryMagazine.definition.builtInSize, //["capacity"] = baseProjectile.primaryMagazine.capacity, ["contents"] = baseProjectile.primaryMagazine.contents, ["type"] = modEntity.GetType().FullName + typeof(BaseProjectile).FullName }; modArray.Add(mod); } } var modProjectile = definition.GetComponent <ItemModProjectile>(); if (modProjectile != null) { var prefab = modProjectile.projectileObject?.Get(); var projectile = prefab?.GetComponent <Projectile>(); if (projectile != null) { var mod = ToJsonObject(projectile); mod.Remove("sourceWeapon"); mod.Remove("projectileID"); mod.Remove("seed"); mod.Remove("velocityScalar"); if (modProjectile.mods != null) { var modsArray = new JSONArray(); foreach (var projectileMod in modProjectile.mods) { var projMod = ToJsonObject(projectileMod); projMod["type"] = projectileMod.GetType().FullName; modsArray.Add(projMod); } mod["mods"] = modsArray; } var spawn = modProjectile as ItemModProjectileSpawn; if (spawn != null) { mod["createOnImpactChance"] = spawn.createOnImpactChance; mod["spreadAngle"] = spawn.spreadAngle; } mod["type"] = modProjectile.GetType().FullName; modArray.Add(mod); } /*var components = modProjectile.projectileObject.targetObject.GetComponents(typeof (Component)); * foreach (var component in components) * { * LocalPuts("Name: " + component.name + " Type: " + component.GetType().Name); * }*/ var timedExplosive = prefab?.GetComponent <TimedExplosive>(); if (timedExplosive != null) { var mod = ToJsonObject(timedExplosive); mod["type"] = modProjectile.GetType().FullName + timedExplosive.GetType().FullName; modArray.Add(mod); } var serverProjectile = prefab?.GetComponent <ServerProjectile>(); if (serverProjectile != null) { var mod = ToJsonObject(serverProjectile); mod["type"] = modProjectile.GetType().FullName + serverProjectile.GetType().FullName; modArray.Add(mod); } } obj["modules"] = modArray; items.Add(obj); } Config["Items"] = JsonObjectToObject(items); var bps = ToJsonArray(bpList); foreach (var bp in bps) { bp.Obj["targetItem"] = bp.Obj.GetObject("targetItem").GetString("shortname", "unnamed"); bp.Obj.Remove("userCraftable"); bp.Obj.Remove("defaultBlueprint"); foreach (var ing in bp.Obj.GetArray("ingredients")) { ing.Obj["shortname"] = ing.Obj.GetObject("itemDef").GetString("shortname", "unnamed"); ing.Obj.Remove("itemDef"); ing.Obj.Remove("itemid"); } } Config["Blueprints"] = JsonObjectToObject(bps); try { Config.Save(_configpath); } catch (Exception e) { Puts("Config save failed: {0}{1}{2}", e.Message, Environment.NewLine, e.StackTrace); return(false); } Puts("Created new config"); return(LoadConfig()); }
/*private void UpdateConstructions() * { * var constructions = Config["Constructions"] as Dictionary<string, object>; * if (constructions == null) * { * LocalPuts("No constructions in config"); * return; * } * var componentList = (List<Construction.Common>) ComponentList.GetValue(null); * var protectionProperties = new HashSet<ProtectionProperties>(); * var manager = SingletonComponent<ItemManager>.Instance; * foreach (var common in componentList) * { * var construction = ObjectToJsonObject(constructions[common.name]); * var grades = construction.Obj.GetObject("grades"); * for (var g = 0; g < common.grades.Length; g++) * { * var gradeType = (BuildingGrade.Enum) g; * if (!grades.ContainsKey(gradeType.ToString())) * { * common.grades[g] = null; * continue; * } * if (common.grades[g] == null) common.grades[g] = new Construction.Grade(); * var grade = common.grades[g]; * var newGrade = grades.GetObject(gradeType.ToString()); * UpdateConstructionHealth(grade, newGrade.GetFloat("maxHealth", 0)); * grade.costToBuild.Clear(); * var costToBuild = newGrade.GetArray("costToBuild"); * foreach (var cost in costToBuild) * { * var itemid = cost.Obj.GetInt("itemid", 0); * var definition = manager.itemList.Find(x => x.itemid == itemid); * grade.costToBuild.Add(new ItemAmount(definition, cost.Obj.GetFloat("amount", 0))); * } * if (grade.damageProtecton != null) * { * protectionProperties.Add(grade.damageProtecton); * } * } * } * var protections = Config["DamageProtections"] as Dictionary<string, object>; * if (protections == null) * return; * foreach (var protectionProperty in protectionProperties) * { * protectionProperty.Clear(); * var damageProtection = protections[protectionProperty.name] as Dictionary<string, object>; * if (damageProtection == null) continue; * foreach (var o in damageProtection) * { * protectionProperty.Add((DamageType) Enum.Parse(typeof (DamageType), o.Key), (float)Convert.ToDouble(o.Value)); * } * } * } * * private void UpdateConstructionHealth(Construction.Grade grade, float newHealth) * { * if (grade.maxHealth == newHealth) return; * grade.maxHealth = newHealth; * var bb = UnityEngine.Object.FindObjectsOfType<BuildingBlock>().Where(b => b.currentGrade == grade); * foreach (var buildingBlock in bb) * { * buildingBlock.SetHealthToMax(); * } * }*/ private static void UpdateItem(ItemDefinition definition, JSONObject item) { definition.shortname = item.GetString("shortname", "unnamed"); definition.itemid = item.GetInt("itemid", 0); definition.stackable = item.GetInt("stackable", 1); definition.category = (ItemCategory)Enum.Parse(typeof(ItemCategory), item.GetString("category", "Weapon")); var condition = item.GetObject("condition"); definition.condition.enabled = condition.GetBoolean("enabled", false); definition.condition.max = condition.GetInt("max", 0); definition.condition.repairable = condition.GetBoolean("repairable", false); definition.rarity = (Rarity)Enum.Parse(typeof(Rarity), item.GetString("rarity", "None")); var modules = item.GetArray("modules").Select(m => m.Obj); var cook = 0; foreach (var mod in modules) { var typeName = mod.GetString("type", ""); if (typeName.Equals("ItemModConsume")) { var itemMod = definition.GetComponent <ItemModConsume>(); var itemEffects = itemMod.GetComponent <ItemModConsumable>().effects; var effects = mod.GetArray("effects"); itemEffects.Clear(); foreach (var effect in effects) { itemEffects.Add(new ItemModConsumable.ConsumableEffect { type = (MetabolismAttribute.Type)Enum.Parse(typeof(MetabolismAttribute.Type), effect.Obj.GetString("type", "")), amount = effect.Obj.GetFloat("amount", 0), time = effect.Obj.GetFloat("time", 0) }); } } else if (typeName.Equals("ItemModContainer")) { var itemMod = definition.GetComponent <ItemModContainer>(); itemMod.capacity = mod.GetInt("capacity", 6); itemMod.openInDeployed = mod.GetBoolean("openInDeployed", true); itemMod.openInInventory = mod.GetBoolean("openInInventory", true); itemMod.defaultContents.Clear(); var defaultContents = mod.GetArray("defaultContents"); var manager = SingletonComponent <ItemManager> .Instance; foreach (var content in defaultContents) { var itemid = content.Obj.GetInt("itemid", 0); var def = manager.itemList.Find(x => x.itemid == itemid); itemMod.defaultContents.Add(new ItemAmount(def, content.Obj.GetFloat("amount", 0))); } } else if (typeName.Equals("ItemModBurnable")) { //definition.gameObject.AddComponent<ItemModBurnable>(); var itemMod = definition.GetComponent <ItemModBurnable>(); itemMod.fuelAmount = mod.GetFloat("fuelAmount", 10f); itemMod.byproductAmount = mod.GetInt("byproductAmount", 1); itemMod.byproductChance = mod.GetFloat("byproductChance", 0.5f); var manager = SingletonComponent <ItemManager> .Instance; var itemid = mod.GetObject("byproductItem").GetInt("itemid", 0); itemMod.byproductItem = manager.itemList.Find(x => x.itemid == itemid); } else if (typeName.Equals("ItemModCookable")) { var itemMods = definition.GetComponents <ItemModCookable>(); var itemMod = itemMods[cook++]; itemMod.cookTime = mod.GetFloat("cookTime", 30f); itemMod.amountOfBecome = mod.GetInt("amountOfBecome", 1); itemMod.lowTemp = mod.GetInt("lowTemp", 0); itemMod.highTemp = mod.GetInt("highTemp", 0); itemMod.setCookingFlag = mod.GetBoolean("setCookingFlag", false); var become = mod.GetObject("becomeOnCooked"); if (become == null) { itemMod.becomeOnCooked = null; continue; } var manager = SingletonComponent <ItemManager> .Instance; var itemid = become.GetInt("itemid", 0); itemMod.becomeOnCooked = manager.itemList.Find(x => x.itemid == itemid); } else if (typeName.Equals("ItemModSwap")) { var itemMod = definition.GetComponent <ItemModSwap>(); itemMod.sendPlayerDropNotification = mod.GetBoolean("sendPlayerDropNotification", false); itemMod.sendPlayerPickupNotification = mod.GetBoolean("sendPlayerPickupNotification", false); var items = new List <ItemAmount>(); var becomeItems = mod.GetArray("becomeItem"); var manager = SingletonComponent <ItemManager> .Instance; foreach (var content in becomeItems) { var itemid = content.Obj.GetInt("itemid", 0); var def = manager.itemList.Find(x => x.itemid == itemid); items.Add(new ItemAmount(def, content.Obj.GetFloat("amount", 0))); } itemMod.becomeItem = items.ToArray(); } else if (typeName.Equals("ItemModProjectile")) { var itemMod = definition.GetComponent <ItemModProjectile>(); var projectile = itemMod.projectileObject.targetObject.GetComponent <Projectile>(); projectile.drag = mod.GetFloat("drag", 0); projectile.thickness = mod.GetFloat("thickness", 0); projectile.remainInWorld = mod.GetBoolean("remainInWorld", false); projectile.stickProbability = mod.GetFloat("stickProbability", 0); projectile.breakProbability = mod.GetFloat("breakProbability", 0); projectile.ricochetChance = mod.GetFloat("ricochetChance", 0); projectile.fullDamageVelocity = mod.GetFloat("fullDamageVelocity", 200); projectile.damageTypes.Clear(); var damageTypes = mod.GetArray("damageTypes"); foreach (var damageType in damageTypes) { projectile.damageTypes.Add(new DamageTypeEntry { amount = damageType.Obj.GetFloat("amount", 0), type = (DamageType)Enum.Parse(typeof(DamageType), damageType.Obj.GetString("type", "")) }); } } } }
private static bool Get(JSON.Object o, string key, ref double d) { return(o.Get(key, ref d)); }
private JSONValue ObjectToJsonObject(object obj) { if (obj == null) { return new JSONValue(JSONValueType.Null); } if (obj is string) { return new JSONValue((string)obj); } if (obj is double) { return new JSONValue((double)obj); } if (obj is int) { return new JSONValue((int)obj); } if (obj is bool) { return new JSONValue((bool)obj); } var dict = obj as Dictionary<string, object>; if (dict != null) { var newObj = new JSONObject(); foreach (var prop in dict) { newObj.Add(prop.Key, ObjectToJsonObject(prop.Value)); } return newObj; } var list = obj as List<object>; if (list != null) { var arr = new JSONArray(); foreach (var o in list) { arr.Add(ObjectToJsonObject(o)); } return arr; } Puts("Unknown: " + obj.GetType().FullName + " Value: " + obj); return new JSONValue(JSONValueType.Null); }
public static JSON.Array Parse(string jsonString) { JSON.Object obj2 = JSON.Object.Parse("{ \"array\" :" + jsonString + '}'); return((obj2 != null) ? obj2.GetValue("array").Array : null); }
private static void StripEntry(JSONObject obj) { obj["item"] = obj.GetObject("itemDef").GetString("shortname", "unnamed"); obj.Remove("itemDef"); obj.Remove("itemid"); }
private void UpdateItem(ItemDefinition definition, JSONObject item) { definition.shortname = item.GetString("shortname", "unnamed"); if (!_stackSizes) { definition.stackable = item.GetInt("stackable", 1); } definition.maxDraggable = item.GetInt("maxDraggable", 0); definition.category = (ItemCategory)Enum.Parse(typeof(ItemCategory), item.GetString("category", "Weapon")); var condition = item.GetObject("condition"); definition.condition.enabled = condition.GetBoolean("enabled", false); definition.condition.max = condition.GetFloat("max", 0); definition.condition.repairable = condition.GetBoolean("repairable", false); definition.rarity = GetRarity(item); definition.Parent = GetItem(item, "Parent"); var modules = item.GetArray("modules").Select(m => m.Obj); foreach (var mod in modules) { var typeName = mod.GetString("type", ""); //Puts("Item: {0} - {1}", definition.shortname, typeName); if (typeName.Equals("ItemModConsume")) { var itemMod = definition.GetComponent <ItemModConsume>(); var itemEffects = itemMod.GetComponent <ItemModConsumable>().effects; var effects = mod.GetArray("effects"); itemEffects.Clear(); foreach (var effect in effects) { itemEffects.Add(new ItemModConsumable.ConsumableEffect { type = (MetabolismAttribute.Type)Enum.Parse(typeof(MetabolismAttribute.Type), effect.Obj.GetString("type", "")), amount = effect.Obj.GetFloat("amount", 0), time = effect.Obj.GetFloat("time", 0) }); } } else if (typeName.Equals("ItemModContainer")) { var itemMod = definition.GetComponent <ItemModContainer>(); itemMod.capacity = mod.GetInt("capacity", 6); itemMod.maxStackSize = mod.GetInt("maxStackSize", 0); itemMod.openInDeployed = mod.GetBoolean("openInDeployed", true); itemMod.openInInventory = mod.GetBoolean("openInInventory", true); itemMod.defaultContents.Clear(); var defaultContents = mod.GetArray("defaultContents"); foreach (var content in defaultContents) { var itemDef = GetItem(content.Obj, "shortname"); if (itemDef == null) { continue; } itemMod.defaultContents.Add(new ItemAmount(itemDef, content.Obj.GetFloat("amount", 0))); } itemMod.onlyAllowedItemType = mod.GetValue("onlyAllowedItemType").Type == JSONValueType.Null ? null : GetItem(mod.GetString("onlyAllowedItemType", "unnamed")); } else if (typeName.Equals("ItemModBurnable")) { var itemMod = definition.GetComponent <ItemModBurnable>() ?? definition.gameObject.AddComponent <ItemModBurnable>(); itemMod.fuelAmount = mod.GetFloat("fuelAmount", 10f); itemMod.byproductAmount = mod.GetInt("byproductAmount", 1); itemMod.byproductChance = mod.GetFloat("byproductChance", 0.5f); itemMod.byproductItem = GetItem(mod, "byproductItem"); } else if (typeName.Equals("ItemModCookable")) { var itemMod = definition.GetComponent <ItemModCookable>() ?? definition.gameObject.AddComponent <ItemModCookable>(); itemMod.cookTime = mod.GetFloat("cookTime", 30f); itemMod.amountOfBecome = mod.GetInt("amountOfBecome", 1); itemMod.lowTemp = mod.GetInt("lowTemp", 0); itemMod.highTemp = mod.GetInt("highTemp", 0); itemMod.setCookingFlag = mod.GetBoolean("setCookingFlag", false); itemMod.becomeOnCooked = GetItem(mod, "becomeOnCooked"); } else if (typeName.Equals("ItemModReveal")) { var itemMod = definition.GetComponent <ItemModReveal>(); itemMod.revealedItemAmount = mod.GetInt("revealedItemAmount", 1); itemMod.numForReveal = mod.GetInt("numForReveal", 1); itemMod.revealedItemOverride = GetItem(mod, "revealedItemOverride"); } else if (typeName.Equals("ItemModUpgrade")) { var itemMod = definition.GetComponent <ItemModUpgrade>(); itemMod.numForUpgrade = mod.GetInt("numForUpgrade", 10); itemMod.upgradeSuccessChance = mod.GetFloat("upgradeSuccessChance", 1f); itemMod.numToLoseOnFail = mod.GetInt("numToLoseOnFail", 2); itemMod.numUpgradedItem = mod.GetInt("numUpgradedItem", 1); itemMod.upgradedItem = GetItem(mod, "upgradedItem"); } else if (typeName.Equals("ItemModRecycleInto")) { var itemMod = definition.GetComponent <ItemModRecycleInto>(); itemMod.numRecycledItemMin = mod.GetInt("numRecycledItemMin", 1); itemMod.numRecycledItemMax = mod.GetInt("numRecycledItemMax", 1); itemMod.recycleIntoItem = GetItem(mod, "recycleIntoItem"); } else if (typeName.Equals("ItemModXPWhenUsed")) { var itemMod = definition.GetComponent <ItemModXPWhenUsed>(); itemMod.xpPerUnit = mod.GetFloat("xpPerUnit", 0); itemMod.unitSize = mod.GetInt("unitSize", 1); } else if (typeName.Equals("ItemModSwap")) { var itemMod = definition.GetComponent <ItemModSwap>(); itemMod.sendPlayerDropNotification = mod.GetBoolean("sendPlayerDropNotification", false); itemMod.sendPlayerPickupNotification = mod.GetBoolean("sendPlayerPickupNotification", false); var items = new List <ItemAmount>(); var becomeItems = mod.GetArray("becomeItem"); foreach (var content in becomeItems) { var itemDef = GetItem(content.Obj, "shortname"); if (itemDef == null) { continue; } items.Add(new ItemAmount(itemDef, content.Obj.GetFloat("amount", 0))); } itemMod.becomeItem = items.ToArray(); } else if (typeName.Equals("ItemModProjectile") || typeName.Equals("ItemModProjectileSpawn")) { var itemMod = definition.GetComponent <ItemModProjectile>(); var projectile = itemMod.projectileObject.Get().GetComponent <Projectile>(); projectile.drag = mod.GetFloat("drag", 0); projectile.thickness = mod.GetFloat("thickness", 0); projectile.remainInWorld = mod.GetBoolean("remainInWorld", false); projectile.breakProbability = mod.GetFloat("breakProbability", 0); projectile.stickProbability = mod.GetFloat("stickProbability", 1f); projectile.ricochetChance = mod.GetFloat("ricochetChance", 0); projectile.penetrationPower = mod.GetFloat("penetrationPower", 1f); UpdateDamageTypes(mod.GetArray("damageTypes"), projectile.damageTypes); var spawn = itemMod as ItemModProjectileSpawn; if (spawn != null) { spawn.createOnImpactChance = mod.GetFloat("createOnImpactChance", 0); spawn.spreadAngle = mod.GetFloat("spreadAngle", 30); } var projMods = mod.GetArray("mods"); var i = 0; foreach (var projMod in projMods) { var curMod = (ItemModProjectileRadialDamage)itemMod.mods[i++]; curMod.radius = projMod.Obj.GetFloat("radius", 0); curMod.damage.amount = projMod.Obj.GetObject("damage").GetFloat("amount", 0); curMod.damage.type = (DamageType)Enum.Parse(typeof(DamageType), projMod.Obj.GetObject("damage").GetString("type", "")); } } else if (typeName.EndsWith("TimedExplosive") || typeName.EndsWith("FlameExplosive") || typeName.EndsWith("SupplySignal") || typeName.EndsWith("SurveyCharge")) { TimedExplosive timedExplosive; if (typeName.StartsWith("ItemModProjectile")) { var itemMod = definition.GetComponent <ItemModProjectile>(); timedExplosive = itemMod.projectileObject.Get().GetComponent <TimedExplosive>(); } else if (typeName.StartsWith("ItemModEntity")) { var itemMod = definition.GetComponent <ItemModEntity>(); timedExplosive = itemMod.entityPrefab.Get().GetComponent <ThrownWeapon>().prefabToThrow.Get().GetComponent <TimedExplosive>(); } else { continue; } var flameExplosive = timedExplosive as FlameExplosive; if (flameExplosive != null) { flameExplosive.maxVelocity = mod.GetFloat("maxVelocity", 5); flameExplosive.minVelocity = mod.GetFloat("minVelocity", 2); flameExplosive.numToCreate = mod.GetFloat("numToCreate", 10); flameExplosive.spreadAngle = mod.GetFloat("spreadAngle", 90); } else { var dudTimedExplosive = timedExplosive as DudTimedExplosive; if (dudTimedExplosive != null) { dudTimedExplosive.dudChance = mod.GetFloat("dudChance", 0.3f); } } timedExplosive.canStick = mod.GetBoolean("canStick", false); timedExplosive.minExplosionRadius = mod.GetFloat("minExplosionRadius", 0); timedExplosive.explosionRadius = mod.GetFloat("explosionRadius", 10); timedExplosive.timerAmountMax = mod.GetFloat("timerAmountMax", 20); timedExplosive.timerAmountMin = mod.GetFloat("timerAmountMin", 10); UpdateDamageTypes(mod.GetArray("damageTypes"), timedExplosive.damageTypes); } else if (typeName.Equals("ItemModProjectileServerProjectile")) { var itemMod = definition.GetComponent <ItemModProjectile>(); var projectile = itemMod.projectileObject.Get().GetComponent <ServerProjectile>(); projectile.drag = mod.GetFloat("drag", 0); projectile.gravityModifier = mod.GetFloat("gravityModifier", 0); projectile.speed = mod.GetFloat("speed", 0); } else if (typeName.Equals("ItemModEntityBaseMelee")) { var itemMod = definition.GetComponent <ItemModEntity>(); var baseMelee = itemMod.entityPrefab.Get().GetComponent <BaseMelee>(); baseMelee.attackRadius = mod.GetFloat("attackRadius", 0.3f); baseMelee.isAutomatic = mod.GetBoolean("isAutomatic", true); baseMelee.maxDistance = mod.GetFloat("maxDistance", 1.5f); baseMelee.repeatDelay = mod.GetFloat("repeatDelay", 1.0f); var gathering = mod.GetObject("gathering"); UpdateGatherPropertyEntry(baseMelee.gathering.Ore, gathering.GetObject("Ore")); UpdateGatherPropertyEntry(baseMelee.gathering.Flesh, gathering.GetObject("Flesh")); UpdateGatherPropertyEntry(baseMelee.gathering.Tree, gathering.GetObject("Tree")); UpdateDamageTypes(mod.GetArray("damageTypes"), baseMelee.damageTypes); } else if (typeName.Equals("ItemModEntityBaseProjectile")) { var itemMod = definition.GetComponent <ItemModEntity>(); var baseProjectile = itemMod.entityPrefab.Get().GetComponent <BaseProjectile>(); baseProjectile.primaryMagazine.contents = mod.GetInt("contents", 4); baseProjectile.primaryMagazine.ammoType = GetItem(mod, "ammoType"); baseProjectile.primaryMagazine.definition.builtInSize = mod.GetInt("builtInSize", 30); //baseProjectile.primaryMagazine.definition.ammoTypes = FromJsonString<AmmoTypes>(mod.GetString("ammoTypes")); } else if (typeName.Equals("ItemModWearable")) { var itemMod = definition.GetComponent <ItemModWearable>(); itemMod.targetWearable.occupationOver = GetOccupationSlot(mod.GetObject("targetWearable").GetValue("occupationOver")); itemMod.targetWearable.occupationUnder = GetOccupationSlot(mod.GetObject("targetWearable").GetValue("occupationUnder")); if (itemMod?.protectionProperties != null) { var protectionObj = mod.GetObject("protection"); var entry = itemMod.protectionProperties; entry.density = protectionObj.GetFloat("density", 1f); var amounts = protectionObj.GetObject("amounts"); foreach (var amount in amounts) { entry.amounts[(int)Enum.Parse(typeof(DamageType), amount.Key)] = (float)amount.Value.Number; } } if (itemMod?.armorProperties != null) { itemMod.armorProperties.area = (HitArea)Enum.Parse(typeof(HitAreaUnity), mod.GetString("armor"), true); } } else if (typeName.Equals("ItemModAlterCondition")) { var itemMod = definition.GetComponentsInChildren <ItemModAlterCondition>(true); itemMod[0].conditionChange = mod.GetFloat("conditionChange", 0); } else if (typeName.Equals("ItemModConditionHasFlag") || typeName.Equals("ItemModCycle") || typeName.Equals("ItemModConditionContainerFlag") || typeName.Equals("ItemModSwitchFlag") || typeName.Equals("ItemModUseContent") || typeName.Equals("ItemModConditionHasContents")) { continue; } else { Puts("Unknown type: {0}", typeName); } } }
private ItemDefinition GetItem(JSONObject obj, string key) { var value = obj.GetValue(key); return(value.Type == JSONValueType.String ? GetItem(value.Str) : null); }
private static bool Get(JSON.Object o, string key, ref JSON.Array a) { return(o.Get(key, ref a)); }
public bool Read(JSON.Object o) { return(o.Help(this)); }
public static JSON.Object Parse(string jsonString) { if (!string.IsNullOrEmpty(jsonString)) { Value value2 = null; List <string> list = new List <string>(); ParsingState key = ParsingState.Object; for (int i = 0; i < jsonString.Length; i++) { string str; char ch; string str2; double num2; Value value4; char ch2; i = SkipWhitespace(jsonString, i); switch (key) { case ParsingState.Object: if (jsonString[i] == '{') { break; } return(Fail('{', i)); case ParsingState.Array: if (jsonString[i] == '[') { goto Label_059A; } return(Fail('[', i)); case ParsingState.EndObject: if (jsonString[i] == '}') { goto Label_00B7; } return(Fail('}', i)); case ParsingState.EndArray: if (jsonString[i] == ']') { goto Label_05D5; } return(Fail(']', i)); case ParsingState.Key: { if (jsonString[i] != '}') { goto Label_0169; } i--; key = ParsingState.EndObject; continue; } case ParsingState.Value: ch = jsonString[i]; if (ch != '"') { goto Label_0235; } key = ParsingState.String; goto Label_02E3; case ParsingState.KeyValueSeparator: if (jsonString[i] == ':') { goto Label_01AC; } return(Fail(':', i)); case ParsingState.ValueSeparator: ch2 = jsonString[i]; switch (ch2) { case ',': goto Label_01DC; case ']': goto Label_0200; case '}': goto Label_01F5; } return(Fail(", } ]", i)); case ParsingState.String: str2 = ParseString(jsonString, ref i); if (str2 != null) { goto Label_0309; } return(Fail("string value", i)); case ParsingState.Number: num2 = ParseNumber(jsonString, ref i); if (!double.IsNaN(num2)) { goto Label_0394; } return(Fail("valid number", i)); case ParsingState.Boolean: if (jsonString[i] != 't') { goto Label_04BE; } if (((jsonString.Length >= (i + 4)) && (jsonString[i + 1] == 'r')) && ((jsonString[i + 2] == 'u') && (jsonString[i + 3] == 'e'))) { goto Label_0455; } return(Fail("true", i)); case ParsingState.Null: if (jsonString[i] != 'n') { goto Label_072A; } if (((jsonString.Length >= (i + 4)) && (jsonString[i + 1] == 'u')) && ((jsonString[i + 2] == 'l') && (jsonString[i + 3] == 'l'))) { goto Label_06C6; } return(Fail("null", i)); default: { continue; } } Value value3 = new JSON.Object(); if (value2 != null) { value3.Parent = value2; } value2 = value3; key = ParsingState.Key; continue; Label_00B7: if (value2.Parent == null) { return(value2.Obj); } JSON.ValueType type = value2.Parent.Type; if (type != JSON.ValueType.Object) { if (type != JSON.ValueType.Array) { return(Fail("valid object", i)); } } else { value2.Parent.Obj.values[list.Pop <string>()] = new Value(value2.Obj); goto Label_0142; } value2.Parent.Array.Add(new Value(value2.Obj)); Label_0142: value2 = value2.Parent; key = ParsingState.ValueSeparator; continue; Label_0169: str = ParseString(jsonString, ref i); if (str == null) { return(Fail("key string", i)); } list.Add(str); key = ParsingState.KeyValueSeparator; continue; Label_01AC: key = ParsingState.Value; continue; Label_01DC: key = (value2.Type != JSON.ValueType.Object) ? ParsingState.Value : ParsingState.Key; continue; Label_01F5: key = ParsingState.EndObject; i--; continue; Label_0200: key = ParsingState.EndArray; i--; continue; Label_0235: if (char.IsDigit(ch) || (ch == '-')) { key = ParsingState.Number; } else { ch2 = ch; switch (ch2) { case '[': key = ParsingState.Array; goto Label_02E3; case ']': if (value2.Type != JSON.ValueType.Array) { return(Fail("valid array", i)); } key = ParsingState.EndArray; goto Label_02E3; } switch (ch2) { case 'f': case 't': key = ParsingState.Boolean; break; case 'n': key = ParsingState.Null; break; default: if (ch2 != '{') { return(Fail("beginning of value", i)); } key = ParsingState.Object; break; } } Label_02E3: i--; continue; Label_0309: type = value2.Type; if (type != JSON.ValueType.Object) { if (type == JSON.ValueType.Array) { goto Label_0348; } goto Label_035F; } value2.Obj.values[list.Pop <string>()] = new Value(str2); goto Label_036B; Label_0348: value2.Array.Add(str2); goto Label_036B; Label_035F: Debug.LogError("Fatal error, current JSON value not valid"); return(null); Label_036B: key = ParsingState.ValueSeparator; continue; Label_0394: type = value2.Type; if (type != JSON.ValueType.Object) { if (type == JSON.ValueType.Array) { goto Label_03D3; } goto Label_03EA; } value2.Obj.values[list.Pop <string>()] = new Value(num2); goto Label_03F6; Label_03D3: value2.Array.Add(num2); goto Label_03F6; Label_03EA: Debug.LogError("Fatal error, current JSON value not valid"); return(null); Label_03F6: key = ParsingState.ValueSeparator; continue; Label_0455: type = value2.Type; if (type != JSON.ValueType.Object) { if (type == JSON.ValueType.Array) { goto Label_0493; } goto Label_04A9; } value2.Obj.values[list.Pop <string>()] = new Value(true); goto Label_04B5; Label_0493: value2.Array.Add(new Value(true)); goto Label_04B5; Label_04A9: Debug.LogError("Fatal error, current JSON value not valid"); return(null); Label_04B5: i += 3; goto Label_057C; Label_04BE: if (((jsonString.Length < (i + 5)) || (jsonString[i + 1] != 'a')) || (((jsonString[i + 2] != 'l') || (jsonString[i + 3] != 's')) || (jsonString[i + 4] != 'e'))) { return(Fail("false", i)); } type = value2.Type; if (type != JSON.ValueType.Object) { if (type == JSON.ValueType.Array) { goto Label_0556; } goto Label_056C; } value2.Obj.values[list.Pop <string>()] = new Value(false); goto Label_0578; Label_0556: value2.Array.Add(new Value(false)); goto Label_0578; Label_056C: Debug.LogError("Fatal error, current JSON value not valid"); return(null); Label_0578: i += 4; Label_057C: key = ParsingState.ValueSeparator; continue; Label_059A: value4 = new JSON.Array(); if (value2 != null) { value4.Parent = value2; } value2 = value4; key = ParsingState.Value; continue; Label_05D5: if (value2.Parent == null) { return(value2.Obj); } type = value2.Parent.Type; if (type != JSON.ValueType.Object) { if (type != JSON.ValueType.Array) { return(Fail("valid object", i)); } } else { value2.Parent.Obj.values[list.Pop <string>()] = new Value(value2.Array); goto Label_0660; } value2.Parent.Array.Add(new Value(value2.Array)); Label_0660: value2 = value2.Parent; key = ParsingState.ValueSeparator; continue; Label_06C6: type = value2.Type; if (type != JSON.ValueType.Object) { if (type == JSON.ValueType.Array) { goto Label_0704; } goto Label_071A; } value2.Obj.values[list.Pop <string>()] = new Value(JSON.ValueType.Null); goto Label_0726; Label_0704: value2.Array.Add(new Value(JSON.ValueType.Null)); goto Label_0726; Label_071A: Debug.LogError("Fatal error, current JSON value not valid"); return(null); Label_0726: i += 3; Label_072A: key = ParsingState.ValueSeparator; } Debug.LogError("Unexpected end of string"); } return(null); }
private static bool Get(JSON.Object o, string key, ref JSON.Object oo) { return(o.Get(key, ref oo)); }
private static JSONObject ToJsonObject(object obj) { return(JSONObject.Parse(ToJsonString(obj))); }
private void UpdateGatherPropertyEntry(ResourceDispenser.GatherPropertyEntry entry, JSONObject obj) { entry.conditionLost = obj.GetFloat("conditionLost", 0); entry.destroyFraction = obj.GetFloat("destroyFraction", 0); entry.gatherDamage = obj.GetFloat("gatherDamage", 0); }