Exemplo n.º 1
0
        private void ResolveAnimatedMovement(long elapsedMs, IEntity entity)
        {
            var moving = entity.Get <Moving>();

            while (elapsedMs > 0)
            {
                var currentMovement = moving.Movements.FirstOrDefault();

                if (currentMovement != null)
                {
                    var    movementAmount = Math.Min(elapsedMs, currentMovement.TimeLeft);
                    double ratio          = (double)movementAmount / (double)currentMovement.Duration;
                    moving.OffsetX           += ratio * currentMovement.Vector.X;
                    moving.OffsetY           += ratio * currentMovement.Vector.Y;
                    elapsedMs                -= movementAmount;
                    currentMovement.TimeLeft -= (int)movementAmount;

                    if (currentMovement.TimeLeft <= 0)
                    {
                        moving.Movements.Remove(currentMovement);
                    }
                }
                else
                {
                    _entityEngine.RemoveComponent(entity, moving);
                    elapsedMs = 0;
                }
            }
        }
Exemplo n.º 2
0
        public void RemoveComponent_RemovesComponent()
        {
            Appearance component  = new Appearance();
            var        testEntity = engine.New("TestEntity", component);


            engine.RemoveComponent(testEntity, component);

            testEntity.Components.Should().NotContain(component);
        }
Exemplo n.º 3
0
        private bool TryRemoveItemFromMap(IEntity item)
        {
            if (item.Has <Position>())
            {
                entityEngine.RemoveComponent <Position>(item);

                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        public void RemovePosition(IEntity entity)
        {
            Position position = entity.Get <Position>();

            if (position != null)
            {
                _entityEngine.RemoveComponent(entity, position);
            }

            RemoveFromCache(entity);
        }
Exemplo n.º 5
0
        public void TransferWealth_DoesntHaveWealth_Fails()
        {
            var entity1 = GetTestEntity();
            var entity2 = GetTestEntity();

            entityEngine.RemoveComponent(entity1, entity1.Get <Wealth>());

            var result = itemSystem.TransferWealth(entity1, entity2, "TestCurrency", 100);

            result.Should().BeFalse();

            itemSystem.CheckWealth(entity1, "TestCurrency").Should().Be(0);
            itemSystem.CheckWealth(entity2, "TestCurrency").Should().Be(0);
        }
Exemplo n.º 6
0
 private void EndPath(IEntity entity)
 {
     _entityEngine.RemoveComponent(entity, this);
     SetWaitingForInputIfPlayer(entity, true);
 }