Beispiel #1
0
        private void DropItemToMap(IEntity item, Inventory inventory)
        {
            var owner    = GetInventoryOwner(inventory);
            var position = owner.Get <Position>();

            entityEngine.AddComponent(item, new Position {
                MapCoordinate = (MapCoordinate)position.MapCoordinate.Clone()
            });
        }
Beispiel #2
0
        public void AddComponent_AddsComponentToEntity()
        {
            var testEntity = engine.New("TestEntity");

            Appearance component = new Appearance();

            engine.AddComponent(testEntity, component);

            testEntity.Get <Appearance>().Should().Be(component);
        }
        public void SetPosition(IEntity entity, MapCoordinate mapCoordinate)
        {
            Position position = entity.Get <Position>();

            if (position == null)
            {
                position = new Position {
                    MapCoordinate = mapCoordinate
                };
                _entityEngine.AddComponent(entity, position);
            }

            SetPosition(entity, position, mapCoordinate);
        }
Beispiel #4
0
        public void StartAnimatedMovement(IEntity entity, List <AnimationMovement> movements)
        {
            Moving component = entity.TryGet <Moving>();

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

            var totalVectorX = movements.Sum(m => m.Vector.X);
            var totalVectorY = movements.Sum(m => m.Vector.Y);

            var moving = new Moving {
                Movements = movements, OffsetX = -totalVectorX, OffsetY = -totalVectorY
            };

            _entityEngine.AddComponent(entity, moving);
        }
Beispiel #5
0
 private void AddStatComponent(IEntity entity, string statName, int value)
 {
     _engine.AddComponent(entity, new Stat {
         Name = statName, Value = value
     });
 }