internal static void Load(VapePlayer modPlayer, TagCompound tag)
        {
            TagCompound stats        = tag.GetCompound("BaseStats");
            TagCompound skillLevels  = tag.GetCompound("SkillLevels");
            TagCompound chaosBonuses = tag.GetCompound("ChaosBonuses");

            string key;

            modPlayer.statPoints  = tag.GetAsInt("StatPoints");
            modPlayer.skillPoints = tag.GetAsInt("SkillPoints");
            modPlayer.chaosPoints = tag.GetAsInt("ChaosPoints");

            // Unboxing values into the proper dictionary
            foreach (var stat in stats)
            {
                key = stat.Key;
                // Intellect was removed in v0.3.1
                if (key == "Intellect")
                {
                    modPlayer.statPoints += (int)stat.Value;
                    continue;
                }
                // Agility was renamed to Haste in v0.3.1
                else if (key == "Agility")
                {
                    key = "Haste";
                }
                modPlayer.BaseStats[key] = (int)stat.Value;
            }

            foreach (var skillLevel in skillLevels)
            {
                modPlayer.SkillLevels[skillLevel.Key] = (int)skillLevel.Value;
            }

            foreach (var chaosBonus in chaosBonuses)
            {
                key = chaosBonus.Key;
                // Movement Speed as a chaos bonus was replaced with Max Run Speed in v0.3.1
                if (key == "Movement Speed")
                {
                    key = "Max Run Speed";
                }
                modPlayer.ChaosBonuses[key] = (float)chaosBonus.Value;
            }

            modPlayer.chaosRank = tag.GetAsInt("ChaosRank");
            modPlayer.chaosXp   = tag.GetAsLong("ChaosXp");

            modPlayer.xp = tag.GetAsLong("Xp");
            Vector2 expUIPos = tag.Get <Vector2>("expUIPos");

            VapeRPG vapeMod = (modPlayer.mod as VapeRPG);

            vapeMod.ExpUI.SetPanelPosition(expUIPos);
        }
Example #2
0
        public override void LoadData(TagCompound tag)
        {
            if (tag.GetBool("initialized"))
            {
                level         = (ushort)tag.GetAsShort("level");
                currentXP     = (ulong)tag.GetAsLong("currentXP");
                neededXP      = CalculateNeededXP(level);
                statPoints    = (ushort)tag.GetAsShort("points");
                talents       = tag.Get <string>("talents");
                talentUnspent = (ushort)tag.GetAsShort("talentPoints");
                constitution  = (ushort)tag.GetAsShort("con");
                strength      = (ushort)tag.GetAsShort("str");
                intelligence  = (ushort)tag.GetAsShort("int");
                charisma      = (ushort)tag.GetAsShort("cha");
                dexterity     = (ushort)tag.GetAsShort("dex");
                mobility      = (ushort)tag.GetAsShort("mob");
                excavation    = (ushort)tag.GetAsShort("exc");
                animalia      = (ushort)tag.GetAsShort("ani");
                luck          = (ushort)(tag.ContainsKey("gra") ? tag.GetAsShort("gra") : tag.GetAsShort("luc"));
                mysticism     = (ushort)tag.GetAsShort("mys");

                if (currentXP > neededXP)
                {
                    LevelUp();
                }
            }
            else
            {
                initialize();
            }

            base.LoadData(tag);
        }
Example #3
0
        public void TestTypePromotions()
        {
            var tag = new TagCompound {
                ["byte1"]   = (byte)5,
                ["byte2"]   = (byte)254,
                ["short1"]  = (short)3200,
                ["short2"]  = (short)-3200,
                ["int1"]    = 0xFFEEFF,
                ["long1"]   = long.MaxValue,
                ["float1"]  = 1.25264f,
                ["float2"]  = float.MaxValue,
                ["float3"]  = float.NaN,
                ["double1"] = 1.25264
            };

            Assert.AreEqual(tag.GetAsShort("byte1"), (short)5);
            Assert.AreEqual(tag.GetAsShort("byte2"), (short)254);
            Assert.AreEqual(tag.GetAsShort("short2"), -3200);
            Assert.AreEqual(tag.GetAsInt("byte1"), 5);
            Assert.AreEqual(tag.GetAsInt("byte2"), 254);
            Assert.AreEqual(tag.GetAsInt("short1"), 3200);
            Assert.AreEqual(tag.GetAsInt("short2"), -3200);
            Assert.AreEqual(tag.GetAsInt("int1"), 0xFFEEFF);
            Assert.AreEqual(tag.GetAsLong("byte1"), 5);
            Assert.AreEqual(tag.GetAsLong("byte2"), 254);
            Assert.AreEqual(tag.GetAsLong("short1"), 3200);
            Assert.AreEqual(tag.GetAsLong("short2"), -3200);
            Assert.AreEqual(tag.GetAsLong("int1"), 0xFFEEFF);
            Assert.AreEqual(tag.GetAsLong("long1"), long.MaxValue);
            Assert.AreEqual(tag.GetAsDouble("float1"), 1.25264f);
            Assert.AreEqual(tag.GetAsDouble("float2"), float.MaxValue);
            Assert.AreEqual(tag.GetAsDouble("float3"), double.NaN);
            Assert.AreEqual(tag.GetAsDouble("double1"), 1.25264);
        }
        public virtual void emptyBagOnFloor(Player p)
        {
            int stackSize = 0;

            /*TagCompound result = new TagCompound();*/
            long remainingOre = 0;
            int  ffs          = firstFreeItemSlot();

            if (ffs >= 396)
            {
                return;
            }
            foreach (String key in order)
            {
                if (items.ContainsKey(key))
                {
                    remainingOre = items.GetAsLong(key);
                    Item i = getItemFromTag(key);
                    if (i.type != 0)
                    {
                        while (remainingOre > 0 && (ffs < 396))
                        {
                            stackSize = (int)Math.Min(remainingOre, i.maxStack);
                            p.QuickSpawnItem(i.type, stackSize);
                            remainingOre -= stackSize;
                            ffs++;
                        }
                        items.Remove(key);
                        if (remainingOre > 0)
                        {
                            items[key] = (long)remainingOre;
                        }
                    }
                }
            }
            if (Main.netMode == NetmodeID.MultiplayerClient)
            {
                ModPacket pack = mod.GetPacket();
                pack.Write((byte)2);
                pack.Write((byte)p.whoAmI);
                pack.Write((byte)p.selectedItem);
                TagIO.Write(items, pack);
                pack.Send();
            }
            recalculateValue();
        }