public override bool ShouldExecute()
        {
            if (cooldownUntilMs > entity.World.ElapsedMilliseconds || failureTime > entity.World.ElapsedMilliseconds)
            {
                return(false);
            }
            prog = entity.GetBehavior <EntityBehaviorProgram>();
            if (prog == null || prog.dormant)
            {
                return(false);
            }
            if (!prog.CheckArea() || prog.workStack == null)
            {
                return(false);
            }
            if (entity.LeftHandItemSlot?.Itemstack != null && entity.LeftHandItemSlot.StackSize >= entity.LeftHandItemSlot.Itemstack.Collectible.MaxStackSize)
            {
                return(false);
            }

            entityUtil.WalkEntities((prog.workArea.Start + prog.workArea.End) / 2, prog.workArea.Length + prog.workArea.Height + prog.workArea.Width, (ent) =>
            {
                if ((ent is EntityItem) && prog.workArea.ContainsOrTouches(ent.ServerPos.XYZ) && prog.workStack.Equals(entity.World, (ent as EntityItem).Itemstack, GlobalConstants.IgnoredStackAttributes))
                {
                    targetPos = ent.ServerPos.XYZ;
                    return(false);
                }

                return(true);
            });

            return(targetPos != null);
        }
        public override bool ShouldExecute()
        {
            if (cooldownUntilMs > entity.World.ElapsedMilliseconds || failureTime > entity.World.ElapsedMilliseconds)
            {
                return(false);
            }
            prog = entity.GetBehavior <EntityBehaviorProgram>();
            if (prog == null || prog.dormant || !prog.CheckArea())
            {
                return(false);
            }

            entityUtil.WalkEntities((prog.workArea.Start + prog.workArea.End) / 2, prog.workArea.Length + prog.workArea.Height + prog.workArea.Width, (ent) =>
            {
                if (!prog.workArea.ContainsOrTouches(ent.ServerPos.XYZ) || ent.GetBehavior <EntityBehaviorProgram>() == null)
                {
                    return(true);
                }
                EntityBehaviorHealth bh = ent.GetBehavior <EntityBehaviorHealth>();
                if (bh == null || bh.Health >= bh.MaxHealth)
                {
                    return(true);
                }

                targetEntity = ent;
                return(false);
            });

            return(targetEntity != null);
        }
        public override bool ShouldExecute()
        {
            if (cooldownUntilMs > entity.World.ElapsedMilliseconds || failureTime > entity.World.ElapsedMilliseconds)
            {
                return(false);
            }
            prog = entity.GetBehavior <EntityBehaviorProgram>();
            if (prog == null || prog.dormant)
            {
                return(false);
            }
            if (!prog.CheckArea() || prog.workPoint == null)
            {
                return(false);
            }
            if (entity.ServerPos.DistanceTo(prog.workPoint.ToVec3d()) <= minDist)
            {
                return(false);
            }

            targetPos = prog.workPoint.ToVec3d();


            return(targetPos != null);
        }
Exemple #4
0
        public override bool ShouldExecute()
        {
            if (cooldownUntilMs > entity.World.ElapsedMilliseconds || failureTime > entity.World.ElapsedMilliseconds)
            {
                return(false);
            }
            prog = entity.GetBehavior <EntityBehaviorProgram>();
            if (prog == null || prog.dormant || !prog.CheckArea() || prog.workStack == null)
            {
                return(false);
            }
            if (entity.LeftHandItemSlot.Itemstack != null)
            {
                return(false);
            }

            entityUtil.WalkEntities((prog.workArea.Start + prog.workArea.End) / 2, prog.workArea.Length + prog.workArea.Height + prog.workArea.Width, (ent) =>
            {
                if (!prog.workArea.ContainsOrTouches(ent.ServerPos.XYZ) || ent.GetBehavior("milkable") == null && ent.GetBehavior("foodmilk") == null)
                {
                    return(true);
                }

                ITreeAttribute mult = ent.WatchedAttributes.GetTreeAttribute("multiply");

                if (ent.World.Calendar.TotalDays - mult.GetDouble("totalDaysLastBirth") <= 21 && ent.World.Calendar.TotalHours - ent.WatchedAttributes.GetFloat("lastMilkedTotalHours") >= ent.World.Calendar.HoursPerDay)
                {
                    targetEntity = ent;
                    return(false);
                }

                return(true);
            });

            return(targetEntity != null);
        }
        public override bool ShouldExecute()
        {
            if (cooldownUntilMs > entity.World.ElapsedMilliseconds || failureTime > entity.World.ElapsedMilliseconds)
            {
                return(false);
            }
            prog = entity.GetBehavior <EntityBehaviorProgram>();
            if (prog == null)
            {
                return(false);
            }
            if (prog.dormant || !entity.LeftHandItemSlot.Empty || prog?.CheckChest() != true || prog.workStack == null || (onlyOnGuard && !prog.CheckArea()))
            {
                return(false);
            }
            Block check = world.BlockAccessor.GetBlock(prog.workChest);

            if (check != null && check.Code.Path.Contains("translocatorchest"))
            {
                if (!prog.TakeFromChest())
                {
                    failureTime = entity.World.ElapsedMilliseconds + TemporalHackerConfig.Loaded.BotFailureCooldownMs;
                }
                else
                {
                    prog.ConsumeEnergy(1);
                }
                return(false);
            }

            targetPos = prog.workChest.ToVec3d();


            return(targetPos != null);
        }
Exemple #6
0
        public override bool ShouldExecute()
        {
            prog = entity.GetBehavior <EntityBehaviorProgram>();
            if (prog == null || prog.dormant)
            {
                return(false);
            }
            if (failureTime > entity.World.ElapsedMilliseconds || cooldownUntilMs > entity.World.ElapsedMilliseconds || !prog.CheckArea() || prog.workArea.Height > 0)
            {
                return(false);
            }
            if (entity.LeftHandItemSlot.Itemstack?.Block == null || ExcludeBlock(entity.LeftHandItemSlot.Itemstack.Collectible.Code))
            {
                return(false);
            }

            if (currentarea == null || !AreaCompare())
            {
                currentarea = prog.workArea.Clone();
                targetPos   = currentarea.End.AddCopy(-1, 0, -1);
                if (entity.World.BlockAccessor.GetBlock(targetPos.AsBlockPos).BlockId == 0)
                {
                    return(true);
                }
            }

            if (checkFinished())
            {
                prog.RemoveArea();
                targetPos   = null;
                currentarea = null;
                return(false);
            }

            findNextPoint();

            while (entity.World.BlockAccessor.GetBlock(targetPos.AsBlockPos).BlockId != 0 && !checkFinished())
            {
                if (!findNextPoint())
                {
                    prog.RemoveArea();
                    targetPos   = null;
                    currentarea = null;
                    return(false);
                }
            }

            return(true);
        }
        public override bool ShouldExecute()
        {
            EntityBehaviorProgram prog = entity.GetBehavior <EntityBehaviorProgram>();

            if (prog == null || prog.dormant)
            {
                return(false);
            }
            if (failureTime > entity.World.ElapsedMilliseconds || cooldownUntilMs > entity.World.ElapsedMilliseconds || !prog.CheckArea() || entity.LeftHandItemSlot.Itemstack?.Collectible?.Tool == null)
            {
                return(false);
            }

            targetPoi = porregistry.GetNearestPoi((prog.workArea.End + prog.workArea.Start) / 2, (float)(prog.workArea.Length + prog.workArea.Height + prog.workArea.Width), (poi) =>
            {
                if (poi.Type != "food" || !prog.workArea.ContainsOrTouches(poi.Position))
                {
                    return(false);
                }
                IAnimalFoodSource foodPoi;

                if ((poi is BlockEntityBerryBush || poi is BlockEntityBeehive) && (foodPoi = poi as IAnimalFoodSource)?.IsSuitableFor(entity) == true)
                {
                    return(true);
                }

                if (poi is BlockEntityFarmland)
                {
                    Block harvest = world.BlockAccessor.GetBlock(poi.Position.AsBlockPos);
                    int stage;
                    int.TryParse(harvest.LastCodePart(), out stage);

                    if ((lumber && (harvest?.Code.Path.Contains("log") == true || harvest?.Code.Path.Contains("bamboo-grown") == true) &&
                         (!harvest.Code.Path.Contains("resin") || !harvest.Code.Path.Contains("resinharvested")) && entity.LeftHandItemSlot.Itemstack.Collectible.Tool == EnumTool.Axe) ||
                        FindMatchCode(harvest.Code) || stage == harvest.CropProps?.GrowthStages || harvest?.GetBehavior <BlockBehaviorHarvestable>() != null)
                    {
                        return(true);
                    }
                }

                return(false);
            }) as IAnimalFoodSource;

            return(targetPoi != null);
        }
Exemple #8
0
        public override bool ShouldExecute()
        {
            EntityBehaviorProgram prog = entity.GetBehavior <EntityBehaviorProgram>();

            if (prog == null || prog.dormant)
            {
                return(false);
            }
            if (failureTime > entity.World.ElapsedMilliseconds || cooldownUntilMs > entity.World.ElapsedMilliseconds || !prog.CheckArea() || !CanPlant(entity.LeftHandItemSlot?.Itemstack?.Collectible))
            {
                return(false);
            }

            targetPoi = porregistry.GetNearestPoi((prog.workArea.End + prog.workArea.Start) / 2, (float)(prog.workArea.Length + prog.workArea.Height + prog.workArea.Width), (poi) =>
            {
                if (prog.workArea.ContainsOrTouches(poi.Position) && poi is BlockEntityFarmland && world.BlockAccessor.GetBlock(poi.Position.AsBlockPos).Replaceable > 9500)
                {
                    return(true);
                }


                return(false);
            });

            return(targetPoi != null);
        }