public override void Load(TagCompound tag) { hasEndlessAmmo = tag.GetBool(nameof(hasEndlessAmmo)); useEndlessAmmoFirst = tag.GetBool(nameof(useEndlessAmmoFirst)); UnlockedAmmo = tag.Get <List <Item> >(nameof(UnlockedAmmo)); SelectedAmmo = tag.Get <List <bool> >(nameof(SelectedAmmo)); }
public override void Load(TagCompound tag) { try { int value = tag.GetInt("value"); if (value > 0) { loadedValue = value; Point position = new Point(tag.GetInt("x"), tag.GetInt("y")); Item[] deathInventory = new Item[player.inventory.Length]; Item[] deathArmor = new Item[player.armor.Length]; Item[] deathDye = new Item[player.dye.Length]; Item[] deathMiscEquips = new Item[player.miscEquips.Length]; Item[] deathMiscDyes = new Item[player.miscDyes.Length]; loadItemList(tag.Get <List <Item> >("deathInventory"), deathInventory); loadItemList(tag.Get <List <Item> >("deathArmor"), deathArmor); loadItemList(tag.Get <List <Item> >("deathDye"), deathDye); loadItemList(tag.Get <List <Item> >("deathMiscEquips"), deathMiscEquips); loadItemList(tag.Get <List <Item> >("deathMiscDyes"), deathMiscDyes); PlayerDeathInventory inventory = new PlayerDeathInventory(deathInventory, deathArmor, deathDye, deathMiscEquips, deathMiscDyes); playerDeathInventoryMap.Add(position, inventory); } } catch (Exception e) { mod.Logger.Error("Error loading saved tombstone inventory " + e.Message); } }
public override void Load(TagCompound tag) { soundId = tag.Get <int>("soundId"); global = tag.Get <bool>("global"); volume = tag.Get <int>("volume"); pitch = tag.Get <int>("pitch"); }
public override void Load(TagCompound tag) { cosmalian = tag.GetBool("cosmalian"); hornColor = tag.Get <Color>("hornColor"); tailColor = tag.Get <Color>("tailColor"); clawColor = tag.Get <Color>("clawColor"); }
private BossCollection(TagCompound tag) { modName = tag.Get <string>(nameof(modName)); bossName = tag.Get <string>(nameof(bossName)); loot = tag.Get <List <Item> >(nameof(loot)); collectibles = tag.Get <List <Item> >(nameof(collectibles)); }
public override void Load(TagCompound tag) { lightColor = tag.Get <Color>("LightColor"); try { PointsCollected = new BitSet(tag.Get <uint>("PointsCollected")); } catch (Exception) { PointsCollected = BitSet.Zero; } ForgeHotbarItems = new int[10]; try { ForgeHotbarItems = tag.Get <int[]>("ForgeHotbarItems").WithLength(10); } catch (Exception) {} string a = player.name; string versionString = "0.0.0.0"; try { versionString = tag.GetString("LastVer"); } catch (Exception e) { if (e is IOException) { try { int[] vers = tag.Get <int[]>("LastVer"); versionString = $" {vers[0]}. {vers[1]}. {vers[2]}. {vers[3]}"; } catch (Exception) { } } } Version.TryParse(versionString, out Version version); FixVersion(version); }
public override void Load(TagCompound tag) { var names = tag.Get <List <string> >("scoreNames"); var values = tag.Get <List <int> >("scoreValues"); scores = names.Zip(values, (k, v) => new { Key = k, Value = v }).ToDictionary(x => x.Key, x => x.Value); }
public static PedestalData Load(TagCompound tag) { PedestalData data = new PedestalData(tag.Get <Item>(nameof(item)), tag.Get <Vector2>(nameof(coordinates))); data.flipped = tag.GetBool(nameof(flipped)); return(data); }
private void LoadNPCs(TagCompound tag) { var keys = tag.Get <List <int> >("AliveTownNPCs.Keys"); var values = tag.Get <List <int> >("AliveTownNPCs.Values"); AliveTownNPCs = keys.Zip(values, (key, value) => new { Key = key, Value = value }).ToDictionary(x => x.Key, x => x.Value); }
public override void Load(TagCompound tag) { this.ductType = (DuctType)tag.Get <byte>("ductType"); if (tag.ContainsKey("filter")) { this.filter = (ItemFilter)tag.Get <ItemFilter>("filter"); } if (tag.ContainsKey("flowItems")) { this.flowItems = tag.GetList <TagCompound>("flowItems").Select((TagCompound t) => { int d = t.Get <int>("direction"); return(Tuple.Create <Item, Direction>(t.Get <Item>("item"), d == -1 ? Direction.NONE : Direction.DIRECTIONS[d])); }).ToList(); } if (tag.ContainsKey("addItems")) { this.addItems = tag.GetList <TagCompound>("addItems").Select((TagCompound t) => { int d = t.Get <int>("direction"); return(Tuple.Create <Item, Direction>(t.Get <Item>("item"), d == -1 ? Direction.NONE : Direction.DIRECTIONS[d])); }).ToList(); } if (tag.ContainsKey("removeItems")) { this.removeItems = tag.GetList <TagCompound>("removeItems").Select((TagCompound t) => { int d = t.Get <int>("direction"); return(Tuple.Create <Item, Direction>(t.Get <Item>("item"), d == -1 ? Direction.NONE : Direction.DIRECTIONS[d])); }).ToList(); } }
public void TestVector2Extension() { var list = new List <Vector2> { Vector2.UnitX, Vector2.UnitY }; var tag = new TagCompound { ["vec1"] = new Vector2(-3, 5), ["vec2"] = new Vector2((float)Math.PI), ["list"] = list }; AssertEqual(tag, new TagCompound { ["vec1"] = new TagCompound { ["x"] = -3f, ["y"] = 5f }, ["vec2"] = new TagCompound { ["x"] = (float)Math.PI, ["y"] = (float)Math.PI }, ["list"] = new List <TagCompound> { new TagCompound { ["x"] = 1f, ["y"] = 0f }, new TagCompound { ["x"] = 0f, ["y"] = 1f } } }); Assert.AreEqual(tag.Get <Vector2>("vec1"), new Vector2(-3, 5)); Assert.AreEqual(tag.Get <Vector2>("vec2"), new Vector2((float)Math.PI)); Assert.AreEqual(tag.Get <Vector2>("default"), new Vector2()); AssertEqual(tag.GetList <Vector2>("list"), list); }
public void TestColorExtension() { var list = new List <Color> { Color.Red, Color.Lime, Color.Blue }; var tag = new TagCompound { ["color1"] = Color.Aqua, ["color2"] = Color.Violet, ["list1"] = new List <Color>(), ["list2"] = list, }; AssertEqual(tag, new TagCompound { ["color1"] = (int)Color.Aqua.PackedValue, ["color2"] = (int)Color.Violet.PackedValue, ["list1"] = new List <int>(), ["list2"] = new List <uint> { 0xFF0000FF, 0xFF00FF00, 0xFFFF0000 } //use internal uint -> int conversion }); Assert.AreEqual(tag.Get <Color>("color1"), Color.Aqua); Assert.AreEqual(tag.Get <Color>("color2"), Color.Violet); Assert.AreEqual(tag.Get <Color>("default"), new Color()); AssertEqual(tag.GetList <Color>("list1"), new List <Color>()); AssertEqual(tag.GetList <Color>("list2"), list); }
public static Entity InstantiatePrefab(string name) { FileInfo file = new FileInfo(Path.Combine(PrefabDirectory, name + ".prefab")); if (!file.Exists) { return(null); } try { using (BinaryReader reader = new BinaryReader(new FileStream(file.FullName, FileMode.Open))) { TagCompound obj = Master.Read(reader); Entity entity = new Entity { Name = obj.Get <TagString>("name").Value, Active = obj.Get <TagBoolean>("active").Value }; foreach (KeyValuePair <string, ITag> rawComponent in obj.Get <TagCompound>("components")) { Type componentType = Component.TypeForIdentifier(rawComponent.Key); Component component = Master.ConvertFromValue(rawComponent.Value, componentType) as Component; entity.Components.Add(component); } return(entity); } } catch (FormatException x) { Console.WriteLine(x.Message); return(null); } }
protected ModEntry(TagCompound tag) { type = tag.Get <ushort>("value"); modName = tag.Get <string>("mod"); name = tag.Get <string>("name"); vanillaReplacementType = tag.Get <ushort>("fallbackID"); unloadedType = tag.Get <string>("uType") ?? DefaultUnloadedType; }
public void TestItemSerializable() { //unfortunately can't test modded items or global data var item1 = new Item(); item1.SetDefaults(ItemID.LastPrism, true); item1.favorited = true; var item2 = new Item(); item2.SetDefaults(ItemID.IronBar, true); item2.stack = 25; var item3 = new Item(); item3.SetDefaults(ItemID.Meowmere, true); item3.prefix = 4; var list = new List <Item> { item1, item2, item3 }; var tag = new TagCompound { ["item1"] = item1, ["item2"] = item2, ["item3"] = item3, ["list"] = list }; var sTag = new TagCompound { ["item1"] = new TagCompound { ["<type>"] = typeof(Item).FullName, ["mod"] = "Terraria", ["id"] = item1.netID, ["fav"] = true }, ["item2"] = new TagCompound { ["<type>"] = typeof(Item).FullName, ["mod"] = "Terraria", ["id"] = item2.netID, ["stack"] = 25 }, ["item3"] = new TagCompound { ["<type>"] = typeof(Item).FullName, ["mod"] = "Terraria", ["id"] = item3.netID, ["prefix"] = (byte)4 } }; sTag["list"] = new[] { "item1", "item2", "item3" }.Select(sTag.GetCompound).ToList(); AssertEqual(tag, sTag); AssertEqual(tag.Get <Item>("item1"), item1); AssertEqual(tag.Get <Item>("item2"), item2); AssertEqual(tag.Get <Item>("item3"), item3); AssertEqual(tag.Get <Item>("default"), new Item()); AssertEqual(tag.GetList <Item>("list"), list); }
public override void Load(TagCompound tag) { if (tag.ContainsKey("KillCounter.Keys")) { var keys = tag.Get <List <int> >("KillCounter.Keys"); var values = tag.Get <List <int> >("KillCounter.Values"); KillCounter = keys.Zip(values, (key, value) => new { Key = key, Value = value }).ToDictionary(x => x.Key, x => x.Value); } }
private static ItemLimit DeserializeData(TagCompound tag) { short id = tag.Get <short>("id"); int limit = tag.Get <int>("limit"); ItemLimit itemLimit = new ItemLimit(id, limit); return(itemLimit); }
public override void Load(TagCompound tag) { maxEnergy = 50000; energy = new Core(maxEnergy); inventory[0] = tag.Get <Item>("inputSlot"); inventory[1] = tag.Get <Item>("outputSlot"); base.Load(tag); }
private CollisionFaceProperties FaceFromJson(TagCompound obj) { return(new CollisionFaceProperties() { Enabled = obj.Get <TagBoolean>("enabled").Value, Friction = obj.Get <TagDouble>("friction").Value, Snap = obj.Get <TagBoolean>("snap").Value }); }
public NetworkItem(TagCompound tag) { item = tag.Get <Item>("Item"); origin = Routed.RoutedLayer[tag.Get <Point16>("Position")]; destination = Routed.RoutedLayer[tag.Get <Point16>("Destination")]; path = Pathfinding.FindPath(origin, destination); CurrentPosition = PreviousPosition = path.Pop(); }
public override void Load(TagCompound tag) { if (tag.ContainsKey("TileWallUI")) { if (tag.Get <object>("TileWallUI").GetType().Equals(typeof(TagCompound))) { saveData = tag.Get <TagCompound>("TileWallUI"); } } }
public override void Load(TagCompound tag) { int downed = tag.GetAsInt("downed"); bossesDown = (MetroidBossDown)downed; spawnedPhazonMeteor = tag.Get <bool>("spawnedPhazonMeteor"); TorizoRoomLocation.X = tag.Get <int>("TorizoRoomLocation.X"); TorizoRoomLocation.Y = tag.Get <int>("TorizoRoomLocation.Y"); }
public override void Load(TagCompound tag) { if (tag.ContainsKey("ChestBrowserUI")) { if (tag.Get<object>("ChestBrowserUI").GetType().Equals(typeof(TagCompound))) { chestBrowserData = tag.Get<TagCompound>("ChestBrowserUI"); } } }
public override void Load(TagCompound tag) { if (tag.ContainsKey("NPCInfoUI")) { if (tag.Get <object>("NPCInfoUI").GetType().Equals(typeof(TagCompound))) { npcInfoData = tag.Get <TagCompound>("NPCInfoUI"); } } }
public override void Load(TagCompound tag) { if (tag.ContainsKey("lightbulb")) { Lightbulb = tag.Get <Item>("lightbulb"); } if (tag.ContainsKey("chip")) { Chip = tag.Get <Item>("chip"); } }
public override void Load(TagCompound tag) { Reset(); this.on = tag.Get <bool>("on"); Item i = tag.Get <Item>("bullets"); if (i != null) { this.bullets = i; } }
public static PackageData Load(TagCompound tag) { int limit = tag.GetInt("SLimit"); bool pickup = tag.GetBool("SPickup"); BagPickup bagInit = new BagPickup(limit, pickup) { contained = tag.Get <List <Item> >("SStorage") }; return(new PackageData(tag.Get <Vector2>("coord"), tag.GetInt("type"), bagInit)); }
public override void Load(TagCompound tag) { base.Load(tag); this.left = tag.Get <int>("left"); this.right = tag.Get <int>("right"); this.top = tag.Get <int>("top"); this.bottom = tag.Get <int>("bottom"); this.filter = tag.Get <EntityFilter>("filter"); }
private void LoadVoid(TagCompound tag) { VoidAffinity = tag.Get <ushort>(nameof(VoidAffinity)); MaxVoidAffinity = tag.Get <ushort>(nameof(MaxVoidAffinity)); VoidItemCooldown = tag.GetAsInt(nameof(VoidItemCooldown)); VoidHeartHP = tag.GetInt(nameof(VoidHeartHP)); MaxVoidHearts = tag.GetInt(nameof(MaxVoidHearts)); }
public static TurtleInfo Load(TagCompound tag) { return(new TurtleInfo( tag.Get <ushort>("Width"), tag.Get <ushort>("Height"), tag.GetByte("Direction"), tag.GetInt("PickaxeType"), tag.GetInt("PickaxePower"), tag.GetInt("PickaxeSpeed") )); }