예제 #1
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);
        }
예제 #2
0
        public override void Load(Item item, TagCompound tag)
        {
            if (item.type == 0 || tag == null || item.type == ModLoader.GetMod("ModLoader").ItemType("MysteryItem"))
            {
                return;
            }
            EMMItem info = item.GetGlobalItem <EMMItem>();

            int[]    ids        = tag.GetIntArray("IDs");
            double[] magnitudes = new double[4];
            magnitudes[0]      = tag.GetAsDouble("Magnitude0");
            magnitudes[1]      = tag.GetAsDouble("Magnitude1");
            magnitudes[2]      = tag.GetAsDouble("Magnitude2");
            magnitudes[3]      = tag.GetAsDouble("Magnitude3");
            info.alreadyRolled = tag.GetBool("Rolled?");
            info.title         = tag.GetString("Title");
            for (int i = 0; i < ids.Length; i++)
            {
                try
                {
                    addPrefix(item, ids[i], (float)magnitudes[i] / ((item.accessory) ? .6f : 1), i);
                }
                catch
                {
                    ErrorLogger.Log("Save Out of Bounds Error! Please report this.");
                }
            }
        }
예제 #3
0
        public override void Load(TagCompound tag)
        {
            // cross compat. from 0.1.3
            if (tag.Any(x => x.Value is float))
            {
                if (tag.ContainsKey("amplitude"))
                {
                    amplitude = (double)tag.GetAsShort("amplitude");
                }
                if (tag.ContainsKey("speed"))
                {
                    speed = (double)tag.GetAsShort("speed");
                }
                if (tag.ContainsKey("universalOffset"))
                {
                    bounceOffset = (double)tag.GetAsShort("universalOffset");
                }
                if (tag.ContainsKey("bounceEvenly"))
                {
                    bounceEvenly = tag.Get <bool>("bounceEvenly");
                }
                if (tag.ContainsKey("disallowModItems"))
                {
                    bounceModItems = !tag.Get <bool>("disallowModItems");
                }
            }
            else
            {
                if (tag.ContainsKey("amplitude"))
                {
                    amplitude = tag.GetAsDouble("amplitude");
                }
                if (tag.ContainsKey("ampMult"))
                {
                    ampMult = tag.GetAsDouble("ampMult");
                }
                if (tag.ContainsKey("speed"))
                {
                    speed = tag.GetAsDouble("speed");
                }
                if (tag.ContainsKey("bounceOffset"))
                {
                    bounceOffset = tag.GetAsDouble("bounceOffset");
                }

                if (tag.ContainsKey("bounceEvenly"))
                {
                    bounceEvenly = tag.Get <bool>("bounceEvenly");
                }
                if (tag.ContainsKey("bounceModItems"))
                {
                    bounceModItems = tag.Get <bool>("bounceModItems");
                }
                if (tag.ContainsKey("byCosine"))
                {
                    byCosine = tag.Get <bool>("byCosine");
                }

                if (tag.ContainsKey("modVersion"))
                {
                    modVersion = ConstrucModversion(tag.GetString("modVersion"));
                }
            }

            if (tag.ContainsKey("bouncyItems"))
            {
                bouncyItems = new List <int>(tag.GetList <int>("bouncyItems"));
            }
        }