Пример #1
0
        public void TestWorldClone()
        {
            using var worldSource = new RevolutionWorld();
            var entSource  = worldSource.CreateEntity();
            var compSource = entSource.SetComponent(new Component1 {
                Value = 42
            });

            using var clone = worldSource.Clone();
            // Since it is a clone, the entity indexes are the sames.
            Assert.AreEqual(compSource.Value, clone.GetComponent <Component1>(entSource.Raw).Value);
        }
Пример #2
0
        public void TestMillionClone()
        {
            using var worldSource = new RevolutionWorld();
            var sw = new Stopwatch();

            sw.Restart();
            for (var i = 0; i != 1_000_000; i++)
            {
                worldSource.CreateEntity();
            }

            sw.Stop();
            Console.WriteLine($"Time to create entities in source: {sw.Elapsed.TotalMilliseconds}ms");

            sw.Restart();
            using var clone = worldSource.Clone();
            sw.Stop();
            Console.WriteLine($"Time to clone: {sw.Elapsed.TotalMilliseconds}ms");

            Assert.AreEqual(worldSource.Chunks.Length, clone.Chunks.Length);
            Assert.AreEqual(worldSource.Chunks[0].Span.Length, clone.Chunks[0].Span.Length);
        }