Ejemplo n.º 1
0
        public void TestLoadSave()
        {
            var testbed = TestUtils.makeAsteroidInfo();

            // NUnit doesn't seem to have a "requires"
            Assert.AreNotEqual(default(uint), testbed.id);
            Assert.AreNotEqual(null, testbed.parentSet);

            ConfigNode   saved = testbed.ToConfigNode();
            AsteroidInfo copy  = AsteroidInfo.FromConfigNode(saved);

            Assert.AreEqual(testbed.id, copy.id);
            Assert.AreEqual(testbed.parentSet, copy.parentSet);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when the module is either constructed or loaded as part of a save game. After
        /// this method returns, the module will be initialized with any settings in <c>node</c>.
        /// </summary>
        /// <param name="node">The ConfigNode representing this ScenarioModule.</param>
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);

            var buffer = new Dictionary <uint, AsteroidInfo> ();

            ConfigNode [] entries = node.GetNodes("asteroid");
            foreach (ConfigNode asteroidNode in entries)
            {
                string encodedId = asteroidNode.GetValue("id");
                uint   id;
                if (uint.TryParse(encodedId, out id))
                {
                    buffer.Add(id, AsteroidInfo.FromConfigNode(asteroidNode));
                }
                else
                {
                    Debug.LogError($"[CustomAsteroidRegistry]: invalid asteroid ID {encodedId}, not loading");
                }
            }
            asteroids = buffer;
        }