Exemplo n.º 1
0
        public void MinigWork_CenterOre_NoMined()
        {
            CreateMap(10, 1);

            Update();

            var mapSettings = TargetSystem.GetSingleton <MapSettings>();

            Assert.IsTrue(_entityManager.HasComponent <MiningWork>(mapSettings.Tiles[4]));
            Assert.AreEqual(10, _entityManager.GetComponentData <ResourceOre>(mapSettings.Tiles[4]).Count);
        }
Exemplo n.º 2
0
        public void Spawn_OneSand()
        {
            // Create request
            var requestEntity = _entityManager.CreateEntity(typeof(MapRequest));

            _entityManager.SetComponentData(requestEntity, new MapRequest()
            {
                Frequency = new float2(0.1f, 0.1f), MapEdgeSize = 1
            });

            // Update
            Update();

            // Gather data
            var mapSetting = TargetSystem.GetSingleton <MapSettings>();
            var created    = mapSetting.Tiles;

            AreEqual(1, created.Length);
        }
Exemplo n.º 3
0
        public void MinigWork_CenterOre_MinedOne()
        {
            CreateMap(1, 0);

            Update();

            var mapSettings = TargetSystem.GetSingleton <MapSettings>();

            Assert.IsFalse(_entityManager.HasComponent <MiningWork>(mapSettings.Tiles[4]));

            var query = _entityManager.CreateEntityQuery(ComponentType.ReadOnly <MinedOre>());

            Assert.AreEqual(1, query.CalculateEntityCount());

            var minedOres = query.ToComponentDataArray <MinedOre>(Unity.Collections.Allocator.TempJob);
            var mined     = minedOres[0];

            Assert.AreEqual(1, mined.MinedCount);
            minedOres.Dispose();
        }
Exemplo n.º 4
0
        private void CreateMap(int oreCount = 10, int resourceTypeIndex = 0)
        {
            // Generate map [3x3] with ore on center Setup MapSettings and others

            var request = _entityManager.CreateEntity(typeof(MapRequest));

            _entityManager.SetComponentData(request, new MapRequest()
            {
                Frequency   = new Unity.Mathematics.float2(0.01f, 0.01f),
                MapEdgeSize = 3,
                Offset      = new Unity.Mathematics.float2(0, 0)
            });

            var spawner = _currentWorld.GetOrCreateSystem <MapSpawner>();

            spawner.Update();

            var mapSettings = TargetSystem.GetSingleton <MapSettings>();

            Assert.AreEqual(9, mapSettings.Tiles.Length);

            //Add MiningWork and WorkProgress
            var oreType = BlobsMemory.Instance.ReferencesOf <ResourceTypeBlob>()[resourceTypeIndex];

            _entityManager.AddComponentData(mapSettings.Tiles[4], new MiningWork());
            _entityManager.AddComponentData(mapSettings.Tiles[4], new WorkProgress()
            {
                Progress = 1f
            });

            // Make sure center tile contains ore
            _entityManager.SetComponentData(mapSettings.Tiles[4], new ResourceOre()
            {
                Capacity = oreCount, Count = oreCount, Type = oreType
            });
        }