Ejemplo n.º 1
0
        public override IEnumerable <CauseFailureCommand> GetActualCauses()
        {
            var result = new List <CauseFailureCommand>();

            var checkOutBorderFirst  = new CheckOutBorder(First, SlotFirst);
            var checkOutBorderSecond = new CheckOutBorder(Second, SlotSecond);

            result.AddRange(checkOutBorderFirst.GetActualCauses());
            result.AddRange(checkOutBorderSecond.GetActualCauses());

            if (checkOutBorderFirst.IsActual() || checkOutBorderSecond.IsActual())
            {
                return(result);
            }

            var slotsNewPositionEntity      = DatabaseReadOnly.GetSlotsForEntityInInventory(First, SlotFirst).ToArray();
            var slotsNewPositionOtherEntity = DatabaseReadOnly.GetSlotsForEntityInInventory(Second, SlotSecond).ToArray();
            var isIntersection = slotsNewPositionEntity.Intersect(slotsNewPositionOtherEntity).Any();

            if (isIntersection)
            {
                result.Add(new CauseIntersectionOfPositions(First, SlotFirst, Second, SlotSecond));
            }
            return(result);
        }
Ejemplo n.º 2
0
        public override IEnumerable <CauseFailureCommand> GetActualCauses()
        {
            var result = new List <CauseFailureCommand>();

            var checkOutBorder = new CheckOutBorder(Entity, Slot);

            result.AddRange(checkOutBorder.GetActualCauses());

            // cant get TargetSlots if IsOutBorder
            if (checkOutBorder.IsActual())
            {
                return(result);
            }

            var targetSlots     = DatabaseReadOnly.GetSlotsForEntityInInventory(Slot.DataInventory, Slot.Vector2Int, Entity).ToList();
            var noValidEntities = DatabaseReadOnly.EntitiesInTargetSlotsWithoutExcluded(Entity, AmountWantPut, targetSlots,
                                                                                        ValidEntities).ToList();

            if (noValidEntities.Count == 1)
            {
                var entity = noValidEntities.Single();
                var cause  = new CauseIsSingleNoValidEntityInSlots(entity, targetSlots);
                result.Add(cause);
            }

            if (noValidEntities.Count > 1)
            {
                var cause = new CauseIsMoreOneNoValidEntityInSlots(noValidEntities, targetSlots);
                result.Add(cause);
            }
            return(result);
        }