Esempio n. 1
0
        public override void Update(GameTime gameTime)
        {
            foreach (var entity in ActiveEntities)
            {
                var modelComponent = _modelMapper.Get(entity);

                DPModel model;
                if (_loadedModels.ContainsKey(modelComponent.Hash))
                {
                    model = _loadedModels[modelComponent.Hash];
                }
                else
                {
                    if (!Models.ModelList.ContainsKey(modelComponent.Hash))
                    {
                        Console.Error.WriteLine("Failed to find model with hash: " + modelComponent.Hash);
                        _modelMapper.Delete(entity);
                        continue;
                    }

                    model = ConvertDProjectModelFormatToModel(Models.ModelList[modelComponent.Hash].AssetPath, _graphicsDevice);
                    _loadedModels.Add(modelComponent.Hash, model);
                }

                var loadedModelComponent = new LoadedModelComponent()
                {
                    Model = model
                };

                _loadedModelMapper.Put(entity, loadedModelComponent);
                _modelMapper.Delete(entity);
            }
        }
Esempio n. 2
0
        // TODO: Add action points restrictions.
        public override void Update(GameTime gameTime)
        {
            if (_entity == null)
            {
                foreach (var entity in ActiveEntities)
                {
                    _turn = _turnMapper.Get(entity);

                    if (_turn != null)
                    {
                        initTurn(entity); return;
                    }
                }
            }
            else
            {
                foreach (var entity in ActiveEntities)
                {
                    var turnEnd = _turnEndMapper.Get(entity);
                    if (turnEnd != null)
                    {
                        _turnEndMapper.Delete(entity);
                        toggleTurn();
                        return;
                    }
                }
            }
        }
Esempio n. 3
0
        public void DeleteComponent()
        {
            const int entityId = 1;

            var mapper    = new ComponentMapper <Transform2>(2, _ => { });
            var component = new Transform2();

            mapper.Put(entityId, component);
            mapper.Delete(entityId);

            Assert.False(mapper.Has(entityId));
        }
        public void OnDelete()
        {
            const int entityId = 1;

            var mapper    = new ComponentMapper <Transform2>(2, _ => { });
            var component = new Transform2();

            mapper.OnDelete += (entId) =>
            {
                Assert.Equal(entityId, entId);
                Assert.False(mapper.Has(entityId));
            };

            mapper.Put(entityId, component);
            mapper.Delete(entityId);
        }